From b7e6fed1813f412be1510b19f11a88cc898eec26 Mon Sep 17 00:00:00 2001 From: lasanthaDLPDS Date: Sat, 22 Jun 2019 23:40:27 +0530 Subject: [PATCH] Construct artifact download URL by using sys props --- .../device/application/mgt/common/LifecycleState.java | 8 ++++---- .../lifecyclestate/GenericLifecycleStateDAOImpl.java | 2 +- .../mgt/core/impl/ApplicationManagerImpl.java | 10 +++++++--- .../mgt/core/impl/SubscriptionManagerImpl.java | 9 ++++++--- .../device/application/mgt/core/util/APIUtil.java | 5 ++++- .../device/application/mgt/core/util/Constants.java | 3 +++ .../impl/ApplicationManagementPublisherAPIImpl.java | 5 ++--- .../src/main/resources/conf/application-mgt.xml | 2 +- 8 files changed, 28 insertions(+), 16 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/LifecycleState.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/LifecycleState.java index 11260d3505..3d6b948872 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/LifecycleState.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/LifecycleState.java @@ -49,9 +49,9 @@ public class LifecycleState { value = "Timestamp of the lifecycle has been updated") private Timestamp updatedAt; - @ApiModelProperty(name = "resonForChange", + @ApiModelProperty(name = "reasonForChange", value = "Reason for the application release lifecycle change from previous state to current state.") - private String resonForChange; + private String reasonForChange; public String getCurrentState() { return currentState; @@ -93,7 +93,7 @@ public class LifecycleState { this.nextStates = nextStates; } - public String getResonForChange() { return resonForChange; } + public String getReasonForChange() { return reasonForChange; } - public void setResonForChange(String resonForChange) { this.resonForChange = resonForChange; } + public void setReasonForChange(String reasonForChange) { this.reasonForChange = reasonForChange; } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/lifecyclestate/GenericLifecycleStateDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/lifecyclestate/GenericLifecycleStateDAOImpl.java index 0673e1cb31..85501dc434 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/lifecyclestate/GenericLifecycleStateDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/lifecyclestate/GenericLifecycleStateDAOImpl.java @@ -188,7 +188,7 @@ public class GenericLifecycleStateDAOImpl extends AbstractDAOImpl implements Lif stmt.setInt(3, tenantId); stmt.setString(4, state.getUpdatedBy()); stmt.setTimestamp(5, timestamp); - stmt.setString(6, state.getResonForChange()); + stmt.setString(6, state.getReasonForChange()); stmt.setInt(7, appReleaseId); stmt.setInt(8, appReleaseId); stmt.executeUpdate(); 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 4b3fff7d4a..3fa843c234 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 @@ -1451,7 +1451,7 @@ public class ApplicationManagerImpl implements ApplicationManager { lifecycleState.setCurrentState(lifecycleChanger.getAction()); lifecycleState.setPreviousState(applicationReleaseDTO.getCurrentState()); lifecycleState.setUpdatedBy(userName); - lifecycleState.setResonForChange(lifecycleChanger.getReason()); + lifecycleState.setReasonForChange(lifecycleChanger.getReason()); applicationReleaseDTO.setCurrentState(lifecycleChanger.getAction()); if (this.applicationReleaseDAO.updateRelease(applicationReleaseDTO, tenantId) == null) { String msg = "Application release updating is failed/."; @@ -2528,10 +2528,14 @@ public class ApplicationManagerImpl implements ApplicationManager { throw new NotFoundException(msg); } ApplicationReleaseDTO applicationReleaseDTO = applicationDTO.getApplicationReleaseDTOs().get(0); + String host = System.getProperty(Constants.IOT_HOST_PROPERTY); + String port = System.getProperty(Constants.IOT_PORT_PROPERTY); String artifactDownloadEndpoint = ConfigurationManager.getInstance().getConfiguration() .getArtifactDownloadEndpoint(); - String artifactDownloadURL = artifactDownloadEndpoint + Constants.FORWARD_SLASH + applicationReleaseDTO.getUuid() - + Constants.FORWARD_SLASH + applicationReleaseDTO.getInstallerName(); + String artifactDownloadURL = + Constants.ARTIFACT_DOWNLOAD_PROTOCOL + "://" + host + ":" + port + artifactDownloadEndpoint + + Constants.FORWARD_SLASH + applicationReleaseDTO.getUuid() + Constants.FORWARD_SLASH + + applicationReleaseDTO.getInstallerName(); String plistContent = "<!DOCTYPE plist PUBLIC "-//Apple//DTDPLIST1.0//EN" "" + "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="" + "1.0"><dict><key>items</key><array><dict><" + diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java index 119550c4f0..e32fe3f5cd 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/SubscriptionManagerImpl.java @@ -478,11 +478,14 @@ public class SubscriptionManagerImpl implements SubscriptionManager { } } else if (DeviceTypes.IOS.toString().equalsIgnoreCase(deviceType)) { if (SubAction.INSTALL.toString().equalsIgnoreCase(action)) { + String host = System.getProperty(Constants.IOT_HOST_PROPERTY); + String port = System.getProperty(Constants.IOT_PORT_PROPERTY); String artifactDownloadEndpoint = ConfigurationManager.getInstance().getConfiguration() .getArtifactDownloadEndpoint(); - String plistDownloadEndpoint = artifactDownloadEndpoint + Constants.FORWARD_SLASH + - MDMAppConstants.IOSConstants.PLIST + Constants.FORWARD_SLASH + - application.getApplicationReleases().get(0).getUuid(); + String plistDownloadEndpoint = + Constants.ARTIFACT_DOWNLOAD_PROTOCOL + "://" + host + ":" + port + artifactDownloadEndpoint + + Constants.FORWARD_SLASH + MDMAppConstants.IOSConstants.PLIST + + Constants.FORWARD_SLASH + application.getApplicationReleases().get(0).getUuid(); mobileApp.setType(mobileAppType); mobileApp.setLocation(plistDownloadEndpoint); Properties properties = new Properties(); 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 2458db3a30..2a6ef030c5 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 @@ -334,9 +334,12 @@ public class APIUtil { } public static ApplicationRelease releaseDtoToRelease(ApplicationReleaseDTO applicationReleaseDTO){ + String host = System.getProperty(Constants.IOT_HOST_PROPERTY); + String port = System.getProperty(Constants.IOT_PORT_PROPERTY); String artifactDownloadEndpoint = ConfigurationManager.getInstance().getConfiguration() .getArtifactDownloadEndpoint(); - String basePath = artifactDownloadEndpoint + Constants.FORWARD_SLASH + applicationReleaseDTO.getUuid() + String basePath = Constants.ARTIFACT_DOWNLOAD_PROTOCOL + "://" + host + ":" + port + artifactDownloadEndpoint + + Constants.FORWARD_SLASH + applicationReleaseDTO.getUuid() + Constants.FORWARD_SLASH; List screenshotPaths = new ArrayList<>(); 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 179bc51a63..783e19bd08 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 @@ -36,6 +36,9 @@ public class Constants { public static final String PLIST_NAME = "Info.plist"; public static final String CF_BUNDLE_VERSION = "CFBundleVersion"; public static final String APP_EXTENSION = ".app"; + public static final String IOT_HOST_PROPERTY = "iot.core.host"; + public static final String IOT_PORT_PROPERTY = "iot.core.http.port"; + public static final String ARTIFACT_DOWNLOAD_PROTOCOL = "http"; public static final String FORWARD_SLASH = "/"; public static final String ANY = "ANY"; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/impl/ApplicationManagementPublisherAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/impl/ApplicationManagementPublisherAPIImpl.java index f3669c0979..0894c0d221 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/impl/ApplicationManagementPublisherAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/impl/ApplicationManagementPublisherAPIImpl.java @@ -367,9 +367,8 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem try { if (!ApplicationType.ENTERPRISE.toString().equals(appType)) { - String msg = "If ApplicationDTO type is " + appType - + ", therefore you don't have application release artifact to update for application release UUID: " - + applicationReleaseUuid; + String msg = "If Application type is " + appType + ", then you don't have application release artifact " + + "to update for application release UUID: " + applicationReleaseUuid; log.error(msg); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); } diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml index 001c06ecbe..ad7b89a56b 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/src/main/resources/conf/application-mgt.xml @@ -172,7 +172,7 @@ - https://localhost:9443/api/application-mgt/v1.0/artifact + /api/application-mgt/v1.0/artifact EMM IoT