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 56c2dd1622..79f49e3850 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 @@ -51,21 +51,8 @@ ${carbon.device.mgt.version} Application Management Common Bundle - org.osgi.framework, - org.osgi.service.component, - org.apache.commons.logging, - javax.xml.*, - org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}", - org.wso2.carbon.device.mgt.core.dto.*;version="${carbon.device.mgt.version}", - org.wso2.carbon.device.mgt.core.dao.*;version="${carbon.device.mgt.version}", org.wso2.carbon.device.mgt.common.operation.mgt.*;version="${carbon.device.mgt.version}", - org.w3c.dom, - org.json, - org.xml.sax, com.google.gson, - javax.naming, - javax.xml.bind.annotation, - javax.xml.bind, io.swagger.annotations.*;resolution:=optional 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 cccf451ace..1335c6d9dc 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 @@ -153,20 +153,20 @@ public interface ApplicationManager { void addLifecycleState(int applicationId, String applicationUuid, LifecycleState state) throws ApplicationManagementException; /** - * To validate the application existence for given application id + * Get the application if application is an accessible one. * * @param applicationId ID of the Application. * @throws ApplicationManagementException Application Management Exception. */ - Application validateApplication(int applicationId) throws ApplicationManagementException; + Application getApplicationIfAccessible(int applicationId) throws ApplicationManagementException; /** - * To validate the application release existence for given application release UUID + * Get the application release for given UUID if application release is exists and application id is valid one. * * @param releaseUuid UUID of the Application Release. * @throws ApplicationManagementException Application Management Exception. */ - ApplicationRelease validateApplicationRelease(int applicationId, String releaseUuid) throws + ApplicationRelease getAppReleaseIfExists(int applicationId, String releaseUuid) throws ApplicationManagementException; /** @@ -188,7 +188,7 @@ public interface ApplicationManager { * @return Updated Application Release. * @throws ApplicationManagementException Application Management Exception. */ - boolean isApplicationReleaseUpdateAcceptable(int appId, String appReleaseUuid) + boolean isAcceptableAppReleaseUpdate(int appId, String appReleaseUuid) throws ApplicationManagementException; /** diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml index 73d7905adf..932265189f 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/pom.xml @@ -57,7 +57,6 @@ org.osgi.framework, org.osgi.service.component, org.apache.commons.logging, - javax.xml.*, javax.xml.parsers;version="${javax.xml.parsers.import.pkg.version}";resolution:=optional, org.wso2.carbon.context.*, org.wso2.carbon.utils.*, @@ -71,35 +70,26 @@ org.wso2.carbon.device.application.mgt.common.*, org.wso2.carbon.device.mgt.core.*, org.wso2.carbon.device.mgt.common.*, - org.apache.axis2.*, org.wso2.carbon.user.core.*, org.wso2.carbon.user.api.*, org.wso2.carbon.ndatasource.core, org.wso2.carbon, javax.annotation, - org.bouncycastle.cert, - org.bouncycastle.cert.jcajce, - org.bouncycastle.cms, - org.bouncycastle.jce.provider, - org.bouncycastle.util, org.xml.sax, org.xml.sax.helpers, org.apache.commons.io, org.apache.commons.codec.binary;version="${commons-codec.wso2.osgi.version.range}", org.apache.commons.codec.digest;version="${commons-codec.wso2.osgi.version.range}", org.wso2.carbon.base, - org.wso2.carbon.device.mgt.core.dto.*;version="${carbon.device.mgt.version}", - org.wso2.carbon.device.mgt.core.dao.*;version="${carbon.device.mgt.version}", - net.dongliu.* + net.dongliu.apk.parser.* apk-parser;scope=compile|runtime;inline=false - true - true + + !org.wso2.carbon.device.application.mgt.core.internal.*, org.wso2.carbon.device.application.mgt.core.* - PlatformDeployer 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 6ffa369960..b4540d23bd 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 @@ -40,6 +40,7 @@ import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionExcep import org.wso2.carbon.device.application.mgt.common.exception.LifecycleManagementException; import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager; import org.wso2.carbon.device.application.mgt.core.dao.ApplicationDAO; +import org.wso2.carbon.device.application.mgt.core.dao.ApplicationReleaseDAO; import org.wso2.carbon.device.application.mgt.core.dao.LifecycleStateDAO; import org.wso2.carbon.device.application.mgt.core.dao.VisibilityDAO; import org.wso2.carbon.device.application.mgt.core.dao.common.ApplicationManagementDAOFactory; @@ -70,6 +71,9 @@ public class ApplicationManagerImpl implements ApplicationManager { private DeviceTypeDAO deviceTypeDAO; private VisibilityDAO visibilityDAO; private ApplicationDAO applicationDAO; + private ApplicationReleaseDAO applicationReleaseDAO; + private LifecycleStateDAO lifecycleStateDAO; + public ApplicationManagerImpl() { initDataAccessObjects(); @@ -79,6 +83,8 @@ public class ApplicationManagerImpl implements ApplicationManager { this.deviceTypeDAO = ApplicationManagementDAOFactory.getDeviceTypeDAO(); this.visibilityDAO = ApplicationManagementDAOFactory.getVisibilityDAO(); this.applicationDAO = ApplicationManagementDAOFactory.getApplicationDAO(); + this.lifecycleStateDAO = ApplicationManagementDAOFactory.getLifecycleStateDAO(); + this.applicationReleaseDAO = ApplicationManagementDAOFactory.getApplicationReleaseDAO(); } @Override @@ -92,7 +98,7 @@ public class ApplicationManagerImpl implements ApplicationManager { } validateAppCreatingRequest(application); - validateReleaseCreatingRequest(application.getApplicationReleases().get(0)); + validateAppReleasePayload(application.getApplicationReleases().get(0)); DeviceType deviceType; ApplicationRelease applicationRelease; List applicationReleases = new ArrayList<>(); @@ -127,16 +133,13 @@ public class ApplicationManagerImpl implements ApplicationManager { + "the payload contains more than one"); } applicationRelease = application.getApplicationReleases().get(0); - applicationRelease = ApplicationManagementDAOFactory.getApplicationReleaseDAO(). - createRelease(applicationRelease, application.getId(), tenantId); + applicationRelease = this.applicationReleaseDAO + .createRelease(applicationRelease, application.getId(), tenantId); LifecycleState lifecycleState = new LifecycleState(); - lifecycleState.setUpdatedBy(userName); lifecycleState.setCurrentState(AppLifecycleState.CREATED.toString()); lifecycleState.setPreviousState(AppLifecycleState.CREATED.toString()); addLifecycleState(application.getId(), applicationRelease.getUuid(), lifecycleState); - LifecycleStateDAO lifecycleStateDAO = ApplicationManagementDAOFactory.getLifecycleStateDAO(); - lifecycleStateDAO.addLifecycleState(lifecycleState, application.getId(), applicationRelease.getId(), tenantId); applicationRelease.setLifecycleState(lifecycleState); applicationReleases.add(applicationRelease); @@ -157,12 +160,7 @@ public class ApplicationManagerImpl implements ApplicationManager { log.error(msg, e); ConnectionManagerUtil.rollbackDBTransaction(); throw new ApplicationManagementException(msg, e); - } catch (LifeCycleManagementDAOException e) { - String msg = "Error occurred while adding application lifecycle state"; - log.error(msg, e); - ConnectionManagerUtil.rollbackDBTransaction(); - throw new ApplicationManagementException(msg, e); - }finally { + } finally { ConnectionManagerUtil.closeDBConnection(); } } @@ -185,13 +183,10 @@ public class ApplicationManagerImpl implements ApplicationManager { if (!isAdminUser(userName, tenantId, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION)) { applicationList = getRoleRestrictedApplicationList(applicationList, userName); } - for (Application application : applicationList.getApplications()) { - applicationReleases = getReleases(application.getId()); application.setApplicationReleases(applicationReleases); } - return applicationList; } catch (UserStoreException e) { throw new ApplicationManagementException( @@ -206,24 +201,30 @@ public class ApplicationManagerImpl implements ApplicationManager { } @Override - public ApplicationRelease createRelease(int applicationId, ApplicationRelease applicationRelease) throws - ApplicationManagementException { + public ApplicationRelease createRelease(int applicationId, ApplicationRelease applicationRelease) + throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); - Application application = validateApplication(applicationId); - validateReleaseCreatingRequest(applicationRelease); + Application application = getApplicationIfAccessible(applicationId); + validateAppReleasePayload(applicationRelease); if (log.isDebugEnabled()) { log.debug("Application release request is received for the application " + application.toString()); } try { ConnectionManagerUtil.beginDBTransaction(); -// todo consider about lifecycle adding - applicationRelease = ApplicationManagementDAOFactory.getApplicationReleaseDAO(). - createRelease(applicationRelease, application.getId(), tenantId); + applicationRelease = this.applicationReleaseDAO + .createRelease(applicationRelease, application.getId(), tenantId); + LifecycleState lifecycleState = new LifecycleState(); + lifecycleState.setCurrentState(AppLifecycleState.CREATED.toString()); + lifecycleState.setPreviousState(AppLifecycleState.CREATED.toString()); + addLifecycleState(application.getId(), applicationRelease.getUuid(), lifecycleState); + ConnectionManagerUtil.commitDBTransaction(); return applicationRelease; } catch (ApplicationManagementDAOException e) { ConnectionManagerUtil.rollbackDBTransaction(); - throw e; + throw new ApplicationManagementException( + "Error occured while adding application release into IoTS app management Application id of the " + + "application release: " + applicationId, e); } finally { ConnectionManagerUtil.closeDBConnection(); } @@ -353,7 +354,7 @@ public class ApplicationManagerImpl implements ApplicationManager { public List getReleases(int applicationId) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); - Application application = validateApplication(applicationId); + Application application = getApplicationIfAccessible(applicationId); List applicationReleases; List filteredApplicationReleases = new ArrayList<>(); if (log.isDebugEnabled()) { @@ -362,8 +363,7 @@ public class ApplicationManagerImpl implements ApplicationManager { } try { ConnectionManagerUtil.openDBConnection(); - applicationReleases = ApplicationManagementDAOFactory.getApplicationReleaseDAO() - .getReleases(application.getName(), application.getType(), tenantId); + applicationReleases = this.applicationReleaseDAO.getReleases(application.getName(), application.getType(), tenantId); for (ApplicationRelease applicationRelease : applicationReleases) { LifecycleState lifecycleState = ApplicationManagementDAOFactory.getLifecycleStateDAO(). getLatestLifeCycleStateByReleaseID(applicationRelease.getId()); @@ -393,7 +393,7 @@ public class ApplicationManagerImpl implements ApplicationManager { "need to have admin permission"); } - if (validateApplication(applicationId) == null) { + if (getApplicationIfAccessible(applicationId) == null) { throw new ApplicationManagementException("Invalid Application"); } List applicationReleases = getReleases(applicationId); @@ -406,7 +406,6 @@ public class ApplicationManagerImpl implements ApplicationManager { LifecycleState newAppLifecycleState = new LifecycleState(); newAppLifecycleState.setPreviousState(appLifecycleState.getCurrentState()); newAppLifecycleState.setCurrentState(AppLifecycleState.REMOVED.toString()); - newAppLifecycleState.setUpdatedBy(userName); addLifecycleState(applicationId, applicationRelease.getUuid(), newAppLifecycleState); storedLocations.add(applicationRelease.getAppHashValue()); } @@ -425,16 +424,11 @@ public class ApplicationManagerImpl implements ApplicationManager { @Override public String deleteApplicationRelease(int applicationId, String releaseUuid) throws ApplicationManagementException { - String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); - int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); - Application application = validateApplication(applicationId); + Application application = getApplicationIfAccessible(applicationId); if (application == null) { throw new ApplicationManagementException("Invalid Application ID is received"); } - ApplicationRelease applicationRelease = validateApplicationRelease(applicationId, releaseUuid); - if (applicationRelease == null) { - throw new ApplicationManagementException("Invalid Application Release UUID is received"); - } + ApplicationRelease applicationRelease = getAppReleaseIfExists(applicationId, releaseUuid); LifecycleState appLifecycleState = getLifecycleState(applicationId, applicationRelease.getUuid()); String currentState = appLifecycleState.getCurrentState(); if (AppLifecycleState.DEPRECATED.toString().equals(currentState) || AppLifecycleState @@ -443,7 +437,6 @@ public class ApplicationManagerImpl implements ApplicationManager { LifecycleState newAppLifecycleState = new LifecycleState(); newAppLifecycleState.setPreviousState(appLifecycleState.getCurrentState()); newAppLifecycleState.setCurrentState(AppLifecycleState.REMOVED.toString()); - newAppLifecycleState.setUpdatedBy(userName); addLifecycleState(applicationId, applicationRelease.getUuid(), newAppLifecycleState); }else{ throw new ApplicationManagementException("Can't delete the application release, You have to move the " + @@ -487,15 +480,14 @@ public class ApplicationManagerImpl implements ApplicationManager { throw new ValidationException("Username and tenant Id cannot be empty"); } if (application.getAppCategory() == null) { - throw new ValidationException("Username and tenant Id cannot be empty"); + throw new ValidationException("Application category can't be empty"); } isValidApplicationType = isValidAppType(application); if (!isValidApplicationType) { throw new ValidationException( - "App Type contains in the application creating payload doesn't match with " + - "supported app types"); + "App Type contains in the application creating payload doesn't match with supported app types"); } validateApplicationExistence(application); @@ -537,12 +529,12 @@ public class ApplicationManagerImpl implements ApplicationManager { } /** - * To validate the pre-request of the ApplicationRelease. + * Get the application if application is an accessible one. * * @param applicationId ID of the Application. * @return Application related with the UUID */ - public Application validateApplication(int applicationId) throws ApplicationManagementException { + public Application getApplicationIfAccessible(int applicationId) throws ApplicationManagementException { if (applicationId <= 0) { throw new ApplicationManagementException("Application id could,t be a negative integer. Hence please add " + "valid application id."); @@ -568,7 +560,8 @@ public class ApplicationManagerImpl implements ApplicationManager { } if (!isAppAllowed) { - throw new NotFoundException("Application of the " + applicationId + " does not exist."); + throw new NotFoundException("Application of the " + applicationId + + " does not exist. Please check whether user have permissions to access the application."); } return application; } catch (UserStoreException e) { @@ -580,12 +573,12 @@ public class ApplicationManagerImpl implements ApplicationManager { } /** - * To validate the pre-request of the ApplicationRelease. + * Get the application release for given UUID if application release is exists and application id is valid one. * * @param applicationUuid UUID of the Application. * @return Application related with the UUID */ - public ApplicationRelease validateApplicationRelease(int applicationId, String applicationUuid) throws + public ApplicationRelease getAppReleaseIfExists(int applicationId, String applicationUuid) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); ApplicationRelease applicationRelease; @@ -600,8 +593,7 @@ public class ApplicationManagerImpl implements ApplicationManager { + "parameter to get the relevant application."); } ConnectionManagerUtil.openDBConnection(); - applicationRelease = ApplicationManagementDAOFactory.getApplicationReleaseDAO().getReleaseByIds - (applicationId, applicationUuid, tenantId); + applicationRelease = this.applicationReleaseDAO.getReleaseByIds(applicationId, applicationUuid, tenantId); if (applicationRelease == null) { throw new ApplicationManagementException("Doesn't exist a application release for application ID: " + applicationId + "and application UUID: " + @@ -617,7 +609,7 @@ public class ApplicationManagerImpl implements ApplicationManager { @Override public ApplicationRelease updateRelease(int appId, ApplicationRelease applicationRelease) throws ApplicationManagementException { - String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + validateAppReleasePayload(applicationRelease); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); if (log.isDebugEnabled()) { log.debug("Updating the Application release. UUID: " + applicationRelease.getUuid() + ", " + @@ -625,10 +617,7 @@ public class ApplicationManagerImpl implements ApplicationManager { } try { ConnectionManagerUtil.openDBConnection(); -// todo consider about lifecycle - applicationRelease = ApplicationManagementDAOFactory.getApplicationReleaseDAO() - .updateRelease(appId, applicationRelease, tenantId); - + applicationRelease = this.applicationReleaseDAO.updateRelease(appId, applicationRelease, tenantId); return applicationRelease; } finally { ConnectionManagerUtil.closeDBConnection(); @@ -636,7 +625,7 @@ public class ApplicationManagerImpl implements ApplicationManager { } @Override - public boolean isApplicationReleaseUpdateAcceptable(int appId, String appReleaseUuid) + public boolean isAcceptableAppReleaseUpdate(int appId, String appReleaseUuid) throws ApplicationManagementException { LifecycleState lifecycleState = getLifecycleState(appId, appReleaseUuid); return AppLifecycleState.CREATED.toString().equals(lifecycleState.getCurrentState()) || AppLifecycleState @@ -673,12 +662,12 @@ public class ApplicationManagerImpl implements ApplicationManager { } /** - * To validate a create release request to make sure all the pre-conditions satisfied. + * To validate a app release creating request and app updating request to make sure all the pre-conditions satisfied. * * @param applicationRelease ApplicationRelease that need to be created. * @throws ApplicationManagementException Application Management Exception. */ - private void validateReleaseCreatingRequest(ApplicationRelease applicationRelease) + private void validateAppReleasePayload(ApplicationRelease applicationRelease) throws ApplicationManagementException { if (applicationRelease.getVersion() == null) { @@ -693,9 +682,13 @@ public class ApplicationManagerImpl implements ApplicationManager { LifecycleState lifecycleState; try { ConnectionManagerUtil.openDBConnection(); - LifecycleStateDAO lifecycleStateDAO = ApplicationManagementDAOFactory.getLifecycleStateDAO(); - ApplicationRelease applicationRelease = validateApplicationRelease(applicationId, applicationUuid); - lifecycleState = lifecycleStateDAO.getLatestLifeCycleStateByReleaseID(applicationRelease.getId()); + lifecycleState = this.lifecycleStateDAO.getLatestLifeCycleStateByReleaseID(applicationId); + if (lifecycleState == null) { + throw new NotFoundException( + "Couldn't find the lifecycle data for appid: " + applicationId + " and app release UUID: " + + applicationUuid); + + } lifecycleState.setNextStates(getNextLifecycleStates(lifecycleState.getCurrentState())); } catch (ApplicationManagementDAOException e) { throw new ApplicationManagementException("Failed to get lifecycle state", e); @@ -708,19 +701,20 @@ public class ApplicationManagerImpl implements ApplicationManager { } @Override - public void addLifecycleState(int applicationId, String applicationUuid, LifecycleState state) throws - ApplicationManagementException { + public void addLifecycleState(int applicationId, String applicationUuid, LifecycleState state) + throws ApplicationManagementException { try { ConnectionManagerUtil.openDBConnection(); - Application application = validateApplication(applicationId); - ApplicationRelease applicationRelease = validateApplicationRelease(applicationId, applicationUuid); - LifecycleStateDAO lifecycleStateDAO; + Application application = getApplicationIfAccessible(applicationId); + ApplicationRelease applicationRelease = getAppReleaseIfExists(applicationId, applicationUuid); int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); + String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); + state.setUpdatedBy(userName); - if (state.getCurrentState() != null && state.getPreviousState() != null && state.getUpdatedBy() != null) { + if (state.getCurrentState() != null && state.getPreviousState() != null) { validateLifecycleState(state); - lifecycleStateDAO = ApplicationManagementDAOFactory.getLifecycleStateDAO(); - lifecycleStateDAO.addLifecycleState(state, application.getId(), applicationRelease.getId(), tenantId); + this.lifecycleStateDAO + .addLifecycleState(state, application.getId(), applicationRelease.getId(), tenantId); } } catch (LifeCycleManagementDAOException | DBConnectionException e) { throw new ApplicationManagementException("Failed to add lifecycle state", e); @@ -828,7 +822,7 @@ public class ApplicationManagerImpl implements ApplicationManager { public Application updateApplication(Application application) throws ApplicationManagementException { int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true); - Application existingApplication = validateApplication(application.getId()); + Application existingApplication = getApplicationIfAccessible(application.getId()); List addingRoleList; List removingRoleList; List addingTags; 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 899887f7ca..957f32c022 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 @@ -23,12 +23,12 @@ import com.dd.plist.NSDictionary; import com.dd.plist.NSString; import com.dd.plist.PropertyListFormatException; import com.dd.plist.PropertyListParser; -import net.dongliu.apk.parser.ApkFile; import net.dongliu.apk.parser.bean.ApkMeta; import org.apache.commons.codec.digest.DigestUtils; 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.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.application.mgt.common.ApplicationRelease; import org.wso2.carbon.device.application.mgt.common.ApplicationType; @@ -41,16 +41,10 @@ import org.wso2.carbon.device.application.mgt.core.util.ArtifactsParser; import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil; import org.wso2.carbon.device.application.mgt.core.util.Constants; import org.wso2.carbon.device.application.mgt.core.util.StorageManagementUtil; -import org.apache.commons.validator.routines.UrlValidator; import org.xml.sax.SAXException; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; +import javax.xml.parsers.ParserConfigurationException; +import java.io.*; import java.text.ParseException; import java.util.HashMap; import java.util.List; @@ -59,8 +53,6 @@ import java.util.Objects; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; -import javax.xml.parsers.ParserConfigurationException; - import static org.wso2.carbon.device.application.mgt.core.util.StorageManagementUtil.deleteDir; import static org.wso2.carbon.device.application.mgt.core.util.StorageManagementUtil.saveFile; 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 7c4fe746c3..f212747cef 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 @@ -208,7 +208,7 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { attachments.add(screenshot.getDataHandler().getInputStream()); } } - applicationRelease = applicationManager.validateApplicationRelease(appId, applicationUuid); + applicationRelease = applicationManager.getAppReleaseIfExists(appId, applicationUuid); LifecycleState lifecycleState = applicationManager.getLifecycleState(appId, applicationRelease.getUuid()); if (AppLifecycleState.PUBLISHED.toString().equals(lifecycleState.getCurrentState()) || AppLifecycleState.DEPRECATED.toString().equals(lifecycleState.getCurrentState())) { @@ -222,7 +222,9 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { return Response.status(Response.Status.OK) .entity("Successfully uploaded artifacts for the application " + applicationUuid).build(); } catch (NotFoundException e) { - String msg = "Couldn't found application release details and storage details"; + String msg = + "Couldn't found application release details or storage details or lifecycle details. Application id: " + + appId + " App release uuid: " + applicationUuid; log.error(msg, e); return APIUtil.getResponse(e, Response.Status.NOT_FOUND); } catch (ApplicationManagementException e) { @@ -260,7 +262,7 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { return APIUtil.getResponse("Uploading artifacts for the application is failed " + applicationUuid, Response.Status.BAD_REQUEST); } - applicationRelease = applicationManager.validateApplicationRelease(applicationId, applicationUuid); + applicationRelease = applicationManager.getAppReleaseIfExists(applicationId, applicationUuid); applicationRelease = applicationStorageManager .updateReleaseArtifacts(applicationRelease, appType, deviceType, binaryFile.getDataHandler().getInputStream()); @@ -323,9 +325,9 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { List attachments = new ArrayList<>(); try { - Application application = applicationManager.validateApplication(applicationId); + Application application = applicationManager.getApplicationIfAccessible(applicationId); - if (!applicationManager.isApplicationReleaseUpdateAcceptable(application.getId(), + if (!applicationManager.isAcceptableAppReleaseUpdate(application.getId(), applicationRelease.getUuid())) { String msg = "Application release is in the " + applicationRelease.getLifecycleState().getCurrentState() + " state. Hence updating is not acceptable when application in this state"; @@ -424,7 +426,13 @@ public class ApplicationManagementAPIImpl implements ApplicationManagementAPI { ApplicationManager applicationManager = APIUtil.getApplicationManager(); try { lifecycleState = applicationManager.getLifecycleState(applicationId, applicationUuid); - } catch (ApplicationManagementException e) { + } catch (NotFoundException e){ + String msg = "Couldn't found application lifecycle details for appid: " + applicationId + + " and app release UUID: " + applicationUuid; + log.error(msg, e); + return Response.status(Response.Status.NOT_FOUND).build(); + } + catch (ApplicationManagementException e) { String msg = "Error occurred while getting lifecycle state."; log.error(msg, e); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.api.feature/pom.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.api.feature/pom.xml index f7bedc059a..571035fb9d 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.api.feature/pom.xml +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.api.feature/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt application-mgt-feature - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.application.mgt.api.feature - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT pom WSO2 Carbon - Application Management API Feature http://wso2.org diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.api.feature/src/main/resources/p2.inf b/features/application-mgt/org.wso2.carbon.device.application.mgt.api.feature/src/main/resources/p2.inf index 1d83a6da71..edf41c6ffd 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.api.feature/src/main/resources/p2.inf +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.api.feature/src/main/resources/p2.inf @@ -1,8 +1,4 @@ instructions.configure = \ org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.application -.mgt.api_${feature.version}/webapps/api#application-mgt-publisher#v1.0.war,target:${installFolder}/../. -./deployment/server/webapps/api#application-mgt-publisher#v1.0.war,overwrite:true);\ -org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.application -.mgt.api_${feature.version}/webapps/api#application-mgt-store#v1.0.war,target:${installFolder}/../. -./deployment/server/webapps/api#application-mgt-store#v1.0.war,overwrite:true);\ \ No newline at end of file +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.application.mgt.api_${feature.version}/webapps/api#application-mgt-publisher#v1.0.war,target:${installFolder}/../../deployment/server/webapps/api#application-mgt-publisher#v1.0.war,overwrite:true);\ +org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.wso2.carbon.device.application.mgt.api_${feature.version}/webapps/api#application-mgt-store#v1.0.war,target:${installFolder}/../../deployment/server/webapps/api#application-mgt-store#v1.0.war,overwrite:true);\ \ No newline at end of file diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.auth.handler.feature/pom.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.auth.handler.feature/pom.xml index 09c5995d73..80e42d1542 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.auth.handler.feature/pom.xml +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.auth.handler.feature/pom.xml @@ -22,12 +22,12 @@ org.wso2.carbon.devicemgt application-mgt-feature - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT 4.0.0 org.wso2.carbon.device.application.mgt.auth.handler.feature - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT pom WSO2 Carbon - Application Management Authentication Handler Feature This feature contains the Authentication Handler implementation for Publisher and Store. diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.extensions.feature/pom.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.extensions.feature/pom.xml index 67e5f3bdd9..504742d404 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.extensions.feature/pom.xml +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.extensions.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt application-mgt-feature - 3.0.46-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.application.mgt.extensions.feature pom - 3.0.46-SNAPSHOT + 3.1.40-SNAPSHOT WSO2 Carbon - Application Management Extension Feature http://wso2.org WSO2 Application Management Extension Feature diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.feature/pom.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.feature/pom.xml index 6e72589d1e..548edd110f 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.feature/pom.xml +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.feature/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt application-mgt-feature - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.application.mgt.feature - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT pom WSO2 Carbon - Application Management Aggregate Feature http://wso2.org @@ -45,14 +45,14 @@ org.wso2.carbon.device.application.mgt.publisher.ui.feature zip - - javax.servlet.jsp - javax.servlet.jsp-api - - - org.wso2.orbit.org.scannotation - scannotation - + + + + + + + + @@ -79,10 +79,10 @@ org.wso2.carbon.devicemgt:org.wso2.carbon.device.application.mgt.server.feature:${carbon.device.mgt.version} org.wso2.carbon.devicemgt:org.wso2.carbon.device.application.mgt.publisher.ui.feature:${carbon.device.mgt.version} - - javax.servlet.jsp:javax.servlet.jsp-api - org.wso2.orbit.org.scannotation:scannotation:${scannotation.version} - + + + + diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui.feature/pom.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui.feature/pom.xml index f9889befd7..4e1a6ce449 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui.feature/pom.xml +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui.feature/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt application-mgt-feature - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.application.mgt.publisher.ui.feature - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT pom WSO2 Carbon - Application Management Publisher UI Feature http://wso2.org diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/pom.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/pom.xml index f30952ed26..f70e66d542 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/pom.xml +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.server.feature/pom.xml @@ -22,14 +22,14 @@ org.wso2.carbon.devicemgt application-mgt-feature - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../pom.xml 4.0.0 org.wso2.carbon.device.application.mgt.server.feature pom - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT WSO2 Carbon - Application Management Server Feature http://wso2.org This feature contains the core bundles required for Back-end Application Management functionality @@ -44,16 +44,24 @@ org.wso2.carbon.devicemgt org.wso2.carbon.device.application.mgt.core - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.application.mgt.api.feature - zip - - - org.wso2.carbon.devicemgt - org.wso2.carbon.device.application.mgt.auth.handler.feature - zip - + + + + + + + + + + + + + + + + + + @@ -103,10 +111,10 @@ org.eclipse.equinox.p2.type.group:false - - org.wso2.carbon.devicemgt:org.wso2.carbon.device.application.mgt.api.feature:${carbon.device.mgt.version} - org.wso2.carbon.devicemgt:org.wso2.carbon.device.application.mgt.auth.handler.feature:${carbon.device.mgt.version} - + + + + org.wso2.carbon.devicemgt:org.wso2.carbon.device.application.mgt.common:${carbon.device.mgt.version} @@ -114,12 +122,14 @@ org.wso2.carbon.devicemgt:org.wso2.carbon.device.application.mgt.core:${carbon.device.mgt.version} + + - - org.wso2.carbon.core.server:${carbon.kernel.version} - + + + diff --git a/features/application-mgt/org.wso2.carbon.device.application.mgt.store.ui.feature/pom.xml b/features/application-mgt/org.wso2.carbon.device.application.mgt.store.ui.feature/pom.xml index 95f67bde04..4984346402 100644 --- a/features/application-mgt/org.wso2.carbon.device.application.mgt.store.ui.feature/pom.xml +++ b/features/application-mgt/org.wso2.carbon.device.application.mgt.store.ui.feature/pom.xml @@ -23,12 +23,12 @@ org.wso2.carbon.devicemgt application-mgt-feature - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT 4.0.0 org.wso2.carbon.device.application.mgt.store.ui.feature - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT pom WSO2 Carbon - Application Management Store UI Feature http://wso2.org diff --git a/features/application-mgt/pom.xml b/features/application-mgt/pom.xml index 8bc11b1ec4..16d3db95a5 100644 --- a/features/application-mgt/pom.xml +++ b/features/application-mgt/pom.xml @@ -22,13 +22,13 @@ org.wso2.carbon.devicemgt carbon-devicemgt - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT ../../pom.xml 4.0.0 application-mgt-feature - 3.1.34-SNAPSHOT + 3.1.40-SNAPSHOT pom WSO2 Carbon - Application Management Feature http://wso2.org diff --git a/pom.xml b/pom.xml index 129a80971c..de54d16244 100644 --- a/pom.xml +++ b/pom.xml @@ -1740,7 +1740,6 @@ apk-parser ${net.dongliu.version} - javax.websocket @@ -2196,7 +2195,7 @@ 1.8 2.4.2 - + 7.0.85 1.0