src/main/java/org/edgegallery/appstore/application/inner/PullablePackageService.java
public Boolean pullPackage(String packageId, String sourceStoreId, User user, PushablePackageDto packagePo) {
        LOGGER.info("pullPackage sourceStoreId {}, userName {}", sourceStoreId, user.getUserName());
        AppStore appStore = appStoreRepository.queryAppStoreById(sourceStoreId);
        if (appStore == null) {
            LOGGER.error(APPSTORE_NOT_EXIST, sourceStoreId);
            return false;
        }
        String baseUrl = appStore.getUrl();
        String packageDownloadUrl = baseUrl + String.format(DOWNLOAD_PACKAGE_API, packageId);
        String iconDownloadUrl = baseUrl + String.format(DOWNLOAD_ICON_API, packageId);
        LOGGER.info("pullPackage packageDownloadUrl {}, iconDownloadUrl {}", packageDownloadUrl, iconDownloadUrl);

        try {
            String parentPath = dir + File.separator + UUID.randomUUID().toString().replace("-", "");
            String targetAppstore = context.platformName;
            File tempPackage = fileService.downloadFile(packageDownloadUrl, parentPath, targetAppstore);
            File tempIcon = fileService.downloadFile(iconDownloadUrl, parentPath, targetAppstore);
            AFile apackage = new AFile(tempPackage.getName(), tempPackage.getCanonicalPath());
            AFile icon = new AFile(tempIcon.getName(), tempIcon.getCanonicalPath());
            apackage.setFileSize(tempPackage.length());
            String appClass = appUtil.getAppClass(apackage.getStorageAddress());
            String showType = "public";
            AppParam appParam = new AppParam(packagePo.getType(), showType, packagePo.getAffinity(),
                packagePo.getIndustry(), false);
            Release release = new Release(apackage, icon, null, user, appParam, appClass);
            // the package pulled from third appstore need to be tested by local appstore's atp
            release.setStatus(EnumPackageStatus.Upload);
            appService.registerApp(release);

            addPullMessage(packagePo);
        } catch (IOException e) {
            LOGGER.error("IOException: {}", e.getMessage());
            throw new AppException("pull package exception.", ResponseConst.RET_PULL_PACKAGE_FAILED);
        }
        return true;
    }
/**
     * get pullable packages by id.
     *
     * @param packageId package id
     * @param sourceStoreId source appstore id
     * @param user user info
     * @param packagePo package info
     * @return dto
     */
get pullable packages by id.
get pullable packages by id .
public Boolean pullPackage(String packageId, String sourceStoreId, User user, PushablePackageDto packagePo) {
        LOGGER.info("pullPackage sourceStoreId {}, userName {}", sourceStoreId, user.getUserName());
        AppStore appStore = appStoreRepository.queryAppStoreById(sourceStoreId);
        if (appStore == null) {
            LOGGER.error(APPSTORE_NOT_EXIST, sourceStoreId);
            return false;
        }
        String baseUrl = appStore.getUrl();
        String packageDownloadUrl = baseUrl + String.format(DOWNLOAD_PACKAGE_API, packageId);
        String iconDownloadUrl = baseUrl + String.format(DOWNLOAD_ICON_API, packageId);
        LOGGER.info("pullPackage packageDownloadUrl {}, iconDownloadUrl {}", packageDownloadUrl, iconDownloadUrl);
        try {
            String parentPath = dir + File.separator + UUID.randomUUID().toString().replace("-", "");
            String targetAppstore = context.platformName;
            File tempPackage = fileService.downloadFile(packageDownloadUrl, parentPath, targetAppstore);
            File tempIcon = fileService.downloadFile(iconDownloadUrl, parentPath, targetAppstore);
            AFile apackage = new AFile(tempPackage.getName(), tempPackage.getCanonicalPath());
            AFile icon = new AFile(tempIcon.getName(), tempIcon.getCanonicalPath());
            apackage.setFileSize(tempPackage.length());
            String appClass = appUtil.getAppClass(apackage.getStorageAddress());
            String showType = "public";
            AppParam appParam = new AppParam(packagePo.getType(), showType, packagePo.getAffinity(),
                packagePo.getIndustry(), false);
            Release release = new Release(apackage, icon, null, user, appParam, appClass);
            release.setStatus(EnumPackageStatus.Upload);
            appService.registerApp(release);
            addPullMessage(packagePo);
        } catch (IOException e) {
            LOGGER.error("IOException: {}", e.getMessage());
            throw new AppException("pull package exception.", ResponseConst.RET_PULL_PACKAGE_FAILED);
        }
        return true;
    }
public Boolean pullPackage ( String packageId , String sourceStoreId , User user , PushablePackageDto packagePo ) { LOGGER . info ( "pullPackage sourceStoreId {}, userName {}" , sourceStoreId , user . getUserName ( ) ) ; AppStore appStore = appStoreRepository . queryAppStoreById ( sourceStoreId ) ; if ( appStore == null ) { LOGGER . error ( APPSTORE_NOT_EXIST , sourceStoreId ) ; return false ; } String baseUrl = appStore . getUrl ( ) ; String packageDownloadUrl = baseUrl + String . format ( DOWNLOAD_PACKAGE_API , packageId ) ; String iconDownloadUrl = baseUrl + String . format ( DOWNLOAD_ICON_API , packageId ) ; LOGGER . info ( "pullPackage packageDownloadUrl {}, iconDownloadUrl {}" , packageDownloadUrl , iconDownloadUrl ) ; try { String parentPath = dir + File . separator + UUID . randomUUID ( ) . toString ( ) . replace ( "-" , "" ) ; String targetAppstore = context . platformName ; File tempPackage = fileService . downloadFile ( packageDownloadUrl , parentPath , targetAppstore ) ; File tempIcon = fileService . downloadFile ( iconDownloadUrl , parentPath , targetAppstore ) ; AFile apackage = new AFile ( tempPackage . getName ( ) , tempPackage . getCanonicalPath ( ) ) ; AFile icon = new AFile ( tempIcon . getName ( ) , tempIcon . getCanonicalPath ( ) ) ; apackage . setFileSize ( tempPackage . length ( ) ) ; String appClass = appUtil . getAppClass ( apackage . getStorageAddress ( ) ) ; String showType = "public" ; AppParam appParam = new AppParam ( packagePo . getType ( ) , showType , packagePo . getAffinity ( ) , packagePo . getIndustry ( ) , false ) ; Release release = new Release ( apackage , icon , null , user , appParam , appClass ) ; release . setStatus ( EnumPackageStatus . Upload ) ; appService . registerApp ( release ) ; addPullMessage ( packagePo ) ; } catch ( IOException e ) { LOGGER . error ( "IOException: {}" , e . getMessage ( ) ) ; throw new AppException ( "pull package exception." , ResponseConst . RET_PULL_PACKAGE_FAILED ) ; } return true ; }
get pullable packages by id.
get pullable packages by id .
// the package pulled from third appstore need to be tested by local appstore's atp