Merge branch 'application-mgt-new' into 'application-mgt-new'

Fix app release artifact updating issue

See merge request entgra/carbon-device-mgt!179
feature/appm-store/pbac
Dharmakeerthi Lasantha 6 years ago
commit fce3596e04

@ -57,7 +57,7 @@ import javax.ws.rs.core.Response;
public interface ArtifactDownloadAPI { public interface ArtifactDownloadAPI {
@GET @GET
@Path("/{uuid}/{fileName}") @Path("/{uuid}/{folderName}/{fileName}")
@Produces(MediaType.APPLICATION_OCTET_STREAM) @Produces(MediaType.APPLICATION_OCTET_STREAM)
@ApiOperation( @ApiOperation(
produces = MediaType.APPLICATION_OCTET_STREAM, produces = MediaType.APPLICATION_OCTET_STREAM,
@ -86,6 +86,11 @@ public interface ArtifactDownloadAPI {
value = "UUID of the application release.", value = "UUID of the application release.",
required = true) required = true)
@PathParam("uuid") String uuid, @PathParam("uuid") String uuid,
@ApiParam(
name = "folderName",
value = "Name of the folder where the artifact store.",
required = true)
@PathParam("folderName") String folderName,
@ApiParam( @ApiParam(
name = "fileName", name = "fileName",
value = "Name of the artifact", value = "Name of the artifact",

@ -47,12 +47,14 @@ public class ArtifactDownloadAPIImpl implements ArtifactDownloadAPI {
@GET @GET
@Override @Override
@Produces(MediaType.APPLICATION_OCTET_STREAM) @Produces(MediaType.APPLICATION_OCTET_STREAM)
@Path("/{uuid}/{fileName}") @Path("/{uuid}/{folderName}/{fileName}")
public Response getArtifact(@PathParam("uuid") String uuid, public Response getArtifact(
@PathParam("uuid") String uuid,
@PathParam("folderName") String folderName,
@PathParam("fileName") String fileName) { @PathParam("fileName") String fileName) {
AppmDataHandler dataHandler = APIUtil.getDataHandler(); AppmDataHandler dataHandler = APIUtil.getDataHandler();
try { try {
InputStream fileInputStream = dataHandler.getArtifactStream(uuid, fileName); InputStream fileInputStream = dataHandler.getArtifactStream(uuid, folderName, fileName);
Response.ResponseBuilder response = Response Response.ResponseBuilder response = Response
.ok(fileInputStream, MediaType.APPLICATION_OCTET_STREAM); .ok(fileInputStream, MediaType.APPLICATION_OCTET_STREAM);
response.status(Response.Status.OK); response.status(Response.Status.OK);

@ -72,7 +72,7 @@ public interface ApplicationStorageManager {
* *
* @throws ApplicationStorageManagementException Not Found Exception. * @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. * 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 * 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} * @return {@link InputStream}
* @throws ApplicationStorageManagementException throws if an error occurs when accessing the file. * @throws ApplicationStorageManagementException throws if an error occurs when accessing the file.
*/ */
InputStream getFileSttream(String path) throws ApplicationStorageManagementException; InputStream getFileStream(String hashVal, String folderName, String fileName) throws ApplicationStorageManagementException;
} }

@ -35,5 +35,6 @@ public interface AppmDataHandler {
Map<String, LifecycleState> getLifecycleConfiguration() throws LifecycleManagementException; Map<String, LifecycleState> getLifecycleConfiguration() throws LifecycleManagementException;
InputStream getArtifactStream(String uuid, String artifactName) throws ApplicationManagementException; InputStream getArtifactStream(String uuid, String folderName, String artifactName)
throws ApplicationManagementException;
} }

@ -451,12 +451,14 @@ public class ApplicationManagerImpl implements ApplicationManager {
ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager(); ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager();
if (!StringUtils.isEmpty(applicationArtifact.getIconName())) { if (!StringUtils.isEmpty(applicationArtifact.getIconName())) {
applicationStorageManager.deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), applicationStorageManager
.deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), Constants.ICON_ARTIFACT,
applicationReleaseDTO.getIconName()); applicationReleaseDTO.getIconName());
applicationReleaseDTO.setIconName(applicationArtifact.getIconName()); applicationReleaseDTO.setIconName(applicationArtifact.getIconName());
} }
if (!StringUtils.isEmpty(applicationArtifact.getBannerName())){ if (!StringUtils.isEmpty(applicationArtifact.getBannerName())){
applicationStorageManager.deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), applicationStorageManager
.deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), Constants.BANNER_ARTIFACT,
applicationReleaseDTO.getBannerName()); applicationReleaseDTO.getBannerName());
applicationReleaseDTO.setBannerName(applicationArtifact.getBannerName()); applicationReleaseDTO.setBannerName(applicationArtifact.getBannerName());
} }
@ -470,16 +472,20 @@ public class ApplicationManagerImpl implements ApplicationManager {
int counter = 1; int counter = 1;
for (String scName : screenshotNames) { for (String scName : screenshotNames) {
String folderPath = Constants.SCREENSHOT_ARTIFACT + counter;
if (counter == 1) { if (counter == 1) {
applicationStorageManager.deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), applicationStorageManager
.deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), folderPath,
applicationReleaseDTO.getScreenshotName1()); applicationReleaseDTO.getScreenshotName1());
applicationReleaseDTO.setScreenshotName1(scName); applicationReleaseDTO.setScreenshotName1(scName);
} else if (counter == 2) { } else if (counter == 2) {
applicationStorageManager.deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), applicationStorageManager
.deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), folderPath,
applicationReleaseDTO.getScreenshotName2()); applicationReleaseDTO.getScreenshotName2());
applicationReleaseDTO.setScreenshotName2(scName); applicationReleaseDTO.setScreenshotName2(scName);
} else if (counter == 3) { } else if (counter == 3) {
applicationStorageManager.deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), applicationStorageManager
.deleteAppReleaseArtifact(applicationReleaseDTO.getAppHashValue(), folderPath,
applicationReleaseDTO.getScreenshotName3()); applicationReleaseDTO.getScreenshotName3());
applicationReleaseDTO.setScreenshotName3(scName); applicationReleaseDTO.setScreenshotName3(scName);
} }
@ -583,12 +589,14 @@ public class ApplicationManagerImpl implements ApplicationManager {
log.error(msg); log.error(msg);
throw new ApplicationManagementException(msg, e); throw new ApplicationManagementException(msg, e);
} catch (UserStoreException e) { } catch (UserStoreException e) {
throw new ApplicationManagementException( String msg = "User-store exception while checking whether the user " + userName + " of tenant " + tenantId
"User-store exception while checking whether the user " + userName + " of tenant " + tenantId + " has the publisher permission";
+ " has the publisher permission", e); log.error(msg);
throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException e) { } catch (ApplicationManagementDAOException e) {
throw new ApplicationManagementException( String msg = "DAO exception while getting applications for the user " + userName + " of tenant " + tenantId;
"DAO exception while getting applications for the user " + userName + " of tenant " + tenantId, e); log.error(msg);
throw new ApplicationManagementException(msg, e);
} finally { } finally {
ConnectionManagerUtil.closeDBConnection(); ConnectionManagerUtil.closeDBConnection();
} }
@ -792,23 +800,26 @@ public class ApplicationManagerImpl implements ApplicationManager {
ConnectionManagerUtil.commitDBTransaction(); ConnectionManagerUtil.commitDBTransaction();
return applicationRelease; return applicationRelease;
} catch (TransactionManagementException e) { } catch (TransactionManagementException e) {
throw new ApplicationManagementException( String msg = "Error occurred while staring application release creating transaction for application Id: "
"Error occurred while staring application release creating transaction for application Id: " + applicationId;
+ applicationId, e); log.error(msg);
throw new ApplicationManagementException(msg, e);
} catch (DBConnectionException e) { } catch (DBConnectionException e) {
throw new ApplicationManagementException( String msg = "Error occurred while adding application release into IoTS app management ApplicationDTO id of"
"Error occurred while adding application release into IoTS app management ApplicationDTO id of the " + " the application release: " + applicationId;
+ "application release: " + applicationId, e); log.error(msg);
throw new ApplicationManagementException(msg, e);
} catch (LifeCycleManagementDAOException e) { } catch (LifeCycleManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction(); ConnectionManagerUtil.rollbackDBTransaction();
throw new ApplicationManagementException( String msg = "Error occurred while adding new application release lifecycle state to the application"
"Error occurred while adding new application release lifecycle state to the application release: " + " release: " + applicationId;
+ applicationId, e); log.error(msg);
throw new ApplicationManagementException(msg, e);
} catch (ApplicationManagementDAOException e) { } catch (ApplicationManagementDAOException e) {
ConnectionManagerUtil.rollbackDBTransaction(); ConnectionManagerUtil.rollbackDBTransaction();
throw new ApplicationManagementException( String msg = "Error occurred while adding new application release for application " + applicationId;
"Error occurred while adding new application release for application " + applicationId, e); log.error(msg);
throw new ApplicationManagementException(msg, e);
} finally { } finally {
ConnectionManagerUtil.closeDBConnection(); ConnectionManagerUtil.closeDBConnection();
} }

@ -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.common.services.ApplicationStorageManager;
import org.wso2.carbon.device.application.mgt.core.exception.ParsingException; 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.ArtifactsParser;
import org.wso2.carbon.device.application.mgt.core.util.Constants;
import org.wso2.carbon.device.application.mgt.core.util.StorageManagementUtil; import org.wso2.carbon.device.application.mgt.core.util.StorageManagementUtil;
import java.io.*; import java.io.*;
@ -60,21 +61,24 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
public ApplicationReleaseDTO uploadImageArtifacts(ApplicationReleaseDTO applicationReleaseDTO, public ApplicationReleaseDTO uploadImageArtifacts(ApplicationReleaseDTO applicationReleaseDTO,
InputStream iconFileStream, InputStream bannerFileStream, List<InputStream> screenShotStreams) InputStream iconFileStream, InputStream bannerFileStream, List<InputStream> screenShotStreams)
throws ResourceManagementException { throws ResourceManagementException {
String artifactDirectoryPath;
String iconStoredLocation; String iconStoredLocation;
String bannerStoredLocation; String bannerStoredLocation;
String scStoredLocation = null; String scStoredLocation = null;
try { try {
artifactDirectoryPath = storagePath + applicationReleaseDTO.getAppHashValue(); String artifactStoringBaseDirPath = storagePath + applicationReleaseDTO.getAppHashValue();
StorageManagementUtil.createArtifactDirectory(artifactDirectoryPath); StorageManagementUtil.createArtifactDirectory(artifactStoringBaseDirPath);
if (iconFileStream != null) { 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); saveFile(iconFileStream, iconStoredLocation);
} }
if (bannerFileStream != null) { 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); saveFile(bannerFileStream, bannerStoredLocation);
} }
if (!screenShotStreams.isEmpty()) { if (!screenShotStreams.isEmpty()) {
@ -86,14 +90,16 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
} }
int count = 1; int count = 1;
for (InputStream screenshotStream : screenShotStreams) { for (InputStream screenshotStream : screenShotStreams) {
String scStoringDir = artifactStoringBaseDirPath + File.separator + Constants.SCREENSHOT_ARTIFACT + count;
StorageManagementUtil.createArtifactDirectory(scStoringDir);
if (count == 1) { if (count == 1) {
scStoredLocation = artifactDirectoryPath + File.separator + applicationReleaseDTO.getScreenshotName1(); scStoredLocation = scStoringDir + File.separator + applicationReleaseDTO.getScreenshotName1();
} }
if (count == 2) { if (count == 2) {
scStoredLocation = artifactDirectoryPath + File.separator + applicationReleaseDTO.getScreenshotName2(); scStoredLocation = scStoringDir + File.separator + applicationReleaseDTO.getScreenshotName2();
} }
if (count == 3) { if (count == 3) {
scStoredLocation = artifactDirectoryPath + File.separator + applicationReleaseDTO.getScreenshotName3(); scStoredLocation = scStoringDir + File.separator + applicationReleaseDTO.getScreenshotName3();
} }
saveFile(screenshotStream, scStoredLocation); saveFile(screenshotStream, scStoredLocation);
count++; count++;
@ -101,8 +107,10 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
} }
return applicationReleaseDTO; return applicationReleaseDTO;
} catch (IOException e) { } catch (IOException e) {
throw new ApplicationStorageManagementException("IO Exception while saving the screens hots for " + String msg = "IO Exception occurred while saving application artifacts for the application which has UUID "
"the application " + applicationReleaseDTO.getUuid(), e); + applicationReleaseDTO.getUuid();
log.error(msg);
throw new ApplicationStorageManagementException(msg, e);
} }
} }
@ -142,7 +150,8 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
String artifactPath; String artifactPath;
byte [] content = IOUtils.toByteArray(binaryFile); byte [] content = IOUtils.toByteArray(binaryFile);
artifactDirectoryPath = storagePath + applicationReleaseDTO.getAppHashValue(); artifactDirectoryPath =
storagePath + applicationReleaseDTO.getAppHashValue() + File.separator + Constants.APP_ARTIFACT;
StorageManagementUtil.createArtifactDirectory(artifactDirectoryPath); StorageManagementUtil.createArtifactDirectory(artifactDirectoryPath);
artifactPath = artifactDirectoryPath + File.separator + applicationReleaseDTO.getInstallerName(); artifactPath = artifactDirectoryPath + File.separator + applicationReleaseDTO.getInstallerName();
saveFile(new ByteArrayInputStream(content), artifactPath); saveFile(new ByteArrayInputStream(content), artifactPath);
@ -168,24 +177,38 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
String screenshot3 = applicationReleaseDTO.getScreenshotName3(); String screenshot3 = applicationReleaseDTO.getScreenshotName3();
if (bannerName != null) { if (bannerName != null) {
StorageManagementUtil.copy(storagePath + deletingAppHashValue + File.separator + bannerName, StorageManagementUtil
storagePath + appHashValue + File.separator + bannerName); .copy(storagePath + deletingAppHashValue + File.separator + Constants.BANNER_ARTIFACT
+ File.separator + bannerName,
storagePath + appHashValue + File.separator + Constants.BANNER_ARTIFACT + File.separator
+ bannerName);
} }
if (iconName != null) { if (iconName != null) {
StorageManagementUtil.copy(storagePath + deletingAppHashValue + File.separator + iconName, StorageManagementUtil.copy(storagePath + deletingAppHashValue + File.separator + Constants.ICON_ARTIFACT
storagePath + appHashValue + File.separator + iconName); + File.separator + iconName,
storagePath + appHashValue + File.separator + Constants.ICON_ARTIFACT + File.separator
+ iconName);
} }
if (screenshot1 != null) { if (screenshot1 != null) {
StorageManagementUtil.copy(storagePath + deletingAppHashValue + File.separator + screenshot1, StorageManagementUtil
storagePath + appHashValue + File.separator + screenshot1); .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) { if (screenshot2 != null) {
StorageManagementUtil.copy(storagePath + deletingAppHashValue + File.separator + screenshot2, StorageManagementUtil
storagePath + appHashValue + File.separator + screenshot2); .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) { if (screenshot3 != null) {
StorageManagementUtil.copy(storagePath + deletingAppHashValue + File.separator + screenshot3, StorageManagementUtil
storagePath + appHashValue + File.separator + screenshot3); .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); deleteAppReleaseArtifact( storagePath + deletingAppHashValue);
} catch (IOException e) { } catch (IOException e) {
@ -198,8 +221,9 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
@Override @Override
public void deleteAppReleaseArtifact(String appReleaseHashVal, String fileName) throws ApplicationStorageManagementException { public void deleteAppReleaseArtifact(String appReleaseHashVal, String folderName, String fileName)
String artifactPath = storagePath + appReleaseHashVal + File.separator + fileName; throws ApplicationStorageManagementException {
String artifactPath = storagePath + appReleaseHashVal + File.separator + folderName + File.separator + fileName;
deleteAppReleaseArtifact(artifactPath); deleteAppReleaseArtifact(artifactPath);
} }
@ -212,8 +236,9 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager
} }
@Override @Override
public InputStream getFileSttream (String path) throws ApplicationStorageManagementException { public InputStream getFileStream(String hashVal, String folderName, String fileName)
String filePath = storagePath + path; throws ApplicationStorageManagementException {
String filePath = storagePath + hashVal + File.separator + folderName + File.separator + fileName;
try { try {
return StorageManagementUtil.getInputStream(filePath); return StorageManagementUtil.getInputStream(filePath);
} catch (IOException e) { } catch (IOException e) {

@ -64,12 +64,11 @@ public class AppmDataHandlerImpl implements AppmDataHandler {
return lifecycleStateManager.getLifecycleConfig(); return lifecycleStateManager.getLifecycleConfig();
} }
@Override @Override public InputStream getArtifactStream(String uuid, String folderName, String artifactName)
public InputStream getArtifactStream(String uuid, String artifactName) throws ApplicationManagementException { throws ApplicationManagementException {
int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true);
ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager(); ApplicationStorageManager applicationStorageManager = DAOUtil.getApplicationStorageManager();
ApplicationReleaseDAO applicationReleaseDAO = ApplicationManagementDAOFactory.getApplicationReleaseDAO(); ApplicationReleaseDAO applicationReleaseDAO = ApplicationManagementDAOFactory.getApplicationReleaseDAO();
String artifactPath;
String appReleaseHashValue; String appReleaseHashValue;
try { try {
ConnectionManagerUtil.openDBConnection(); ConnectionManagerUtil.openDBConnection();
@ -79,10 +78,10 @@ public class AppmDataHandlerImpl implements AppmDataHandler {
log.error(msg); log.error(msg);
throw new NotFoundException(msg); throw new NotFoundException(msg);
} }
artifactPath = appReleaseHashValue + Constants.FORWARD_SLASH + artifactName; InputStream inputStream = applicationStorageManager
InputStream inputStream = applicationStorageManager.getFileSttream(artifactPath); .getFileStream(appReleaseHashValue, folderName, artifactName);
if (inputStream == null) { 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); log.error(msg);
throw new ApplicationManagementException(msg); throw new ApplicationManagementException(msg);
} }

@ -338,8 +338,7 @@ public class APIUtil {
String artifactDownloadEndpoint = ConfigurationManager.getInstance().getConfiguration() String artifactDownloadEndpoint = ConfigurationManager.getInstance().getConfiguration()
.getArtifactDownloadEndpoint(); .getArtifactDownloadEndpoint();
String basePath = Constants.ARTIFACT_DOWNLOAD_PROTOCOL + "://" + host + ":" + port + artifactDownloadEndpoint String basePath = Constants.ARTIFACT_DOWNLOAD_PROTOCOL + "://" + host + ":" + port + artifactDownloadEndpoint
+ Constants.FORWARD_SLASH + applicationReleaseDTO.getUuid() + Constants.FORWARD_SLASH + applicationReleaseDTO.getUuid() + Constants.FORWARD_SLASH;
+ Constants.FORWARD_SLASH;
List<String> screenshotPaths = new ArrayList<>(); List<String> screenshotPaths = new ArrayList<>();
ApplicationRelease applicationRelease = new ApplicationRelease(); ApplicationRelease applicationRelease = new ApplicationRelease();
@ -356,28 +355,37 @@ public class APIUtil {
applicationRelease.setIsSharedWithAllTenants(applicationReleaseDTO.getIsSharedWithAllTenants()); applicationRelease.setIsSharedWithAllTenants(applicationReleaseDTO.getIsSharedWithAllTenants());
applicationRelease.setSupportedOsVersions(applicationReleaseDTO.getSupportedOsVersions()); applicationRelease.setSupportedOsVersions(applicationReleaseDTO.getSupportedOsVersions());
applicationRelease.setRating(applicationReleaseDTO.getRating()); 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())){ 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())) { if (urlValidator.isValid(applicationReleaseDTO.getInstallerName())) {
applicationRelease applicationRelease.setInstallerPath(applicationReleaseDTO.getInstallerName());
.setInstallerPath(applicationReleaseDTO.getInstallerName());
} else { } else {
applicationRelease applicationRelease.setInstallerPath(
.setInstallerPath(basePath + applicationReleaseDTO.getInstallerName()); basePath + Constants.APP_ARTIFACT + Constants.FORWARD_SLASH + applicationReleaseDTO
.getInstallerName());
} }
if (!StringUtils.isEmpty(applicationReleaseDTO.getScreenshotName1())) { 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())) { 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())) { 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); applicationRelease.setScreenshots(screenshotPaths);
return applicationRelease; return applicationRelease;

@ -61,16 +61,25 @@ public class Constants {
public static final String DB_TYPE_POSTGRESQL = "PostgreSQL"; 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; public static final int REVIEW_PARENT_ID = -1;

Loading…
Cancel
Save