From b06a908f5fc7fc563fc2026dbeb815370ec1e210 Mon Sep 17 00:00:00 2001 From: lasanthaDLPDS Date: Mon, 8 Apr 2019 08:07:10 +0530 Subject: [PATCH] Modify Entity Class name --- .../mgt/api/services/ArtifactDownloadAPI.java | 4 +- .../mgt/api/services/ConfigRetrieveAPI.java | 4 +- .../impl/ArtifactDownloadAPIImpl.java | 2 +- .../services/impl/ConfigRetrieveAPIImpl.java | 2 +- .../pom.xml | 225 ------- .../api/services/AppArtifactRetrievalAPI.java | 19 - .../impl/AppArtifactRetrivaalAPIImpl.java | 19 - .../src/main/webapp/META-INF/permissions.xml | 33 - .../webapp/META-INF/webapp-classloading.xml | 35 -- .../src/main/webapp/WEB-INF/cxf-servlet.xml | 67 -- .../src/main/webapp/WEB-INF/web.xml | 120 ---- .../application/mgt/common/AppOperation.java | 8 +- .../mgt/common/ApplicationList.java | 10 +- .../mgt/common/EnterpriseApplication.java | 2 +- .../common/EnterpriseInstallationDetails.java | 2 +- .../ApplicationDTO.java} | 18 +- .../ApplicationReleaseDTO.java} | 14 +- .../CategoryDTO.java} | 4 +- .../LifecycleStateDTO.java} | 6 +- .../TagEntity.java => dto/TagDTO.java} | 4 +- .../mgt/common/response/Application.java | 2 +- .../common/response/ApplicationRelease.java | 6 +- .../common/services/ApplicationManager.java | 132 ++-- .../services/ApplicationStorageManager.java | 39 +- .../mgt/common/services/AppmDataHandler.java | 2 +- .../common/services/SubscriptionManager.java | 6 +- .../wrapper/ApplicationReleaseWrapper.java | 4 +- .../common/wrapper/ApplicationWrapper.java | 4 +- .../mgt/core/dao/ApplicationDAO.java | 80 +-- .../mgt/core/dao/ApplicationReleaseDAO.java | 75 ++- .../mgt/core/dao/LifecycleStateDAO.java | 14 +- .../mgt/core/dao/SubscriptionDAO.java | 20 +- .../application/mgt/core/dao/common/Util.java | 48 +- .../core/dao/impl/Review/ReviewDAOImpl.java | 4 +- .../GenericApplicationDAOImpl.java | 53 +- .../GenericApplicationReleaseDAOImpl.java | 77 ++- .../GenericLifecycleStateDAOImpl.java | 20 +- .../ApplicationManagementDAOException.java | 2 +- .../mgt/core/impl/ApplicationManagerImpl.java | 580 +++++++++--------- .../impl/ApplicationStorageManagerImpl.java | 69 +-- .../core/impl/SubscriptionManagerImpl.java | 14 +- ...ApplicationManagementServiceComponent.java | 4 +- .../application/mgt/core/util/APIUtil.java | 8 +- .../src/test/resources/application-mgt.xml | 2 +- .../services/ApplicationManagementAPI.java | 74 ++- .../impl/ApplicationManagementAPIImpl.java | 52 +- .../src/main/webapp/META-INF/permissions.xml | 2 +- .../react-app/public/fonts/font-wso2.svg | 2 +- .../services/ApplicationManagementAPI.java | 20 +- .../services/SubscriptionManagementAPI.java | 22 +- .../impl/ApplicationManagementAPIImpl.java | 4 +- .../impl/SubscriptionManagementAPIImpl.java | 6 +- .../src/main/webapp/META-INF/permissions.xml | 2 +- .../react-app/public/fonts/font-wso2.svg | 2 +- 54 files changed, 784 insertions(+), 1265 deletions(-) delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/pom.xml delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/java/org/wso2/carbon/device/application/mgt/artifact/retrieve/api/services/AppArtifactRetrievalAPI.java delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/java/org/wso2/carbon/device/application/mgt/artifact/retrieve/api/services/impl/AppArtifactRetrivaalAPIImpl.java delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/webapp/META-INF/permissions.xml delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/webapp/META-INF/webapp-classloading.xml delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/webapp/WEB-INF/cxf-servlet.xml delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/webapp/WEB-INF/web.xml rename components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/{entity/ApplicationEntity.java => dto/ApplicationDTO.java} (88%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/{entity/ApplicationReleaseEntity.java => dto/ApplicationReleaseDTO.java} (93%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/{entity/CategoryEntity.java => dto/CategoryDTO.java} (84%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/{entity/LifecycleStateEntity.java => dto/LifecycleStateDTO.java} (92%) rename components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/{entity/TagEntity.java => dto/TagDTO.java} (84%) 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 e00231eb76..676696c67e 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 @@ -42,7 +42,7 @@ import javax.ws.rs.core.Response; @SwaggerDefinition( info = @Info( version = "1.0.0", - title = "ApplicationEntity Management Common Service", + title = "ApplicationDTO Management Common Service", extensions = { @Extension(properties = { @ExtensionProperty(name = "name", value = "ApplicationManagementArtifactDownloadService"), @@ -52,7 +52,7 @@ import javax.ws.rs.core.Response; ) ) @Path("/artifact") -@Api(value = "ApplicationEntity Management Artifact Downloading Service", description = "This API carries all application management artifact downloading services") +@Api(value = "ApplicationDTO Management Artifact Downloading Service", description = "This API carries all application management artifact downloading services") @Produces(MediaType.APPLICATION_JSON) public interface ArtifactDownloadAPI { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ConfigRetrieveAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ConfigRetrieveAPI.java index b67d309a29..23073823c1 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ConfigRetrieveAPI.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ConfigRetrieveAPI.java @@ -40,7 +40,7 @@ import javax.ws.rs.core.Response; @SwaggerDefinition( info = @Info( version = "1.0.0", - title = "ApplicationEntity Management Common Service", + title = "ApplicationDTO Management Common Service", extensions = { @Extension(properties = { @ExtensionProperty(name = "name", value = "ApplicationManagementCommonService"), @@ -50,7 +50,7 @@ import javax.ws.rs.core.Response; ) ) @Path("/config") -@Api(value = "ApplicationEntity Management Common Service", description = "This API carries all application management common services") +@Api(value = "ApplicationDTO Management Common Service", description = "This API carries all application management common services") @Produces(MediaType.APPLICATION_JSON) public interface ConfigRetrieveAPI { 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 75a01d96f5..581ff3f8a0 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 @@ -33,7 +33,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; /** - * Implementation of ApplicationEntity Management related APIs. + * Implementation of ApplicationDTO Management related APIs. */ @Produces({"application/json"}) @Path("/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/ConfigRetrieveAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ConfigRetrieveAPIImpl.java index 65394acab0..e32c4b1089 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ConfigRetrieveAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ConfigRetrieveAPIImpl.java @@ -32,7 +32,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.Response; /** - * Implementation of ApplicationEntity Management related APIs. + * Implementation of ApplicationDTO Management related APIs. */ @Produces({"application/json"}) @Path("/config") diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/pom.xml deleted file mode 100644 index 44c9556373..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/pom.xml +++ /dev/null @@ -1,225 +0,0 @@ - - - - - - - application-mgt - org.wso2.carbon.devicemgt - 3.2.2-SNAPSHOT - ../pom.xml - - - 4.0.0 - org.wso2.carbon.device.application.mgt.artifact.retrieve.api - 3.2.2-SNAPSHOT - war - WSO2 Carbon - Application Management Artifact_Retrieve API - WSO2 Carbon - Application Management API for getting application artifacts - http://wso2.org - - - - - maven-war-plugin - - WEB-INF/lib/*cxf*.jar - api#application-mgt-artifact-retrieve#v1.0 - - - - - - - - deploy - - compile - - - org.apache.maven.plugins - maven-antrun-plugin - 1.8 - - - compile - - run - - - - - - - - - - - - - - - - - - client - - test - - - org.codehaus.mojo - exec-maven-plugin - 1.5.0 - - - test - - java - - - - - - - - - - - - org.apache.cxf - cxf-rt-frontend-jaxws - provided - - - org.apache.cxf - cxf-rt-frontend-jaxrs - provided - - - org.apache.cxf - cxf-rt-transports-http - provided - - - junit - junit - test - - - org.codehaus.jackson - jackson-jaxrs - - - org.codehaus.jackson - jackson-core-asl - - - javax.ws.rs - jsr311-api - provided - - - org.wso2.carbon - org.wso2.carbon.utils - provided - - - org.wso2.carbon - org.wso2.carbon.logging - provided - - - org.json.wso2 - json - - - commons-codec.wso2 - commons-codec - provided - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.application.mgt.core - provided - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.application.mgt.common - provided - - - io.swagger - swagger-annotations - - - io.swagger - swagger-core - - - com.fasterxml.jackson.module - jackson-module-jaxb-annotations - - - org.slf4j - slf4j-api - - - org.wso2.orbit.com.fasterxml.jackson.core - jackson-core - - - - - io.swagger - swagger-jaxrs - - - com.fasterxml.jackson.module - jackson-module-jaxb-annotations - - - org.slf4j - slf4j-api - - - org.wso2.orbit.com.fasterxml.jackson.core - jackson-core - - - - - javax.servlet - javax.servlet-api - provided - - - org.wso2.carbon.devicemgt - org.wso2.carbon.apimgt.annotations - provided - - - org.wso2.orbit.com.fasterxml.jackson.core - jackson-annotations - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.application.mgt.addons - - - \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/java/org/wso2/carbon/device/application/mgt/artifact/retrieve/api/services/AppArtifactRetrievalAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/java/org/wso2/carbon/device/application/mgt/artifact/retrieve/api/services/AppArtifactRetrievalAPI.java deleted file mode 100644 index f129996803..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/java/org/wso2/carbon/device/application/mgt/artifact/retrieve/api/services/AppArtifactRetrievalAPI.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.wso2.carbon.device.application.mgt.artifact.retrieve.api.services;/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -public interface AppArtifactRetrievalAPI { -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/java/org/wso2/carbon/device/application/mgt/artifact/retrieve/api/services/impl/AppArtifactRetrivaalAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/java/org/wso2/carbon/device/application/mgt/artifact/retrieve/api/services/impl/AppArtifactRetrivaalAPIImpl.java deleted file mode 100644 index 8189ecdd18..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/java/org/wso2/carbon/device/application/mgt/artifact/retrieve/api/services/impl/AppArtifactRetrivaalAPIImpl.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.wso2.carbon.device.application.mgt.artifact.retrieve.api.services.impl;/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. - * - * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, - * Version 2.0 (the "License"); you may not use this file except - * in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -public class AppArtifactRetrivaalAPIImpl { -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/webapp/META-INF/permissions.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/webapp/META-INF/permissions.xml deleted file mode 100644 index c15153a078..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/webapp/META-INF/permissions.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/webapp/META-INF/webapp-classloading.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/webapp/META-INF/webapp-classloading.xml deleted file mode 100644 index e195e08097..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/webapp/META-INF/webapp-classloading.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - false - - - CXF,Carbon - diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/webapp/WEB-INF/cxf-servlet.xml deleted file mode 100644 index 8cfd529adf..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/webapp/WEB-INF/cxf-servlet.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/webapp/WEB-INF/web.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/webapp/WEB-INF/web.xml deleted file mode 100644 index bc86f46a54..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.artifact.retrieve.api/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - - Application Management Webapp - - JAX-WS/JAX-RS Application Management Endpoint - JAX-WS/JAX-RS Servlet - CXFServlet - - org.apache.cxf.transport.servlet.CXFServlet - - - - swagger.security.filter - ApiAuthorizationFilterImpl - - 1 - - - CXFServlet - /* - - - 60 - - - doAuthentication - false - - - - - - ApplicationMgt-Admin - /* - - - CONFIDENTIAL - - - - - - managed-api-enabled - true - - - managed-api-owner - admin - - - isSharedWithAllTenants - true - - - - ApiOriginFilter - org.wso2.carbon.device.application.mgt.addons.ApiOriginFilter - - - - HttpHeaderSecurityFilter - org.apache.catalina.filters.HttpHeaderSecurityFilter - - hstsEnabled - false - - - - - ContentTypeBasedCachePreventionFilter - org.wso2.carbon.ui.filters.cache.ContentTypeBasedCachePreventionFilter - - patterns - text/html" ,application/json" ,text/plain - - - filterAction - enforce - - - httpHeaders - Cache-Control: no-store, no-cache, must-revalidate, private - - - - - HttpHeaderSecurityFilter - /* - - - - ContentTypeBasedCachePreventionFilter - /* - - - - ApiOriginFilter - /* - - - \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/AppOperation.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/AppOperation.java index 8fe8464e50..f81911f05d 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/AppOperation.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/AppOperation.java @@ -18,13 +18,13 @@ */ package org.wso2.carbon.device.application.mgt.common; -import org.wso2.carbon.device.application.mgt.common.entity.ApplicationEntity; +import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO; public class AppOperation { private static final long serialVersionUID = 7603215716452548282L; - private ApplicationEntity application; + private ApplicationDTO application; private int tenantId; private String activityId; private String scheduledDateTime; @@ -73,11 +73,11 @@ public class AppOperation { this.type = type; } - public ApplicationEntity getApplication() { + public ApplicationDTO getApplication() { return application; } - public void setApplication(ApplicationEntity application) { + public void setApplication(ApplicationDTO application) { this.application = application; } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationList.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationList.java index 8c59f17dd4..6c0f1ff515 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationList.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationList.java @@ -18,24 +18,24 @@ */ package org.wso2.carbon.device.application.mgt.common; -import org.wso2.carbon.device.application.mgt.common.entity.ApplicationEntity; +import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO; import java.util.List; /** - * Represents a list of {@link ApplicationEntity}. + * Represents a list of {@link ApplicationDTO}. */ public class ApplicationList { - private List applications; + private List applications; private Pagination pagination; - public List getApplications() { + public List getApplications() { return applications; } - public void setApplications(List applications) { + public void setApplications(List applications) { this.applications = applications; } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/EnterpriseApplication.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/EnterpriseApplication.java index 15a29a4051..9fa337a284 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/EnterpriseApplication.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/EnterpriseApplication.java @@ -21,7 +21,7 @@ package org.wso2.carbon.device.application.mgt.common; import java.io.Serializable; /** - * This class represents the Enterprise ApplicationEntity information. + * This class represents the Enterprise ApplicationDTO information. */ public class EnterpriseApplication extends AndroidApplication implements Serializable { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/EnterpriseInstallationDetails.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/EnterpriseInstallationDetails.java index c5d7fbe2b2..5c386fd9e9 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/EnterpriseInstallationDetails.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/EnterpriseInstallationDetails.java @@ -37,7 +37,7 @@ public class EnterpriseInstallationDetails { @ApiModelProperty( name = "applicationUUID", - value = "ApplicationEntity ID", + value = "ApplicationDTO ID", required = true, example = "4354c752-109f-11e8-b642-0ed5f89f718b" ) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/entity/ApplicationEntity.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/dto/ApplicationDTO.java similarity index 88% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/entity/ApplicationEntity.java rename to components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/dto/ApplicationDTO.java index a65996de17..484dc4c255 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/entity/ApplicationEntity.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/dto/ApplicationDTO.java @@ -16,18 +16,16 @@ * under the License. * */ -package org.wso2.carbon.device.application.mgt.common.entity; +package org.wso2.carbon.device.application.mgt.common.dto; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import org.wso2.carbon.device.application.mgt.common.User; -import org.wso2.carbon.device.mgt.core.dto.DeviceType; import java.util.List; -@ApiModel(value = "ApplicationEntity", description = "ApplicationEntity represents the an ApplicationEntity in ApplicationEntity Store") -public class ApplicationEntity { +@ApiModel(value = "ApplicationDTO", description = "ApplicationDTO represents an Application details.") +public class ApplicationDTO { @ApiModelProperty(name = "id", value = "The ID given to the application when it is stored in the APPM database") @@ -44,7 +42,7 @@ public class ApplicationEntity { private String description; @ApiModelProperty(name = "appCategory", - value = "CategoryEntity of the application", + value = "Category of the application", required = true, example = "Educational, Gaming, Travel, Entertainment etc") private String appCategory; @@ -92,7 +90,7 @@ public class ApplicationEntity { private int appRating; @ApiModelProperty(name = "status", - value = "ApplicationEntity status", + value = "Application status", required = true, example = "REMOVED, ACTIVE") private String status; @@ -100,7 +98,7 @@ public class ApplicationEntity { @ApiModelProperty(name = "applicationReleases", value = "List of application releases", required = true) - private List applicationReleases; + private List applicationReleases; public int getId() { return id; @@ -154,11 +152,11 @@ public class ApplicationEntity { this.paymentCurrency = paymentCurrency; } - public List getApplicationReleases() { + public List getApplicationReleases() { return applicationReleases; } - public void setApplicationReleases(List applicationReleases) { + public void setApplicationReleases(List applicationReleases) { this.applicationReleases = applicationReleases; } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/entity/ApplicationReleaseEntity.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/dto/ApplicationReleaseDTO.java similarity index 93% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/entity/ApplicationReleaseEntity.java rename to components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/dto/ApplicationReleaseDTO.java index 007b28b577..f57035cc7a 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/entity/ApplicationReleaseEntity.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/dto/ApplicationReleaseDTO.java @@ -16,15 +16,15 @@ * under the License. * */ -package org.wso2.carbon.device.application.mgt.common.entity; +package org.wso2.carbon.device.application.mgt.common.dto; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import org.codehaus.jackson.annotate.JsonIgnoreProperties; -@ApiModel(value = "ApplicationReleaseEntity", description = "This class holds the details when releasing an ApplicationEntity to application store") +@ApiModel(value = "ApplicationReleaseDTO", description = "This class holds the details when releasing an ApplicationDTO to application store") @JsonIgnoreProperties({"appHashValue"}) -public class ApplicationReleaseEntity { +public class ApplicationReleaseDTO { @ApiModelProperty(name = "id", value = "ID of the application release") @@ -43,7 +43,7 @@ public class ApplicationReleaseEntity { private String uuid; @ApiModelProperty(name = "installerName", - value = "ApplicationEntity storing location") + value = "ApplicationDTO storing location") private String installerName; @ApiModelProperty(name = "bannerName", @@ -104,7 +104,7 @@ public class ApplicationReleaseEntity { private String url; @ApiModelProperty(name = "supportedOsVersions", - value = "ApplicationEntity release supported OS versions") + value = "ApplicationDTO release supported OS versions") private String supportedOsVersions; @ApiModelProperty(name = "currentState", @@ -112,10 +112,10 @@ public class ApplicationReleaseEntity { private String currentState; @ApiModelProperty(name = "packageName", - value = "ApplicationEntity bundle identifier") + value = "ApplicationDTO bundle identifier") private String packageName; - public ApplicationReleaseEntity() { + public ApplicationReleaseDTO() { } public int getRatedUsers() { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/entity/CategoryEntity.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/dto/CategoryDTO.java similarity index 84% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/entity/CategoryEntity.java rename to components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/dto/CategoryDTO.java index 293136948e..ff3d9d42bf 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/entity/CategoryEntity.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/dto/CategoryDTO.java @@ -1,4 +1,4 @@ -package org.wso2.carbon.device.application.mgt.common.entity;/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. +package org.wso2.carbon.device.application.mgt.common.dto;/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. * * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -15,7 +15,7 @@ package org.wso2.carbon.device.application.mgt.common.entity;/* Copyright (c) 20 * under the License. */ -public class CategoryEntity { +public class CategoryDTO { int id; String categoryName; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/entity/LifecycleStateEntity.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/dto/LifecycleStateDTO.java similarity index 92% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/entity/LifecycleStateEntity.java rename to components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/dto/LifecycleStateDTO.java index e4c3754e85..9130e8a9fb 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/entity/LifecycleStateEntity.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/dto/LifecycleStateDTO.java @@ -16,7 +16,7 @@ * under the License. * */ -package org.wso2.carbon.device.application.mgt.common.entity; +package org.wso2.carbon.device.application.mgt.common.dto; import java.sql.Timestamp; import io.swagger.annotations.ApiModel; @@ -24,8 +24,8 @@ import io.swagger.annotations.ApiModelProperty; import java.util.List; -@ApiModel(value = "LifecycleStateEntity", description = "LifecycleStateEntity represents the Lifecycle state for an application release") -public class LifecycleStateEntity { +@ApiModel(value = "LifecycleStateDTO", description = "LifecycleStateDTO represents the Lifecycle state for an application release") +public class LifecycleStateDTO { @ApiModelProperty(name = "id", value = "ID of the application release lifecycle", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/entity/TagEntity.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/dto/TagDTO.java similarity index 84% rename from components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/entity/TagEntity.java rename to components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/dto/TagDTO.java index 5095485a97..2817044575 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/entity/TagEntity.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/dto/TagDTO.java @@ -1,4 +1,4 @@ -package org.wso2.carbon.device.application.mgt.common.entity;/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. +package org.wso2.carbon.device.application.mgt.common.dto;/* Copyright (c) 2019, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved. * * Entgra (Pvt) Ltd. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except @@ -15,7 +15,7 @@ package org.wso2.carbon.device.application.mgt.common.entity;/* Copyright (c) 20 * under the License. */ -public class TagEntity { +public class TagDTO { int id; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/response/Application.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/response/Application.java index 9d98dfc1e0..b1d536297b 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/response/Application.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/response/Application.java @@ -36,7 +36,7 @@ public class Application { private String description; @ApiModelProperty(name = "appCategory", - value = "CategoryEntity of the application", + value = "CategoryDTO of the application", required = true, example = "Educational, Gaming, Travel, Entertainment etc") private String appCategory; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/response/ApplicationRelease.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/response/ApplicationRelease.java index 16c4e8eed8..f442afc38c 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/response/ApplicationRelease.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/response/ApplicationRelease.java @@ -21,7 +21,7 @@ package org.wso2.carbon.device.application.mgt.common.response; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -@ApiModel(value = "ApplicationReleaseEntity", description = "This class holds the details when releasing an ApplicationEntity to application store") +@ApiModel(value = "ApplicationReleaseDTO", description = "This class holds the details when releasing an ApplicationDTO to application store") public class ApplicationRelease { @ApiModelProperty(name = "description", @@ -37,7 +37,7 @@ public class ApplicationRelease { private String uuid; @ApiModelProperty(name = "installerPath", - value = "ApplicationEntity storing location") + value = "ApplicationDTO storing location") private String installerPath; @ApiModelProperty(name = "bannerPath", @@ -86,7 +86,7 @@ public class ApplicationRelease { private String url; @ApiModelProperty(name = "supportedOsVersions", - value = "ApplicationEntity release supported OS versions") + value = "ApplicationDTO release supported OS versions") private String supportedOsVersions; public String getReleaseType() { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManager.java index 072d0081a5..eda97c6aa6 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationManager.java @@ -20,11 +20,11 @@ package org.wso2.carbon.device.application.mgt.common.services; import org.apache.cxf.jaxrs.ext.multipart.Attachment; import org.wso2.carbon.device.application.mgt.common.ApplicationArtifact; -import org.wso2.carbon.device.application.mgt.common.entity.ApplicationEntity; +import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO; import org.wso2.carbon.device.application.mgt.common.ApplicationList; -import org.wso2.carbon.device.application.mgt.common.entity.ApplicationReleaseEntity; +import org.wso2.carbon.device.application.mgt.common.dto.ApplicationReleaseDTO; import org.wso2.carbon.device.application.mgt.common.Filter; -import org.wso2.carbon.device.application.mgt.common.entity.LifecycleStateEntity; +import org.wso2.carbon.device.application.mgt.common.dto.LifecycleStateDTO; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; import org.wso2.carbon.device.application.mgt.common.exception.RequestValidatingException; import org.wso2.carbon.device.application.mgt.common.response.Application; @@ -33,7 +33,6 @@ import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationWrapper; import java.io.InputStream; import java.util.List; -import java.util.Map; /** * This interface manages the application creation, deletion and editing of the application. @@ -43,9 +42,9 @@ public interface ApplicationManager { /** * Creates an application. * - * @param applicationWrapper ApplicationEntity that need to be created. + * @param applicationWrapper Application that need to be created. * @return Created application - * @throws ApplicationManagementException ApplicationEntity Management Exception + * @throws ApplicationManagementException ApplicationDTO Management Exception */ Application createApplication(ApplicationWrapper applicationWrapper, ApplicationArtifact applicationArtifact) throws ApplicationManagementException, RequestValidatingException; @@ -53,18 +52,18 @@ public interface ApplicationManager { /** * Updates an already existing application. * - * @param application ApplicationEntity that need to be updated. + * @param application Application that need to be updated. * @param applicationId ID of the application - * @return Updated ApplicationEntity - * @throws ApplicationManagementException ApplicationEntity Management Exception + * @return Updated Application + * @throws ApplicationManagementException ApplicationDTO Management Exception */ - ApplicationEntity updateApplication(int applicationId, ApplicationEntity application) throws ApplicationManagementException; + ApplicationDTO updateApplication(int applicationId, ApplicationDTO application) throws ApplicationManagementException; /** * Delete an application identified by the unique ID. * * @param applicationId ID for tha application - * @throws ApplicationManagementException ApplicationEntity Management Exception + * @throws ApplicationManagementException ApplicationDTO Management Exception */ List deleteApplication(int applicationId) throws ApplicationManagementException; @@ -73,7 +72,7 @@ public interface ApplicationManager { * * @param applicationId ID of tha application * @param releaseUuid UUID of tha application release - * @throws ApplicationManagementException ApplicationEntity Management Exception + * @throws ApplicationManagementException ApplicationDTO Management Exception */ String deleteApplicationRelease(int applicationId, String releaseUuid) throws ApplicationManagementException; @@ -82,69 +81,69 @@ public interface ApplicationManager { * * @param filter Search filter * @return Applications that matches the given filter criteria. - * @throws ApplicationManagementException ApplicationEntity Management Exception + * @throws ApplicationManagementException ApplicationDTO Management Exception */ ApplicationList getApplications(Filter filter, String deviceTypeName) throws ApplicationManagementException; /** - * To get the ApplicationEntity for given Id. + * To get the ApplicationDTO for given Id. * - * @param id id of the ApplicationEntity - * @param state state of the ApplicationEntity - * @return the ApplicationEntity identified by the ID - * @throws ApplicationManagementException ApplicationEntity Management Exception. + * @param id id of the ApplicationDTO + * @param state state of the ApplicationDTO + * @return the ApplicationDTO identified by the ID + * @throws ApplicationManagementException ApplicationDTO Management Exception. */ - ApplicationEntity getApplicationById(int id, String state) throws ApplicationManagementException; + ApplicationDTO getApplicationById(int id, String state) throws ApplicationManagementException; /** - * To get the ApplicationEntity for given application relase UUID. + * To get the ApplicationDTO for given application relase UUID. * - * @param uuid UUID of the ApplicationEntity - * @param state state of the ApplicationEntity - * @return the ApplicationEntity identified by the ID - * @throws ApplicationManagementException ApplicationEntity Management Exception. + * @param uuid UUID of the ApplicationDTO + * @param state state of the ApplicationDTO + * @return the ApplicationDTO identified by the ID + * @throws ApplicationManagementException ApplicationDTO Management Exception. */ - ApplicationEntity getApplicationByUuid(String uuid, String state) throws ApplicationManagementException; + ApplicationDTO getApplicationByUuid(String uuid, String state) throws ApplicationManagementException; /** * To get an application associated with the release. * * @param appReleaseUUID UUID of the app release - * @return {@link ApplicationEntity} associated with the release - * @throws ApplicationManagementException If unable to retrieve {@link ApplicationEntity} associated with the given UUID + * @return {@link ApplicationDTO} associated with the release + * @throws ApplicationManagementException If unable to retrieve {@link ApplicationDTO} associated with the given UUID */ - ApplicationEntity getApplicationByRelease(String appReleaseUUID) throws ApplicationManagementException; + ApplicationDTO getApplicationByRelease(String appReleaseUUID) throws ApplicationManagementException; /** - * To get all the releases of a particular ApplicationEntity. + * To get all the releases of a particular ApplicationDTO. * - * @param applicationId ID of the ApplicationEntity . - * @param releaseUuid UUID of the ApplicationEntity Release. - * @return the LifecycleStateEntity of the ApplicationEntity releases related with the particular ApplicationEntity. - * @throws ApplicationManagementException ApplicationEntity Management Exception. + * @param applicationId ID of the ApplicationDTO . + * @param releaseUuid UUID of the ApplicationDTO Release. + * @return the LifecycleStateDTO of the ApplicationDTO releases related with the particular ApplicationDTO. + * @throws ApplicationManagementException ApplicationDTO Management Exception. */ - LifecycleStateEntity getLifecycleState(int applicationId, String releaseUuid) throws ApplicationManagementException; + LifecycleStateDTO getLifecycleState(int applicationId, String releaseUuid) throws ApplicationManagementException; /** - * To get all the releases of a particular ApplicationEntity. + * To get all the releases of a particular ApplicationDTO. * - * @param applicationId ID of the ApplicationEntity. - * @param releaseUuid UUID of the ApplicationEntity Release. + * @param applicationId ID of the ApplicationDTO. + * @param releaseUuid UUID of the ApplicationDTO Release. * @param state Lifecycle state to change the app - * @throws ApplicationManagementException ApplicationEntity Management Exception. + * @throws ApplicationManagementException ApplicationDTO Management Exception. */ - void changeLifecycleState(int applicationId, String releaseUuid, LifecycleStateEntity state) + void changeLifecycleState(int applicationId, String releaseUuid, LifecycleStateDTO state) throws ApplicationManagementException; /** * To update release images such as icons, banner and screenshots. * - * @param appId ID of the ApplicationEntity - * @param uuid uuid of the ApplicationEntity + * @param appId ID of the ApplicationDTO + * @param uuid uuid of the ApplicationDTO * @param iconFileStream icon file of the release * @param bannerFileStream bannerFileStream of the release. * @param attachments screenshot attachments of the release - * @throws ApplicationManagementException ApplicationEntity Management Exception. + * @throws ApplicationManagementException ApplicationDTO Management Exception. */ void updateApplicationImageArtifact(int appId, String uuid, InputStream iconFileStream, InputStream bannerFileStream, List attachments) throws ApplicationManagementException; @@ -153,23 +152,23 @@ public interface ApplicationManager { /** * To update release images. * - * @param appId ID of the ApplicationEntity + * @param appId ID of the ApplicationDTO * @param deviceType Applicable device type of the application - * @param uuid uuid of the ApplicationEntity + * @param uuid uuid of the ApplicationDTO * @param binaryFile binaryFile of the release. - * @throws ApplicationManagementException ApplicationEntity Management Exception. + * @throws ApplicationManagementException ApplicationDTO Management Exception. */ void updateApplicationArtifact(int appId, String deviceType, String uuid, InputStream binaryFile) throws ApplicationManagementException; /** - * To create an application release for an ApplicationEntity. + * To create an application release for an ApplicationDTO. * - * @param applicationId ID of the ApplicationEntity + * @param applicationId ID of the ApplicationDTO * @param applicationRelease ApplicatonRelease that need to be be created. * @return the unique id of the application release, if the application release succeeded else -1 */ - ApplicationReleaseEntity createRelease(int applicationId, ApplicationReleaseEntity applicationRelease) + ApplicationReleaseDTO createRelease(int applicationId, ApplicationReleaseDTO applicationRelease) throws ApplicationManagementException; /*** @@ -177,23 +176,46 @@ public interface ApplicationManager { * @param applicationId ID of the application * @param releaseUuid UUID of the application release * @param deviceType Supported device type of the application - * @param applicationRelease {@link ApplicationReleaseEntity} + * @param applicationRelease {@link ApplicationReleaseDTO} * @param binaryFileStram {@link InputStream} of the binary file * @param iconFileStream {@link InputStream} of the icon * @param bannerFileStream {@link InputStream} of the banner * @param attachments {@link List} of {@link InputStream} of attachments * @return If the application release is updated correctly True returns, otherwise retuen False */ - boolean updateRelease(int applicationId, String releaseUuid, String deviceType, ApplicationReleaseEntity applicationRelease, + boolean updateRelease(int applicationId, String releaseUuid, String deviceType, ApplicationReleaseDTO applicationRelease, InputStream binaryFileStram, InputStream iconFileStream, InputStream bannerFileStream, List attachments) throws ApplicationManagementException; - void validateAppCreatingRequest(ApplicationWrapper applicationWrapper, Attachment binaryFile, Attachment iconFile, - Attachment bannerFile, List attachmentList) throws RequestValidatingException; + /*** + * To validate the application creating request + * + * @param applicationWrapper {@link ApplicationDTO} + * @throws RequestValidatingException if the payload contains invalid inputs. + */ + void validateAppCreatingRequest(ApplicationWrapper applicationWrapper) throws RequestValidatingException; + + /*** + * + * @param applicationReleaseWrapper {@link ApplicationReleaseDTO} + * @param applicationType Type of the application + * @throws RequestValidatingException throws if payload does not satisfy requrements. + */ + void validateReleaseCreatingRequest(ApplicationReleaseWrapper applicationReleaseWrapper, + String applicationType) throws RequestValidatingException; + + /*** + * + * @param binaryFile Uploading binary fila. i.e .apk or .ipa + * @param iconFile Icon file for the application. + * @param bannerFile Banner file for the application. + * @param attachmentList Screenshot list. + * @param applicationType Type of the application. + * @throws RequestValidatingException If request doesn't contains required attachments. + */ + void isValidAttachmentSet(Attachment binaryFile, Attachment iconFile, Attachment bannerFile, + List attachmentList, String applicationType) throws RequestValidatingException; - void validateReleaseCreatingRequest(ApplicationReleaseWrapper applicationReleaseWrapper, String applicationType, - Attachment binaryFile, Attachment iconFile, Attachment bannerFile, List attachmentList) - throws RequestValidatingException; void addAplicationCategories(List categories) throws ApplicationManagementException; 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 9a7a10c47d..879e06b3d9 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 @@ -19,8 +19,7 @@ package org.wso2.carbon.device.application.mgt.common.services; -import org.apache.cxf.jaxrs.ext.multipart.Attachment; -import org.wso2.carbon.device.application.mgt.common.entity.ApplicationReleaseEntity; +import org.wso2.carbon.device.application.mgt.common.dto.ApplicationReleaseDTO; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationStorageManagementException; import org.wso2.carbon.device.application.mgt.common.exception.RequestValidatingException; import org.wso2.carbon.device.application.mgt.common.exception.ResourceManagementException; @@ -29,22 +28,22 @@ import java.io.InputStream; import java.util.List; /** - * This manages all the storage related requirements of ApplicationEntity. + * This manages all the storage related requirements of ApplicationDTO. */ public interface ApplicationStorageManager { /** - * To upload image artifacts related with an ApplicationEntity. + * To upload image artifacts related with an ApplicationDTO. * - * @param applicationRelease ApplicationReleaseEntity Object + * @param applicationRelease ApplicationReleaseDTO Object * @param iconFile Icon File input stream * @param bannerFile Banner File input stream * @throws ResourceManagementException Resource Management Exception. */ - ApplicationReleaseEntity uploadImageArtifacts(ApplicationReleaseEntity applicationRelease, + ApplicationReleaseDTO uploadImageArtifacts(ApplicationReleaseDTO applicationRelease, InputStream iconFile, InputStream bannerFile, List screenshots) throws ResourceManagementException; /** - * To upload image artifacts related with an ApplicationEntity. + * To upload image artifacts related with an ApplicationDTO. * * @param applicationRelease Release of the application * @param iconFile Icon File input stream @@ -52,35 +51,35 @@ public interface ApplicationStorageManager { * @param screenshots Input Streams of screenshots * @throws ResourceManagementException Resource Management Exception. */ - ApplicationReleaseEntity updateImageArtifacts(ApplicationReleaseEntity applicationRelease, InputStream iconFile, + ApplicationReleaseDTO updateImageArtifacts(ApplicationReleaseDTO applicationRelease, InputStream iconFile, InputStream bannerFile, List screenshots) throws ResourceManagementException; /** - * To upload release artifacts for an ApplicationEntity. + * To upload release artifacts for an ApplicationDTO. * - * @param applicationRelease ApplicationEntity Release Object. - * @param appType ApplicationEntity Type. + * @param applicationRelease ApplicationDTO Release Object. + * @param appType ApplicationDTO Type. * @param deviceType Compatible device tipe of the application. * @param binaryFile Binary File for the release. * @throws ResourceManagementException Resource Management Exception. */ - ApplicationReleaseEntity uploadReleaseArtifact(ApplicationReleaseEntity applicationRelease, String appType, String deviceType, - InputStream binaryFile) throws ResourceManagementException, RequestValidatingException; + ApplicationReleaseDTO uploadReleaseArtifact(ApplicationReleaseDTO applicationRelease, String appType, String deviceType, + InputStream binaryFile) throws ResourceManagementException; /** - * To upload release artifacts for an ApplicationEntity. + * To upload release artifacts for an ApplicationDTO. * - * @param applicationRelease applicationRelease ApplicationEntity release of a particular application. + * @param applicationRelease applicationRelease ApplicationDTO release of a particular application. * @param appType Type of the application. * @param deviceType Compatible device tipe of the application. * @param binaryFile Binary File for the release. * @throws ApplicationStorageManagementException Resource Management Exception. */ - ApplicationReleaseEntity updateReleaseArtifacts(ApplicationReleaseEntity applicationRelease, String appType, String deviceType, + ApplicationReleaseDTO updateReleaseArtifacts(ApplicationReleaseDTO applicationRelease, String appType, String deviceType, InputStream binaryFile) throws ApplicationStorageManagementException, RequestValidatingException; /** - * To delete the artifacts related with particular ApplicationEntity Release. + * To delete the artifacts related with particular ApplicationDTO Release. * * @param directoryPath Hash value of the application artifact. * @throws ApplicationStorageManagementException Not Found Exception. @@ -88,10 +87,10 @@ public interface ApplicationStorageManager { void deleteApplicationReleaseArtifacts(String directoryPath) throws ApplicationStorageManagementException; /** - * To delete all release artifacts related with particular ApplicationEntity Release. + * To delete all release artifacts related with particular ApplicationDTO Release. * - * @param directoryPaths Hash values of the ApplicationEntity. - * @throws ApplicationStorageManagementException ApplicationEntity Storage Management Exception + * @param directoryPaths Hash values of the ApplicationDTO. + * @throws ApplicationStorageManagementException ApplicationDTO Storage Management Exception */ void deleteAllApplicationReleaseArtifacts(List directoryPaths) 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 7b5f841c01..bfab5f78df 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 @@ -27,7 +27,7 @@ public interface AppmDataHandler { * Get UI configuration which is defined in the app-manager.xml * * @return {@link UIConfiguration} UI configuration - * @throws ApplicationManagementException Exceptions of the ApplicationEntity management. + * @throws ApplicationManagementException Exceptions of the ApplicationDTO management. */ UIConfiguration getUIConfiguration() throws ApplicationManagementException; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java index 1a4676b118..e5c360d508 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java @@ -25,7 +25,7 @@ import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import java.util.List; /** - * This interface manages all the operations related with ApplicationEntity Subscription. + * This interface manages all the operations related with ApplicationDTO Subscription. */ public interface SubscriptionManager { /** @@ -70,10 +70,10 @@ public interface SubscriptionManager { /** * To uninstall an application from a given list of devices. - * @param applicationUUID ApplicationEntity ID + * @param applicationUUID ApplicationDTO ID * @param deviceList Device list * @return Failed Device List which the application was unable to uninstall - * @throws ApplicationManagementException ApplicationEntity Management Exception + * @throws ApplicationManagementException ApplicationDTO Management Exception */ List uninstallApplication(String applicationUUID, List deviceList) throws ApplicationManagementException; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/wrapper/ApplicationReleaseWrapper.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/wrapper/ApplicationReleaseWrapper.java index a1d0f3555c..cef7d31e0c 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/wrapper/ApplicationReleaseWrapper.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/wrapper/ApplicationReleaseWrapper.java @@ -21,7 +21,7 @@ package org.wso2.carbon.device.application.mgt.common.wrapper; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -@ApiModel(value = "ApplicationReleaseEntity", description = "This class holds the details when releasing an ApplicationEntity to application store") +@ApiModel(value = "ApplicationReleaseDTO", description = "This class holds the details when releasing an ApplicationDTO to application store") public class ApplicationReleaseWrapper { @ApiModelProperty(name = "description", @@ -54,7 +54,7 @@ public class ApplicationReleaseWrapper { private String url; @ApiModelProperty(name = "supportedOsVersions", - value = "ApplicationEntity release supported OS versions") + value = "ApplicationDTO release supported OS versions") private String supportedOsVersions; public String getReleaseType() { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/wrapper/ApplicationWrapper.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/wrapper/ApplicationWrapper.java index c4edb05cf3..b83bbc6a7d 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/wrapper/ApplicationWrapper.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/wrapper/ApplicationWrapper.java @@ -23,7 +23,7 @@ import io.swagger.annotations.ApiModelProperty; import java.util.List; -@ApiModel(value = "ApplicationWrapper", description = "ApplicationWrapper represents the an ApplicationEntity in ApplicationEntity Store") +@ApiModel(value = "ApplicationWrapper", description = "ApplicationWrapper represents the an ApplicationDTO in ApplicationDTO Store") public class ApplicationWrapper { @@ -38,7 +38,7 @@ public class ApplicationWrapper { private String description; @ApiModelProperty(name = "appCategory", - value = "CategoryEntity of the application", + value = "CategoryDTO of the application", required = true, example = "Educational, Gaming, Travel, Entertainment etc") private String appCategory; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationDAO.java index c216039b5c..312b02b8f7 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationDAO.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationDAO.java @@ -19,43 +19,43 @@ package org.wso2.carbon.device.application.mgt.core.dao; import org.wso2.carbon.device.application.mgt.common.*; -import org.wso2.carbon.device.application.mgt.common.entity.ApplicationEntity; -import org.wso2.carbon.device.application.mgt.common.entity.ApplicationReleaseEntity; -import org.wso2.carbon.device.application.mgt.common.entity.CategoryEntity; -import org.wso2.carbon.device.application.mgt.common.entity.TagEntity; +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.CategoryDTO; +import org.wso2.carbon.device.application.mgt.common.dto.TagDTO; import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException; import java.util.List; /** - * ApplicationDAO is responsible for handling all the Database related operations related with ApplicationEntity Management. + * ApplicationDAO is responsible for handling all the Database related operations related with ApplicationDTO Management. */ public interface ApplicationDAO { /** * To create an application. * - * @param application ApplicationEntity that need to be created. + * @param application ApplicationDTO that need to be created. * @return Created Application. - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ - int createApplication(ApplicationEntity application, int tenantId) throws ApplicationManagementDAOException; + int createApplication(ApplicationDTO application, int tenantId) throws ApplicationManagementDAOException; /** * To add tags for a particular application. * * @param tags tags that need to be added for a application. - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ void addTags(List tags, int tenantId) throws ApplicationManagementDAOException; - List getAllTags(int tenantId) throws ApplicationManagementDAOException; + List getAllTags(int tenantId) throws ApplicationManagementDAOException; List getTagIdsForTagNames (List tagNames, int tenantId) throws ApplicationManagementDAOException; void addTagMapping (List tagIds, int applicationId, int tenantId) throws ApplicationManagementDAOException; - List getAllCategories(int tenantId) throws ApplicationManagementDAOException; + List getAllCategories(int tenantId) throws ApplicationManagementDAOException; void addCategories(List categories, int tenantId) throws ApplicationManagementDAOException; @@ -68,7 +68,7 @@ public interface ApplicationDAO { * @param appName appName that need to identify application. * @param type type that need to identify application. * @param tenantId tenantId that need to identify application. - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ boolean isExistApplication(String appName, String type, int tenantId) throws ApplicationManagementDAOException; @@ -77,8 +77,8 @@ public interface ApplicationDAO { * * @param filter Filter criteria. * @param tenantId Id of the tenant. - * @return ApplicationEntity list - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @return ApplicationDTO list + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ ApplicationList getApplications(Filter filter, int tenantId) throws ApplicationManagementDAOException; @@ -86,7 +86,7 @@ public interface ApplicationDAO { * To get the UUID of latest app release that satisfy the given criteria. * * @param appId application id - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ String getUuidOfLatestRelease(int appId) throws ApplicationManagementDAOException; @@ -97,9 +97,9 @@ public interface ApplicationDAO { * @param tenantId ID of the tenant. * @param appType Type of the application. * @return the application - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ - ApplicationEntity getApplication(String appName, String appType, int tenantId) throws ApplicationManagementDAOException; + ApplicationDTO getApplication(String appName, String appType, int tenantId) throws ApplicationManagementDAOException; /** * To get the application with the given id @@ -107,9 +107,9 @@ public interface ApplicationDAO { * @param id ID of the application. * @param tenantId ID of the tenant. * @return the application - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ - ApplicationEntity getApplicationById(String id, int tenantId) throws + ApplicationDTO getApplicationById(String id, int tenantId) throws ApplicationManagementDAOException; /** @@ -118,9 +118,9 @@ public interface ApplicationDAO { * @param applicationId Id of the application to be retrieved. * @param tenantId ID of the tenant. * @return the application - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ - ApplicationEntity getApplicationById(int applicationId, int tenantId) throws ApplicationManagementDAOException; + ApplicationDTO getApplicationById(int applicationId, int tenantId) throws ApplicationManagementDAOException; /** * To get the application with the given uuid @@ -128,9 +128,9 @@ public interface ApplicationDAO { * @param releaseUuid UUID of the application release. * @param tenantId ID of the tenant. * @return the application - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ - ApplicationEntity getApplicationByUUID(String releaseUuid, int tenantId) throws ApplicationManagementDAOException; + ApplicationDTO getApplicationByUUID(String releaseUuid, int tenantId) throws ApplicationManagementDAOException; /** * To get the application with the given uuid @@ -138,7 +138,7 @@ public interface ApplicationDAO { * @param appId ID of the application * @param tenantId Tenant Id * @return the boolean value - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ boolean verifyApplicationExistenceById(int appId, int tenantId) throws ApplicationManagementDAOException; @@ -148,36 +148,36 @@ public interface ApplicationDAO { * @param appName name of the application. * @param appType type of the application. * @param tenantId ID of the tenant. - * @return ID of the ApplicationEntity. - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @return ID of the ApplicationDTO. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ int getApplicationId(String appName, String appType, int tenantId) throws ApplicationManagementDAOException; /** * To edit the given application. * - * @param application ApplicationEntity that need to be edited. - * @param tenantId Tenant ID of the ApplicationEntity. - * @return Updated ApplicationEntity. - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @param application ApplicationDTO that need to be edited. + * @param tenantId Tenant ID of the ApplicationDTO. + * @return Updated ApplicationDTO. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ - ApplicationEntity editApplication(ApplicationEntity application, int tenantId) throws ApplicationManagementDAOException; + ApplicationDTO editApplication(ApplicationDTO application, int tenantId) throws ApplicationManagementDAOException; /** * To delete the application * * @param appId ID of the application. - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ void deleteApplication(int appId) throws ApplicationManagementDAOException; /** * To get the application count that satisfies gives search query. * - * @param filter ApplicationEntity Filter. + * @param filter ApplicationDTO Filter. * @param tenantId Id of the tenant * @return count of the applications - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ int getApplicationCount(Filter filter, int tenantId) throws ApplicationManagementDAOException; @@ -187,18 +187,18 @@ public interface ApplicationDAO { * @param tags Tags which are going to delete. * @param applicationId ID of the application to delete the tags. * @param tenantId Tenant Id - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ void deleteTags(List tags, int applicationId, int tenantId) throws ApplicationManagementDAOException; /** - * To get an {@link ApplicationEntity} associated with the given release + * To get an {@link ApplicationDTO} associated with the given release * - * @param appReleaseUUID UUID of the {@link ApplicationReleaseEntity} + * @param appReleaseUUID UUID of the {@link ApplicationReleaseDTO} * @param tenantId ID of the tenant - * @return {@link ApplicationEntity} associated with the given release UUID - * @throws ApplicationManagementDAOException if unable to fetch the ApplicationEntity from the data store. + * @return {@link ApplicationDTO} associated with the given release UUID + * @throws ApplicationManagementDAOException if unable to fetch the ApplicationDTO from the data store. */ - ApplicationEntity getApplicationByRelease(String appReleaseUUID, int tenantId) throws ApplicationManagementDAOException; + ApplicationDTO getApplicationByRelease(String appReleaseUUID, int tenantId) throws ApplicationManagementDAOException; } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationReleaseDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationReleaseDAO.java index 72fb54342f..993dfe5bf1 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationReleaseDAO.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/ApplicationReleaseDAO.java @@ -18,7 +18,7 @@ */ package org.wso2.carbon.device.application.mgt.core.dao; -import org.wso2.carbon.device.application.mgt.common.entity.ApplicationReleaseEntity; +import org.wso2.carbon.device.application.mgt.common.dto.ApplicationReleaseDTO; import org.wso2.carbon.device.application.mgt.common.ApplicationReleaseArtifactPaths; import org.wso2.carbon.device.application.mgt.common.Rating; import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException; @@ -26,18 +26,18 @@ import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManageme import java.util.List; /** - * This is responsible for ApplicationEntity Release related DAO operations. + * This is responsible for ApplicationDTO Release related DAO operations. */ public interface ApplicationReleaseDAO { /** - * To create an ApplicationEntity release. + * To create an ApplicationDTO release. * - * @param applicationRelease ApplicationEntity Release that need to be created. + * @param applicationRelease ApplicationDTO Release that need to be created. * @return Unique ID of the relevant release. - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ - ApplicationReleaseEntity createRelease(ApplicationReleaseEntity applicationRelease, int appId, int tenantId) throws + ApplicationReleaseDTO createRelease(ApplicationReleaseDTO applicationRelease, int appId, int tenantId) throws ApplicationManagementDAOException; /** @@ -48,54 +48,54 @@ public interface ApplicationReleaseDAO { * @param releaseType type of the release * @param tenantId tenantId of the application - * @return ApplicationReleaseEntity for the particular version of the given application - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @return ApplicationReleaseDTO for the particular version of the given application + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ - ApplicationReleaseEntity getRelease(String applicationName,String applicationType, String versionName, + ApplicationReleaseDTO getRelease(String applicationName,String applicationType, String versionName, String releaseType, int tenantId) throws ApplicationManagementDAOException; /** * To get all the releases of a particular application. * - * @param applicationId Id of the ApplicationEntity + * @param applicationId Id of the application * @param tenantId tenant id of the application * @return list of the application releases - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ - List getReleases(int applicationId, int tenantId) throws + List getReleases(int applicationId, int tenantId) throws ApplicationManagementDAOException; /** * To get the release by state. * - * @param appId Id of the ApplicationEntity + * @param appId Id of the ApplicationDTO * @param tenantId tenant id of the application * @param state state of the application * @return list of the application releases - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ - List getReleaseByState(int appId, int tenantId, String state) + List getReleaseByState(int appId, int tenantId, String state) throws ApplicationManagementDAOException; /** - * To update an ApplicationEntity release. + * To update an ApplicationDTO release. * - * @param applicationRelease ApplicationReleaseEntity that need to be updated. + * @param applicationRelease ApplicationReleaseDTO that need to be updated. * @param applicationId Id of the application. * @param tenantId Id of the tenant - * @return the updated ApplicationEntity Release - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception + * @return the updated ApplicationDTO Release + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception */ - ApplicationReleaseEntity updateRelease(int applicationId, ApplicationReleaseEntity applicationRelease, int tenantId) throws + ApplicationReleaseDTO updateRelease(int applicationId, ApplicationReleaseDTO applicationRelease, int tenantId) throws ApplicationManagementDAOException; /** - * To update an ApplicationEntity release. - * @param uuid UUID of the ApplicationReleaseEntity that need to be updated. + * To update an ApplicationDTO release. + * @param uuid UUID of the ApplicationReleaseDTO that need to be updated. * @param rating given stars for the application. * @param ratedUsers number of users who has rated for the application release. - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception */ void updateRatingValue(String uuid, double rating, int ratedUsers) throws ApplicationManagementDAOException; @@ -104,7 +104,7 @@ public interface ApplicationReleaseDAO { * * @param uuid UUID of the application Release. * @param tenantId Tenant Id - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ Rating getRating(String uuid, int tenantId) throws ApplicationManagementDAOException; @@ -112,9 +112,9 @@ public interface ApplicationReleaseDAO { /** * To delete a particular release. * - * @param id ID of the ApplicationEntity which the release need to be deleted. - * @param version Version of the ApplicationEntity Release - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @param id ID of the ApplicationDTO which the release need to be deleted. + * @param version Version of the ApplicationDTO Release + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ void deleteRelease(int id, String version) throws ApplicationManagementDAOException; @@ -124,9 +124,9 @@ public interface ApplicationReleaseDAO { * @param applicationId ID of the application. * @param releaseUuid UUID of the application release. * @param tenantId Tenant Id - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ - ApplicationReleaseEntity getReleaseByIds(int applicationId, String releaseUuid, int tenantId) throws + ApplicationReleaseDTO getReleaseByIds(int applicationId, String releaseUuid, int tenantId) throws ApplicationManagementDAOException; /** @@ -135,7 +135,7 @@ public interface ApplicationReleaseDAO { * @param appId ID of the application. * @param uuid UUID of the application release. * @param tenantId Tenant Id - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ boolean verifyReleaseExistence(int appId, String uuid, int tenantId) throws ApplicationManagementDAOException; @@ -145,7 +145,7 @@ public interface ApplicationReleaseDAO { * @param appId ID of the application. * @param hashVal Hash value of the application release. * @param tenantId Tenant Id - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ boolean verifyReleaseExistenceByHash(int appId, String hashVal, int tenantId) throws ApplicationManagementDAOException; @@ -155,7 +155,7 @@ public interface ApplicationReleaseDAO { * * @param appId ID of the application. * @param tenantId Tenant Id - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException Application Management DAO Exception. */ String getPackageName(int appId, int tenantId) throws ApplicationManagementDAOException; @@ -164,10 +164,19 @@ public interface ApplicationReleaseDAO { * * @param uuid UUID of the application release. * @param tenantId Tenant Id - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException Application Management DAO Exception. */ boolean verifyReleaseExistenceByUuid(String uuid, int tenantId) throws ApplicationManagementDAOException; ApplicationReleaseArtifactPaths getReleaseArtifactPaths(String uuid, int tenantId) throws ApplicationManagementDAOException; + /*** + * + * @param packageName Application release package name + * @param tenantId Tenant ID + * @return True if application release package name already exist in the IoT server, Otherwise returns False. + * @throws ApplicationManagementDAOException Application Management DAO Exception. + */ + boolean isAppExisitForPackageName (String packageName, int tenantId) throws ApplicationManagementDAOException; + } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/LifecycleStateDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/LifecycleStateDAO.java index f771614dd0..4c8494e9e6 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/LifecycleStateDAO.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/LifecycleStateDAO.java @@ -18,7 +18,7 @@ */ package org.wso2.carbon.device.application.mgt.core.dao; -import org.wso2.carbon.device.application.mgt.common.entity.LifecycleStateEntity; +import org.wso2.carbon.device.application.mgt.common.dto.LifecycleStateDTO; import org.wso2.carbon.device.application.mgt.core.exception.LifeCycleManagementDAOException; import java.util.List; @@ -35,7 +35,7 @@ public interface LifecycleStateDAO { * @return Latest Lifecycle State for the given application release * @throws LifeCycleManagementDAOException Lifecycle Management DAO Exception. */ - LifecycleStateEntity getLatestLifeCycleStateByReleaseID(int applicationReleaseId) throws LifeCycleManagementDAOException; + LifecycleStateDTO getLatestLifeCycleStateByReleaseID(int applicationReleaseId) throws LifeCycleManagementDAOException; /** * To get the latest lifecycle state for the given application id and the application release UUID. @@ -45,7 +45,7 @@ public interface LifecycleStateDAO { * @return Latest Lifecycle State for the given application release * @throws LifeCycleManagementDAOException Lifecycle Management DAO Exception. */ - LifecycleStateEntity getLatestLifeCycleState(int appId, String uuid) throws LifeCycleManagementDAOException; + LifecycleStateDTO getLatestLifeCycleState(int appId, String uuid) throws LifeCycleManagementDAOException; /** * To get all changed lifecycle states for the given application release id. @@ -54,23 +54,23 @@ public interface LifecycleStateDAO { * @return Lifecycle States for the given application release * @throws LifeCycleManagementDAOException Lifecycle Management DAO Exception. */ - List getLifecycleStates(int appReleaseId) throws LifeCycleManagementDAOException; + List getLifecycleStates(int appReleaseId) throws LifeCycleManagementDAOException; /** * To add new lifecycle states for the given application release. * @param uuid Id of the application release. * @param appId Id of the application. - * @param state LifecycleStateEntity. + * @param state LifecycleStateDTO. * @param tenantId Tenant id * * @throws LifeCycleManagementDAOException Lifecycle Management DAO Exception. */ - void addLifecycleState(LifecycleStateEntity state, int appId, String uuid, int tenantId) + void addLifecycleState(LifecycleStateDTO state, int appId, String uuid, int tenantId) throws LifeCycleManagementDAOException; /** * To delete a specific lifecycle state for application release. - * @param identifier Id of the LifecycleStateEntity. + * @param identifier Id of the LifecycleStateDTO. * * @throws LifeCycleManagementDAOException Lifecycle Management DAO Exception. */ diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java index a2636198e4..2045bf62ca 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/SubscriptionDAO.java @@ -18,8 +18,8 @@ */ package org.wso2.carbon.device.application.mgt.core.dao; -import org.wso2.carbon.device.application.mgt.common.entity.ApplicationEntity; -import org.wso2.carbon.device.application.mgt.common.entity.ApplicationReleaseEntity; +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.core.exception.ApplicationManagementDAOException; import org.wso2.carbon.device.mgt.common.Device; import org.wso2.carbon.device.mgt.common.group.mgt.DeviceGroup; @@ -38,8 +38,8 @@ public interface SubscriptionDAO { * @param tenantId id of the tenant * @param subscribedBy username of the user who subscribe the application * @param deviceList List of {@link Device} which the application is installed on - * @param appId id of the {@link ApplicationEntity} which installs - * @param releaseId id of the {@link ApplicationReleaseEntity} + * @param appId id of the {@link ApplicationDTO} which installs + * @param releaseId id of the {@link ApplicationReleaseDTO} * @throws ApplicationManagementDAOException If unable to add a mapping between device and application */ void subscribeDeviceToApplication(int tenantId, String subscribedBy, List deviceList, int appId, @@ -52,8 +52,8 @@ public interface SubscriptionDAO { * @param tenantId id of the tenant * @param subscribedBy username of the user who subscribe the application * @param userList list of user names of the users whose devices are subscribed to the application - * @param appId id of the {@link ApplicationEntity} which installs - * @param releaseId id of the {@link ApplicationReleaseEntity} + * @param appId id of the {@link ApplicationDTO} which installs + * @param releaseId id of the {@link ApplicationReleaseDTO} * @throws ApplicationManagementDAOException If unable to add a mapping between device and application */ void subscribeUserToApplication(int tenantId, String subscribedBy, List userList, int appId, int releaseId) @@ -66,8 +66,8 @@ public interface SubscriptionDAO { * @param tenantId id of the tenant * @param subscribedBy username of the user who subscribe the application * @param roleList list of roles which belongs devices are subscribed to the application - * @param appId id of the {@link ApplicationEntity} which installs - * @param releaseId id of the {@link ApplicationReleaseEntity} + * @param appId id of the {@link ApplicationDTO} which installs + * @param releaseId id of the {@link ApplicationReleaseDTO} * @throws ApplicationManagementDAOException If unable to add a mapping between device and application */ void subscribeRoleToApplication(int tenantId, String subscribedBy, List roleList, int appId, int releaseId) @@ -80,8 +80,8 @@ public interface SubscriptionDAO { * @param tenantId id of the tenant * @param subscribedBy username of the user who subscribe the application * @param groupList list of {@link DeviceGroup} which belongs the devices that are subscribed to the application - * @param appId id of the {@link ApplicationEntity} which installs - * @param releaseId id of the {@link ApplicationReleaseEntity} + * @param appId id of the {@link ApplicationDTO} which installs + * @param releaseId id of the {@link ApplicationReleaseDTO} * @throws ApplicationManagementDAOException If unable to add a mapping between device and application */ void subscribeGroupToApplication(int tenantId, String subscribedBy, List groupList, int appId, diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java index 36d409750e..79f9c7cc43 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/common/Util.java @@ -22,10 +22,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.JSONException; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.application.mgt.common.entity.ApplicationEntity; +import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO; import org.wso2.carbon.device.application.mgt.common.PaginationRequest; -import org.wso2.carbon.device.application.mgt.common.entity.ApplicationReleaseEntity; +import org.wso2.carbon.device.application.mgt.common.dto.ApplicationReleaseDTO; import org.wso2.carbon.device.application.mgt.common.exception.ReviewManagementException; import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager; import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager; @@ -55,10 +55,10 @@ public class Util { // * @throws SQLException SQL Exception // * @throws JSONException JSONException. // */ -// public static List loadApplications(ResultSet rs) throws SQLException, JSONException { +// public static List loadApplications(ResultSet rs) throws SQLException, JSONException { // -// List applications = new ArrayList<>(); -// ApplicationEntity application = null; +// List applications = new ArrayList<>(); +// ApplicationDTO application = null; // int applicationId = -1; // boolean hasNext = rs.next(); // @@ -68,7 +68,7 @@ public class Util { // applications.add(application); // } // applicationId = rs.getInt("APP_ID"); -// application = new ApplicationEntity(); +// application = new ApplicationDTO(); // application.setTags(new ArrayList<>()); // application.setUnrestrictedRoles(new ArrayList<>()); // application.setId(applicationId); @@ -115,10 +115,10 @@ public class Util { * @throws SQLException SQL Exception * @throws JSONException JSONException. */ - public static List loadApplications(ResultSet rs) throws SQLException, JSONException { + public static List loadApplications(ResultSet rs) throws SQLException, JSONException { - List applications = new ArrayList<>(); - ApplicationEntity application = null; + List applications = new ArrayList<>(); + ApplicationDTO application = null; int applicationId = -1; boolean hasNext = rs.next(); @@ -127,7 +127,7 @@ public class Util { if (application != null) { applications.add(application); } - application = new ApplicationEntity(); + application = new ApplicationDTO(); application.setApplicationReleases(new ArrayList<>()); applicationId = rs.getInt("APP_ID"); application.setId(applicationId); @@ -140,7 +140,7 @@ public class Util { application.setAppRating(rs.getInt("APP_RATING")); application.setDeviceTypeId(rs.getInt("APP_DEVICE_TYPE_ID")); } else { - ApplicationReleaseEntity appRelease = new ApplicationReleaseEntity(); + ApplicationReleaseDTO appRelease = new ApplicationReleaseDTO(); appRelease.setDescription(rs.getString("RELEASE_DESCRIPTION")); appRelease.setUuid(rs.getString("RELEASE_UUID")); appRelease.setReleaseType(rs.getString("RELEASE_TYPE")); @@ -173,19 +173,19 @@ public class Util { * To create application object from the result set retrieved from the Database. * * @param rs ResultSet - * @return ApplicationEntity that is retrieved from the Database. + * @return ApplicationDTO that is retrieved from the Database. * @throws SQLException SQL Exception * @throws JSONException JSONException. */ - public static ApplicationEntity loadApplication(ResultSet rs) throws SQLException, JSONException { + public static ApplicationDTO loadApplication(ResultSet rs) throws SQLException, JSONException { - ApplicationEntity application = null; + ApplicationDTO application = null; int applicatioId; int iteration = 0; if (rs != null) { while (rs.next()) { if (iteration == 0) { - application = new ApplicationEntity(); + application = new ApplicationDTO(); application.setTags(new ArrayList<>()); application.setUnrestrictedRoles(new ArrayList<>()); applicatioId = rs.getInt("APP_ID"); @@ -215,14 +215,14 @@ public class Util { } /** - * Populates {@link ApplicationReleaseEntity} object with the result obtained from the database. + * Populates {@link ApplicationReleaseDTO} object with the result obtained from the database. * * @param resultSet {@link ResultSet} from obtained from the database - * @return {@link ApplicationReleaseEntity} object populated with the data - * @throws SQLException If unable to populate {@link ApplicationReleaseEntity} object with the data + * @return {@link ApplicationReleaseDTO} object populated with the data + * @throws SQLException If unable to populate {@link ApplicationReleaseDTO} object with the data */ - public static ApplicationReleaseEntity loadApplicationRelease(ResultSet resultSet) throws SQLException { - ApplicationReleaseEntity applicationRelease = new ApplicationReleaseEntity(); + public static ApplicationReleaseDTO loadApplicationRelease(ResultSet resultSet) throws SQLException { + ApplicationReleaseDTO applicationRelease = new ApplicationReleaseDTO(); applicationRelease.setId(resultSet.getInt("RELEASE_ID")); applicationRelease.setVersion(resultSet.getString("RELEASE_VERSION")); applicationRelease.setUuid(resultSet.getString("UUID")); @@ -274,7 +274,7 @@ public class Util { commentManagementConfig.getPaginationConfiguration().getCommentListPageSize()); } else { throw new ReviewManagementException( - "ApplicationEntity Management configuration has not initialized. Please check the application-mgt.xml file."); + "ApplicationDTO Management configuration has not initialized. Please check the application-mgt.xml file."); } } return paginationRequest; @@ -292,7 +292,7 @@ public class Util { applicationManager = (ApplicationManager) ctx.getOSGiService(ApplicationManager.class, null); if (applicationManager == null) { - String msg = "ApplicationEntity Manager service has not initialized."; + String msg = "ApplicationDTO Manager service has not initialized."; log.error(msg); throw new IllegalStateException(msg); } @@ -303,7 +303,7 @@ public class Util { } /** - * To get the ApplicationEntity Storage Manager from the osgi context. + * To get the ApplicationDTO Storage Manager from the osgi context. * @return ApplicationStoreManager instance in the current osgi context. */ public static ApplicationStorageManager getApplicationStorageManager() { @@ -314,7 +314,7 @@ public class Util { applicationStorageManager = (ApplicationStorageManager) ctx .getOSGiService(ApplicationStorageManager.class, null); if (applicationStorageManager == null) { - String msg = "ApplicationEntity Storage Manager service has not initialized."; + String msg = "ApplicationDTO Storage Manager service has not initialized."; log.error(msg); throw new IllegalStateException(msg); } 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/Review/ReviewDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/Review/ReviewDAOImpl.java index 138a154ce9..c5af36b6d4 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/Review/ReviewDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/Review/ReviewDAOImpl.java @@ -51,7 +51,7 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO { @Override public boolean addReview(Review review, String uuid, int tenantId) throws ReviewManagementDAOException { if (log.isDebugEnabled()) { - log.debug("Request received in DAO Layer to add review for application release. ApplicationEntity UUID: " + uuid); + log.debug("Request received in DAO Layer to add review for application release. ApplicationDTO UUID: " + uuid); } PreparedStatement statement = null; ResultSet rs = null; @@ -93,7 +93,7 @@ public class ReviewDAOImpl extends AbstractDAOImpl implements ReviewDAO { if (log.isDebugEnabled()) { log.debug( "Request received in DAO Layer to check whether user have already commented or not for the " - + "application release. ApplicationEntity UUID: " + uuid + " comment owner: " + username + + + "application release. ApplicationDTO UUID: " + uuid + " comment owner: " + username + " tenant-id " + tenantId); } Connection conn; 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/application/GenericApplicationDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java index 5ac087b64f..4d49b4c8be 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/GenericApplicationDAOImpl.java @@ -22,20 +22,19 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.json.JSONException; import org.wso2.carbon.device.application.mgt.common.AppLifecycleState; -import org.wso2.carbon.device.application.mgt.common.entity.ApplicationEntity; +import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO; import org.wso2.carbon.device.application.mgt.common.ApplicationList; -import org.wso2.carbon.device.application.mgt.common.entity.ApplicationReleaseEntity; -import org.wso2.carbon.device.application.mgt.common.entity.CategoryEntity; +import org.wso2.carbon.device.application.mgt.common.dto.ApplicationReleaseDTO; +import org.wso2.carbon.device.application.mgt.common.dto.CategoryDTO; import org.wso2.carbon.device.application.mgt.common.Filter; import org.wso2.carbon.device.application.mgt.common.Pagination; -import org.wso2.carbon.device.application.mgt.common.entity.TagEntity; +import org.wso2.carbon.device.application.mgt.common.dto.TagDTO; import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException; import org.wso2.carbon.device.application.mgt.core.dao.ApplicationDAO; import org.wso2.carbon.device.application.mgt.core.dao.common.Util; import org.wso2.carbon.device.application.mgt.core.dao.impl.AbstractDAOImpl; import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException; -import java.sql.Array; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; @@ -53,10 +52,10 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic private static final Log log = LogFactory.getLog(GenericApplicationDAOImpl.class); @Override - public int createApplication(ApplicationEntity application, int tenantId) throws ApplicationManagementDAOException { + public int createApplication(ApplicationDTO application, int tenantId) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Request received in DAO Layer to create an application"); - log.debug("ApplicationEntity Details : "); + log.debug("ApplicationDTO Details : "); log.debug("App Name : " + application.getName() + " App Type : " + application.getType()); } Connection conn; @@ -443,7 +442,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic } @Override - public ApplicationEntity getApplication(String appName, String appType, int tenantId) throws + public ApplicationDTO getApplication(String appName, String appType, int tenantId) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Getting application with the type(" + appType + " and Name " + appName + @@ -488,7 +487,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic } @Override - public ApplicationEntity getApplicationById(String id, int tenantId) throws + public ApplicationDTO getApplicationById(String id, int tenantId) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Getting application with the id:" + id); @@ -530,7 +529,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic } @Override - public ApplicationEntity getApplicationByUUID(String releaseUuid, int tenantId) throws + public ApplicationDTO getApplicationByUUID(String releaseUuid, int tenantId) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Getting application with the release UUID: " + releaseUuid + " from the database"); @@ -577,7 +576,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic } @Override - public ApplicationEntity getApplicationById(int applicationId, int tenantId) throws + public ApplicationDTO getApplicationById(int applicationId, int tenantId) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Getting application with the id (" + applicationId + ") from the database"); @@ -656,11 +655,11 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic } @Override - public ApplicationEntity editApplication(ApplicationEntity application, int tenantId) throws ApplicationManagementDAOException { + public ApplicationDTO editApplication(ApplicationDTO application, int tenantId) throws ApplicationManagementDAOException { int paramIndex = 1; Connection conn; PreparedStatement stmt = null; - ApplicationEntity existingApplication = this.getApplicationById(application.getId(), tenantId); + ApplicationDTO existingApplication = this.getApplicationById(application.getId(), tenantId); if (existingApplication == null) { throw new ApplicationManagementDAOException("There doesn't have an application for updating"); @@ -770,7 +769,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic } @Override - public List getAllTags(int tenantId) throws ApplicationManagementDAOException { + public List getAllTags(int tenantId) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Request received in DAO Layer to get all tags"); } @@ -778,7 +777,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic PreparedStatement stmt = null; ResultSet rs = null; try { - List tagEntities = new ArrayList<>(); + List tagEntities = new ArrayList<>(); String sql = "SELECT " + "AP_APP_TAG.ID AS ID, " + "AP_APP_TAG.TAG AS TAG " @@ -790,10 +789,10 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic rs = stmt.executeQuery(); while(rs.next()){ - TagEntity tagEntity = new TagEntity(); - tagEntity.setId(rs.getInt("ID")); - tagEntity.setTagName(rs.getString("TAG")); - tagEntities.add(tagEntity); + TagDTO tagDTO = new TagDTO(); + tagDTO.setId(rs.getInt("ID")); + tagDTO.setTagName(rs.getString("TAG")); + tagEntities.add(tagDTO); } return tagEntities; } catch (DBConnectionException e) { @@ -807,7 +806,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic } @Override - public List getAllCategories(int tenantId) throws ApplicationManagementDAOException { + public List getAllCategories(int tenantId) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Request received in DAO Layer to get all tags"); } @@ -815,7 +814,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic PreparedStatement stmt = null; ResultSet rs = null; try { - List categories = new ArrayList<>(); + List categories = new ArrayList<>(); String sql = "SELECT " + "AP_APP_CATEGORY.ID AS ID, " + "AP_APP_CATEGORY.CATEGORY AS CATEGORY " @@ -827,7 +826,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic rs = stmt.executeQuery(); while(rs.next()){ - CategoryEntity category = new CategoryEntity(); + CategoryDTO category = new CategoryDTO(); category.setId(rs.getInt("ID")); category.setCategoryName(rs.getString("CATEGORY")); categories.add(category); @@ -1003,7 +1002,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic } @Override - public ApplicationEntity getApplicationByRelease(String appReleaseUUID, int tenantId) + public ApplicationDTO getApplicationByRelease(String appReleaseUUID, int tenantId) throws ApplicationManagementDAOException { if (log.isDebugEnabled()) { log.debug("Getting application with the UUID (" + appReleaseUUID + ") from the database"); @@ -1034,10 +1033,10 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic log.debug("Successfully retrieved details of the application with the UUID " + appReleaseUUID); } - ApplicationEntity application = null; + ApplicationDTO application = null; while (rs.next()) { - ApplicationReleaseEntity appRelease = Util.loadApplicationRelease(rs); - application = new ApplicationEntity(); + ApplicationReleaseDTO appRelease = Util.loadApplicationRelease(rs); + application = new ApplicationDTO(); application.setId(rs.getInt("APP_ID")); application.setName(rs.getString("APP_NAME")); @@ -1053,7 +1052,7 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic application.setUnrestrictedRoles(unrestrictedRoleList); - List applicationReleaseList = new ArrayList<>(); + List applicationReleaseList = new ArrayList<>(); applicationReleaseList.add(appRelease); application.setApplicationReleases(applicationReleaseList); 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/application/release/GenericApplicationReleaseDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java index 4ff1cdc0bb..2d866469a8 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/release/GenericApplicationReleaseDAOImpl.java @@ -21,7 +21,7 @@ package org.wso2.carbon.device.application.mgt.core.dao.impl.application.release import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.wso2.carbon.device.application.mgt.common.entity.ApplicationReleaseEntity; +import org.wso2.carbon.device.application.mgt.common.dto.ApplicationReleaseDTO; import org.wso2.carbon.device.application.mgt.common.ApplicationReleaseArtifactPaths; import org.wso2.carbon.device.application.mgt.common.Rating; import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException; @@ -38,21 +38,21 @@ import java.util.ArrayList; import java.util.List; /** - * GenericApplicationReleaseDAOImpl holds the implementation of ApplicationReleaseEntity related DAO operations. + * GenericApplicationReleaseDAOImpl holds the implementation of ApplicationReleaseDTO related DAO operations. */ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements ApplicationReleaseDAO { private static final Log log = LogFactory.getLog(GenericApplicationReleaseDAOImpl.class); /** - * To insert the ApplicationEntity Release Details. + * To insert the ApplicationDTO Release Details. * * @param appId Id of the application - * @param applicationRelease ApplicationEntity Release the properties of which that need to be inserted. + * @param applicationRelease ApplicationDTO Release the properties of which that need to be inserted. * @param tenantId Tenant Id - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ - @Override public ApplicationReleaseEntity createRelease(ApplicationReleaseEntity applicationRelease, int appId, int tenantId) + @Override public ApplicationReleaseDTO createRelease(ApplicationReleaseDTO applicationRelease, int appId, int tenantId) throws ApplicationManagementDAOException { Connection connection; PreparedStatement statement = null; @@ -128,9 +128,9 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements * @param versionName version name of the application. * @param releaseType type of the application release. * @param tenantId Tenant Id - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ - @Override public ApplicationReleaseEntity getRelease(String applicationName, String applicationType, String versionName, + @Override public ApplicationReleaseDTO getRelease(String applicationName, String applicationType, String versionName, String releaseType, int tenantId) throws ApplicationManagementDAOException { //todo no usage Connection connection; @@ -178,9 +178,9 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements * @param applicationId ID of the application. * @param releaseUuid UUID of the application release. * @param tenantId Tenant Id - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ - @Override public ApplicationReleaseEntity getReleaseByIds(int applicationId, String releaseUuid, int tenantId) + @Override public ApplicationReleaseDTO getReleaseByIds(int applicationId, String releaseUuid, int tenantId) throws ApplicationManagementDAOException { Connection connection; @@ -226,14 +226,14 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements * * @param applicationId Id of the application. * @param tenantId Tenant Id - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ - @Override public List getReleases(int applicationId, int tenantId) + @Override public List getReleases(int applicationId, int tenantId) throws ApplicationManagementDAOException { Connection connection; PreparedStatement statement = null; ResultSet resultSet = null; - List applicationReleases = new ArrayList<>(); + List applicationReleases = new ArrayList<>(); String sql = "SELECT AR.ID AS RELEASE_ID, AR.VERSION AS RELEASE_VERSION, AR.UUID, AR.RELEASE_TYPE " + "AS RELEASE_TYPE, AR.PACKAGE_NAME AS PACKAGE_NAME, AR.APP_PRICE, AR.STORED_LOCATION, AR.ICON_LOCATION, " + "AR.BANNER_LOCATION, AR.SC_1_LOCATION AS SCREEN_SHOT_1, AR.SC_2_LOCATION AS SCREEN_SHOT_2, " @@ -249,7 +249,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements resultSet = statement.executeQuery(); while (resultSet.next()) { - ApplicationReleaseEntity applicationRelease = Util.loadApplicationRelease(resultSet); + ApplicationReleaseDTO applicationRelease = Util.loadApplicationRelease(resultSet); applicationReleases.add(applicationRelease); } return applicationReleases; @@ -267,12 +267,12 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements //todo this has to be removed @Override - public List getReleaseByState(int appId, int tenantId, String state) throws + public List getReleaseByState(int appId, int tenantId, String state) throws ApplicationManagementDAOException { Connection connection; PreparedStatement statement = null; ResultSet resultSet = null; - List applicationReleases = new ArrayList<>(); + List applicationReleases = new ArrayList<>(); String sql = "SELECT AR.ID AS RELEASE_ID, AR.VERSION AS RELEASE_VERSION, AR.UUID AS UUID, AR.RELEASE_TYPE AS " + "RELEASE_TYPE, AR.PACKAGE_NAME AS PACKAGE_NAME, AR.APP_PRICE AS APP_PRICE, AR.STORED_LOCATION AS " + "STORED_LOCATION, AR.BANNER_LOCATION AS BANNER_LOCATION, ICON_LOCATION, AR.SC_1_LOCATION AS " @@ -292,7 +292,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements resultSet = statement.executeQuery(); while (resultSet.next()) { - ApplicationReleaseEntity appRelease = Util.loadApplicationRelease(resultSet); + ApplicationReleaseDTO appRelease = Util.loadApplicationRelease(resultSet); applicationReleases.add(appRelease); } return applicationReleases; @@ -313,7 +313,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements * * @param uuid UUID of the application Release. * @param rating given stars for the application release. - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ @Override public void updateRatingValue(String uuid, double rating, int ratedUsers) throws ApplicationManagementDAOException { @@ -342,7 +342,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements * To retrieve rating of an application release. * * @param uuid UUID of the application Release. - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ @Override public Rating getRating(String uuid, int tenantId) throws ApplicationManagementDAOException { Connection connection; @@ -377,11 +377,11 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements /** * To insert the application release properties. * - * @param applicationRelease ApplicationEntity Release the properties of which that need to be inserted. - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @param applicationRelease ApplicationDTO Release the properties of which that need to be inserted. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ @Override - public ApplicationReleaseEntity updateRelease(int applicationId, ApplicationReleaseEntity applicationRelease, int tenantId) + public ApplicationReleaseDTO updateRelease(int applicationId, ApplicationReleaseDTO applicationRelease, int tenantId) throws ApplicationManagementDAOException { Connection connection; PreparedStatement statement = null; @@ -430,7 +430,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements * * @param id Id of the application Release. * @param version version name of the application release. - * @throws ApplicationManagementDAOException ApplicationEntity Management DAO Exception. + * @throws ApplicationManagementDAOException ApplicationDTO Management DAO Exception. */ @Override public void deleteRelease(int id, String version) throws ApplicationManagementDAOException { Connection connection; @@ -477,7 +477,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements if (log.isDebugEnabled()) { log.debug("Successfully retrieved basic details of the application release with the application ID " - + appId + " ApplicationEntity release hash value: " + hashVal); + + appId + " ApplicationDTO release hash value: " + hashVal); } return rs.next(); } catch (SQLException e) { @@ -551,7 +551,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements if (log.isDebugEnabled()) { log.debug("Successfully retrieved basic details of the application release with the application ID " - + appId + " ApplicationEntity release uuid: " + uuid); + + appId + " ApplicationDTO release uuid: " + uuid); } return rs.next(); } catch (SQLException e) { @@ -656,4 +656,31 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements } } + @Override + public boolean isAppExisitForPackageName (String packageName, int tenantId) throws ApplicationManagementDAOException { + if (log.isDebugEnabled()) { + log.debug("Verifying application release existence for package name:" + packageName); + } + Connection conn; + try { + conn = this.getDBConnection(); + String sql = "SELECT AR.ID AS RELEASE_ID " + + "FROM AP_APP_RELEASE AS AR " + + "WHERE AR.PACKAGE_NAME = ? AND AR.TENANT_ID = ? LIMIT 1"; + + try (PreparedStatement stmt = conn.prepareStatement(sql)) { + stmt.setString(1, packageName); + stmt.setInt(2, tenantId); + try (ResultSet rs = stmt.executeQuery()) { + return rs.next(); + } + } + } catch (SQLException e) { + throw new ApplicationManagementDAOException( + "Error occurred while getting application release details for package name: " + packageName, e); + } catch (DBConnectionException e) { + throw new ApplicationManagementDAOException("Error occurred while obtaining the DB connection.", e); + } + } + } \ No newline at end of file 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 44a6ad06b8..b3bc877e8e 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 @@ -19,7 +19,7 @@ package org.wso2.carbon.device.application.mgt.core.dao.impl.lifecyclestate; import org.wso2.carbon.device.application.mgt.common.AppLifecycleState; -import org.wso2.carbon.device.application.mgt.common.entity.LifecycleStateEntity; +import org.wso2.carbon.device.application.mgt.common.dto.LifecycleStateDTO; import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException; import org.wso2.carbon.device.application.mgt.core.dao.LifecycleStateDAO; import org.wso2.carbon.device.application.mgt.core.dao.common.Util; @@ -41,7 +41,7 @@ import java.util.List; public class GenericLifecycleStateDAOImpl extends AbstractDAOImpl implements LifecycleStateDAO { @Override - public LifecycleStateEntity getLatestLifeCycleStateByReleaseID(int applicationReleaseId) throws LifeCycleManagementDAOException { + public LifecycleStateDTO getLatestLifeCycleStateByReleaseID(int applicationReleaseId) throws LifeCycleManagementDAOException { Connection conn = null; PreparedStatement stmt = null; @@ -65,7 +65,7 @@ public class GenericLifecycleStateDAOImpl extends AbstractDAOImpl implements Lif } } - public LifecycleStateEntity getLatestLifeCycleState(int appId, String uuid) throws LifeCycleManagementDAOException{ + public LifecycleStateDTO getLatestLifeCycleState(int appId, String uuid) throws LifeCycleManagementDAOException{ Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; @@ -122,8 +122,8 @@ public class GenericLifecycleStateDAOImpl extends AbstractDAOImpl implements Lif } @Override - public List getLifecycleStates(int appReleaseId) throws LifeCycleManagementDAOException { - List lifecycleStates = new ArrayList<>(); + public List getLifecycleStates(int appReleaseId) throws LifeCycleManagementDAOException { + List lifecycleStates = new ArrayList<>(); Connection conn = null; PreparedStatement stmt = null; ResultSet rs = null; @@ -135,7 +135,7 @@ public class GenericLifecycleStateDAOImpl extends AbstractDAOImpl implements Lif stmt.setInt(1,appReleaseId); rs = stmt.executeQuery(); while (rs.next()) { - LifecycleStateEntity lifecycleState = new LifecycleStateEntity(); + LifecycleStateDTO lifecycleState = new LifecycleStateDTO(); lifecycleState.setId(rs.getInt("ID")); lifecycleState.setCurrentState(rs.getString("CURRENT_STATE")); lifecycleState.setPreviousState(rs.getString("PREVIOUS_STATE")); @@ -155,7 +155,7 @@ public class GenericLifecycleStateDAOImpl extends AbstractDAOImpl implements Lif } @Override - public void addLifecycleState(LifecycleStateEntity state, int appId, String uuid, int tenantId) throws LifeCycleManagementDAOException { + public void addLifecycleState(LifecycleStateDTO state, int appId, String uuid, int tenantId) throws LifeCycleManagementDAOException { Connection conn = null; PreparedStatement stmt = null; try { @@ -213,11 +213,11 @@ public class GenericLifecycleStateDAOImpl extends AbstractDAOImpl implements Lif } } - private LifecycleStateEntity constructLifecycle(ResultSet rs) throws LifeCycleManagementDAOException { - LifecycleStateEntity lifecycleState = null; + private LifecycleStateDTO constructLifecycle(ResultSet rs) throws LifeCycleManagementDAOException { + LifecycleStateDTO lifecycleState = null; try { if (rs !=null && rs.next()) { - lifecycleState = new LifecycleStateEntity(); + lifecycleState = new LifecycleStateDTO(); lifecycleState.setId(rs.getInt("ID")); lifecycleState.setCurrentState(rs.getString("CURRENT_STATE")); lifecycleState.setPreviousState(rs.getString("PREVIOUS_STATE")); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/exception/ApplicationManagementDAOException.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/exception/ApplicationManagementDAOException.java index cd56b83267..44c78804a6 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/exception/ApplicationManagementDAOException.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/exception/ApplicationManagementDAOException.java @@ -21,7 +21,7 @@ package org.wso2.carbon.device.application.mgt.core.exception; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; /** - * Exception thrown during the ApplicationEntity Management DAO operations. + * Exception thrown during the ApplicationDTO Management DAO operations. */ public class ApplicationManagementDAOException extends 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 4efdd86cfc..342d172153 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 @@ -19,6 +19,7 @@ package org.wso2.carbon.device.application.mgt.core.impl; import org.apache.commons.lang.StringUtils; +import org.apache.commons.validator.routines.UrlValidator; import org.apache.cxf.jaxrs.ext.multipart.Attachment; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -27,15 +28,15 @@ import org.wso2.carbon.context.CarbonContext; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.application.mgt.common.AppLifecycleState; import org.wso2.carbon.device.application.mgt.common.ApplicationArtifact; -import org.wso2.carbon.device.application.mgt.common.entity.ApplicationEntity; +import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO; import org.wso2.carbon.device.application.mgt.common.ApplicationList; -import org.wso2.carbon.device.application.mgt.common.entity.ApplicationReleaseEntity; +import org.wso2.carbon.device.application.mgt.common.dto.ApplicationReleaseDTO; import org.wso2.carbon.device.application.mgt.common.ApplicationSubscriptionType; import org.wso2.carbon.device.application.mgt.common.ApplicationType; -import org.wso2.carbon.device.application.mgt.common.entity.CategoryEntity; +import org.wso2.carbon.device.application.mgt.common.dto.CategoryDTO; import org.wso2.carbon.device.application.mgt.common.Filter; -import org.wso2.carbon.device.application.mgt.common.entity.LifecycleStateEntity; -import org.wso2.carbon.device.application.mgt.common.entity.TagEntity; +import org.wso2.carbon.device.application.mgt.common.dto.LifecycleStateDTO; +import org.wso2.carbon.device.application.mgt.common.dto.TagDTO; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationStorageManagementException; import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException; @@ -115,8 +116,8 @@ public class ApplicationManagerImpl implements ApplicationManager { /*** * The responsbility of this method is the creating an application. - * @param applicationWrapper ApplicationEntity that need to be created. - * @return {@link ApplicationEntity} + * @param applicationWrapper ApplicationDTO that need to be created. + * @return {@link ApplicationDTO} * @throws RequestValidatingException if application creating request is invalid, returns {@link RequestValidatingException} * @throws ApplicationManagementException Catch all other throwing exceptions and returns {@link ApplicationManagementException} */ @@ -126,37 +127,42 @@ public class ApplicationManagerImpl implements ApplicationManager { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); - ApplicationEntity applicationEntity; + ApplicationDTO applicationDTO; Application application; if (log.isDebugEnabled()) { log.debug("Application create request is received for the tenant : " + tenantId + " From" + " the user : " + userName); } try { - applicationEntity = addApplicationReleaseArtifacts(appWrapperToAppEntity(applicationWrapper), applicationArtifact); + applicationDTO = addApplicationReleaseArtifacts(appWrapperToAppDTO(applicationWrapper), + applicationArtifact); } catch (UnexpectedServerErrorException e) { - throw new ApplicationManagementException(e.getMessage(), e); + String msg = "Error occurred when getting Device Type data."; + log.error(msg); + throw new ApplicationManagementException(msg, e); } catch (ResourceManagementException e) { - String msg = "Error Occured when uploading artifacts of the application.: " + applicationWrapper.getName(); + String msg = "Error Occured when uploading artifacts of the application: " + applicationWrapper.getName(); log.error(msg); throw new ApplicationManagementException(msg, e); } try { - List applicationReleaseEntities = new ArrayList<>(); - ApplicationReleaseEntity applicationReleaseEntity; + List applicationReleaseEntities = new ArrayList<>(); + ApplicationReleaseDTO applicationReleaseDTO; Filter filter = new Filter(); filter.setFullMatch(true); - filter.setAppName(applicationEntity.getName().trim()); - filter.setDeviceTypeId(applicationEntity.getDeviceTypeId()); + filter.setAppName(applicationDTO.getName().trim()); + filter.setDeviceTypeId(applicationDTO.getDeviceTypeId()); filter.setOffset(0); filter.setLimit(1); ConnectionManagerUtil.beginDBTransaction(); - //todo check is there an application release with same md5sum, if there is an applicatio release delete - // application storage and thrown an error + // todo resolve following comment + /*check is there an application release with same package name, if there is an application release + throw an error and request to delete the existing application or add this as new application release + for existing application*/ ApplicationList applicationList = applicationDAO.getApplications(filter, tenantId); if (!applicationList.getApplications().isEmpty()) { @@ -168,14 +174,14 @@ public class ApplicationManagerImpl implements ApplicationManager { } // Insert to application table - int appId = this.applicationDAO.createApplication(applicationEntity, tenantId); + int appId = this.applicationDAO.createApplication(applicationDTO, tenantId); if (appId == -1) { - log.error("ApplicationEntity creation is Failed"); + log.error("ApplicationDTO creation is Failed"); ConnectionManagerUtil.rollbackDBTransaction(); return null; } else { if (log.isDebugEnabled()) { - log.debug("New ApplicationEntity entry added to AP_APP table. App Id:" + appId); + log.debug("New ApplicationDTO entry added to AP_APP table. App Id:" + appId); } //adding application unrestricted roles List unrestrictedRoles = applicationWrapper.getUnrestrictedRoles(); @@ -192,11 +198,12 @@ public class ApplicationManagerImpl implements ApplicationManager { } } - List registeredCatehgories = this.applicationDAO.getAllCategories(tenantId); + List registeredCategories = this.applicationDAO.getAllCategories(tenantId); String categoryName = applicationWrapper.getAppCategory(); - Optional category = registeredCatehgories.stream().filter(obj -> obj.getCategoryName().equals(categoryName)).findAny(); + Optional category = registeredCategories.stream() + .filter(obj -> obj.getCategoryName().equals(categoryName)).findAny(); - if (registeredCatehgories.isEmpty()) { + if (registeredCategories.isEmpty()) { ConnectionManagerUtil.rollbackDBTransaction(); String msg = "Registered application category set is empty category: " + categoryName; log.error(msg); @@ -223,14 +230,14 @@ public class ApplicationManagerImpl implements ApplicationManager { //adding application tags List tags = applicationWrapper.getTags(); if (!tags.isEmpty()) { - List allRegisteredTagEntities = applicationDAO.getAllTags(tenantId); - List allRegisteredTagNames = new ArrayList<>(); + List registeredTags = applicationDAO.getAllTags(tenantId); + List registeredTagNames = new ArrayList<>(); List tagIds = new ArrayList<>(); - for (TagEntity tagEntity : allRegisteredTagEntities) { - allRegisteredTagNames.add(tagEntity.getTagName()); + for (TagDTO tagDTO : registeredTags) { + registeredTagNames.add(tagDTO.getTagName()); } - List newTags = getDifference(tags, allRegisteredTagNames); + List newTags = getDifference(tags, registeredTagNames); if (!newTags.isEmpty()) { this.applicationDAO.addTags(newTags, tenantId); if (log.isDebugEnabled()) { @@ -239,10 +246,10 @@ public class ApplicationManagerImpl implements ApplicationManager { tagIds = this.applicationDAO.getTagIdsForTagNames(tags, tenantId); } else { - for (TagEntity tagEntity : allRegisteredTagEntities) { + for (TagDTO tagDTO : registeredTags) { for (String tagName : tags) { - if (tagName.equals(tagEntity.getTagName())) { - tagIds.add(tagEntity.getId()); + if (tagName.equals(tagDTO.getTagName())) { + tagIds.add(tagDTO.getId()); break; } } @@ -254,54 +261,54 @@ public class ApplicationManagerImpl implements ApplicationManager { if (log.isDebugEnabled()) { log.debug("Creating a new release. App Id:" + appId); } - applicationReleaseEntity = applicationEntity.getApplicationReleases().get(0); - applicationReleaseEntity.setCurrentState(AppLifecycleState.CREATED.toString()); - applicationReleaseEntity = this.applicationReleaseDAO.createRelease(applicationReleaseEntity, appId, tenantId); + applicationReleaseDTO = applicationDTO.getApplicationReleases().get(0); + applicationReleaseDTO.setCurrentState(AppLifecycleState.CREATED.toString()); + applicationReleaseDTO = this.applicationReleaseDAO.createRelease(applicationReleaseDTO, appId, tenantId); if (log.isDebugEnabled()) { log.debug("Changing lifecycle state. App Id:" + appId); } //todo get initial state from lifecycle manager and set current state to Release object - LifecycleStateEntity lifecycleState = getLifecycleStateInstance(AppLifecycleState.CREATED.toString(), + LifecycleStateDTO lifecycleState = getLifecycleStateInstance(AppLifecycleState.CREATED.toString(), AppLifecycleState.CREATED.toString()); - this.lifecycleStateDAO.addLifecycleState(lifecycleState, appId, applicationReleaseEntity.getUuid(), tenantId); - applicationReleaseEntity.setCurrentState(AppLifecycleState.CREATED.toString()); - applicationReleaseEntities.add(applicationReleaseEntity); - applicationEntity.setApplicationReleases(applicationReleaseEntities); - application = appDtoToAppResponse(applicationEntity); + this.lifecycleStateDAO.addLifecycleState(lifecycleState, appId, applicationReleaseDTO.getUuid(), tenantId); + applicationReleaseDTO.setCurrentState(AppLifecycleState.CREATED.toString()); + applicationReleaseEntities.add(applicationReleaseDTO); + applicationDTO.setApplicationReleases(applicationReleaseEntities); + application = appDtoToAppResponse(applicationDTO); ConnectionManagerUtil.commitDBTransaction(); } return application; } catch (LifeCycleManagementDAOException e) { ConnectionManagerUtil.rollbackDBTransaction(); - String msg = "Error occured while adding lifecycle state. application name: " + applicationWrapper.getName() + String msg = "Error occurred while adding lifecycle state. application name: " + applicationWrapper.getName() + " application type: is " + applicationWrapper.getType(); log.error(msg); throw new ApplicationManagementException(msg, e); } catch (ApplicationManagementDAOException e) { ConnectionManagerUtil.rollbackDBTransaction(); String msg = - "Error occured while adding application or application release. application name: " + applicationWrapper + "Error occurred while adding application or application release. application name: " + applicationWrapper .getName() + " application type: " + applicationWrapper.getType(); log.error(msg); throw new ApplicationManagementException(msg, e); } catch (DBConnectionException e) { - String msg = "Error occured while getting database connection."; + String msg = "Error occurred while getting database connection."; log.error(msg); throw new ApplicationManagementException(msg, e); } catch (VisibilityManagementDAOException e) { ConnectionManagerUtil.rollbackDBTransaction(); - String msg = "Error occured while adding unrestricted roles. application name: " + applicationWrapper.getName() + String msg = "Error occurred while adding unrestricted roles. application name: " + applicationWrapper.getName() + " application type: " + applicationWrapper.getType(); log.error(msg); throw new ApplicationManagementException(msg, e); } catch (TransactionManagementException e) { - String msg = "Error occured while disabling AutoCommit."; + String msg = "Error occurred while disabling AutoCommit."; log.error(msg); throw new ApplicationManagementException(msg, e); } catch (UserStoreException e) { ConnectionManagerUtil.rollbackDBTransaction(); - String msg = "Error occured when validating the unrestricted roles given for the application"; + String msg = "Error occurred when validating the unrestricted roles given for the application"; log.error(msg); throw new ApplicationManagementException(msg, e); } finally { @@ -309,58 +316,51 @@ public class ApplicationManagerImpl implements ApplicationManager { } } - private ApplicationEntity addApplicationReleaseArtifacts(ApplicationEntity applicationEntity, + private ApplicationDTO addApplicationReleaseArtifacts(ApplicationDTO applicationDTO, ApplicationArtifact applicationArtifact) throws ResourceManagementException { ApplicationStorageManager applicationStorageManager = Util.getApplicationStorageManager(); - List applicationReleaseEntities = new ArrayList<>(); - ApplicationReleaseEntity applicationReleaseEntity; - try { - applicationReleaseEntity = applicationEntity.getApplicationReleases().get(0); - // The application executable artifacts such as apks are uploaded. - if (!ApplicationType.ENTERPRISE.toString().equals(applicationEntity.getType())) { - applicationReleaseEntity = applicationStorageManager - .uploadReleaseArtifact(applicationReleaseEntity, applicationEntity.getType(), - applicationEntity.getDeviceTypeName(), null); - } else { - applicationReleaseEntity.setInstallerName(applicationArtifact.getInstallerName()); - applicationReleaseEntity = applicationStorageManager - .uploadReleaseArtifact(applicationReleaseEntity, applicationEntity.getType(), - applicationEntity.getDeviceTypeName(), applicationArtifact.getInstallerStream()); - } + List applicationReleaseEntities = new ArrayList<>(); + ApplicationReleaseDTO applicationReleaseDTO; + applicationReleaseDTO = applicationDTO.getApplicationReleases().get(0); + // The application executable artifacts such as apks are uploaded. + if (!ApplicationType.ENTERPRISE.toString().equals(applicationDTO.getType())) { + applicationReleaseDTO = applicationStorageManager + .uploadReleaseArtifact(applicationReleaseDTO, applicationDTO.getType(), + applicationDTO.getDeviceTypeName(), null); + } else { + applicationReleaseDTO.setInstallerName(applicationArtifact.getInstallerName()); + applicationReleaseDTO = applicationStorageManager + .uploadReleaseArtifact(applicationReleaseDTO, applicationDTO.getType(), + applicationDTO.getDeviceTypeName(), applicationArtifact.getInstallerStream()); + } - applicationReleaseEntity.setIconName(applicationArtifact.getIconName()); - applicationReleaseEntity.setBannerName(applicationArtifact.getBannername()); + applicationReleaseDTO.setIconName(applicationArtifact.getIconName()); + applicationReleaseDTO.setBannerName(applicationArtifact.getBannername()); - Map screenshots = applicationArtifact.getScreenshots(); - List screenshotNames = new ArrayList<>(screenshots.keySet()); + Map screenshots = applicationArtifact.getScreenshots(); + List screenshotNames = new ArrayList<>(screenshots.keySet()); - int counter = 1; - for (String scName : screenshotNames) { - if (counter == 1) { - applicationReleaseEntity.setScreenshotName1(scName); - } else if (counter == 2) { - applicationReleaseEntity.setScreenshotName2(scName); + int counter = 1; + for (String scName : screenshotNames) { + if (counter == 1) { + applicationReleaseDTO.setScreenshotName1(scName); + } else if (counter == 2) { + applicationReleaseDTO.setScreenshotName2(scName); - } else if (counter == 3) { - applicationReleaseEntity.setScreenshotName3(scName); - } - counter++; + } else if (counter == 3) { + applicationReleaseDTO.setScreenshotName3(scName); } - - // Upload images - applicationReleaseEntity = applicationStorageManager - .uploadImageArtifacts(applicationReleaseEntity, applicationArtifact.getIconStream(), - applicationArtifact.getBannerStream(), new ArrayList<>(screenshots.values())); - applicationReleaseEntity.setUuid(UUID.randomUUID().toString()); - applicationReleaseEntities.add(applicationReleaseEntity); - applicationEntity.setApplicationReleases(applicationReleaseEntities); - return applicationEntity; - } catch (RequestValidatingException e) { - // todo remove this exception cath, do this validation in the request validate method - String msg = "Error Occured when uploading artifacts of the application.: " + applicationEntity.getName(); - log.error(msg); - throw new ResourceManagementException(msg, e); + counter++; } + + // Upload images + applicationReleaseDTO = applicationStorageManager + .uploadImageArtifacts(applicationReleaseDTO, applicationArtifact.getIconStream(), + applicationArtifact.getBannerStream(), new ArrayList<>(screenshots.values())); + applicationReleaseDTO.setUuid(UUID.randomUUID().toString()); + applicationReleaseEntities.add(applicationReleaseDTO); + applicationDTO.setApplicationReleases(applicationReleaseEntities); + return applicationDTO; } @Override @@ -369,8 +369,8 @@ public class ApplicationManagerImpl implements ApplicationManager { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); ApplicationList applicationList; - List apps; - List releases; + List apps; + List releases; DeviceType deviceType; filter = validateFilter(filter); @@ -381,7 +381,7 @@ public class ApplicationManagerImpl implements ApplicationManager { try { if (!StringUtils.isEmpty(deviceTypeName)){ try { - deviceType = getDevceTypeData(deviceTypeName); + deviceType = getDeviceTypeData(deviceTypeName); filter.setDeviceTypeId(deviceType.getId()); } catch (UnexpectedServerErrorException e){ throw new ApplicationManagementException(e.getMessage(), e); @@ -392,7 +392,7 @@ public class ApplicationManagerImpl implements ApplicationManager { // todo modify this logic, join app n release tables applicationList = applicationDAO.getApplications(filter, tenantId); apps = applicationList.getApplications(); - for ( ApplicationEntity app : apps){ + for ( ApplicationDTO app : apps){ if (AppLifecycleState.REMOVED.toString().equals(app.getStatus())){ apps.remove(app); } @@ -403,7 +403,7 @@ public class ApplicationManagerImpl implements ApplicationManager { if (!isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) { applicationList = getRoleRestrictedApplicationList(applicationList, userName); } - for (ApplicationEntity application : applicationList.getApplications()) { + for (ApplicationDTO application : applicationList.getApplications()) { releases = getReleases(application, filter.getCurrentAppReleaseState()); application.setApplicationReleases(releases); } @@ -421,17 +421,17 @@ public class ApplicationManagerImpl implements ApplicationManager { } } - @Override public ApplicationReleaseEntity createRelease(int applicationId, ApplicationReleaseEntity applicationRelease) + @Override public ApplicationReleaseDTO createRelease(int applicationId, ApplicationReleaseDTO applicationRelease) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); // validateAppReleasePayload(applicationRelease); if (log.isDebugEnabled()) { - log.debug("ApplicationEntity release request is received for the application id: " + applicationId); + log.debug("ApplicationDTO release request is received for the application id: " + applicationId); } try { ConnectionManagerUtil.beginDBTransaction(); - ApplicationEntity existingApplication = this.applicationDAO.getApplicationById(applicationId, tenantId); + ApplicationDTO existingApplication = this.applicationDAO.getApplicationById(applicationId, tenantId); if (existingApplication == null) { throw new NotFoundException("Couldn't find application for the application Id: " + applicationId); } @@ -445,12 +445,12 @@ public class ApplicationManagerImpl implements ApplicationManager { } if (!existingApplication.getUnrestrictedRoles().isEmpty() && !isRoleExists( existingApplication.getUnrestrictedRoles(), userName)) { - String msg = "ApplicationEntity is visible to limited roles and those roles are not assigned to " + userName; + String msg = "ApplicationDTO is visible to limited roles and those roles are not assigned to " + userName; throw new ApplicationManagementException(msg); } if (this.applicationReleaseDAO .verifyReleaseExistenceByHash(applicationId, applicationRelease.getAppHashValue(), tenantId)) { - throw new BadRequestException("ApplicationEntity release exists for the application Id: " + applicationId + throw new BadRequestException("ApplicationDTO release exists for the application Id: " + applicationId + " and uploaded binary file"); } String packageName = this.applicationReleaseDAO.getPackageName(applicationId, tenantId); @@ -460,7 +460,7 @@ public class ApplicationManagerImpl implements ApplicationManager { } applicationRelease = this.applicationReleaseDAO .createRelease(applicationRelease, existingApplication.getId(), tenantId); - LifecycleStateEntity lifecycleState = getLifecycleStateInstance(AppLifecycleState.CREATED.toString(), + LifecycleStateDTO lifecycleState = getLifecycleStateInstance(AppLifecycleState.CREATED.toString(), AppLifecycleState.CREATED.toString()); this.lifecycleStateDAO .addLifecycleState(lifecycleState, applicationId, applicationRelease.getUuid(), tenantId); @@ -472,7 +472,7 @@ public class ApplicationManagerImpl implements ApplicationManager { + applicationId, e); } catch (DBConnectionException e) { throw new ApplicationManagementException( - "Error occurred while adding application release into IoTS app management ApplicationEntity id of the " + "Error occurred while adding application release into IoTS app management ApplicationDTO id of the " + "application release: " + applicationId, e); } catch (LifeCycleManagementDAOException e) { @@ -487,19 +487,19 @@ public class ApplicationManagerImpl implements ApplicationManager { } catch (UserStoreException e) { ConnectionManagerUtil.rollbackDBTransaction(); throw new ApplicationManagementException( - "Error occurred whecn checking whether user is admin user or not. ApplicationEntity release: " + "Error occurred whecn checking whether user is admin user or not. ApplicationDTO release: " + applicationId, e); } finally { ConnectionManagerUtil.closeDBConnection(); } } - @Override public ApplicationEntity getApplicationById(int appId, String state) throws ApplicationManagementException { + @Override public ApplicationDTO getApplicationById(int appId, String state) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); - ApplicationEntity application; + ApplicationDTO application; boolean isAppAllowed = false; - List applicationReleases; + List applicationReleases; try { ConnectionManagerUtil.openDBConnection(); application = this.applicationDAO.getApplicationById(appId, tenantId); @@ -535,12 +535,12 @@ public class ApplicationManagerImpl implements ApplicationManager { } @Override - public ApplicationEntity getApplicationByUuid(String uuid, String state) throws ApplicationManagementException { + public ApplicationDTO getApplicationByUuid(String uuid, String state) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); - ApplicationEntity application; + ApplicationDTO application; boolean isAppAllowed = false; - List applicationReleases; + List applicationReleases; try { ConnectionManagerUtil.openDBConnection(); application = this.applicationDAO.getApplicationByUUID(uuid, tenantId); @@ -618,12 +618,12 @@ public class ApplicationManagerImpl implements ApplicationManager { return roleList; } - public ApplicationEntity getApplication(String appType, String appName) throws ApplicationManagementException { + public ApplicationDTO getApplication(String appType, String appName) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); - ApplicationEntity application; + ApplicationDTO application; boolean isAppAllowed = false; - List applicationReleases; + List applicationReleases; try { ConnectionManagerUtil.openDBConnection(); application = this.applicationDAO.getApplication(appName, appType, tenantId); @@ -656,10 +656,10 @@ public class ApplicationManagerImpl implements ApplicationManager { } } - @Override public ApplicationEntity getApplicationByRelease(String appReleaseUUID) throws ApplicationManagementException { + @Override public ApplicationDTO getApplicationByRelease(String appReleaseUUID) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); - ApplicationEntity application; + ApplicationDTO application; try { ConnectionManagerUtil.openDBConnection(); application = this.applicationDAO.getApplicationByRelease(appReleaseUUID, tenantId); @@ -678,17 +678,17 @@ public class ApplicationManagerImpl implements ApplicationManager { } // todo rethink about this method - private List getReleases(ApplicationEntity application, String releaseState) + private List getReleases(ApplicationDTO application, String releaseState) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); - List applicationReleases; + List applicationReleases; if (log.isDebugEnabled()) { log.debug("Request is received to retrieve all the releases related with the application " + application .toString()); } applicationReleases = this.applicationReleaseDAO.getReleases(application.getId(), tenantId); - for (ApplicationReleaseEntity applicationRelease : applicationReleases) { - LifecycleStateEntity lifecycleState = null; + for (ApplicationReleaseDTO applicationRelease : applicationReleases) { + LifecycleStateDTO lifecycleState = null; try { lifecycleState = this.lifecycleStateDAO.getLatestLifeCycleStateByReleaseID(applicationRelease.getId()); } catch (LifeCycleManagementDAOException e) { @@ -705,12 +705,12 @@ public class ApplicationManagerImpl implements ApplicationManager { // return filterAppReleaseByCurrentState(applicationReleases, releaseState); } -// private List filterAppReleaseByCurrentState(List applicationReleases, +// private List filterAppReleaseByCurrentState(List applicationReleases, // String state) { -// List filteredReleases = new ArrayList<>(); +// List filteredReleases = new ArrayList<>(); // // if (state != null && !state.isEmpty()) { -// for (ApplicationReleaseEntity applicationRelease : applicationReleases) { +// for (ApplicationReleaseDTO applicationRelease : applicationReleases) { // if (state.equals(applicationRelease.getLifecycleState().getCurrentState())) { // filteredReleases.add(applicationRelease); // } @@ -736,31 +736,31 @@ public class ApplicationManagerImpl implements ApplicationManager { String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); List storedLocations = new ArrayList<>(); - ApplicationEntity application; + ApplicationDTO application; try { ConnectionManagerUtil.beginDBTransaction(); application = this.applicationDAO.getApplicationById(applicationId, tenantId); if (application == null) { - throw new NotFoundException("Couldn't found an application for ApplicationEntity ID: " + applicationId); + throw new NotFoundException("Couldn't found an application for ApplicationDTO ID: " + applicationId); } if (!isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION) && !application .getUnrestrictedRoles().isEmpty() && isRoleExists(application.getUnrestrictedRoles(), userName)) { throw new ForbiddenException( "You don't have permission to delete this application. In order to delete an application you " - + "need to have required permission. ApplicationEntity ID: " + applicationId); + + "need to have required permission. ApplicationDTO ID: " + applicationId); } - List applicationReleases = getReleases(application, null); + List applicationReleases = getReleases(application, null); if (log.isDebugEnabled()) { log.debug("Request is received to delete applications which are related with the application id " + applicationId); } - for (ApplicationReleaseEntity applicationRelease : applicationReleases) { - LifecycleStateEntity appLifecycleState = this.lifecycleStateDAO + for (ApplicationReleaseDTO applicationRelease : applicationReleases) { + LifecycleStateDTO appLifecycleState = this.lifecycleStateDAO .getLatestLifeCycleState(applicationId, applicationRelease.getUuid()); - LifecycleStateEntity newAppLifecycleState = getLifecycleStateInstance(AppLifecycleState.REMOVED.toString(), + LifecycleStateDTO newAppLifecycleState = getLifecycleStateInstance(AppLifecycleState.REMOVED.toString(), appLifecycleState.getCurrentState()); if (lifecycleStateManger.isValidStateChange(newAppLifecycleState.getPreviousState(), newAppLifecycleState.getCurrentState())) { @@ -772,7 +772,7 @@ public class ApplicationManagerImpl implements ApplicationManager { List lifecycleFlow = searchLifecycleStateFlow(currentState, AppLifecycleState.REMOVED.toString()); for (String nextState : lifecycleFlow) { - LifecycleStateEntity lifecycleState = getLifecycleStateInstance(nextState, currentState); + LifecycleStateDTO lifecycleState = getLifecycleStateInstance(nextState, currentState); if (lifecycleStateManger.isValidStateChange(currentState, nextState)) { this.lifecycleStateDAO .addLifecycleState(lifecycleState, applicationId, applicationRelease.getUuid(), @@ -860,7 +860,7 @@ public class ApplicationManagerImpl implements ApplicationManager { throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); - ApplicationEntity application; + ApplicationDTO application; try { ConnectionManagerUtil.beginDBTransaction(); application = this.applicationDAO.getApplicationById(applicationId, tenantId); @@ -870,17 +870,17 @@ public class ApplicationManagerImpl implements ApplicationManager { if (!isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION) && !application .getUnrestrictedRoles().isEmpty() && isRoleExists(application.getUnrestrictedRoles(), userName)) { throw new ForbiddenException( - "You don't have permission for deleting application release. ApplicationEntity id: " + applicationId + "You don't have permission for deleting application release. ApplicationDTO id: " + applicationId + " and release UUID: " + releaseUuid); } - ApplicationReleaseEntity applicationRelease = this.applicationReleaseDAO + ApplicationReleaseDTO applicationRelease = this.applicationReleaseDAO .getReleaseByIds(applicationId, releaseUuid, tenantId); if (applicationRelease == null) { throw new NotFoundException("Couldn't find an application release for application ID: " + applicationId + " and release UUID: " + releaseUuid); } - LifecycleStateEntity appLifecycleState = this.lifecycleStateDAO + LifecycleStateDTO appLifecycleState = this.lifecycleStateDAO .getLatestLifeCycleState(applicationId, releaseUuid); if (appLifecycleState == null) { throw new NotFoundException( @@ -890,7 +890,7 @@ public class ApplicationManagerImpl implements ApplicationManager { String currentState = appLifecycleState.getCurrentState(); if (AppLifecycleState.DEPRECATED.toString().equals(currentState) || AppLifecycleState.REJECTED.toString() .equals(currentState) || AppLifecycleState.UNPUBLISHED.toString().equals(currentState)) { - LifecycleStateEntity newAppLifecycleState = getLifecycleStateInstance(AppLifecycleState.REMOVED.toString(), + LifecycleStateDTO newAppLifecycleState = getLifecycleStateInstance(AppLifecycleState.REMOVED.toString(), appLifecycleState.getCurrentState()); if (lifecycleStateManger.isValidStateChange(newAppLifecycleState.getPreviousState(), newAppLifecycleState.getCurrentState())) { @@ -902,7 +902,7 @@ public class ApplicationManagerImpl implements ApplicationManager { List lifecycleFlow = searchLifecycleStateFlow(currentState, AppLifecycleState.REMOVED.toString()); for (String nextState : lifecycleFlow) { - LifecycleStateEntity lifecycleState = getLifecycleStateInstance(nextState, currentState); + LifecycleStateDTO lifecycleState = getLifecycleStateInstance(nextState, currentState); if (lifecycleStateManger.isValidStateChange(currentState, nextState)) { this.lifecycleStateDAO .addLifecycleState(lifecycleState, applicationId, applicationRelease.getUuid(), @@ -934,8 +934,8 @@ public class ApplicationManagerImpl implements ApplicationManager { + " and application release UUID of " + releaseUuid, e); } catch (UserStoreException e) { throw new ApplicationManagementException( - "Error occured when checking permission for executing application release update. ApplicationEntity ID: " - + applicationId + " and ApplicationEntity UUID: " + releaseUuid); + "Error occured when checking permission for executing application release update. ApplicationDTO ID: " + + applicationId + " and ApplicationDTO UUID: " + releaseUuid); } finally { ConnectionManagerUtil.closeDBConnection(); } @@ -980,11 +980,11 @@ public class ApplicationManagerImpl implements ApplicationManager { InputStream bannerFileStream, List attachments) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); ApplicationStorageManager applicationStorageManager = Util.getApplicationStorageManager(); - ApplicationReleaseEntity applicationRelease; + ApplicationReleaseDTO applicationRelease; try { if (appId <= 0) { throw new ValidationException( - "ApplicationEntity id could,t be a negative integer. Hence please add valid application id."); + "ApplicationDTO id could,t be a negative integer. Hence please add valid application id."); } ConnectionManagerUtil.beginDBTransaction(); applicationRelease = this.applicationReleaseDAO.getReleaseByIds(appId, uuid, tenantId); @@ -993,7 +993,7 @@ public class ApplicationManagerImpl implements ApplicationManager { "Doesn't exist a application release for application ID: " + appId + "and application UUID: " + uuid); } - LifecycleStateEntity lifecycleState = this.lifecycleStateDAO + LifecycleStateDTO lifecycleState = this.lifecycleStateDAO .getLatestLifeCycleState(appId, applicationRelease.getUuid()); if (AppLifecycleState.PUBLISHED.toString().equals(lifecycleState.getCurrentState()) || AppLifecycleState.DEPRECATED.toString().equals(lifecycleState.getCurrentState())) { @@ -1006,8 +1006,8 @@ public class ApplicationManagerImpl implements ApplicationManager { if (applicationRelease == null) { ConnectionManagerUtil.rollbackDBTransaction(); throw new ApplicationManagementException( - "ApplicationEntity release updating count is 0. ApplicationEntity id: " + appId - + " ApplicationEntity release UUID: " + uuid); + "ApplicationDTO release updating count is 0. ApplicationDTO id: " + appId + + " ApplicationDTO release UUID: " + uuid); } ConnectionManagerUtil.commitDBTransaction(); @@ -1041,7 +1041,7 @@ public class ApplicationManagerImpl implements ApplicationManager { throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); ApplicationStorageManager applicationStorageManager = Util.getApplicationStorageManager(); - ApplicationReleaseEntity applicationRelease; + ApplicationReleaseDTO applicationRelease; try { boolean isValidDeviceType = false; List deviceTypes = Util.getDeviceManagementService().getDeviceTypes(); @@ -1054,16 +1054,16 @@ public class ApplicationManagerImpl implements ApplicationManager { if (!isValidDeviceType) { throw new ValidationException( "Invalid request to update application release artifact, invalid application type: " - + deviceType + " for ApplicationEntity id: " + appId + " application release uuid: " + uuid); + + deviceType + " for ApplicationDTO id: " + appId + " application release uuid: " + uuid); } if (appId <= 0) { throw new ValidationException( - "ApplicationEntity id could,t be a negative integer. Hence please add valid application id. application type: " - + deviceType + " ApplicationEntity id: " + appId + " UUID: " + uuid); + "ApplicationDTO id could,t be a negative integer. Hence please add valid application id. application type: " + + deviceType + " ApplicationDTO id: " + appId + " UUID: " + uuid); } ConnectionManagerUtil.beginDBTransaction(); - ApplicationEntity application = this.applicationDAO.getApplicationById(appId, tenantId); + ApplicationDTO application = this.applicationDAO.getApplicationById(appId, tenantId); if (application == null) { throw new NotFoundException("Doesn't exist a application for the application ID: " + appId); } @@ -1080,8 +1080,8 @@ public class ApplicationManagerImpl implements ApplicationManager { if (applicationRelease == null) { ConnectionManagerUtil.rollbackDBTransaction(); throw new ApplicationManagementException( - "ApplicationEntity release updating count is 0. ApplicationEntity id: " + appId - + " ApplicationEntity release UUID: " + uuid); + "ApplicationDTO release updating count is 0. ApplicationDTO id: " + appId + + " ApplicationDTO release UUID: " + uuid); } ConnectionManagerUtil.commitDBTransaction(); @@ -1115,13 +1115,13 @@ public class ApplicationManagerImpl implements ApplicationManager { * * @param applicationList list of applications. * @param userName user name - * @return ApplicationEntity related with the UUID + * @return ApplicationDTO related with the UUID */ private ApplicationList getRoleRestrictedApplicationList(ApplicationList applicationList, String userName) throws ApplicationManagementException { ApplicationList roleRestrictedApplicationList = new ApplicationList(); - ArrayList unRestrictedApplications = new ArrayList<>(); - for (ApplicationEntity application : applicationList.getApplications()) { + ArrayList unRestrictedApplications = new ArrayList<>(); + for (ApplicationDTO application : applicationList.getApplications()) { if (application.getUnrestrictedRoles().isEmpty()) { unRestrictedApplications.add(application); } else { @@ -1141,21 +1141,21 @@ public class ApplicationManagerImpl implements ApplicationManager { /** * To validate a app release creating request and app updating request to make sure all the pre-conditions satisfied. * - * @param applicationRelease ApplicationReleaseEntity that need to be created. - * @throws ApplicationManagementException ApplicationEntity Management Exception. + * @param applicationRelease ApplicationReleaseDTO that need to be created. + * @throws ApplicationManagementException ApplicationDTO Management Exception. */ - private void validateAppReleasePayload(ApplicationReleaseEntity applicationRelease) + private void validateAppReleasePayload(ApplicationReleaseDTO applicationRelease) throws ApplicationManagementException { if (applicationRelease.getVersion() == null) { - throw new ApplicationManagementException("ApplicationReleaseEntity version name is a mandatory parameter for " + throw new ApplicationManagementException("ApplicationReleaseDTO version name is a mandatory parameter for " + "creating release. It cannot be found."); } } @Override - public LifecycleStateEntity getLifecycleState(int applicationId, String releaseUuid) + public LifecycleStateDTO getLifecycleState(int applicationId, String releaseUuid) throws ApplicationManagementException { - LifecycleStateEntity lifecycleState; + LifecycleStateDTO lifecycleState; try { ConnectionManagerUtil.openDBConnection(); lifecycleState = this.lifecycleStateDAO.getLatestLifeCycleState(applicationId, releaseUuid); @@ -1174,7 +1174,7 @@ public class ApplicationManagerImpl implements ApplicationManager { } @Override - public void changeLifecycleState(int applicationId, String releaseUuid, LifecycleStateEntity state) + public void changeLifecycleState(int applicationId, String releaseUuid, LifecycleStateDTO state) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); try { @@ -1186,7 +1186,7 @@ public class ApplicationManagerImpl implements ApplicationManager { throw new NotFoundException("Couldn't find application release for the application Id: " + applicationId + " application release uuid: " + releaseUuid); } - LifecycleStateEntity currentState = this.lifecycleStateDAO.getLatestLifeCycleState(applicationId, releaseUuid); + LifecycleStateDTO currentState = this.lifecycleStateDAO.getLatestLifeCycleState(applicationId, releaseUuid); if (currentState == null) { throw new ApplicationManagementException( "Couldn't find latest lifecycle state for the appId: " + applicationId @@ -1208,14 +1208,14 @@ public class ApplicationManagerImpl implements ApplicationManager { log.error("Invalid lifecycle state transition from '" + state.getPreviousState() + "'" + " to '" + state.getCurrentState() + "'"); throw new ApplicationManagementException( - "Lifecycle State Validation failed. ApplicationEntity Id: " + applicationId - + " ApplicationEntity release UUID: " + releaseUuid); + "Lifecycle State Validation failed. ApplicationDTO Id: " + applicationId + + " ApplicationDTO release UUID: " + releaseUuid); } } } catch (LifeCycleManagementDAOException e) { ConnectionManagerUtil.rollbackDBTransaction(); throw new ApplicationManagementException( - "Failed to add lifecycle state. ApplicationEntity Id: " + applicationId + " ApplicationEntity release UUID: " + "Failed to add lifecycle state. ApplicationDTO Id: " + applicationId + " ApplicationDTO release UUID: " + releaseUuid, e); } finally { ConnectionManagerUtil.closeDBConnection(); @@ -1227,8 +1227,8 @@ public class ApplicationManagerImpl implements ApplicationManager { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); try { ConnectionManagerUtil.beginDBTransaction(); - List existingCategories = applicationDAO.getAllCategories(tenantId); - List existingCategoryNames = existingCategories.stream().map(CategoryEntity::getCategoryName) + List existingCategories = applicationDAO.getAllCategories(tenantId); + List existingCategoryNames = existingCategories.stream().map(CategoryDTO::getCategoryName) .collect(Collectors.toList()); if(!existingCategoryNames.containsAll(categories)){ List newCategories = getDifference(categories, existingCategoryNames); @@ -1246,12 +1246,12 @@ public class ApplicationManagerImpl implements ApplicationManager { } @Override - public ApplicationEntity updateApplication(int applicationId, ApplicationEntity application) + public ApplicationDTO updateApplication(int applicationId, ApplicationDTO application) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); - ApplicationEntity existingApplication; + ApplicationDTO existingApplication; boolean isExistingAppRestricted = false; List addingRoleList; List removingRoleList; @@ -1263,7 +1263,7 @@ public class ApplicationManagerImpl implements ApplicationManager { existingApplication = this.applicationDAO.getApplicationById(applicationId, tenantId); if (existingApplication == null) { ConnectionManagerUtil.rollbackDBTransaction(); - throw new NotFoundException("Tried to update ApplicationEntity which is not in the publisher, " + throw new NotFoundException("Tried to update ApplicationDTO which is not in the publisher, " + "Please verify application details"); } if (!existingApplication.getUnrestrictedRoles().isEmpty()) { @@ -1334,15 +1334,15 @@ public class ApplicationManagerImpl implements ApplicationManager { } catch (VisibilityManagementDAOException e) { ConnectionManagerUtil.rollbackDBTransaction(); throw new ApplicationManagementException( - "Error occurred while updating the visibility restriction of the application. ApplicationEntity id is " + "Error occurred while updating the visibility restriction of the application. ApplicationDTO id is " + applicationId); } catch (TransactionManagementException e) { throw new ApplicationManagementException( - "Error occurred while starting database transaction for application updating. ApplicationEntity id is " + "Error occurred while starting database transaction for application updating. ApplicationDTO id is " + applicationId); } catch (DBConnectionException e) { throw new ApplicationManagementException( - "Error occurred while getting database connection for application updating. ApplicationEntity id is " + "Error occurred while getting database connection for application updating. ApplicationDTO id is " + applicationId); } finally { ConnectionManagerUtil.closeDBConnection(); @@ -1379,11 +1379,11 @@ public class ApplicationManagerImpl implements ApplicationManager { * By invoking the method, it returns Lifecycle State Instance. * @param currentState Current state of the lifecycle * @param previousState Previouse state of the Lifecycle - * @return {@link LifecycleStateEntity} + * @return {@link LifecycleStateDTO} */ - private LifecycleStateEntity getLifecycleStateInstance(String currentState, String previousState) { + private LifecycleStateDTO getLifecycleStateInstance(String currentState, String previousState) { String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); - LifecycleStateEntity lifecycleState = new LifecycleStateEntity(); + LifecycleStateDTO lifecycleState = new LifecycleStateDTO(); lifecycleState.setCurrentState(currentState); lifecycleState.setPreviousState(previousState); lifecycleState.setUpdatedBy(userName); @@ -1391,14 +1391,15 @@ public class ApplicationManagerImpl implements ApplicationManager { } //todo check whether package names are same - @Override public boolean updateRelease(int applicationId, String releaseUuid, String deviceType, - ApplicationReleaseEntity updateRelease, InputStream binaryFileStram, InputStream iconFileStream, + @Override + public boolean updateRelease(int applicationId, String releaseUuid, String deviceType, + ApplicationReleaseDTO updateRelease, InputStream binaryFileStram, InputStream iconFileStream, InputStream bannerFileStream, List attachments) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); - ApplicationReleaseEntity release; - ApplicationEntity app = null; + ApplicationReleaseDTO release; + ApplicationDTO app = null; ApplicationStorageManager applicationStorageManager = Util.getApplicationStorageManager(); DeviceType deviceTypeObj; boolean isAdminUser; @@ -1415,19 +1416,19 @@ public class ApplicationManagerImpl implements ApplicationManager { if (app == null) { ConnectionManagerUtil.rollbackDBTransaction(); throw new NotFoundException( - "Couldn't found an application for updating. ApplicationEntity id: " + applicationId); + "Couldn't found an application for updating. ApplicationDTO id: " + applicationId); } if (deviceTypeObj == null || deviceTypeObj.getId() != app.getDeviceTypeId()) { ConnectionManagerUtil.rollbackDBTransaction(); throw new BadRequestException( "Request to update application release for Invalid device type. Device type: " + deviceType - + " application ID " + applicationId + " ApplicationEntity Release UUID " + releaseUuid); + + " application ID " + applicationId + " ApplicationDTO Release UUID " + releaseUuid); } if (release == null) { ConnectionManagerUtil.rollbackDBTransaction(); throw new NotFoundException( - "Couldn't found an application realise for updating. ApplicationEntity id: " + applicationId + "Couldn't found an application realise for updating. ApplicationDTO id: " + applicationId + " and application release UUID: " + releaseUuid); } @@ -1439,9 +1440,9 @@ public class ApplicationManagerImpl implements ApplicationManager { || (price > 0.0 && ApplicationSubscriptionType.FREE.toString().equals(app.getSubType()))) { ConnectionManagerUtil.rollbackDBTransaction(); throw new BadRequestException( - "Invalid app release payload for updating application release. ApplicationEntity price is " + price - + " for " + app.getSubType() + " application. ApplicationEntity ID: " + applicationId - + ", ApplicationEntity Release UUID " + releaseUuid + " and supported device type is " + "Invalid app release payload for updating application release. ApplicationDTO price is " + price + + " for " + app.getSubType() + " application. ApplicationDTO ID: " + applicationId + + ", ApplicationDTO Release UUID " + releaseUuid + " and supported device type is " + deviceType); } release.setPrice(price); @@ -1464,7 +1465,7 @@ public class ApplicationManagerImpl implements ApplicationManager { } //todo try to remove this DB call and get it when getting application release - LifecycleStateEntity lifecycleState = this.lifecycleStateDAO.getLatestLifeCycleState(applicationId, releaseUuid); + LifecycleStateDTO lifecycleState = this.lifecycleStateDAO.getLatestLifeCycleState(applicationId, releaseUuid); if (!AppLifecycleState.CREATED.toString().equals(lifecycleState.getCurrentState()) && !AppLifecycleState.IN_REVIEW.toString().equals(lifecycleState.getCurrentState()) && !AppLifecycleState.REJECTED.toString().equals(lifecycleState.getCurrentState())) { @@ -1493,69 +1494,59 @@ public class ApplicationManagerImpl implements ApplicationManager { } catch (ApplicationManagementDAOException e) { ConnectionManagerUtil.rollbackDBTransaction(); throw new ApplicationManagementException( - "Error occured when updating ApplicationEntity release. ApplicationEntity ID " + applicationId - + " ApplicationEntity Release UUID: " + releaseUuid, e); + "Error occured when updating ApplicationDTO release. ApplicationDTO ID " + applicationId + + " ApplicationDTO Release UUID: " + releaseUuid, e); } catch (ApplicationStorageManagementException e) { ConnectionManagerUtil.rollbackDBTransaction(); throw new ApplicationManagementException( - "Error occured when updating application release artifact. ApplicationEntity ID " + applicationId - + " ApplicationEntity release UUID: " + releaseUuid, e); + "Error occured when updating application release artifact. ApplicationDTO ID " + applicationId + + " ApplicationDTO release UUID: " + releaseUuid, e); } catch (ResourceManagementException e) { // updating images ConnectionManagerUtil.rollbackDBTransaction(); throw new ApplicationManagementException( - "Error occured when updating image artifact of the application release. ApplicationEntity ID: " - + applicationId + " ApplicationEntity release UUID: " + releaseUuid, e); + "Error occured when updating image artifact of the application release. ApplicationDTO ID: " + + applicationId + " ApplicationDTO release UUID: " + releaseUuid, e); } catch (RequestValidatingException e) { ConnectionManagerUtil.rollbackDBTransaction(); throw new ApplicationManagementException( "Error occured when validating application release artifact for device type " + deviceType + " And application type " + app.getType() + ". Applicationn ID: " + applicationId - + " ApplicationEntity release UUID: " + releaseUuid); + + " ApplicationDTO release UUID: " + releaseUuid); } } - /*** - * To validate the application creating request - * - * @param applicationWrapper {@link ApplicationEntity} - * @param binaryFile Uploading binary fila. i.e .apk or .ipa - * @param iconFile Icon file for the application. - * @param bannerFile Banner file for the application. - * @param attachmentList Screenshot list. - * @throws RequestValidatingException if the payload contains invalid inputs. - */ - public void validateAppCreatingRequest(ApplicationWrapper applicationWrapper, Attachment binaryFile, - Attachment iconFile, Attachment bannerFile, List attachmentList) - throws RequestValidatingException { + + @Override + public void validateAppCreatingRequest(ApplicationWrapper applicationWrapper) throws RequestValidatingException { boolean isValidApplicationType; String applicationType = applicationWrapper.getType(); if (StringUtils.isEmpty(applicationWrapper.getName())) { - String msg = "ApplicationEntity name cannot be empty"; + String msg = "Application name cannot be empty."; log.error(msg); throw new RequestValidatingException(msg); } if (StringUtils.isEmpty(applicationWrapper.getAppCategory())) { - String msg = "ApplicationEntity category can't be empty"; + String msg = "Application category can't be empty."; log.error(msg); throw new RequestValidatingException(msg); } if (StringUtils.isEmpty(applicationType)) { - String msg = "ApplicationEntity type can't be empty"; + String msg = "Application type can't be empty."; log.error(msg); throw new RequestValidatingException(msg); } if (StringUtils.isEmpty(applicationWrapper.getDeviceType())) { - String msg = "Device type can't be empty for the application"; + String msg = "Device type can't be empty for the application."; log.error(msg); throw new RequestValidatingException(msg); } isValidApplicationType = isValidAppType(applicationWrapper.getType()); if (!isValidApplicationType) { - String msg = "App Type contains in the application creating payload doesn't match with supported app types"; + String msg = "App Type contains in the application creating payload doesn't match with supported app types."; log.error(msg); throw new RequestValidatingException(msg); } @@ -1565,45 +1556,44 @@ public class ApplicationManagerImpl implements ApplicationManager { if (applicationReleaseWrappers == null || applicationReleaseWrappers.size() != 1) { String msg = - "Invalid application creating request. ApplicationEntity creating request must have single application " - + "release. ApplicationEntity name:" + applicationWrapper.getName() + " and type: " + applicationWrapper + "Invalid application creating request. ApplicationDTO creating request must have single application " + + "release. ApplicationDTO name:" + applicationWrapper.getName() + " and type: " + applicationWrapper .getType(); log.error(msg); throw new RequestValidatingException(msg); } - validateReleaseCreatingRequest(applicationReleaseWrappers.get(0), applicationType, binaryFile, iconFile, bannerFile, - attachmentList); + } - /*** - * - * @param applicationReleaseWrapper {@link ApplicationReleaseEntity} - * @param applicationType Type of the application - * @param binaryFile Uploading binary fila. i.e .apk or .ipa - * @param iconFile Icon file for the application. - * @param bannerFile Banner file for the application. - * @param attachmentList Screenshot list. - * @throws RequestValidatingException throws if payload does not satisfy requrements. - */ - public void validateReleaseCreatingRequest(ApplicationReleaseWrapper applicationReleaseWrapper, String applicationType, - Attachment binaryFile, Attachment iconFile, Attachment bannerFile, List attachmentList) - throws RequestValidatingException { - if (ApplicationType.WEB_CLIP.toString().equals(applicationType) && applicationReleaseWrapper.getUrl() == null){ - String msg = "URL should't be null for the application release creating request for application type: " - + applicationType; - log.error(msg); - throw new RequestValidatingException(msg); + @Override + public void validateReleaseCreatingRequest(ApplicationReleaseWrapper applicationReleaseWrapper, + String applicationType) throws RequestValidatingException { + + if (ApplicationType.WEB_CLIP.toString().equals(applicationType)) { + UrlValidator urlValidator = new UrlValidator(); + if (StringUtils + .isEmpty(applicationReleaseWrapper.getUrl())){ + String msg = "URL should't be null for the application release creating request for application type WEB_CLIP"; + log.error(msg); + throw new RequestValidatingException(msg); + } + if (!urlValidator.isValid(applicationReleaseWrapper.getUrl())){ + String msg = "Request payload contains an invalid Web Clip URL."; + log.error(msg); + throw new RequestValidatingException(msg); + } } if (StringUtils.isEmpty(applicationReleaseWrapper.getSupportedOsVersions())){ - String msg = "Supported OS Vershios shouldn't be null or empty."; + String msg = "Supported OS Version shouldn't be null or empty."; log.error(msg); throw new RequestValidatingException(msg); } - isValidAttachmentSet(binaryFile, iconFile, bannerFile, attachmentList, applicationType); } - private void isValidAttachmentSet(Attachment binaryFile, Attachment iconFile, Attachment bannerFile, + + @Override + public void isValidAttachmentSet(Attachment binaryFile, Attachment iconFile, Attachment bannerFile, List attachmentList, String applicationType) throws RequestValidatingException { if (iconFile == null) { String msg = "Icon file is not found with the application release creating request."; @@ -1626,7 +1616,7 @@ public class ApplicationManagerImpl implements ApplicationManager { throw new RequestValidatingException(msg); } if (binaryFile == null && ApplicationType.ENTERPRISE.toString().equals(applicationType)) { - String msg = "Binary file is not found with the application release creating request. ApplicationEntity type: " + String msg = "Binary file is not found with the application release creating request. ApplicationDTO type: " + applicationType; log.error(msg); throw new RequestValidatingException(msg); @@ -1634,89 +1624,89 @@ public class ApplicationManagerImpl implements ApplicationManager { } - private ApplicationEntity appWrapperToAppEntity(ApplicationWrapper applicationWrapper) + private ApplicationDTO appWrapperToAppDTO(ApplicationWrapper applicationWrapper) throws BadRequestException, UnexpectedServerErrorException { - DeviceType deviceType = getDevceTypeData(applicationWrapper.getDeviceType()); - ApplicationEntity applicationEntity = new ApplicationEntity(); - applicationEntity.setName(applicationWrapper.getName()); - applicationEntity.setDescription(applicationWrapper.getDescription()); - applicationEntity.setAppCategory(applicationWrapper.getAppCategory()); - applicationEntity.setType(applicationWrapper.getType()); - applicationEntity.setSubType(applicationWrapper.getSubType()); - applicationEntity.setPaymentCurrency(applicationWrapper.getPaymentCurrency()); - applicationEntity.setTags(applicationWrapper.getTags()); - applicationEntity.setUnrestrictedRoles(applicationWrapper.getUnrestrictedRoles()); - applicationEntity.setDeviceTypeId(deviceType.getId()); - applicationEntity.setDeviceTypeName(deviceType.getName()); - List applicationReleaseEntities = applicationWrapper.getApplicationReleaseWrappers() - .stream().map(this::releaseWrapperToReleaseEntity).collect(Collectors.toList()); - applicationEntity.setApplicationReleases(applicationReleaseEntities); - return applicationEntity; + DeviceType deviceType = getDeviceTypeData(applicationWrapper.getDeviceType()); + ApplicationDTO applicationDTO = new ApplicationDTO(); + applicationDTO.setName(applicationWrapper.getName()); + applicationDTO.setDescription(applicationWrapper.getDescription()); + applicationDTO.setAppCategory(applicationWrapper.getAppCategory()); + applicationDTO.setType(applicationWrapper.getType()); + applicationDTO.setSubType(applicationWrapper.getSubType()); + applicationDTO.setPaymentCurrency(applicationWrapper.getPaymentCurrency()); + applicationDTO.setTags(applicationWrapper.getTags()); + applicationDTO.setUnrestrictedRoles(applicationWrapper.getUnrestrictedRoles()); + applicationDTO.setDeviceTypeId(deviceType.getId()); + applicationDTO.setDeviceTypeName(deviceType.getName()); + List applicationReleaseEntities = applicationWrapper.getApplicationReleaseWrappers() + .stream().map(this::releaseWrapperToReleaseDTO).collect(Collectors.toList()); + applicationDTO.setApplicationReleases(applicationReleaseEntities); + return applicationDTO; } - private ApplicationReleaseEntity releaseWrapperToReleaseEntity(ApplicationReleaseWrapper applicationReleaseWrapper){ - ApplicationReleaseEntity applicationReleaseEntity = new ApplicationReleaseEntity(); - applicationReleaseEntity.setDescription(applicationReleaseWrapper.getDescription()); - applicationReleaseEntity.setReleaseType(applicationReleaseWrapper.getReleaseType()); - applicationReleaseEntity.setPrice(applicationReleaseWrapper.getPrice()); - applicationReleaseEntity.setIsSharedWithAllTenants(applicationReleaseWrapper.getIsSharedWithAllTenants()); - applicationReleaseEntity.setMetaData(applicationReleaseWrapper.getMetaData()); - applicationReleaseEntity.setUrl(applicationReleaseWrapper.getUrl()); - applicationReleaseEntity.setSupportedOsVersions(applicationReleaseWrapper.getSupportedOsVersions()); - return applicationReleaseEntity; + private ApplicationReleaseDTO releaseWrapperToReleaseDTO(ApplicationReleaseWrapper applicationReleaseWrapper){ + ApplicationReleaseDTO applicationReleaseDTO = new ApplicationReleaseDTO(); + applicationReleaseDTO.setDescription(applicationReleaseWrapper.getDescription()); + applicationReleaseDTO.setReleaseType(applicationReleaseWrapper.getReleaseType()); + applicationReleaseDTO.setPrice(applicationReleaseWrapper.getPrice()); + applicationReleaseDTO.setIsSharedWithAllTenants(applicationReleaseWrapper.getIsSharedWithAllTenants()); + applicationReleaseDTO.setMetaData(applicationReleaseWrapper.getMetaData()); + applicationReleaseDTO.setUrl(applicationReleaseWrapper.getUrl()); + applicationReleaseDTO.setSupportedOsVersions(applicationReleaseWrapper.getSupportedOsVersions()); + return applicationReleaseDTO; } - private Application appDtoToAppResponse(ApplicationEntity applicationEntity) { + private Application appDtoToAppResponse(ApplicationDTO applicationDTO) { Application application = new Application(); - application.setId(applicationEntity.getId()); - application.setName(applicationEntity.getName()); - application.setDescription(applicationEntity.getDescription()); - application.setAppCategory(applicationEntity.getAppCategory()); - application.setType(applicationEntity.getType()); - application.setSubType(applicationEntity.getSubType()); - application.setPaymentCurrency(applicationEntity.getPaymentCurrency()); - application.setTags(applicationEntity.getTags()); - application.setUnrestrictedRoles(applicationEntity.getUnrestrictedRoles()); - application.setDeviceType(applicationEntity.getDeviceTypeName()); - List applicationReleases = applicationEntity.getApplicationReleases() + application.setId(applicationDTO.getId()); + application.setName(applicationDTO.getName()); + application.setDescription(applicationDTO.getDescription()); + application.setAppCategory(applicationDTO.getAppCategory()); + application.setType(applicationDTO.getType()); + application.setSubType(applicationDTO.getSubType()); + application.setPaymentCurrency(applicationDTO.getPaymentCurrency()); + application.setTags(applicationDTO.getTags()); + application.setUnrestrictedRoles(applicationDTO.getUnrestrictedRoles()); + application.setDeviceType(applicationDTO.getDeviceTypeName()); + List applicationReleases = applicationDTO.getApplicationReleases() .stream().map(this::releaseDtoToRelease).collect(Collectors.toList()); application.setApplicationReleases(applicationReleases); return application; } - private ApplicationRelease releaseDtoToRelease(ApplicationReleaseEntity applicationReleaseEntity){ + private ApplicationRelease releaseDtoToRelease(ApplicationReleaseDTO applicationReleaseDTO){ String artifactDownloadEndpoint = ConfigurationManager.getInstance().getConfiguration().getArtifactDownloadEndpoint(); - String basePath = artifactDownloadEndpoint + Constants.FORWARD_SLASH + applicationReleaseEntity.getUuid(); + String basePath = artifactDownloadEndpoint + Constants.FORWARD_SLASH + applicationReleaseDTO.getUuid(); ApplicationRelease applicationRelease = new ApplicationRelease(); - applicationRelease.setDescription(applicationReleaseEntity.getDescription()); - applicationRelease.setReleaseType(applicationReleaseEntity.getReleaseType()); - applicationRelease.setPrice(applicationReleaseEntity.getPrice()); - applicationRelease.setIsSharedWithAllTenants(applicationReleaseEntity.getIsSharedWithAllTenants()); - applicationRelease.setMetaData(applicationReleaseEntity.getMetaData()); - applicationRelease.setUrl(applicationReleaseEntity.getUrl()); - applicationRelease.setSupportedOsVersions(applicationReleaseEntity.getSupportedOsVersions()); - applicationRelease.setInstallerPath(basePath + Constants.FORWARD_SLASH + applicationReleaseEntity.getInstallerName()); - applicationRelease.setIconPath(basePath + Constants.FORWARD_SLASH + applicationReleaseEntity.getIconName()); - applicationRelease.setBannerPath(basePath + Constants.FORWARD_SLASH + applicationReleaseEntity.getBannerName()); - - if (!StringUtils.isEmpty(applicationReleaseEntity.getScreenshotName1())) { + applicationRelease.setDescription(applicationReleaseDTO.getDescription()); + applicationRelease.setReleaseType(applicationReleaseDTO.getReleaseType()); + applicationRelease.setPrice(applicationReleaseDTO.getPrice()); + applicationRelease.setIsSharedWithAllTenants(applicationReleaseDTO.getIsSharedWithAllTenants()); + applicationRelease.setMetaData(applicationReleaseDTO.getMetaData()); + applicationRelease.setUrl(applicationReleaseDTO.getUrl()); + applicationRelease.setSupportedOsVersions(applicationReleaseDTO.getSupportedOsVersions()); + applicationRelease.setInstallerPath(basePath + Constants.FORWARD_SLASH + applicationReleaseDTO.getInstallerName()); + applicationRelease.setIconPath(basePath + Constants.FORWARD_SLASH + applicationReleaseDTO.getIconName()); + applicationRelease.setBannerPath(basePath + Constants.FORWARD_SLASH + applicationReleaseDTO.getBannerName()); + + if (!StringUtils.isEmpty(applicationReleaseDTO.getScreenshotName1())) { applicationRelease.setScreenshotPath1( - basePath + Constants.FORWARD_SLASH + applicationReleaseEntity.getScreenshotName1()); + basePath + Constants.FORWARD_SLASH + applicationReleaseDTO.getScreenshotName1()); } - if (!StringUtils.isEmpty(applicationReleaseEntity.getScreenshotName2())) { + if (!StringUtils.isEmpty(applicationReleaseDTO.getScreenshotName2())) { applicationRelease.setScreenshotPath2( - basePath + Constants.FORWARD_SLASH + applicationReleaseEntity.getScreenshotName2()); + basePath + Constants.FORWARD_SLASH + applicationReleaseDTO.getScreenshotName2()); } - if (!StringUtils.isEmpty(applicationReleaseEntity.getScreenshotName3())) { + if (!StringUtils.isEmpty(applicationReleaseDTO.getScreenshotName3())) { applicationRelease.setScreenshotPath3( - basePath + Constants.FORWARD_SLASH + applicationReleaseEntity.getScreenshotName3()); + basePath + Constants.FORWARD_SLASH + applicationReleaseDTO.getScreenshotName3()); } return applicationRelease; } - private DeviceType getDevceTypeData( T deviceTypeAttr) + private DeviceType getDeviceTypeData( T deviceTypeAttr) throws BadRequestException, UnexpectedServerErrorException { List deviceTypes; try { 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 1132522100..20e9e5d892 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 @@ -29,9 +29,8 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.commons.validator.routines.UrlValidator; -import org.apache.cxf.jaxrs.ext.multipart.Attachment; import org.wso2.carbon.context.PrivilegedCarbonContext; -import org.wso2.carbon.device.application.mgt.common.entity.ApplicationReleaseEntity; +import org.wso2.carbon.device.application.mgt.common.dto.ApplicationReleaseDTO; import org.wso2.carbon.device.application.mgt.common.ApplicationType; import org.wso2.carbon.device.application.mgt.common.DeviceTypes; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationStorageManagementException; @@ -44,11 +43,9 @@ import org.wso2.carbon.device.application.mgt.core.util.Constants; import org.wso2.carbon.device.application.mgt.core.util.StorageManagementUtil; import org.xml.sax.SAXException; -import javax.activation.DataHandler; import javax.xml.parsers.ParserConfigurationException; import java.io.*; import java.text.ParseException; -import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -80,7 +77,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager } @Override - public ApplicationReleaseEntity uploadImageArtifacts(ApplicationReleaseEntity applicationRelease, InputStream iconFileStream, + public ApplicationReleaseDTO uploadImageArtifacts(ApplicationReleaseDTO applicationRelease, InputStream iconFileStream, InputStream bannerFileStream, List screenShotStreams) throws ResourceManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); @@ -90,6 +87,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager String scStoredLocation = null; try { + // todo handle WEB CLIP and save data in different folder (uuid) artifactDirectoryPath = storagePath + applicationRelease.getAppHashValue(); StorageManagementUtil.createArtifactDirectory(artifactDirectoryPath); iconStoredLocation = artifactDirectoryPath + File.separator + applicationRelease.getIconName(); @@ -128,7 +126,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager throw new ApplicationStorageManagementException("IO Exception while saving the screens hots for " + "the application " + applicationRelease.getUuid(), e); } catch (ApplicationStorageManagementException e) { - throw new ApplicationStorageManagementException("ApplicationEntity Management DAO exception while trying to " + throw new ApplicationStorageManagementException("ApplicationDTO Management DAO exception while trying to " + "update the screen-shot count for the application " + applicationRelease.getUuid() + " for the tenant id " + tenantId, e); } @@ -136,7 +134,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager @Override - public ApplicationReleaseEntity updateImageArtifacts(ApplicationReleaseEntity applicationRelease, InputStream + public ApplicationReleaseDTO updateImageArtifacts(ApplicationReleaseDTO applicationRelease, InputStream iconFileStream, InputStream bannerFileStream, List screenShotStreams) throws ResourceManagementException { @@ -171,27 +169,22 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager screenShotStreams); return applicationRelease; } catch (ApplicationStorageManagementException e) { - throw new ApplicationStorageManagementException("ApplicationEntity Storage exception while trying to" + throw new ApplicationStorageManagementException("ApplicationDTO Storage exception while trying to" + " update the screen-shot count for the application Release " + applicationRelease.getUuid() + " for the tenant " + tenantId, e); } } @Override - public ApplicationReleaseEntity uploadReleaseArtifact(ApplicationReleaseEntity applicationRelease, String appType, - String deviceType, InputStream binaryFile) throws ResourceManagementException, RequestValidatingException { + public ApplicationReleaseDTO uploadReleaseArtifact(ApplicationReleaseDTO applicationReleaseDTO, String appType, + String deviceType, InputStream binaryFile) throws ResourceManagementException { try { + // move version and package getting code into separate method and check whether package exist in db if (ApplicationType.WEB_CLIP.toString().equals(appType)) { - applicationRelease.setVersion(Constants.DEFAULT_VERSION); - UrlValidator urlValidator = new UrlValidator(); - if (applicationRelease.getUrl() == null || !urlValidator.isValid(applicationRelease.getUrl())) { - String msg = "Request payload doesn't contains Web Clip URL with application release object or Web Clip URL is invalid"; - log.error(msg); - throw new RequestValidatingException(msg); - } - applicationRelease.setInstallerName(applicationRelease.getUrl()); - applicationRelease.setAppHashValue(null); - return applicationRelease; + applicationReleaseDTO.setVersion(Constants.DEFAULT_VERSION); + applicationReleaseDTO.setInstallerName(applicationReleaseDTO.getUrl()); + applicationReleaseDTO.setAppHashValue(null); + return applicationReleaseDTO; } String artifactDirectoryPath; String md5OfApp; @@ -200,9 +193,8 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager md5OfApp = getMD5(new ByteArrayInputStream(content)); if (md5OfApp == null) { - String msg = - "Error occurred while md5sum value retrieving process: application UUID " + applicationRelease - .getUuid(); + String msg = "Error occurred while md5sum value retrieving process: application UUID " + + applicationReleaseDTO.getUuid(); log.error(msg); throw new ApplicationStorageManagementException(msg); } @@ -210,16 +202,16 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager artifactDirectoryPath = storagePath + md5OfApp; if (DeviceTypes.ANDROID.toString().equalsIgnoreCase(deviceType)) { ApkMeta apkMeta = ArtifactsParser.readAndroidManifestFile(new ByteArrayInputStream(content)); - applicationRelease.setVersion(apkMeta.getVersionName()); - applicationRelease.setPackageName(apkMeta.getPackageName()); + applicationReleaseDTO.setVersion(apkMeta.getVersionName()); + applicationReleaseDTO.setPackageName(apkMeta.getPackageName()); } else if (DeviceTypes.IOS.toString().equalsIgnoreCase(deviceType)) { NSDictionary plistInfo = ArtifactsParser.readiOSManifestFile(binaryFile); - applicationRelease + applicationReleaseDTO .setVersion(plistInfo.objectForKey(ArtifactsParser.IPA_BUNDLE_VERSION_KEY).toString()); - applicationRelease + applicationReleaseDTO .setPackageName(plistInfo.objectForKey(ArtifactsParser.IPA_BUNDLE_IDENTIFIER_KEY).toString()); } else { - String msg = "ApplicationEntity Type doesn't match with supporting application types " + applicationRelease + String msg = "Application Type doesn't match with supporting application types " + applicationReleaseDTO .getUuid(); log.error(msg); throw new ApplicationStorageManagementException(msg); @@ -227,30 +219,29 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager if (log.isDebugEnabled()) { log.debug("Artifact Directory Path for saving the application release related artifacts related with " - + "application UUID " + applicationRelease.getUuid() + " is " + artifactDirectoryPath); + + "application UUID " + applicationReleaseDTO.getUuid() + " is " + artifactDirectoryPath); } StorageManagementUtil.createArtifactDirectory(artifactDirectoryPath); - artifactPath = artifactDirectoryPath + File.separator + applicationRelease.getInstallerName(); + artifactPath = artifactDirectoryPath + File.separator + applicationReleaseDTO.getInstallerName(); saveFile(new ByteArrayInputStream(content), artifactPath); - applicationRelease.setAppHashValue(md5OfApp); + applicationReleaseDTO.setAppHashValue(md5OfApp); } catch (IOException e) { String msg = "IO Exception while saving the release artifacts in the server for the application UUID " - + applicationRelease.getUuid(); + + applicationReleaseDTO.getUuid(); log.error(msg); throw new ApplicationStorageManagementException( msg, e); } catch (ParsingException e) { - String msg = - "Error occurred while parsing the artifact file. ApplicationEntity release UUID is " + applicationRelease - .getUuid(); + String msg = "Error occurred while parsing the artifact file. Application release UUID is " + + applicationReleaseDTO.getUuid(); log.error(msg); throw new ApplicationStorageManagementException(msg, e); } - return applicationRelease; + return applicationReleaseDTO; } @Override - public ApplicationReleaseEntity updateReleaseArtifacts(ApplicationReleaseEntity applicationRelease, String appType, + public ApplicationReleaseDTO updateReleaseArtifacts(ApplicationReleaseDTO applicationRelease, String appType, String deviceType, InputStream binaryFile) throws ApplicationStorageManagementException, RequestValidatingException { @@ -258,9 +249,9 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager deleteApplicationReleaseArtifacts(applicationRelease.getInstallerName()); applicationRelease = uploadReleaseArtifact(applicationRelease, appType, deviceType, binaryFile); } catch (ApplicationStorageManagementException e) { - throw new ApplicationStorageManagementException("ApplicationEntity Artifact doesn't contains in the System", e); + throw new ApplicationStorageManagementException("ApplicationDTO Artifact doesn't contains in the System", e); } catch (ResourceManagementException e) { - throw new ApplicationStorageManagementException("ApplicationEntity Artifact Updating failed", e); + throw new ApplicationStorageManagementException("ApplicationDTO Artifact Updating failed", e); } 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/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 be84e78e78..e5fa42ab12 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 @@ -21,7 +21,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.application.mgt.common.AppOperation; -import org.wso2.carbon.device.application.mgt.common.entity.ApplicationEntity; +import org.wso2.carbon.device.application.mgt.common.dto.ApplicationDTO; import org.wso2.carbon.device.application.mgt.common.ApplicationInstallResponse; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager; @@ -70,7 +70,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { log.debug("Install application: " + applicationUUID + " to " + deviceList.size() + "devices."); } ApplicationManager applicationManager = DataHolder.getInstance().getApplicationManager(); - ApplicationEntity application = applicationManager.getApplicationByRelease(applicationUUID); + ApplicationDTO application = applicationManager.getApplicationByRelease(applicationUUID); return installApplication(application, deviceList); } @@ -82,7 +82,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { log.debug("Install application: " + applicationUUID + " to " + userList.size() + " users."); } ApplicationManager applicationManager = DataHolder.getInstance().getApplicationManager(); - ApplicationEntity application = applicationManager.getApplicationByRelease(applicationUUID); + ApplicationDTO application = applicationManager.getApplicationByRelease(applicationUUID); List deviceList = new ArrayList<>(); for (String user : userList) { try { @@ -123,7 +123,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { log.debug("Install application: " + applicationUUID + " to " + roleList.size() + " roles."); } ApplicationManager applicationManager = DataHolder.getInstance().getApplicationManager(); - ApplicationEntity application = applicationManager.getApplicationByRelease(applicationUUID); + ApplicationDTO application = applicationManager.getApplicationByRelease(applicationUUID); List deviceList = new ArrayList<>(); for (String role : roleList) { try { @@ -164,7 +164,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { log.debug("Install application: " + applicationUUID + " to " + deviceGroupList.size() + " groups."); } ApplicationManager applicationManager = DataHolder.getInstance().getApplicationManager(); - ApplicationEntity application = applicationManager.getApplicationByRelease(applicationUUID); + ApplicationDTO application = applicationManager.getApplicationByRelease(applicationUUID); GroupManagementProviderService groupManagementProviderService = HelperUtil.getGroupManagementProviderService(); List groupList = new ArrayList<>(); List deviceList = new ArrayList<>(); @@ -207,7 +207,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { return null; } - private ApplicationInstallResponse installApplication(ApplicationEntity application, + private ApplicationInstallResponse installApplication(ApplicationDTO application, List deviceIdentifierList) throws ApplicationManagementException { DeviceManagementProviderService deviceManagementProviderService = HelperUtil .getDeviceManagementProviderService(); @@ -259,7 +259,7 @@ public class SubscriptionManagerImpl implements SubscriptionManager { return response; } - private Operation generateOperationPayloadByDeviceType(String deviceType, ApplicationEntity application) { + private Operation generateOperationPayloadByDeviceType(String deviceType, ApplicationDTO application) { ProfileOperation operation = new ProfileOperation(); operation.setCode(INSTALL_APPLICATION); operation.setType(Operation.Type.PROFILE); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ApplicationManagementServiceComponent.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ApplicationManagementServiceComponent.java index f1d3c92cd9..cca3e32608 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ApplicationManagementServiceComponent.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ApplicationManagementServiceComponent.java @@ -120,14 +120,14 @@ public class ApplicationManagementServiceComponent { protected void setDeviceManagementService(DeviceManagementProviderService deviceManagementProviderService) { if (log.isDebugEnabled()) { - log.debug("Setting ApplicationEntity Management OSGI Manager"); + log.debug("Setting ApplicationDTO Management OSGI Manager"); } DataHolder.getInstance().setDeviceManagementService(deviceManagementProviderService); } protected void unsetDeviceManagementService(DeviceManagementProviderService deviceManagementProviderService) { if (log.isDebugEnabled()) { - log.debug("Removing ApplicationEntity Management OSGI Manager"); + log.debug("Removing ApplicationDTO Management OSGI Manager"); } DataHolder.getInstance().setDeviceManagementService(null); } 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 bf1719b355..21fc719134 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 @@ -29,7 +29,7 @@ import javax.ws.rs.core.Response; /** - * Holds util methods required for ApplicationEntity-Mgt API component. + * Holds util methods required for ApplicationDTO-Mgt API component. */ public class APIUtil { @@ -49,7 +49,7 @@ public class APIUtil { applicationManager = (ApplicationManager) ctx.getOSGiService(ApplicationManager.class, null); if (applicationManager == null) { - String msg = "ApplicationEntity Manager service has not initialized."; + String msg = "ApplicationDTO Manager service has not initialized."; log.error(msg); throw new IllegalStateException(msg); } @@ -60,7 +60,7 @@ public class APIUtil { } /** - * To get the ApplicationEntity Storage Manager from the osgi context. + * To get the ApplicationDTO Storage Manager from the osgi context. * @return ApplicationStoreManager instance in the current osgi context. */ public static ApplicationStorageManager getApplicationStorageManager() { @@ -71,7 +71,7 @@ public class APIUtil { applicationStorageManager = (ApplicationStorageManager) ctx .getOSGiService(ApplicationStorageManager.class, null); if (applicationStorageManager == null) { - String msg = "ApplicationEntity Storage Manager service has not initialized."; + String msg = "ApplicationDTO Storage Manager service has not initialized."; log.error(msg); throw new IllegalStateException(msg); } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/application-mgt.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/application-mgt.xml index a443d6cf6c..2665bf13d3 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/application-mgt.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/test/resources/application-mgt.xml @@ -19,7 +19,7 @@ - + jdbc/APPM_DS 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/ApplicationManagementAPI.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/ApplicationManagementAPI.java index 7ab6583c02..819ac72b71 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/ApplicationManagementAPI.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/ApplicationManagementAPI.java @@ -34,10 +34,8 @@ import org.wso2.carbon.apimgt.annotations.api.Scope; import org.wso2.carbon.apimgt.annotations.api.Scopes; import org.wso2.carbon.device.application.mgt.common.*; import org.wso2.carbon.device.application.mgt.common.ErrorResponse; -import org.wso2.carbon.device.application.mgt.common.entity.ApplicationEntity; -import org.wso2.carbon.device.application.mgt.common.entity.ApplicationReleaseEntity; -import org.wso2.carbon.device.application.mgt.common.response.Application; -import org.wso2.carbon.device.application.mgt.common.wrapper.ApplicationReleaseWrapper; +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.wrapper.ApplicationWrapper; import java.util.List; @@ -60,7 +58,7 @@ import javax.ws.rs.core.Response; @SwaggerDefinition( info = @Info( version = "1.0.0", - title = "ApplicationEntity Management Service", + title = "ApplicationDTO Management Service", extensions = { @Extension(properties = { @ExtensionProperty(name = "name", value = "ApplicationManagementService"), @@ -69,20 +67,20 @@ import javax.ws.rs.core.Response; } ), tags = { - @Tag(name = "application_management, device_management", description = "ApplicationEntity Management related " + @Tag(name = "application_management, device_management", description = "ApplicationDTO Management related " + "APIs") } ) @Scopes( scopes = { @Scope( - name = "Get ApplicationEntity Details", + name = "Get ApplicationDTO Details", description = "Get application details", key = "perm:app:publisher:view", permissions = {"/device-mgt/application/view"} ), @Scope( - name = "Update an ApplicationEntity", + name = "Update an ApplicationDTO", description = "Update an application", key = "perm:app:publisher:update", permissions = {"/device-mgt/application/update"} @@ -90,7 +88,7 @@ import javax.ws.rs.core.Response; } ) @Path("/publisher/applications") -@Api(value = "ApplicationEntity Management", description = "This API carries all application management related operations " + +@Api(value = "ApplicationDTO Management", description = "This API carries all application management related operations " + "such as get all the applications, add application, etc.") @Produces(MediaType.APPLICATION_JSON) public interface ApplicationManagementAPI { @@ -106,7 +104,7 @@ public interface ApplicationManagementAPI { httpMethod = "GET", value = "get all applications", notes = "This will get all applications", - tags = "ApplicationEntity Management", + tags = "ApplicationDTO Management", extensions = { @Extension(properties = { @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:view") @@ -143,7 +141,7 @@ public interface ApplicationManagementAPI { @QueryParam("type") String appType, @ApiParam( name = "category", - value = "CategoryEntity of the application") + value = "CategoryDTO of the application") @QueryParam("category") String appCategory, @ApiParam( name = "exact-match", @@ -180,7 +178,7 @@ public interface ApplicationManagementAPI { httpMethod = "GET", value = "get the application of requesting application id and state", notes = "This will get the application identified by the application id and state, if exists", - tags = "ApplicationEntity Management", + tags = "ApplicationDTO Management", extensions = { @Extension(properties = { @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:view") @@ -192,10 +190,10 @@ public interface ApplicationManagementAPI { @ApiResponse( code = 200, message = "OK. \n Successfully retrieved relevant application.", - response = ApplicationEntity.class), + response = ApplicationDTO.class), @ApiResponse( code = 404, - message = "ApplicationEntity not found"), + message = "ApplicationDTO not found"), @ApiResponse( code = 500, message = "Internal Server Error. \n Error occurred while getting relevant application.", @@ -224,7 +222,7 @@ public interface ApplicationManagementAPI { httpMethod = "PUT", value = "Edit an application", notes = "This will edit the new application", - tags = "ApplicationEntity Management", + tags = "ApplicationDTO Management", extensions = { @Extension(properties = { @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") @@ -236,11 +234,11 @@ public interface ApplicationManagementAPI { @ApiResponse( code = 200, message = "OK. \n Successfully edited the application.", - response = ApplicationEntity.class), + response = ApplicationDTO.class), @ApiResponse( code = 400, message = "Bad Request. \n " + - "ApplicationEntity updating payload contains unacceptable or vulnerable data"), + "ApplicationDTO updating payload contains unacceptable or vulnerable data"), @ApiResponse( code = 500, message = "Internal Server Error. \n Error occurred while editing the application.", @@ -256,7 +254,7 @@ public interface ApplicationManagementAPI { name = "application", value = "The application that need to be edited.", required = true) - @Valid ApplicationEntity application + @Valid ApplicationDTO application ); @POST @@ -268,7 +266,7 @@ public interface ApplicationManagementAPI { httpMethod = "POST", value = "Create an application", notes = "This will create a new application", - tags = "ApplicationEntity Management", + tags = "ApplicationDTO Management", extensions = { @Extension(properties = { @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") @@ -280,11 +278,11 @@ public interface ApplicationManagementAPI { @ApiResponse( code = 201, message = "OK. \n Successfully created an application.", - response = ApplicationEntity.class), + response = ApplicationDTO.class), @ApiResponse( code = 400, message = "Bad Request. \n " + - "ApplicationEntity creating payload contains unacceptable or vulnerable data"), + "ApplicationDTO creating payload contains unacceptable or vulnerable data"), @ApiResponse( code = 500, message = "Internal Server Error. \n Error occurred while creating the application.", @@ -338,7 +336,7 @@ public interface ApplicationManagementAPI { // httpMethod = "POST", // value = "Create an application", // notes = "This will create a new application", -// tags = "ApplicationEntity Management", +// tags = "ApplicationDTO Management", // extensions = { // @Extension(properties = { // @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") @@ -354,7 +352,7 @@ public interface ApplicationManagementAPI { // @ApiResponse( // code = 400, // message = "Bad Request. \n " + -// "ApplicationEntity creating payload contains unacceptable or vulnerable data"), +// "ApplicationDTO creating payload contains unacceptable or vulnerable data"), // @ApiResponse( // code = 500, // message = "Internal Server Error. \n Error occurred while creating the application.", @@ -368,7 +366,7 @@ public interface ApplicationManagementAPI { // name = "applicationRelease", // value = "The application release that need to be created.", // required = true) -// @Multipart("applicationRelease") ApplicationReleaseEntity applicationRelease, +// @Multipart("applicationRelease") ApplicationReleaseDTO applicationRelease, // @ApiParam( // name = "binaryFile", // value = "Binary file of uploading application", @@ -410,7 +408,7 @@ public interface ApplicationManagementAPI { httpMethod = "DELETE", value = "Delete the application with the given UUID", notes = "This will delete the application with the given UUID", - tags = "ApplicationEntity Management", + tags = "ApplicationDTO Management", extensions = { @Extension(properties = { @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") @@ -431,7 +429,7 @@ public interface ApplicationManagementAPI { Response deleteApplication( @ApiParam( name = "UUID", - value = "Unique identifier of the ApplicationEntity", + value = "Unique identifier of the ApplicationDTO", required = true) @PathParam("appid") int applicationId ); @@ -446,7 +444,7 @@ public interface ApplicationManagementAPI { httpMethod = "POST", value = "Upload artifacts", notes = "This will create a new application", - tags = "ApplicationEntity Management", + tags = "ApplicationDTO Management", extensions = { @Extension(properties = { @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") @@ -522,7 +520,7 @@ public interface ApplicationManagementAPI { httpMethod = "POST", value = "Upload artifacts", notes = "This will create a new application", - tags = "ApplicationEntity Management", + tags = "ApplicationDTO Management", extensions = { @Extension(properties = { @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") @@ -537,7 +535,7 @@ public interface ApplicationManagementAPI { @ApiResponse( code = 400, message = "Bad Request. \n " + - "ApplicationEntity artifact updating payload contains unacceptable or vulnerable data"), + "ApplicationDTO artifact updating payload contains unacceptable or vulnerable data"), @ApiResponse( code = 404, message = "NOT FOUND. \n Couldn't found application/application release to update applocation release artifact."), @@ -568,7 +566,7 @@ public interface ApplicationManagementAPI { httpMethod = "PUT", value = "Update an application release", notes = "This will update a new application release", - tags = "ApplicationEntity Management", + tags = "ApplicationDTO Management", extensions = { @Extension(properties = { @ExtensionProperty(name = SCOPE, value = "perm:app:publisher:update") @@ -580,11 +578,11 @@ public interface ApplicationManagementAPI { @ApiResponse( code = 201, message = "OK. \n Successfully created an application release.", - response = ApplicationReleaseEntity.class), + response = ApplicationReleaseDTO.class), @ApiResponse( code = 400, message = "Bad Request. \n " + - "ApplicationEntity release updating payload contains unacceptable or vulnerable data"), + "ApplicationDTO release updating payload contains unacceptable or vulnerable data"), @ApiResponse( code = 500, message = "Internal Server Error. \n Error occurred while releasing the application.", @@ -593,11 +591,11 @@ public interface ApplicationManagementAPI { Response updateApplicationRelease( @ApiParam(name = "deviceType", value = "Supported device type of the application", required = true) @PathParam("deviceType") String deviceType, - @ApiParam(name = "appId", value = "Identifier of the ApplicationEntity", required = true) + @ApiParam(name = "appId", value = "Identifier of the ApplicationDTO", required = true) @PathParam("appId") int applicationId, - @ApiParam(name = "UUID", value = "Unique identifier of the ApplicationEntity Release", required = true) + @ApiParam(name = "UUID", value = "Unique identifier of the ApplicationDTO Release", required = true) @PathParam("uuid") String applicationUUID, - @Multipart(value = "applicationRelease", required = false, type = "application/json") ApplicationReleaseEntity applicationRelease, + @Multipart(value = "applicationRelease", required = false, type = "application/json") ApplicationReleaseDTO applicationRelease, @Multipart(value = "binaryFile", required = false) Attachment binaryFile, @Multipart(value = "icon", required = false) Attachment iconFile, @Multipart(value = "banner", required = false) Attachment bannerFile, @@ -660,7 +658,7 @@ public interface ApplicationManagementAPI { @ApiResponse( code = 201, message = "OK. \n Successfully add a lifecycle state.", - response = ApplicationEntity.class), + response = ApplicationDTO.class), @ApiResponse( code = 400, message = "Bad Request. \n " + @@ -677,12 +675,12 @@ public interface ApplicationManagementAPI { Response addLifecycleState( @ApiParam( name = "appId", - value = "Identifier of the ApplicationEntity", + value = "Identifier of the ApplicationDTO", required = true) @PathParam("appId") int applicationId, @ApiParam( name = "uuid", - value = "UUID of the ApplicationEntity Release", + value = "UUID of the ApplicationDTO Release", required = true) @PathParam("uuid") String applicationUuid, @ApiParam( 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/ApplicationManagementAPIImpl.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/ApplicationManagementAPIImpl.java index 2fa3323851..17017f85d2 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/ApplicationManagementAPIImpl.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/ApplicationManagementAPIImpl.java @@ -23,9 +23,9 @@ import org.apache.commons.logging.LogFactory; import org.apache.cxf.jaxrs.ext.multipart.Attachment; import org.apache.cxf.jaxrs.ext.multipart.Multipart; import org.wso2.carbon.device.application.mgt.common.*; -import org.wso2.carbon.device.application.mgt.common.entity.ApplicationEntity; -import org.wso2.carbon.device.application.mgt.common.entity.ApplicationReleaseEntity; -import org.wso2.carbon.device.application.mgt.common.entity.LifecycleStateEntity; +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.LifecycleStateDTO; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationStorageManagementException; import org.wso2.carbon.device.application.mgt.common.exception.RequestValidatingException; import org.wso2.carbon.device.application.mgt.common.response.Application; @@ -62,7 +62,7 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; /** - * Implementation of ApplicationEntity Management related APIs. + * Implementation of Application Management related APIs. */ @Produces({"application/json"}) @Path("/applications") @@ -114,10 +114,10 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { @DefaultValue("PUBLISHED") @QueryParam("state") String state) { ApplicationManager applicationManager = APIUtil.getApplicationManager(); try { - ApplicationEntity application = applicationManager.getApplicationById(appId, state); + ApplicationDTO application = applicationManager.getApplicationById(appId, state); return Response.status(Response.Status.OK).entity(application).build(); } catch (NotFoundException e) { - String msg = "ApplicationEntity with application id: " + appId + " not found"; + String msg = "ApplicationDTO with application id: " + appId + " not found"; log.error(msg, e); return Response.status(Response.Status.NOT_FOUND).entity(msg).build(); } catch (ApplicationManagementException e) { @@ -151,17 +151,21 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { } try { - applicationManager - .validateAppCreatingRequest(applicationWrapper, binaryFile, iconFile, bannerFile, attachmentList); + applicationManager.validateAppCreatingRequest(applicationWrapper); + applicationManager.validateReleaseCreatingRequest(applicationWrapper.getApplicationReleaseWrappers().get(0), + applicationWrapper.getType()); + applicationManager.isValidAttachmentSet(binaryFile, iconFile, bannerFile, attachmentList, + applicationWrapper.getType()); + // Created new application entry - Application createdApplication = applicationManager.createApplication(applicationWrapper, + Application application = applicationManager.createApplication(applicationWrapper, constructApplicationArtifact(binaryFile, iconFile, bannerFile, attachmentList)); - if (createdApplication != null) { - return Response.status(Response.Status.CREATED).entity(createdApplication).build(); + if (application != null) { + return Response.status(Response.Status.CREATED).entity(application).build(); } else { - String msg = "ApplicationEntity creation is failed"; + String msg = "ApplicationDTO creation is failed"; log.error(msg); - return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); + return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); } } catch (ApplicationManagementException e) { String msg = "Error occurred while creating the application"; @@ -181,7 +185,7 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { // @PathParam("deviceType") String deviceType, // @PathParam("appType") String appType, // @PathParam("appId") int appId, -// @Multipart("applicationRelease") ApplicationReleaseEntity applicationRelease, +// @Multipart("applicationRelease") ApplicationReleaseDTO applicationRelease, // @Multipart("binaryFile") Attachment binaryFile, // @Multipart("icon") Attachment iconFile, // @Multipart("banner") Attachment bannerFile, @@ -233,11 +237,11 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { // applicationRelease.setUuid(UUID.randomUUID().toString()); // // // Created new application release entry -// ApplicationReleaseEntity release = applicationManager.createRelease(appId, applicationRelease); +// ApplicationReleaseDTO release = applicationManager.createRelease(appId, applicationRelease); // if (release != null) { // return Response.status(Response.Status.CREATED).entity(release).build(); // } else { -// log.error("ApplicationEntity Creation Failed"); +// log.error("ApplicationDTO Creation Failed"); // return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); // } // } catch (ApplicationManagementException e) { @@ -337,7 +341,7 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { + applicationReleaseUuid).build(); } if (!ApplicationType.ENTERPRISE.toString().equals(appType)) { - return Response.status(Response.Status.BAD_REQUEST).entity("If ApplicationEntity type is " + appType + return Response.status(Response.Status.BAD_REQUEST).entity("If ApplicationDTO type is " + appType + ", therefore you don't have application release artifact to update for application release UUID: " + applicationReleaseUuid).build(); } @@ -370,7 +374,7 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { @Path("/{appId}") public Response updateApplication( @PathParam("appId") int applicationId, - @Valid ApplicationEntity application) { + @Valid ApplicationDTO application) { ApplicationManager applicationManager = APIUtil.getApplicationManager(); try { application = applicationManager.updateApplication(applicationId, application); @@ -395,7 +399,7 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { @PathParam("deviceType") String deviceType, @PathParam("appId") int applicationId, @PathParam("uuid") String applicationUUID, - @Multipart("applicationRelease") ApplicationReleaseEntity applicationRelease, + @Multipart("applicationRelease") ApplicationReleaseDTO applicationRelease, @Multipart("binaryFile") Attachment binaryFile, @Multipart("icon") Attachment iconFile, @Multipart("banner") Attachment bannerFile, @@ -434,12 +438,12 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { .updateRelease(applicationId, applicationUUID, deviceType, applicationRelease, binaryFileStram, iconFileStream, bannerFileStream, attachments); if (!status){ - log.error("ApplicationEntity release updating is failed. Please contact the administrator. ApplicationEntity id: " - + applicationId + ", ApplicationEntity release UUID: " + applicationUUID + ", Supported device type: " + log.error("ApplicationDTO release updating is failed. Please contact the administrator. ApplicationDTO id: " + + applicationId + ", ApplicationDTO release UUID: " + applicationUUID + ", Supported device type: " + deviceType); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(applicationRelease).build(); } - return Response.status(Response.Status.OK).entity("ApplicationEntity release is successfully updated.").build(); + return Response.status(Response.Status.OK).entity("ApplicationDTO release is successfully updated.").build(); } catch(BadRequestException e){ String msg = "Invalid request to update application release for application release UUID " + applicationUUID; log.error(msg, e); @@ -536,7 +540,7 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { public Response getLifecycleState( @PathParam("appId") int applicationId, @PathParam("uuid") String applicationUuid) { - LifecycleStateEntity lifecycleState; + LifecycleStateDTO lifecycleState; ApplicationManager applicationManager = APIUtil.getApplicationManager(); try { lifecycleState = applicationManager.getLifecycleState(applicationId, applicationUuid); @@ -567,7 +571,7 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { log.error(msg); return Response.status(Response.Status.BAD_REQUEST).build(); } - LifecycleStateEntity state = new LifecycleStateEntity(); + LifecycleStateDTO state = new LifecycleStateDTO(); state.setCurrentState(action); applicationManager.changeLifecycleState(applicationId, applicationUuid, state); } catch (NotFoundException e) { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/webapp/META-INF/permissions.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/webapp/META-INF/permissions.xml index 84d60e4539..f837099bed 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/webapp/META-INF/permissions.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/webapp/META-INF/permissions.xml @@ -30,7 +30,7 @@ - + Get Application Details /device-mgt/application/get diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/fonts/font-wso2.svg b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/fonts/font-wso2.svg index 4f0a65a47e..91614ea75e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/fonts/font-wso2.svg +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/public/fonts/font-wso2.svg @@ -1841,7 +1841,7 @@ c29.2568 87.7715 113.371 149.942 212.114 149.942z" /> d="M512 411.429v-413.257h-512v413.257h512zM138.972 257.828h175.543v87.7715h-175.543v-87.7715zM318.172 213.942h-175.543v-65.8281h175.543v65.8281zM142.629 42.0576h175.543v65.8281h-175.543v-65.8281zM43.8857 345.6v-87.7715h54.8574v87.7715h-54.8574z M362.058 257.828h106.057v87.7715h-106.057v-87.7715zM95.0859 148.114v65.8281h-54.8574v-65.8281h54.8574zM362.058 148.114h106.057v65.8281h-106.057v-65.8281zM43.8857 104.229v-65.8281h54.8574v65.8281h-54.8574zM468.114 104.229h-106.057v-65.8281h106.057v65.8281 z" /> - - + Get Application /device-mgt/application/get diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/public/fonts/font-wso2.svg b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/public/fonts/font-wso2.svg index 4f0a65a47e..91614ea75e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/public/fonts/font-wso2.svg +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.store.ui/react-app/public/fonts/font-wso2.svg @@ -1841,7 +1841,7 @@ c29.2568 87.7715 113.371 149.942 212.114 149.942z" /> d="M512 411.429v-413.257h-512v413.257h512zM138.972 257.828h175.543v87.7715h-175.543v-87.7715zM318.172 213.942h-175.543v-65.8281h175.543v65.8281zM142.629 42.0576h175.543v65.8281h-175.543v-65.8281zM43.8857 345.6v-87.7715h54.8574v87.7715h-54.8574z M362.058 257.828h106.057v87.7715h-106.057v-87.7715zM95.0859 148.114v65.8281h-54.8574v-65.8281h54.8574zM362.058 148.114h106.057v65.8281h-106.057v-65.8281zM43.8857 104.229v-65.8281h54.8574v65.8281h-54.8574zM468.114 104.229h-106.057v-65.8281h106.057v65.8281 z" /> -