|
|
@ -21,7 +21,9 @@ package org.wso2.carbon.device.application.mgt.core.util;
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
|
|
|
|
import org.apache.commons.validator.routines.UrlValidator;
|
|
|
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
|
|
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
|
|
|
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.ApplicationType;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationReleaseDTO;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.dto.ApplicationReleaseDTO;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.response.Application;
|
|
|
|
import org.wso2.carbon.device.application.mgt.common.response.Application;
|
|
|
@ -280,10 +282,11 @@ public class APIUtil {
|
|
|
|
throws BadRequestException, UnexpectedServerErrorException {
|
|
|
|
throws BadRequestException, UnexpectedServerErrorException {
|
|
|
|
|
|
|
|
|
|
|
|
Application application = new Application();
|
|
|
|
Application application = new Application();
|
|
|
|
//This is for handling web-apps
|
|
|
|
if (!ApplicationType.WEB_CLIP.toString().equals(applicationDTO.getType())) {
|
|
|
|
if (applicationDTO.getDeviceTypeId() > 0) {
|
|
|
|
|
|
|
|
DeviceType deviceType = getDeviceTypeData(applicationDTO.getDeviceTypeId());
|
|
|
|
DeviceType deviceType = getDeviceTypeData(applicationDTO.getDeviceTypeId());
|
|
|
|
application.setDeviceType(deviceType.getName());
|
|
|
|
application.setDeviceType(deviceType.getName());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
application.setDeviceType("ANY");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
application.setId(applicationDTO.getId());
|
|
|
|
application.setId(applicationDTO.getId());
|
|
|
|
application.setName(applicationDTO.getName());
|
|
|
|
application.setName(applicationDTO.getName());
|
|
|
@ -306,8 +309,11 @@ public class APIUtil {
|
|
|
|
.getArtifactDownloadEndpoint();
|
|
|
|
.getArtifactDownloadEndpoint();
|
|
|
|
String basePath = artifactDownloadEndpoint + Constants.FORWARD_SLASH + applicationReleaseDTO.getUuid()
|
|
|
|
String basePath = artifactDownloadEndpoint + 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();
|
|
|
|
|
|
|
|
UrlValidator urlValidator = new UrlValidator();
|
|
|
|
|
|
|
|
|
|
|
|
applicationRelease.setDescription(applicationReleaseDTO.getDescription());
|
|
|
|
applicationRelease.setDescription(applicationReleaseDTO.getDescription());
|
|
|
|
applicationRelease.setVersion(applicationReleaseDTO.getVersion());
|
|
|
|
applicationRelease.setVersion(applicationReleaseDTO.getVersion());
|
|
|
|
applicationRelease.setUuid(applicationReleaseDTO.getUuid());
|
|
|
|
applicationRelease.setUuid(applicationReleaseDTO.getUuid());
|
|
|
@ -315,16 +321,21 @@ public class APIUtil {
|
|
|
|
applicationRelease.setPrice(applicationReleaseDTO.getPrice());
|
|
|
|
applicationRelease.setPrice(applicationReleaseDTO.getPrice());
|
|
|
|
applicationRelease.setIsSharedWithAllTenants(applicationReleaseDTO.getIsSharedWithAllTenants());
|
|
|
|
applicationRelease.setIsSharedWithAllTenants(applicationReleaseDTO.getIsSharedWithAllTenants());
|
|
|
|
applicationRelease.setMetaData(applicationReleaseDTO.getMetaData());
|
|
|
|
applicationRelease.setMetaData(applicationReleaseDTO.getMetaData());
|
|
|
|
applicationRelease.setUrl(applicationReleaseDTO.getUrl());
|
|
|
|
|
|
|
|
applicationRelease.setCurrentStatus(applicationReleaseDTO.getCurrentState());
|
|
|
|
applicationRelease.setCurrentStatus(applicationReleaseDTO.getCurrentState());
|
|
|
|
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
|
|
|
|
|
|
|
|
.setInstallerPath(basePath + applicationReleaseDTO.getInstallerName());
|
|
|
|
|
|
|
|
applicationRelease.setIconPath(basePath + applicationReleaseDTO.getIconName());
|
|
|
|
applicationRelease.setIconPath(basePath + applicationReleaseDTO.getIconName());
|
|
|
|
applicationRelease.setBannerPath(basePath + applicationReleaseDTO.getBannerName());
|
|
|
|
applicationRelease.setBannerPath(basePath + applicationReleaseDTO.getBannerName());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (urlValidator.isValid(applicationReleaseDTO.getInstallerName())){
|
|
|
|
|
|
|
|
applicationRelease
|
|
|
|
|
|
|
|
.setInstallerPath(applicationReleaseDTO.getInstallerName());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
applicationRelease
|
|
|
|
|
|
|
|
.setInstallerPath(basePath + applicationReleaseDTO.getInstallerName());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.isEmpty(applicationReleaseDTO.getScreenshotName1())) {
|
|
|
|
if (!StringUtils.isEmpty(applicationReleaseDTO.getScreenshotName1())) {
|
|
|
|
screenshotPaths.add(basePath + applicationReleaseDTO.getScreenshotName1());
|
|
|
|
screenshotPaths.add(basePath + applicationReleaseDTO.getScreenshotName1());
|
|
|
|
}
|
|
|
|
}
|
|
|
|