From cf11ed671cde023ef12a61fc53c40650ae78588a Mon Sep 17 00:00:00 2001 From: Geeth Munasinghe Date: Fri, 22 Mar 2019 15:02:01 +0530 Subject: [PATCH] Adding todos --- .../pom.xml | 3 ++- .../application/GenericApplicationDAOImpl.java | 2 ++ .../GenericApplicationReleaseDAOImpl.java | 1 + .../visibility/GenericVisibilityDAOImpl.java | 2 +- .../mgt/core/impl/ApplicationManagerImpl.java | 16 ++++++++-------- .../core/impl/ApplicationStorageManagerImpl.java | 2 ++ .../impl/ApplicationManagementAPIImpl.java | 2 ++ 7 files changed, 18 insertions(+), 10 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/pom.xml index 597b97169a..a28d1d5f6c 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/pom.xml @@ -56,7 +56,8 @@ io.swagger.annotations.*;resolution:=optional, com.fasterxml.jackson.annotation, javax.validation.constraints, - javax.xml.bind.annotation.* + javax.xml.bind.annotation.*, + org.wso2.carbon.device.mgt.core.dto org.wso2.carbon.device.application.mgt.common.* 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 8d18bf0daf..c8be155237 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 @@ -79,6 +79,8 @@ public class GenericApplicationDAOImpl extends AbstractDAOImpl implements Applic if (rs.next()) { applicationId = rs.getInt(1); } + + // TODO : throw error if applicationId = -1 return applicationId; } 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/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 ce5829ac7f..3081fbba23 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 @@ -62,6 +62,7 @@ public class GenericApplicationReleaseDAOImpl extends AbstractDAOImpl implements + "APP_HASH_VALUE, SHARED_WITH_ALL_TENANTS, APP_META_INFO,AP_APP_ID) " + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);"; + // TODO : make this readable int index = 0; String generatedColumns[] = { "ID" }; try { 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/visibility/GenericVisibilityDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/visibility/GenericVisibilityDAOImpl.java index 07edb26c22..dc568a7b82 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/visibility/GenericVisibilityDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/visibility/GenericVisibilityDAOImpl.java @@ -89,7 +89,7 @@ public class GenericVisibilityDAOImpl extends AbstractDAOImpl implements Visibil rs = stmt.executeQuery(); while (rs.next()){ - unrestrictedRoles.add(rs.getString("ROLE").toLowerCase()); + unrestrictedRoles.add(rs.getString("ROLE")); } return unrestrictedRoles; 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 3f107267cf..69d4e2e6c8 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 @@ -126,7 +126,6 @@ public class ApplicationManagerImpl implements ApplicationManager { ConnectionManagerUtil.beginDBTransaction(); if (deviceType == null) { log.error("Device type is not matched with application type"); - ConnectionManagerUtil.rollbackDBTransaction(); return null; } if (!application.getUnrestrictedRoles().isEmpty()) { @@ -166,7 +165,8 @@ public class ApplicationManagerImpl implements ApplicationManager { if (log.isDebugEnabled()) { log.debug("Changing lifecycle state. App Id:" + appId); } - LifecycleState lifecycleState = getLifecycleStateInstant(AppLifecycleState.CREATED.toString(), + //todo get initial state from lifecycle manager and set current state to Release object + LifecycleState lifecycleState = getLifecycleStateInstance(AppLifecycleState.CREATED.toString(), AppLifecycleState.CREATED.toString()); this.lifecycleStateDAO.addLifecycleState(lifecycleState, appId, applicationRelease.getUuid(), tenantId); applicationRelease.setLifecycleState(lifecycleState); @@ -305,7 +305,7 @@ public class ApplicationManagerImpl implements ApplicationManager { } applicationRelease = this.applicationReleaseDAO .createRelease(applicationRelease, existingApplication.getId(), tenantId); - LifecycleState lifecycleState = getLifecycleStateInstant(AppLifecycleState.CREATED.toString(), + LifecycleState lifecycleState = getLifecycleStateInstance(AppLifecycleState.CREATED.toString(), AppLifecycleState.CREATED.toString()); this.lifecycleStateDAO .addLifecycleState(lifecycleState, applicationId, applicationRelease.getUuid(), tenantId); @@ -583,7 +583,7 @@ public class ApplicationManagerImpl implements ApplicationManager { for (ApplicationRelease applicationRelease : applicationReleases) { LifecycleState appLifecycleState = this.lifecycleStateDAO .getLatestLifeCycleState(applicationId, applicationRelease.getUuid()); - LifecycleState newAppLifecycleState = getLifecycleStateInstant(AppLifecycleState.REMOVED.toString(), + LifecycleState newAppLifecycleState = getLifecycleStateInstance(AppLifecycleState.REMOVED.toString(), appLifecycleState.getCurrentState()); if (lifecycleStateManger.isValidStateChange(newAppLifecycleState.getPreviousState(), newAppLifecycleState.getCurrentState())) { @@ -595,7 +595,7 @@ public class ApplicationManagerImpl implements ApplicationManager { List lifecycleFlow = searchLifecycleStateFlow(currentState, AppLifecycleState.REMOVED.toString()); for (String nextState : lifecycleFlow) { - LifecycleState lifecycleState = getLifecycleStateInstant(nextState, currentState); + LifecycleState lifecycleState = getLifecycleStateInstance(nextState, currentState); if (lifecycleStateManger.isValidStateChange(currentState, nextState)) { this.lifecycleStateDAO .addLifecycleState(lifecycleState, applicationId, applicationRelease.getUuid(), @@ -712,7 +712,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)) { - LifecycleState newAppLifecycleState = getLifecycleStateInstant(AppLifecycleState.REMOVED.toString(), + LifecycleState newAppLifecycleState = getLifecycleStateInstance(AppLifecycleState.REMOVED.toString(), appLifecycleState.getCurrentState()); if (lifecycleStateManger.isValidStateChange(newAppLifecycleState.getPreviousState(), newAppLifecycleState.getCurrentState())) { @@ -724,7 +724,7 @@ public class ApplicationManagerImpl implements ApplicationManager { List lifecycleFlow = searchLifecycleStateFlow(currentState, AppLifecycleState.REMOVED.toString()); for (String nextState : lifecycleFlow) { - LifecycleState lifecycleState = getLifecycleStateInstant(nextState, currentState); + LifecycleState lifecycleState = getLifecycleStateInstance(nextState, currentState); if (lifecycleStateManger.isValidStateChange(currentState, nextState)) { this.lifecycleStateDAO .addLifecycleState(lifecycleState, applicationId, applicationRelease.getUuid(), @@ -1237,7 +1237,7 @@ public class ApplicationManagerImpl implements ApplicationManager { * @param previousState Previouse state of the Lifecycle * @return {@link LifecycleState} */ - private LifecycleState getLifecycleStateInstant(String currentState, String previousState) { + private LifecycleState getLifecycleStateInstance(String currentState, String previousState) { String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); LifecycleState lifecycleState = new LifecycleState(); lifecycleState.setCurrentState(currentState); 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 293704b8f2..ae90d07472 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 @@ -224,12 +224,14 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager + "application UUID " + applicationRelease.getUuid() + " is " + artifactDirectoryPath); } + // TODO : handle ios String artifactPath = artifactDirectoryPath + File.separator + Constants.RELEASE_ARTIFACT +".apk"; saveFile(cloneInputStream[1], artifactPath); applicationRelease.setAppStoredLoc(artifactPath); applicationRelease.setAppHashValue(md5OfApp); } catch (IOException e) { + // TODO : throw new ApplicationStorageManagementException( "IO Exception while saving the release artifacts in the server for the application UUID " + applicationRelease.getUuid(), e); 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 d40ea6ebec..b0c6c7fb5d 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 @@ -168,6 +168,7 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { } try { + //TODO : catch the error message if (isInvalidReleaseCreatingRequest(binaryFile, iconFile, bannerFile, attachmentList, application.getType())) { // todo add msg return Response.status(Response.Status.BAD_REQUEST).build(); @@ -175,6 +176,7 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { // The application executable artifacts such as apks are uploaded. if (!ApplicationType.ENTERPRISE.toString().equals(application.getType())) { + // TODO Null check applicationRelease = application.getApplicationReleases().get(0); applicationRelease = applicationStorageManager .uploadReleaseArtifact(applicationRelease, application.getType(), application.getDeviceType(),