src/main/java/org/edgegallery/appstore/domain/model/app/App.java
public void checkReleases(Release release) {
        releases.stream().filter(r -> r.getStatus() == EnumPackageStatus.Published).forEach(r1 -> {
            if (release.getAppBasicInfo().getVersion().equals(r1.getAppBasicInfo().getVersion())) {
                try {
                    FileUtils.deleteDirectory(new File(release.getPackageFile().getStorageAddress()).getParentFile());
                } catch (IOException e) {
                    LOGGER.error("Delete the package directory exception: {}", e.getMessage());
                }
                throw new AppException("The same app has existed.", ResponseConst.RET_SAME_APP_EXIST);
            }
        });
        AtomicInteger sameSize = new AtomicInteger();
        releases.stream().filter(r -> r.getStatus() != EnumPackageStatus.Published).forEach(r1 -> {
            if (release.getAppBasicInfo().getVersion().equals(r1.getAppBasicInfo().getVersion())
                && release.getUser().getUserId().equals(r1.getUser().getUserId())
                && sameSize.incrementAndGet() >= MAX_SAME_RELEASES) {
                try {
                    FileUtils.deleteDirectory(new File(release.getPackageFile().getStorageAddress()).getParentFile());
                } catch (IOException e) {
                    LOGGER.error("Delete the package directory exception: {}", e.getMessage());
                }
                throw new AppException("The same unPublished apps have reach the limit.",
                    ResponseConst.RET_SAME_APP_REACH_LIMIT, MAX_SAME_RELEASES);
            }
        });
    }
/**
     * check release unique.
     *
     * @param release app release.
     */
check release unique.
@param release app release.
check release unique . @param release app release .
public void checkReleases(Release release) {
        releases.stream().filter(r -> r.getStatus() == EnumPackageStatus.Published).forEach(r1 -> {
            if (release.getAppBasicInfo().getVersion().equals(r1.getAppBasicInfo().getVersion())) {
                try {
                    FileUtils.deleteDirectory(new File(release.getPackageFile().getStorageAddress()).getParentFile());
                } catch (IOException e) {
                    LOGGER.error("Delete the package directory exception: {}", e.getMessage());
                }
                throw new AppException("The same app has existed.", ResponseConst.RET_SAME_APP_EXIST);
            }
        });
        AtomicInteger sameSize = new AtomicInteger();
        releases.stream().filter(r -> r.getStatus() != EnumPackageStatus.Published).forEach(r1 -> {
            if (release.getAppBasicInfo().getVersion().equals(r1.getAppBasicInfo().getVersion())
                && release.getUser().getUserId().equals(r1.getUser().getUserId())
                && sameSize.incrementAndGet() >= MAX_SAME_RELEASES) {
                try {
                    FileUtils.deleteDirectory(new File(release.getPackageFile().getStorageAddress()).getParentFile());
                } catch (IOException e) {
                    LOGGER.error("Delete the package directory exception: {}", e.getMessage());
                }
                throw new AppException("The same unPublished apps have reach the limit.",
                    ResponseConst.RET_SAME_APP_REACH_LIMIT, MAX_SAME_RELEASES);
            }
        });
    }
public void checkReleases ( Release release ) { releases . stream ( ) . filter ( r -> r . getStatus ( ) == EnumPackageStatus . Published ) . forEach ( r1 -> { if ( release . getAppBasicInfo ( ) . getVersion ( ) . equals ( r1 . getAppBasicInfo ( ) . getVersion ( ) ) ) { try { FileUtils . deleteDirectory ( new File ( release . getPackageFile ( ) . getStorageAddress ( ) ) . getParentFile ( ) ) ; } catch ( IOException e ) { LOGGER . error ( "Delete the package directory exception: {}" , e . getMessage ( ) ) ; } throw new AppException ( "The same app has existed." , ResponseConst . RET_SAME_APP_EXIST ) ; } } ) ; AtomicInteger sameSize = new AtomicInteger ( ) ; releases . stream ( ) . filter ( r -> r . getStatus ( ) != EnumPackageStatus . Published ) . forEach ( r1 -> { if ( release . getAppBasicInfo ( ) . getVersion ( ) . equals ( r1 . getAppBasicInfo ( ) . getVersion ( ) ) && release . getUser ( ) . getUserId ( ) . equals ( r1 . getUser ( ) . getUserId ( ) ) && sameSize . incrementAndGet ( ) >= MAX_SAME_RELEASES ) { try { FileUtils . deleteDirectory ( new File ( release . getPackageFile ( ) . getStorageAddress ( ) ) . getParentFile ( ) ) ; } catch ( IOException e ) { LOGGER . error ( "Delete the package directory exception: {}" , e . getMessage ( ) ) ; } throw new AppException ( "The same unPublished apps have reach the limit." , ResponseConst . RET_SAME_APP_REACH_LIMIT , MAX_SAME_RELEASES ) ; } } ) ; }
check release unique.
check release unique .