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 d081f618c1..caa3f666d4 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 @@ -515,9 +515,10 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic PreparedStatement stmt = null; try { conn = this.getDBConnection(); - String sql = "DELETE FROM AP_APP WHERE ID = ? "; + String sql = "UPDATE AP_APP SET STATUS = ? WHERE ID = ? "; stmt = conn.prepareStatement(sql); - stmt.setInt(1, appId); + stmt.setString(1, AppLifecycleState.REMOVED.toString()); + stmt.setInt(2, appId); stmt.executeUpdate(); } catch (DBConnectionException e) { 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 fc836f69c7..e560986548 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 @@ -422,7 +422,12 @@ public class ApplicationManagerImpl implements ApplicationManager { addLifecycleState(applicationId, applicationRelease.getUuid(), newAppLifecycleState); storedLocations.add(applicationRelease.getAppHashValue()); } - //todo add column into application and move application into removed state + try { + ConnectionManagerUtil.openDBConnection(); + ApplicationManagementDAOFactory.getApplicationDAO().deleteApplication(applicationId); + } finally { + ConnectionManagerUtil.closeDBConnection(); + } return storedLocations; } 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 eaa12feed8..a364abe936 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 @@ -232,7 +232,6 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { } applicationRelease = applicationStorageManager .updateImageArtifacts(applicationRelease, iconFileStream, bannerFileStream, attachments); - //todo need to implement updateRelease method applicationManager.updateRelease(appId, applicationRelease); return Response.status(Response.Status.OK) .entity("Successfully uploaded artifacts for the application " + applicationUuid).build(); @@ -262,7 +261,7 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { public Response updateApplicationArtifact( @PathParam("appType") String appType, @PathParam("appId") int applicationId, - @PathParam("uuid") String applicationUuuid, + @PathParam("uuid") String applicationUuid, @Multipart("binaryFile") Attachment binaryFile) { ApplicationStorageManager applicationStorageManager = APIUtil.getApplicationStorageManager(); ApplicationManager applicationManager = APIUtil.getApplicationManager(); @@ -272,27 +271,26 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { if (binaryFile == null) { return Response.status(Response.Status.BAD_REQUEST) - .entity("Uploading artifacts for the application is failed " + applicationUuuid).build(); + .entity("Uploading artifacts for the application is failed " + applicationUuid).build(); } - applicationRelease = applicationManager.validateApplicationRelease(applicationUuuid); + applicationRelease = applicationManager.validateApplicationRelease(applicationUuid); applicationRelease = applicationStorageManager.updateReleaseArtifacts(applicationRelease, appType, binaryFile.getDataHandler().getInputStream()); - //todo applicationManager.updateRelease(applicationId, applicationRelease); return Response.status(Response.Status.OK) - .entity("Successfully uploaded artifacts for the application " + applicationUuuid).build(); + .entity("Successfully uploaded artifacts for the application " + applicationUuid).build(); } catch (IOException e) { - log.error("Exception while trying to read icon, banner files for the application " + applicationUuuid); + log.error("Exception while trying to read icon, banner files for the application " + applicationUuid); return APIUtil.getResponse(new ApplicationManagementException( - "Exception while trying to read icon, banner files for the application " + applicationUuuid, e), + "Exception while trying to read icon, banner files for the application " + applicationUuid, e), Response.Status.BAD_REQUEST); } catch (ResourceManagementException e) { log.error("Error occurred while uploading the image artifacts of the application with the uuid " - + applicationUuuid, e); + + applicationUuid, e); return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR); } catch (ApplicationManagementException e) { log.error("Error occurred while updating the image artifacts of the application with the uuid " - + applicationUuuid, e); + + applicationUuid, e); return APIUtil.getResponse(e, Response.Status.INTERNAL_SERVER_ERROR); } } @@ -361,8 +359,6 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { applicationRelease = applicationStorageManager .updateImageArtifacts(applicationRelease, iconFileStream, bannerFileStream, attachments); - - //todo applicationRelease = applicationManager.updateRelease(applicationId, applicationRelease); return Response.status(Response.Status.OK).entity(applicationRelease).build();