From 1b0983dafb8673a31faacc6fa8a82b1e92c4a64e Mon Sep 17 00:00:00 2001 From: lasanthaDLPDS Date: Fri, 10 May 2019 09:25:06 +0530 Subject: [PATCH] Fix isues in app release update --- .../mgt/common/services/ApplicationManager.java | 3 +-- .../application/mgt/core/dao/LifecycleStateDAO.java | 3 +-- .../release/GenericApplicationReleaseDAOImpl.java | 8 ++++---- .../application/mgt/core/impl/ApplicationManagerImpl.java | 6 +++++- .../api/services/ApplicationManagementPublisherAPI.java | 6 +++--- .../impl/ApplicationManagementPublisherAPIImpl.java | 6 +++--- 6 files changed, 17 insertions(+), 15 deletions(-) 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 4628aa0bae2..6c6676d18fe 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 @@ -150,8 +150,7 @@ public interface ApplicationManager { * @param stateName Lifecycle state to change the app * @throws ApplicationManagementException ApplicationDTO Management Exception. */ - void changeLifecycleState(String releaseUuid, String stateName) - throws ApplicationManagementException; + void changeLifecycleState(String releaseUuid, String stateName) throws ApplicationManagementException; /** * To update release images such as icons, banner and screenshots. 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 a41c779ff08..3a62f54d7f8 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 @@ -64,8 +64,7 @@ public interface LifecycleStateDAO { * * @throws LifeCycleManagementDAOException Lifecycle Management DAO Exception. */ - void addLifecycleState(LifecycleState state, int appReleaseId, int tenantId) - throws LifeCycleManagementDAOException; + void addLifecycleState(LifecycleState state, int appReleaseId, int tenantId) throws LifeCycleManagementDAOException; /** * To delete lifecycle state data of specific application release. 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 b034e2e6414..808d1603dfb 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 @@ -102,7 +102,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements statement.setBoolean(15, applicationRelease.getIsSharedWithAllTenants()); statement.setString(16, applicationRelease.getMetaData()); statement.setString(17, applicationRelease.getSupportedOsVersions()); - statement.setString(18, applicationRelease.getCurrentState()); + statement.setString(18, applicationRelease.getCurrentState().toUpperCase()); statement.setInt(19, appId); statement.executeUpdate(); resultSet = statement.getGeneratedKeys(); @@ -474,9 +474,9 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements statement.setBoolean(14, applicationReleaseDTO.getIsSharedWithAllTenants()); statement.setString(15, applicationReleaseDTO.getMetaData()); statement.setString(16, applicationReleaseDTO.getSupportedOsVersions()); - statement.setString(17, applicationReleaseDTO.getCurrentState()); - statement.setInt(18, tenantId); - statement.setInt(19, applicationReleaseDTO.getId()); + statement.setString(17, applicationReleaseDTO.getCurrentState().toUpperCase()); + statement.setInt(18, applicationReleaseDTO.getId()); + statement.setInt(19, tenantId); if (statement.executeUpdate() == 0) { return null; } 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 8280402398e..047db1adb77 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 @@ -1625,7 +1625,11 @@ public class ApplicationManagerImpl implements ApplicationManager { lifecycleState.setPreviousState(applicationReleaseDTO.getCurrentState()); lifecycleState.setUpdatedBy(userName); applicationReleaseDTO.setCurrentState(stateName); - this.applicationReleaseDAO.updateRelease(applicationReleaseDTO, tenantId); + if (this.applicationReleaseDAO.updateRelease(applicationReleaseDTO, tenantId) == null) { + String msg = "Application release updating is failed/."; + log.error(msg); + throw new ApplicationManagementException(msg); + } this.lifecycleStateDAO.addLifecycleState(lifecycleState, applicationReleaseDTO.getId(), tenantId); ConnectionManagerUtil.commitDBTransaction(); } else { 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/ApplicationManagementPublisherAPI.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/ApplicationManagementPublisherAPI.java index 18c1e4adc4f..2c3cc24a675 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/ApplicationManagementPublisherAPI.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/ApplicationManagementPublisherAPI.java @@ -931,12 +931,12 @@ public interface ApplicationManagementPublisherAPI { name = "oldTagName", value = "Existing Tag Name", required = true) - @PathParam("oldTagName") String oldTagName, + @QueryParam("from") String oldTagName, @ApiParam( - name = "tag", + name = "newTagName", value = "Modifying Tag Name", required = true) - @QueryParam("tag") String newTagName + @QueryParam("to") String newTagName ); @GET diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/impl/ApplicationManagementPublisherAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/impl/ApplicationManagementPublisherAPIImpl.java index 30fafccb65b..d152f6f2665 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/impl/ApplicationManagementPublisherAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.api/src/main/java/org/wso2/carbon/device/application/mgt/publisher/api/services/impl/ApplicationManagementPublisherAPIImpl.java @@ -551,10 +551,10 @@ public class ApplicationManagementPublisherAPIImpl implements ApplicationManagem @PUT @Override @Consumes("application/json") - @Path("/tags/{oldTagName}") + @Path("/tags/rename") public Response modifyTagName( - @PathParam("oldTagName") String oldTagName, - @QueryParam("tag") String newTagName) { + @QueryParam("from") String oldTagName, + @QueryParam("to") String newTagName) { ApplicationManager applicationManager = APIUtil.getApplicationManager(); try { applicationManager.updateTag(oldTagName, newTagName);