From 8d3611d0ce7d89ad495a1019f93d5003bf798d36 Mon Sep 17 00:00:00 2001 From: lasanthaDLPDS Date: Tue, 16 Jul 2019 23:48:17 +0530 Subject: [PATCH] Fix app release artfact updating issue --- .../mgt/api/services/ArtifactDownloadAPI.java | 7 +- .../impl/ArtifactDownloadAPIImpl.java | 8 +- .../services/ApplicationStorageManager.java | 6 +- .../mgt/common/services/AppmDataHandler.java | 3 +- .../mgt/core/impl/ApplicationManagerImpl.java | 26 ++++--- .../impl/ApplicationStorageManagerImpl.java | 75 ++++++++++++------- .../mgt/core/impl/AppmDataHandlerImpl.java | 11 ++- .../application/mgt/core/util/APIUtil.java | 32 +++++--- .../application/mgt/core/util/Constants.java | 17 ++++- 9 files changed, 120 insertions(+), 65 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ArtifactDownloadAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ArtifactDownloadAPI.java index f6d221792b..816b96c62b 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ArtifactDownloadAPI.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ArtifactDownloadAPI.java @@ -57,7 +57,7 @@ import javax.ws.rs.core.Response; public interface ArtifactDownloadAPI { @GET - @Path("/{uuid}/{fileName}") + @Path("/{uuid}/{folderName}/{fileName}") @Produces(MediaType.APPLICATION_OCTET_STREAM) @ApiOperation( produces = MediaType.APPLICATION_OCTET_STREAM, @@ -86,6 +86,11 @@ public interface ArtifactDownloadAPI { value = "UUID of the application release.", required = true) @PathParam("uuid") String uuid, + @ApiParam( + name = "folderName", + value = "Name of the folder where the artifact store.", + required = true) + @PathParam("folderName") String folderName, @ApiParam( name = "fileName", value = "Name of the artifact", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ArtifactDownloadAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ArtifactDownloadAPIImpl.java index 23fd133f59..c603b85161 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ArtifactDownloadAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ArtifactDownloadAPIImpl.java @@ -47,12 +47,14 @@ public class ArtifactDownloadAPIImpl implements ArtifactDownloadAPI { @GET @Override @Produces(MediaType.APPLICATION_OCTET_STREAM) - @Path("/{uuid}/{fileName}") - public Response getArtifact(@PathParam("uuid") String uuid, + @Path("/{uuid}/{folderName}/{fileName}") + public Response getArtifact( + @PathParam("uuid") String uuid, + @PathParam("folderName") String folderName, @PathParam("fileName") String fileName) { AppmDataHandler dataHandler = APIUtil.getDataHandler(); try { - InputStream fileInputStream = dataHandler.getArtifactStream(uuid, fileName); + InputStream fileInputStream = dataHandler.getArtifactStream(uuid, folderName, fileName); Response.ResponseBuilder response = Response .ok(fileInputStream, MediaType.APPLICATION_OCTET_STREAM); response.status(Response.Status.OK); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationStorageManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationStorageManager.java index d2e44b6cfd..fd93372178 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationStorageManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationStorageManager.java @@ -72,7 +72,7 @@ public interface ApplicationStorageManager { * * @throws ApplicationStorageManagementException Not Found Exception. */ - void deleteAppReleaseArtifact(String appReleaseHashVal, String fileName) throws ApplicationStorageManagementException; + void deleteAppReleaseArtifact(String appReleaseHashVal, String folderName, String fileName) throws ApplicationStorageManagementException; /** * To delete all release artifacts related with particular ApplicationDTO Release. @@ -84,9 +84,9 @@ public interface ApplicationStorageManager { /*** * Get the InputStream of the file which is located in filePath - * @param path file path + * @param hashVal Hash Value of the application release. * @return {@link InputStream} * @throws ApplicationStorageManagementException throws if an error occurs when accessing the file. */ - InputStream getFileStream(String path) throws ApplicationStorageManagementException; + InputStream getFileStream(String hashVal, String folderName, String fileName) throws ApplicationStorageManagementException; } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/AppmDataHandler.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/AppmDataHandler.java index 960196389a..7e4cb13a82 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/AppmDataHandler.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/AppmDataHandler.java @@ -35,5 +35,6 @@ public interface AppmDataHandler { Map getLifecycleConfiguration() throws LifecycleManagementException; - InputStream getArtifactStream(String uuid, String artifactName) throws ApplicationManagementException; + InputStream getArtifactStream(String uuid, String folderName, String artifactName) + throws ApplicationManagementException; } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java index 4536fc9c29..6ea15fcf97 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationManagerImpl.java @@ -451,13 +451,15 @@ public class ApplicationManagerImpl implements ApplicationManager { ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager(); if (!StringUtils.isEmpty(applicationArtifact.getIconName())) { - applicationStorageManager.deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), - applicationReleaseDTO.getIconName()); + applicationStorageManager + .deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), Constants.ICON_ARTIFACT, + applicationReleaseDTO.getIconName()); applicationReleaseDTO.setIconName(applicationArtifact.getIconName()); } if (!StringUtils.isEmpty(applicationArtifact.getBannerName())){ - applicationStorageManager.deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), - applicationReleaseDTO.getBannerName()); + applicationStorageManager + .deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), Constants.BANNER_ARTIFACT, + applicationReleaseDTO.getBannerName()); applicationReleaseDTO.setBannerName(applicationArtifact.getBannerName()); } @@ -470,17 +472,21 @@ public class ApplicationManagerImpl implements ApplicationManager { int counter = 1; for (String scName : screenshotNames) { + String folderPath = Constants.SCREENSHOT_ARTIFACT + counter; if (counter == 1) { - applicationStorageManager.deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), - applicationReleaseDTO.getScreenshotName1()); + applicationStorageManager + .deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), folderPath, + applicationReleaseDTO.getScreenshotName1()); applicationReleaseDTO.setScreenshotName1(scName); } else if (counter == 2) { - applicationStorageManager.deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), - applicationReleaseDTO.getScreenshotName2()); + applicationStorageManager + .deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), folderPath, + applicationReleaseDTO.getScreenshotName2()); applicationReleaseDTO.setScreenshotName2(scName); } else if (counter == 3) { - applicationStorageManager.deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), - applicationReleaseDTO.getScreenshotName3()); + applicationStorageManager + .deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), folderPath, + applicationReleaseDTO.getScreenshotName3()); applicationReleaseDTO.setScreenshotName3(scName); } counter++; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java index 1142a02452..4a41f16cd2 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationStorageManagerImpl.java @@ -30,6 +30,7 @@ import org.wso2.carbon.device.application.mgt.common.exception.ResourceManagemen import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager; import org.wso2.carbon.device.application.mgt.core.exception.ParsingException; import org.wso2.carbon.device.application.mgt.core.util.ArtifactsParser; +import org.wso2.carbon.device.application.mgt.core.util.Constants; import org.wso2.carbon.device.application.mgt.core.util.StorageManagementUtil; import java.io.*; @@ -60,21 +61,24 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager public ApplicationReleaseDTO uploadImageArtifacts(ApplicationReleaseDTO applicationReleaseDTO, InputStream iconFileStream, InputStream bannerFileStream, List screenShotStreams) throws ResourceManagementException { - String artifactDirectoryPath; String iconStoredLocation; String bannerStoredLocation; String scStoredLocation = null; try { - artifactDirectoryPath = storagePath + applicationReleaseDTO.getAppHashValue(); - StorageManagementUtil.createArtifactDirectory(artifactDirectoryPath); + String artifactStoringBaseDirPath = storagePath + applicationReleaseDTO.getAppHashValue(); + StorageManagementUtil.createArtifactDirectory(artifactStoringBaseDirPath); if (iconFileStream != null) { - iconStoredLocation = artifactDirectoryPath + File.separator + applicationReleaseDTO.getIconName(); + String iconStoringDir = artifactStoringBaseDirPath + File.separator + Constants.ICON_ARTIFACT; + StorageManagementUtil.createArtifactDirectory(iconStoringDir); + iconStoredLocation = iconStoringDir + File.separator + applicationReleaseDTO.getIconName(); saveFile(iconFileStream, iconStoredLocation); } if (bannerFileStream != null) { - bannerStoredLocation = artifactDirectoryPath + File.separator + applicationReleaseDTO.getBannerName(); + String bannerStoringDir = artifactStoringBaseDirPath + File.separator + Constants.BANNER_ARTIFACT; + StorageManagementUtil.createArtifactDirectory(bannerStoringDir); + bannerStoredLocation = bannerStoringDir + File.separator + applicationReleaseDTO.getBannerName(); saveFile(bannerFileStream, bannerStoredLocation); } if (!screenShotStreams.isEmpty()) { @@ -86,14 +90,16 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager } int count = 1; for (InputStream screenshotStream : screenShotStreams) { + String scStoringDir = artifactStoringBaseDirPath + File.separator + Constants.SCREENSHOT_ARTIFACT + count; + StorageManagementUtil.createArtifactDirectory(scStoringDir); if (count == 1) { - scStoredLocation = artifactDirectoryPath + File.separator + applicationReleaseDTO.getScreenshotName1(); + scStoredLocation = scStoringDir + File.separator + applicationReleaseDTO.getScreenshotName1(); } if (count == 2) { - scStoredLocation = artifactDirectoryPath + File.separator + applicationReleaseDTO.getScreenshotName2(); + scStoredLocation = scStoringDir + File.separator + applicationReleaseDTO.getScreenshotName2(); } if (count == 3) { - scStoredLocation = artifactDirectoryPath + File.separator + applicationReleaseDTO.getScreenshotName3(); + scStoredLocation = scStoringDir + File.separator + applicationReleaseDTO.getScreenshotName3(); } saveFile(screenshotStream, scStoredLocation); count++; @@ -101,8 +107,10 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager } return applicationReleaseDTO; } catch (IOException e) { - throw new ApplicationStorageManagementException("IO Exception while saving the screens hots for " + - "the application " + applicationReleaseDTO.getUuid(), e); + String msg = "IO Exception occurred while saving application artifacts for the application which has UUID " + + applicationReleaseDTO.getUuid(); + log.error(msg); + throw new ApplicationStorageManagementException(msg, e); } } @@ -142,7 +150,8 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager String artifactPath; byte [] content = IOUtils.toByteArray(binaryFile); - artifactDirectoryPath = storagePath + applicationReleaseDTO.getAppHashValue(); + artifactDirectoryPath = + storagePath + applicationReleaseDTO.getAppHashValue() + File.separator + Constants.APP_ARTIFACT; StorageManagementUtil.createArtifactDirectory(artifactDirectoryPath); artifactPath = artifactDirectoryPath + File.separator + applicationReleaseDTO.getInstallerName(); saveFile(new ByteArrayInputStream(content), artifactPath); @@ -168,24 +177,38 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager String screenshot3 = applicationReleaseDTO.getScreenshotName3(); if (bannerName != null) { - StorageManagementUtil.copy(storagePath + deletingAppHashValue + File.separator + bannerName, - storagePath + appHashValue + File.separator + bannerName); + StorageManagementUtil + .copy(storagePath + deletingAppHashValue + File.separator + Constants.BANNER_ARTIFACT + + File.separator + bannerName, + storagePath + appHashValue + File.separator + Constants.BANNER_ARTIFACT + File.separator + + bannerName); } if (iconName != null) { - StorageManagementUtil.copy(storagePath + deletingAppHashValue + File.separator + iconName, - storagePath + appHashValue + File.separator + iconName); + StorageManagementUtil.copy(storagePath + deletingAppHashValue + File.separator + Constants.ICON_ARTIFACT + + File.separator + iconName, + storagePath + appHashValue + File.separator + Constants.ICON_ARTIFACT + File.separator + + iconName); } if (screenshot1 != null) { - StorageManagementUtil.copy(storagePath + deletingAppHashValue + File.separator + screenshot1, - storagePath + appHashValue + File.separator + screenshot1); + StorageManagementUtil + .copy(storagePath + deletingAppHashValue + File.separator + Constants.SCREENSHOT_ARTIFACT + 1 + + File.separator + screenshot1, + storagePath + appHashValue + File.separator + Constants.SCREENSHOT_ARTIFACT + 1 + + File.separator + screenshot1); } if (screenshot2 != null) { - StorageManagementUtil.copy(storagePath + deletingAppHashValue + File.separator + screenshot2, - storagePath + appHashValue + File.separator + screenshot2); + StorageManagementUtil + .copy(storagePath + deletingAppHashValue + File.separator + Constants.SCREENSHOT_ARTIFACT + 2 + + File.separator + screenshot2, + storagePath + appHashValue + File.separator + Constants.SCREENSHOT_ARTIFACT + 2 + + File.separator + screenshot2); } if (screenshot3 != null) { - StorageManagementUtil.copy(storagePath + deletingAppHashValue + File.separator + screenshot3, - storagePath + appHashValue + File.separator + screenshot3); + StorageManagementUtil + .copy(storagePath + deletingAppHashValue + File.separator + Constants.SCREENSHOT_ARTIFACT + 3 + + File.separator + screenshot3, + storagePath + appHashValue + File.separator + Constants.SCREENSHOT_ARTIFACT + 3 + + File.separator + screenshot3); } deleteAppReleaseArtifact( storagePath + deletingAppHashValue); } catch (IOException e) { @@ -198,8 +221,9 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager @Override - public void deleteAppReleaseArtifact(String appReleaseHashVal, String fileName) throws ApplicationStorageManagementException { - String artifactPath = storagePath + appReleaseHashVal + File.separator + fileName; + public void deleteAppReleaseArtifact(String appReleaseHashVal, String folderName, String fileName) + throws ApplicationStorageManagementException { + String artifactPath = storagePath + appReleaseHashVal + File.separator + folderName + File.separator + fileName; deleteAppReleaseArtifact(artifactPath); } @@ -212,8 +236,9 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager } @Override - public InputStream getFileStream(String path) throws ApplicationStorageManagementException { - String filePath = storagePath + path; + public InputStream getFileStream(String hashVal, String folderName, String fileName) + throws ApplicationStorageManagementException { + String filePath = storagePath + hashVal + File.separator + folderName + File.separator + fileName; try { return StorageManagementUtil.getInputStream(filePath); } catch (IOException e) { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/AppmDataHandlerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/AppmDataHandlerImpl.java index 56d81a4b6c..1d8c0d4ecf 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/AppmDataHandlerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/AppmDataHandlerImpl.java @@ -64,12 +64,11 @@ public class AppmDataHandlerImpl implements AppmDataHandler { return lifecycleStateManager.getLifecycleConfig(); } - @Override - public InputStream getArtifactStream(String uuid, String artifactName) throws ApplicationManagementException { + @Override public InputStream getArtifactStream(String uuid, String folderName, String artifactName) + throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager(); ApplicationReleaseDAO applicationReleaseDAO = ApplicationManagementDAOFactory.getApplicationReleaseDAO(); - String artifactPath; String appReleaseHashValue; try { ConnectionManagerUtil.openDBConnection(); @@ -79,10 +78,10 @@ public class AppmDataHandlerImpl implements AppmDataHandler { log.error(msg); throw new NotFoundException(msg); } - artifactPath = appReleaseHashValue + Constants.FORWARD_SLASH + artifactName; - InputStream inputStream = applicationStorageManager.getFileStream(artifactPath); + InputStream inputStream = applicationStorageManager + .getFileStream(appReleaseHashValue, folderName, artifactName); if (inputStream == null) { - String msg = "Couldn't file the file in the file system. File path: " + artifactPath; + String msg = "Couldn't file the file in the file system."; log.error(msg); throw new ApplicationManagementException(msg); } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/APIUtil.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/APIUtil.java index 5cb4062643..cac7a34013 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/APIUtil.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/APIUtil.java @@ -338,8 +338,7 @@ public class APIUtil { String artifactDownloadEndpoint = ConfigurationManager.getInstance().getConfiguration() .getArtifactDownloadEndpoint(); String basePath = Constants.ARTIFACT_DOWNLOAD_PROTOCOL + "://" + host + ":" + port + artifactDownloadEndpoint - + Constants.FORWARD_SLASH + applicationReleaseDTO.getUuid() - + Constants.FORWARD_SLASH; + + Constants.FORWARD_SLASH + applicationReleaseDTO.getUuid() + Constants.FORWARD_SLASH; List screenshotPaths = new ArrayList<>(); ApplicationRelease applicationRelease = new ApplicationRelease(); @@ -356,28 +355,37 @@ public class APIUtil { applicationRelease.setIsSharedWithAllTenants(applicationReleaseDTO.getIsSharedWithAllTenants()); applicationRelease.setSupportedOsVersions(applicationReleaseDTO.getSupportedOsVersions()); applicationRelease.setRating(applicationReleaseDTO.getRating()); - applicationRelease.setIconPath(basePath + applicationReleaseDTO.getIconName()); + applicationRelease.setIconPath( + basePath + Constants.ICON_ARTIFACT + Constants.FORWARD_SLASH + applicationReleaseDTO.getIconName()); if (!StringUtils.isEmpty(applicationReleaseDTO.getBannerName())){ - applicationRelease.setBannerPath(basePath + applicationReleaseDTO.getBannerName()); + applicationRelease.setBannerPath( + basePath + Constants.BANNER_ARTIFACT + Constants.FORWARD_SLASH + applicationReleaseDTO + .getBannerName()); } - if (urlValidator.isValid(applicationReleaseDTO.getInstallerName())){ - applicationRelease - .setInstallerPath(applicationReleaseDTO.getInstallerName()); + if (urlValidator.isValid(applicationReleaseDTO.getInstallerName())) { + applicationRelease.setInstallerPath(applicationReleaseDTO.getInstallerName()); } else { - applicationRelease - .setInstallerPath(basePath + applicationReleaseDTO.getInstallerName()); + applicationRelease.setInstallerPath( + basePath + Constants.APP_ARTIFACT + Constants.FORWARD_SLASH + applicationReleaseDTO + .getInstallerName()); } if (!StringUtils.isEmpty(applicationReleaseDTO.getScreenshotName1())) { - screenshotPaths.add(basePath + applicationReleaseDTO.getScreenshotName1()); + screenshotPaths + .add(basePath + Constants.SCREENSHOT_ARTIFACT + 1 + Constants.FORWARD_SLASH + applicationReleaseDTO + .getScreenshotName1()); } if (!StringUtils.isEmpty(applicationReleaseDTO.getScreenshotName2())) { - screenshotPaths.add(basePath + applicationReleaseDTO.getScreenshotName2()); + screenshotPaths + .add(basePath + Constants.SCREENSHOT_ARTIFACT + 2 + Constants.FORWARD_SLASH + applicationReleaseDTO + .getScreenshotName2()); } if (!StringUtils.isEmpty(applicationReleaseDTO.getScreenshotName3())) { - screenshotPaths.add(basePath + applicationReleaseDTO.getScreenshotName3()); + screenshotPaths + .add(basePath + Constants.SCREENSHOT_ARTIFACT + 3 + Constants.FORWARD_SLASH + applicationReleaseDTO + .getScreenshotName3()); } applicationRelease.setScreenshots(screenshotPaths); return applicationRelease; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/Constants.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/Constants.java index 783e19bd08..1e05e2df74 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/Constants.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/Constants.java @@ -61,16 +61,25 @@ public class Constants { public static final String DB_TYPE_POSTGRESQL = "PostgreSQL"; } + /** + * Directory name of the icon artifact that are saved in the file system. + */ + public static final String ICON_ARTIFACT = "icon"; + + /** + * Directory name of the banner artifact that are saved in the file system. + */ + public static final String BANNER_ARTIFACT = "banner"; /** - * Name of the image artifacts that are saved in the file system. + * Common directory name of the screenshot artifact that are saved in the file system. */ - public static final String[] IMAGE_ARTIFACTS = {"icon", "banner", "screenshot"}; + public static final String SCREENSHOT_ARTIFACT = "screenshot"; /** - * Directory name of the release artifacts that are saved in the file system. + * Naming directory name of the application artifact that are saved in the file system. */ - public static final String RELEASE_ARTIFACT = "artifact"; + public static final String APP_ARTIFACT = "app"; public static final int REVIEW_PARENT_ID = -1;