src/main/java/org/edgegallery/appstore/application/inner/MessageService.java
public void downloadFromMessage(String messageId, User user) {
        Message message = messageRepository.getOneMessage(messageId);
        String packageDownloadUrl = message.getPackageDownloadUrl();
        String iconDownloadUrl = message.getIconDownloadUrl();
        String demoVideoDownloadUrl = message.getDemoVideoDownloadUrl();
        if (packageDownloadUrl == null || iconDownloadUrl == null) {
            LOGGER.error("download url null: package download url is {}, icon download url is {}", packageDownloadUrl,
                iconDownloadUrl);
            throw new AppException("download url is null.",
                ResponseConst.RET_MESSAGE_DOWNLOAD_URL_NULL, packageDownloadUrl, iconDownloadUrl);
        }
        try {
            String parentPath = dir + File.separator + UUID.randomUUID().toString();
            String targetAppstore = message.getTargetAppStore();
            File tempPackage = fileService.downloadFile(packageDownloadUrl, parentPath, targetAppstore);
            File tempIcon = fileService.downloadFile(iconDownloadUrl, parentPath, targetAppstore);
            AFile demoVideo = null;
            if (demoVideoDownloadUrl != null) {
                File tempDemoVideo = fileService.downloadFile(demoVideoDownloadUrl, parentPath, targetAppstore);
                demoVideo = new AFile(tempDemoVideo.getName(), tempDemoVideo.getCanonicalPath());
            }
            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(message.getBasicInfo().getType(), showType,
                message.getBasicInfo().getAffinity(), message.getBasicInfo().getIndustry(), false);
            Release release = new Release(apackage, icon, demoVideo, 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);

            addDownloadMessage(message);
        } catch (IOException e) {
            LOGGER.error("IOException: {}", e.getMessage());
            throw new AppException("download file from message.", ResponseConst.RET_DOWNLOAD_FROM_MESSAGE_FAILED);
        }
    }
/**
     * download package and icon by the url in message.
     *
     * @param messageId message id
     * @param user user info
     */
download package and icon by the url in message.
@param messageId message id
@param user user info
download package and icon by the url in message . @param messageId message id @param user user info
public void downloadFromMessage(String messageId, User user) {
        Message message = messageRepository.getOneMessage(messageId);
        String packageDownloadUrl = message.getPackageDownloadUrl();
        String iconDownloadUrl = message.getIconDownloadUrl();
        String demoVideoDownloadUrl = message.getDemoVideoDownloadUrl();
        if (packageDownloadUrl == null || iconDownloadUrl == null) {
            LOGGER.error("download url null: package download url is {}, icon download url is {}", packageDownloadUrl,
                iconDownloadUrl);
            throw new AppException("download url is null.",
                ResponseConst.RET_MESSAGE_DOWNLOAD_URL_NULL, packageDownloadUrl, iconDownloadUrl);
        }
        try {
            String parentPath = dir + File.separator + UUID.randomUUID().toString();
            String targetAppstore = message.getTargetAppStore();
            File tempPackage = fileService.downloadFile(packageDownloadUrl, parentPath, targetAppstore);
            File tempIcon = fileService.downloadFile(iconDownloadUrl, parentPath, targetAppstore);
            AFile demoVideo = null;
            if (demoVideoDownloadUrl != null) {
                File tempDemoVideo = fileService.downloadFile(demoVideoDownloadUrl, parentPath, targetAppstore);
                demoVideo = new AFile(tempDemoVideo.getName(), tempDemoVideo.getCanonicalPath());
            }
            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(message.getBasicInfo().getType(), showType,
                message.getBasicInfo().getAffinity(), message.getBasicInfo().getIndustry(), false);
            Release release = new Release(apackage, icon, demoVideo, user, appParam, appClass);
            release.setStatus(EnumPackageStatus.Upload);
            appService.registerApp(release);
            addDownloadMessage(message);
        } catch (IOException e) {
            LOGGER.error("IOException: {}", e.getMessage());
            throw new AppException("download file from message.", ResponseConst.RET_DOWNLOAD_FROM_MESSAGE_FAILED);
        }
    }
public void downloadFromMessage ( String messageId , User user ) { Message message = messageRepository . getOneMessage ( messageId ) ; String packageDownloadUrl = message . getPackageDownloadUrl ( ) ; String iconDownloadUrl = message . getIconDownloadUrl ( ) ; String demoVideoDownloadUrl = message . getDemoVideoDownloadUrl ( ) ; if ( packageDownloadUrl == null || iconDownloadUrl == null ) { LOGGER . error ( "download url null: package download url is {}, icon download url is {}" , packageDownloadUrl , iconDownloadUrl ) ; throw new AppException ( "download url is null." , ResponseConst . RET_MESSAGE_DOWNLOAD_URL_NULL , packageDownloadUrl , iconDownloadUrl ) ; } try { String parentPath = dir + File . separator + UUID . randomUUID ( ) . toString ( ) ; String targetAppstore = message . getTargetAppStore ( ) ; File tempPackage = fileService . downloadFile ( packageDownloadUrl , parentPath , targetAppstore ) ; File tempIcon = fileService . downloadFile ( iconDownloadUrl , parentPath , targetAppstore ) ; AFile demoVideo = null ; if ( demoVideoDownloadUrl != null ) { File tempDemoVideo = fileService . downloadFile ( demoVideoDownloadUrl , parentPath , targetAppstore ) ; demoVideo = new AFile ( tempDemoVideo . getName ( ) , tempDemoVideo . getCanonicalPath ( ) ) ; } 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 ( message . getBasicInfo ( ) . getType ( ) , showType , message . getBasicInfo ( ) . getAffinity ( ) , message . getBasicInfo ( ) . getIndustry ( ) , false ) ; Release release = new Release ( apackage , icon , demoVideo , user , appParam , appClass ) ; release . setStatus ( EnumPackageStatus . Upload ) ; appService . registerApp ( release ) ; addDownloadMessage ( message ) ; } catch ( IOException e ) { LOGGER . error ( "IOException: {}" , e . getMessage ( ) ) ; throw new AppException ( "download file from message." , ResponseConst . RET_DOWNLOAD_FROM_MESSAGE_FAILED ) ; } }
download package and icon by the url in message.
download package and icon by the url in message .
// the package pulled from third appstore need to be tested by local appstore's atp