From 7fd7fbb30e3ae185bc17fed55e55192628dd499c Mon Sep 17 00:00:00 2001 From: megala21 Date: Sun, 20 Aug 2017 23:31:57 +0530 Subject: [PATCH] Adding refactoring as per maven checkstyle plugin --- .../device/application/mgt/api/APIUtil.java | 6 +- .../mgt/api/FileStreamingOutput.java | 4 +- .../mgt/api/JSONMessageHandler.java | 13 ++- .../mgt/api/MultipartCustomProvider.java | 85 ++++++++++--------- .../mgt/api/beans/ErrorListItem.java | 3 + .../mgt/api/beans/ErrorResponse.java | 4 + .../services/ApplicationManagementAPI.java | 1 + .../api/services/LifecycleManagementAPI.java | 9 +- .../impl/ApplicationManagementAPIImpl.java | 11 +-- .../impl/LifecycleManagementAPIImpl.java | 7 +- .../application/mgt/common/Application.java | 6 +- ...ApplicationStorageManagementException.java | 2 +- .../common/services/ApplicationManager.java | 10 ++- .../services/ApplicationReleaseManager.java | 12 +-- .../services/ApplicationStorageManager.java | 1 - .../services/ApplicationUploadManager.java | 26 ------ .../mgt/core/dao/LifecycleStateDAO.java | 3 + .../mgt/core/dao/impl/AbstractDAOImpl.java | 3 + .../GenericLifecycleStateImpl.java | 5 +- .../ApplicationManagementDAOException.java | 3 + .../mgt/core/exception/DAOException.java | 3 + .../mgt/core/exception/NotFoundException.java | 3 + .../core/exception/ValidationException.java | 3 + .../mgt/core/impl/ApplicationManagerImpl.java | 19 +++-- .../impl/ApplicationReleaseManagerImpl.java | 57 +++++++------ .../impl/ApplicationStorageManagerImpl.java | 21 +++-- .../impl/ApplicationUploadManagerImpl.java | 29 ------- .../core/impl/LifecycleStateManagerImpl.java | 3 + .../mgt/core/internal/DataHolder.java | 21 +++-- .../mgt/core/internal/ServiceComponent.java | 17 ++-- .../core/util/ApplicationManagementUtil.java | 17 ++-- .../application/mgt/core/util/Constants.java | 5 +- 32 files changed, 220 insertions(+), 192 deletions(-) delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationUploadManager.java delete mode 100644 components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationUploadManagerImpl.java diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/APIUtil.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/APIUtil.java index c7a3ca4115..5c6e52837e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/APIUtil.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/APIUtil.java @@ -23,7 +23,11 @@ import org.apache.commons.logging.LogFactory; import org.wso2.carbon.context.PrivilegedCarbonContext; import org.wso2.carbon.device.application.mgt.api.beans.ErrorResponse; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; -import org.wso2.carbon.device.application.mgt.common.services.*; +import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager; +import org.wso2.carbon.device.application.mgt.common.services.ApplicationReleaseManager; +import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager; +import org.wso2.carbon.device.application.mgt.common.services.LifecycleStateManager; +import org.wso2.carbon.device.application.mgt.common.services.PlatformManager; import javax.ws.rs.core.Response; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/FileStreamingOutput.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/FileStreamingOutput.java index dd637c2e5e..aad9a9a73e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/FileStreamingOutput.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/FileStreamingOutput.java @@ -19,11 +19,11 @@ package org.wso2.carbon.device.application.mgt.api; -import javax.ws.rs.WebApplicationException; -import javax.ws.rs.core.StreamingOutput; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.StreamingOutput; /** * FileStreamingOutput to allow the user to send the files as Stream. diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/JSONMessageHandler.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/JSONMessageHandler.java index 2f88b22306..d01bed5199 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/JSONMessageHandler.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/JSONMessageHandler.java @@ -23,6 +23,13 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import org.wso2.carbon.device.application.mgt.common.jaxrs.AnnotationExclusionStrategy; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.lang.annotation.Annotation; +import java.lang.reflect.Type; import javax.ws.rs.Consumes; import javax.ws.rs.Produces; import javax.ws.rs.WebApplicationException; @@ -31,12 +38,12 @@ import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.ext.MessageBodyReader; import javax.ws.rs.ext.MessageBodyWriter; import javax.ws.rs.ext.Provider; -import java.io.*; -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; import static javax.ws.rs.core.MediaType.APPLICATION_JSON; +/** + * This provider is used to change a JSON object to complex object and inversely in request and response. + */ @Provider @Produces(APPLICATION_JSON) @Consumes(APPLICATION_JSON) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/MultipartCustomProvider.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/MultipartCustomProvider.java index 2fcd51c295..84ed5e634a 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/MultipartCustomProvider.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/MultipartCustomProvider.java @@ -1,3 +1,21 @@ +/* +* Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. +* WSO2 Inc. 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. +* +*/ + package org.wso2.carbon.device.application.mgt.api; import com.google.gson.Gson; @@ -5,64 +23,51 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import org.apache.cxf.jaxrs.ext.multipart.Attachment; -import org.apache.cxf.jaxrs.provider.MultipartProvider; -import org.wso2.carbon.device.application.mgt.common.ApplicationRelease; import org.wso2.carbon.device.application.mgt.common.jaxrs.AnnotationExclusionStrategy; -import javax.mail.Multipart; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.lang.annotation.Annotation; +import java.lang.reflect.Type; import javax.ws.rs.Consumes; -import javax.ws.rs.Produces; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.ext.MessageBodyReader; import javax.ws.rs.ext.Provider; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; - -import static java.nio.charset.StandardCharsets.UTF_8; +/** + * Provider for the text/plain type of input. Particularly use-ful for the complex objects sent along with Multipart + * request. + */ @Provider @Consumes(MediaType.TEXT_PLAIN) public class MultipartCustomProvider implements MessageBodyReader { private Gson gson; + public MultipartCustomProvider() { + final GsonBuilder gsonBuilder = new GsonBuilder().setDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz") + .setExclusionStrategies(new AnnotationExclusionStrategy()); + gson = gsonBuilder.create(); + } @Override public boolean isReadable(Class aClass, Type type, Annotation[] annotations, MediaType mediaType) { - return true; + return !aClass.equals(Attachment.class); } - public Object readFrom(Class c, Type t, Annotation[] anns, MediaType mt, MultivaluedMap headers, InputStream inputStream) throws IOException, WebApplicationException { - ByteArrayOutputStream result = new ByteArrayOutputStream(); - byte[] buffer = new byte[1024]; - int length; - while ((length = inputStream.read(buffer)) != -1) { - result.write(buffer, 0, length); - } - String jsonString = result.toString(); - - JsonObject obj = new JsonParser().parse(jsonString).getAsJsonObject(); - - return getGson().fromJson(obj, t); - - } - - private Gson getGson() { - if (gson == null) { - final GsonBuilder gsonBuilder = new GsonBuilder() - .setDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz") - .setExclusionStrategies(new AnnotationExclusionStrategy()); - gson = gsonBuilder.create(); + @Override + public Object readFrom(Class objectClass, Type type, Annotation[] annotations, MediaType mediaType, + MultivaluedMap headers, InputStream inputStream) throws IOException, + WebApplicationException { + ByteArrayOutputStream result = new ByteArrayOutputStream(); + byte[] buffer = new byte[1024]; + int length; + while ((length = inputStream.read(buffer)) != -1) { + result.write(buffer, 0, length); } - return gson; + String jsonString = result.toString(); + JsonObject obj = new JsonParser().parse(jsonString).getAsJsonObject(); + return gson.fromJson(obj, type); } - - } - - diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/beans/ErrorListItem.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/beans/ErrorListItem.java index 91599d539a..3c04946592 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/beans/ErrorListItem.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/beans/ErrorListItem.java @@ -24,6 +24,9 @@ import io.swagger.annotations.ApiModelProperty; import javax.validation.constraints.NotNull; +/** + * Represents a single error item in the error response. + */ @ApiModel(description = "Error List Item") public class ErrorListItem { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/beans/ErrorResponse.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/beans/ErrorResponse.java index a755b82a4e..6c9321e334 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/beans/ErrorResponse.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/beans/ErrorResponse.java @@ -25,6 +25,10 @@ import io.swagger.annotations.ApiModelProperty; import java.util.ArrayList; import java.util.List; +/** + * This represents a response that need to be send back to the client, when the request cannot be completed + * successfully. + */ @ApiModel(description = "Error Response") public class ErrorResponse { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ApplicationManagementAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ApplicationManagementAPI.java index 6be716ec38..69f2c8f3e3 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ApplicationManagementAPI.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ApplicationManagementAPI.java @@ -483,6 +483,7 @@ public interface ApplicationManagementAPI { message = "Internal Server Error. \n Error occurred while releasing the application.", response = ErrorResponse.class) }) + Response createApplicationRelease( @ApiParam( name = "UUID", diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/LifecycleManagementAPI.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/LifecycleManagementAPI.java index fdd33f1a29..0386c12e25 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/LifecycleManagementAPI.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/LifecycleManagementAPI.java @@ -31,8 +31,8 @@ import org.wso2.carbon.apimgt.annotations.api.Scopes; import org.wso2.carbon.device.application.mgt.api.beans.ErrorResponse; import org.wso2.carbon.device.application.mgt.common.Application; import org.wso2.carbon.device.application.mgt.common.LifecycleState; -import org.wso2.carbon.device.application.mgt.common.Platform; +import java.util.List; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -40,8 +40,10 @@ import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.util.List; +/** + * Lifecycle management related APIs. + */ @SwaggerDefinition( info = @Info( version = "1.0.0", @@ -139,7 +141,8 @@ public interface LifecycleManagementAPI { @ApiResponse( code = 304, message = "Not Modified. \n " + - "Empty body because the client already has the latest version of the requested resource."), + "Empty body because the client already has the latest version of the requested " + + "resource."), @ApiResponse( code = 500, message = "Internal Server Error. \n Error occurred adding a lifecycle state.", 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/ApplicationManagementAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementAPIImpl.java index 2eb60e6b6c..271520149e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementAPIImpl.java @@ -36,6 +36,11 @@ import org.wso2.carbon.device.application.mgt.common.services.ApplicationRelease import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager; import org.wso2.carbon.device.application.mgt.core.util.Constants; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; import javax.validation.Valid; import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; @@ -48,11 +53,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; + /** * Implementation of Application Management related APIs. 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/LifecycleManagementAPIImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/LifecycleManagementAPIImpl.java index 751b0dc225..985c0b7bb8 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/LifecycleManagementAPIImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/LifecycleManagementAPIImpl.java @@ -25,15 +25,18 @@ import org.wso2.carbon.device.application.mgt.common.LifecycleState; import org.wso2.carbon.device.application.mgt.common.exception.LifecycleManagementException; import org.wso2.carbon.device.application.mgt.common.services.LifecycleStateManager; +import java.util.ArrayList; +import java.util.List; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.core.Response; -import java.util.ArrayList; -import java.util.List; +/** + * Lifecycle Management related jax-rs APIs. + */ @Path("/lifecycles") public class LifecycleManagementAPIImpl implements LifecycleManagementAPI { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Application.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Application.java index 0afbeff1ee..4fe9a25c38 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Application.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Application.java @@ -26,7 +26,7 @@ import java.util.List; import java.util.Map; /** - * Application represents the an Application in Application Store + * Application represents the an Application in Application Store. */ public class Application { @@ -253,7 +253,7 @@ public class Application { @Override public String toString() { - return "UUID : " + uuid + "\tIdentifier : " + identifier + "\tName : " + name + "\tShort Description : " + - shortDescription + "\tLifecycle State : " + currentLifecycle.getLifecycleState() ; + return "UUID : " + uuid + "\tIdentifier : " + identifier + "\tName : " + name + "\tShort Description : " + + shortDescription + "\tLifecycle State : " + currentLifecycle.getLifecycleState(); } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/ApplicationStorageManagementException.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/ApplicationStorageManagementException.java index 7b661e4d5d..cba6915bcb 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/ApplicationStorageManagementException.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/ApplicationStorageManagementException.java @@ -22,7 +22,7 @@ package org.wso2.carbon.device.application.mgt.common.exception; /** * Represents the exception thrown during storing and retrieving the artifacts. */ -public class ApplicationStorageManagementException extends ApplicationManagementException{ +public class ApplicationStorageManagementException extends ApplicationManagementException { public ApplicationStorageManagementException(String message, Throwable ex) { super(message, ex); } 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 2899f997c6..89a46e8bd8 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 @@ -18,10 +18,12 @@ */ package org.wso2.carbon.device.application.mgt.common.services; -import org.wso2.carbon.device.application.mgt.common.*; +import org.wso2.carbon.device.application.mgt.common.Application; +import org.wso2.carbon.device.application.mgt.common.ApplicationList; +import org.wso2.carbon.device.application.mgt.common.Filter; +import org.wso2.carbon.device.application.mgt.common.LifecycleStateTransition; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; -import java.io.InputStream; import java.util.List; /** @@ -63,11 +65,11 @@ public interface ApplicationManager { /** * To change the lifecycle of the Application. * - * @param applicationUUID UUID of the Application + * @param applicationUuid UUID of the Application * @param lifecycleIdentifier New life-cycle that need to be changed. * @throws ApplicationManagementException Application Management Exception. */ - public void changeLifecycle(String applicationUUID, String lifecycleIdentifier) throws + public void changeLifecycle(String applicationUuid, String lifecycleIdentifier) 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/ApplicationReleaseManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationReleaseManager.java index 5e8ba10868..05d293282f 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationReleaseManager.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationReleaseManager.java @@ -34,29 +34,29 @@ public interface ApplicationReleaseManager { /** * To create an application release for an Application. * - * @param UUID UUID of the Application + * @param appicationUuid UUID of the Application * @param applicationRelease ApplicatonRelease that need to be be created. * @return the unique id of the application release, if the application release succeeded else -1 */ - public ApplicationRelease createRelease(String UUID, ApplicationRelease applicationRelease) throws + public ApplicationRelease createRelease(String appicationUuid, ApplicationRelease applicationRelease) throws ApplicationManagementException; /** * To get the application release of the Application/ - * @param UUID UUID of the Application. + * @param applicationUuid UUID of the Application. * @param version Version of the ApplicationRelease that need to be retrieved. * @return ApplicationRelease related with particular Application UUID and version. * @throws ApplicationManagementException ApplicationManagementException */ - public ApplicationRelease getRelease(String UUID, String version) throws ApplicationManagementException; + public ApplicationRelease getRelease(String applicationUuid, String version) throws ApplicationManagementException; /** * To get all the releases of a particular Application. - * @param UUID UUID of the Application to get all the releases. + * @param applicationUuid UUID of the Application to get all the releases. * @return the List of the Application releases related with the particular Application. * @throws ApplicationManagementException Application Management Exception. */ - public List getReleases(String UUID) throws ApplicationManagementException; + public List getReleases(String applicationUuid) throws ApplicationManagementException; /** * To make a release as the default one for an application. 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 4765366d69..72da318963 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 @@ -22,7 +22,6 @@ package org.wso2.carbon.device.application.mgt.common.services; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationStorageManagementException; import java.io.InputStream; -import java.io.OutputStream; import java.util.List; /** diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationUploadManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationUploadManager.java deleted file mode 100644 index 997342bd5a..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/ApplicationUploadManager.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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. - * - */ -package org.wso2.carbon.device.application.mgt.common.services; - -/** - * This interface manages all the operations related with Application Upload. - */ -public interface ApplicationUploadManager { - -} 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 dbe164b7cb..b408621582 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 @@ -24,6 +24,9 @@ import org.wso2.carbon.device.application.mgt.core.exception.DAOException; import java.util.List; +/** + * This is responsible for all the DAO operations related to Lifecycle state. + */ public interface LifecycleStateDAO { LifecycleState getLifeCycleStateByIdentifier(String identifier) 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/impl/AbstractDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/AbstractDAOImpl.java index a85ce946a5..bbc1f85c0e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/AbstractDAOImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/AbstractDAOImpl.java @@ -23,6 +23,9 @@ import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil; import java.sql.Connection; +/** + * This class deals with getting the DB connection. + */ public abstract class AbstractDAOImpl { protected Connection getDBConnection() throws DBConnectionException { 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/GenericLifecycleStateImpl.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/GenericLifecycleStateImpl.java index 0c1edf5c22..a772ba8583 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/GenericLifecycleStateImpl.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/GenericLifecycleStateImpl.java @@ -33,6 +33,9 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +/** + * Concrete implementation for Lifecycle related DB operations. + */ public class GenericLifecycleStateImpl extends AbstractDAOImpl implements LifecycleStateDAO { @Override @@ -82,7 +85,7 @@ public class GenericLifecycleStateImpl extends AbstractDAOImpl implements Lifecy String sql = "SELECT IDENTIFIER, NAME, DESCRIPTION FROM APPM_LIFECYCLE_STATE"; stmt = conn.prepareStatement(sql); rs = stmt.executeQuery(); - while(rs.next()) { + while (rs.next()) { LifecycleState lifecycleState = new LifecycleState(); lifecycleState.setIdentifier(rs.getString("IDENTIFIER")); lifecycleState.setName(rs.getString("NAME")); 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 d951b84c9d..c50602a186 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 @@ -20,6 +20,9 @@ package org.wso2.carbon.device.application.mgt.core.exception; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; +/** + * Exception thrown during the Application Management DAO operations. + */ public class ApplicationManagementDAOException extends ApplicationManagementException { public ApplicationManagementDAOException(String message, Throwable throwable) { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/exception/DAOException.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/exception/DAOException.java index 2d5121bdca..82fb6e1530 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/exception/DAOException.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/exception/DAOException.java @@ -17,6 +17,9 @@ */ package org.wso2.carbon.device.application.mgt.core.exception; +/** + * This exception will be thrown when there is an issue with Lifecycle related DAO operations. + */ public class DAOException extends Exception { public DAOException(String message) { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/exception/NotFoundException.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/exception/NotFoundException.java index 5314dd06ac..43daf8890a 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/exception/NotFoundException.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/exception/NotFoundException.java @@ -20,6 +20,9 @@ package org.wso2.carbon.device.application.mgt.core.exception; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; +/** + * This exception will be thrown when the requested application or platform not found. + */ public class NotFoundException extends ApplicationManagementException { public NotFoundException(String message, Throwable throwable) { diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/exception/ValidationException.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/exception/ValidationException.java index 7044f2ce5e..a537cdf7cb 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/exception/ValidationException.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/exception/ValidationException.java @@ -20,6 +20,9 @@ package org.wso2.carbon.device.application.mgt.core.exception; import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException; +/** + * This exception will be thrown when the initial validation fails to perform an operation. + */ public class ValidationException extends ApplicationManagementException { public ValidationException(String message, Throwable throwable) { 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 4641c6734f..837ba1ea7c 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 @@ -41,17 +41,19 @@ import org.wso2.carbon.device.application.mgt.core.exception.NotFoundException; import org.wso2.carbon.device.application.mgt.core.exception.ValidationException; import org.wso2.carbon.device.application.mgt.core.internal.DataHolder; 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.HelperUtil; import org.wso2.carbon.user.api.UserRealm; import org.wso2.carbon.user.api.UserStoreException; import org.wso2.carbon.utils.multitenancy.MultitenantUtils; -import java.io.*; +import java.io.InputStream; import java.util.ArrayList; import java.util.Date; import java.util.List; +/** + * Default Concrete implementation of Application Management related implementations. + */ public class ApplicationManagerImpl implements ApplicationManager { private static final Log log = LogFactory.getLog(ApplicationManagerImpl.class); @@ -184,15 +186,15 @@ public class ApplicationManagerImpl implements ApplicationManager { } @Override - public void changeLifecycle(String applicationUUID, String lifecycleIdentifier) throws + public void changeLifecycle(String applicationUuid, String lifecycleIdentifier) throws ApplicationManagementException { boolean isAvailableNextState = false; String userName = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(); - List nextLifeCycles = getLifeCycleStates(applicationUUID); + List nextLifeCycles = getLifeCycleStates(applicationUuid); for (LifecycleStateTransition lifecycleStateTransition : nextLifeCycles) { if (log.isDebugEnabled()) { - log.debug("Lifecycle state of the application " + applicationUUID + " can be changed to" + log.debug("Lifecycle state of the application " + applicationUuid + " can be changed to" + lifecycleStateTransition.getNextState()); } if (lifecycleStateTransition.getNextState().equalsIgnoreCase(lifecycleIdentifier)) { @@ -202,13 +204,13 @@ public class ApplicationManagerImpl implements ApplicationManager { } if (!isAvailableNextState) { throw new ApplicationManagementException("User " + userName + " does not have the permission to change " - + "the lifecycle state of the application " + applicationUUID + " to lifecycle state " + + "the lifecycle state of the application " + applicationUuid + " to lifecycle state " + lifecycleIdentifier); } try { ConnectionManagerUtil.beginDBTransaction(); ApplicationDAO applicationDAO = DAOFactory.getApplicationDAO(); - applicationDAO.changeLifecycle(applicationUUID, lifecycleIdentifier, userName); + applicationDAO.changeLifecycle(applicationUuid, lifecycleIdentifier, userName); ConnectionManagerUtil.commitDBTransaction(); } catch (ApplicationManagementDAOException e) { ConnectionManagerUtil.rollbackDBTransaction(); @@ -305,7 +307,8 @@ public class ApplicationManagerImpl implements ApplicationManager { } } catch (UserStoreException e) { throw new ApplicationManagementException("Userstore exception while checking whether user is an admin", e); - } try { + } + try { ConnectionManagerUtil.openDBConnection(); Application application = DAOFactory.getApplicationDAO().getApplication(applicationUUID); return application.getUser().getUserName().equals(userName) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationReleaseManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationReleaseManagerImpl.java index ccd1f81a58..bc7cfa33a0 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationReleaseManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationReleaseManagerImpl.java @@ -32,13 +32,16 @@ import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil; import java.util.Date; import java.util.List; +/** + * Concrete implementation for Application Release Management related tasks. + */ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager { private static Log log = LogFactory.getLog(ApplicationReleaseManagerImpl.class); @Override - public ApplicationRelease createRelease(String UUID, ApplicationRelease applicationRelease) throws + public ApplicationRelease createRelease(String appicationUuid, ApplicationRelease applicationRelease) throws ApplicationManagementException { - Application application = validateReleaseCreateRequest(UUID, applicationRelease); + Application application = validateReleaseCreateRequest(appicationUuid, applicationRelease); if (log.isDebugEnabled()) { log.debug("Application release request is received for the application " + application.toString()); } @@ -58,30 +61,31 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager } @Override - public ApplicationRelease getRelease(String UUID, String version) throws ApplicationManagementException { - Application application = validationGetReleaseRequest(UUID); + public ApplicationRelease getRelease(String applicationUuid, String version) throws + ApplicationManagementException { + Application application = validationGetReleaseRequest(applicationUuid); if (log.isDebugEnabled()) { log.debug("Application release retrieval request is received for the application " + application.toString() + " and version " + version); } try { ConnectionManagerUtil.openDBConnection(); - return DAOFactory.getApplicationReleaseDAO().getRelease(UUID, version); + return DAOFactory.getApplicationReleaseDAO().getRelease(applicationUuid, version); } finally { ConnectionManagerUtil.closeDBConnection(); } } @Override - public List getReleases(String UUID) throws ApplicationManagementException { - Application application = validationGetReleaseRequest(UUID); + public List getReleases(String applicationUuid) throws ApplicationManagementException { + Application application = validationGetReleaseRequest(applicationUuid); if (log.isDebugEnabled()) { log.debug("Request is received to retrieve all the releases related with the application " + application.toString()); } try { ConnectionManagerUtil.openDBConnection(); - return DAOFactory.getApplicationReleaseDAO().getApplicationReleases(UUID); + return DAOFactory.getApplicationReleaseDAO().getApplicationReleases(applicationUuid); } finally { ConnectionManagerUtil.closeDBConnection(); } @@ -100,18 +104,19 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager /** * To validate the pre-request of the ApplicationRelease. * - * @param UUID UUID of the Application. + * @param applicationUuid UUID of the Application. * @return Application related with the UUID */ - private Application validationGetReleaseRequest(String UUID) throws ApplicationManagementException { - if (UUID == null) { + private Application validationGetReleaseRequest(String applicationUuid) throws ApplicationManagementException { + if (applicationUuid == null) { throw new ApplicationManagementException("Application UUID is null. Application UUID is a required " + "parameter to get the releases related to a particular application."); } - Application application = DataHolder.getInstance().getApplicationManager().getApplication(UUID); + Application application = DataHolder.getInstance().getApplicationManager().getApplication(applicationUuid); if (application == null) { - throw new ApplicationManagementException("Application with UUID " + UUID + " does not exist. Cannot " - + "retrieve the releases for a non-existing application."); + throw new ApplicationManagementException( + "Application with UUID " + applicationUuid + " does not exist. Cannot " + + "retrieve the releases for a non-existing application."); } return application; } @@ -119,30 +124,32 @@ public class ApplicationReleaseManagerImpl implements ApplicationReleaseManager /** * To validate a create release request to make sure all the pre-conditions satisfied. * - * @param UUID UUID of the Application. + * @param applicationUuid UUID of the Application. * @param applicationRelease ApplicationRelease that need to be created. * @return the Application related with the particular Application Release * @throws ApplicationManagementException Application Management Exception. */ - private Application validateReleaseCreateRequest(String UUID, ApplicationRelease applicationRelease) + private Application validateReleaseCreateRequest(String applicationUuid, ApplicationRelease applicationRelease) throws ApplicationManagementException { - if (UUID == null) { + if (applicationUuid == null) { throw new ApplicationManagementException("Application UUID is null. Application UUID is a required " + "parameter to do the application release"); } - Application application = DataHolder.getInstance().getApplicationManager().getApplication(UUID); + Application application = DataHolder.getInstance().getApplicationManager().getApplication(applicationUuid); if (application == null) { - throw new ApplicationManagementException("Application with UUID " + UUID + " does not exist. Cannot " - + "release an application that is not existing"); + throw new ApplicationManagementException( + "Application with UUID " + applicationUuid + " does not exist. Cannot " + + "release an application that is not existing"); } - if (applicationRelease == null || applicationRelease.getVersionName() == null){ + if (applicationRelease == null || applicationRelease.getVersionName() == null) { throw new ApplicationManagementException("ApplicationRelease version name is a mandatory parameter for " + "creating release. It cannot be found."); } - if (getRelease(UUID, applicationRelease.getVersionName()) != null){ - throw new ApplicationManagementException("Application Release for the Application UUID " + UUID + " " - + "with the version " + applicationRelease.getVersionName() + " already exists. Cannot create an " - + "application release with the same version."); + if (getRelease(applicationUuid, applicationRelease.getVersionName()) != null) { + throw new ApplicationManagementException( + "Application Release for the Application UUID " + applicationUuid + " " + "with the version " + + applicationRelease.getVersionName() + " already exists. Cannot create an " + + "application release with the same version."); } return application; } 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 d848bcaa82..30e9499dfa 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 @@ -28,13 +28,19 @@ import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorage import org.wso2.carbon.device.application.mgt.core.internal.DataHolder; import org.wso2.carbon.device.application.mgt.core.util.Constants; -import java.io.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.util.List; /** * This class contains the default concrete implementation of ApplicationStorage Management. */ -public class ApplicationStorageManagerImpl implements ApplicationStorageManager{ +public class ApplicationStorageManagerImpl implements ApplicationStorageManager { private static final Log log = LogFactory.getLog(ApplicationStorageManagerImpl.class); @Override @@ -44,14 +50,15 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager{ try { application = DataHolder.getInstance().getApplicationManager().getApplication(applicationUUID); } catch (ApplicationManagementException e) { - throw new ApplicationStorageManagementException("Exception while retrieving the application details for " - + "the application with UUID " + applicationUUID); + throw new ApplicationStorageManagementException( + "Exception while retrieving the application details for " + "the application with UUID " + + applicationUUID); } if (application == null) { throw new ApplicationStorageManagementException("Application with UUID " + applicationUUID + " does not " + "exist. Cannot upload the artifacts to non-existing application."); } - String artifactDirectoryPath = Constants.ARTIFACT_PATH + application.getId(); + String artifactDirectoryPath = Constants.artifactPath + application.getId(); if (log.isDebugEnabled()) { log.debug("Artifact Directory Path for saving the artifacts related with application " + applicationUUID + " is " + artifactDirectoryPath); @@ -117,7 +124,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager{ throw new ApplicationStorageManagementException("Application with UUID " + applicationUUID + " does not " + "exist. Cannot upload release artifacts for not existing application."); } - String artifactDirectoryPath = Constants.ARTIFACT_PATH + application.getId(); + String artifactDirectoryPath = Constants.artifactPath + application.getId(); if (log.isDebugEnabled()) { log.debug("Artifact Directory Path for saving the application release related artifacts related with " + "application " + applicationUUID + " is " + artifactDirectoryPath); @@ -150,7 +157,7 @@ public class ApplicationStorageManagerImpl implements ApplicationStorageManager{ throw new ApplicationStorageManagementException("Application with UUID " + applicationUUID + " does not " + "exist. Cannot retrieve release artifacts for not existing application."); } - String artifactPath = Constants.ARTIFACT_PATH + application.getId() + File.separator + versionName; + String artifactPath = Constants.artifactPath + application.getId() + File.separator + versionName; if (log.isDebugEnabled()) { log.debug("ApplicationRelease artifacts are searched in the location " + artifactPath); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationUploadManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationUploadManagerImpl.java deleted file mode 100644 index 38b908c00d..0000000000 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/ApplicationUploadManagerImpl.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2017, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * WSO2 Inc. 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. - * - */ -package org.wso2.carbon.device.application.mgt.core.impl; - - -import org.wso2.carbon.device.application.mgt.common.services.ApplicationUploadManager; - -public class ApplicationUploadManagerImpl implements ApplicationUploadManager { - - public ApplicationUploadManagerImpl(String uploadPath){ - - } -} diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/LifecycleStateManagerImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/LifecycleStateManagerImpl.java index eccf7d4530..9e9f8d9b74 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/LifecycleStateManagerImpl.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/impl/LifecycleStateManagerImpl.java @@ -30,6 +30,9 @@ import org.wso2.carbon.device.application.mgt.core.util.ConnectionManagerUtil; import java.util.List; +/** + * Concrete implementation of Lifecycle state management. + */ public class LifecycleStateManagerImpl implements LifecycleStateManager { private static final Log log = LogFactory.getLog(LifecycleStateManagerImpl.class); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/DataHolder.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/DataHolder.java index 2f7331e4a4..426b13b02e 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/DataHolder.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/DataHolder.java @@ -18,7 +18,16 @@ */ package org.wso2.carbon.device.application.mgt.core.internal; -import org.wso2.carbon.device.application.mgt.common.services.*; +import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager; +import org.wso2.carbon.device.application.mgt.common.services.ApplicationReleaseManager; +import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager; +import org.wso2.carbon.device.application.mgt.common.services.CategoryManager; +import org.wso2.carbon.device.application.mgt.common.services.CommentsManager; +import org.wso2.carbon.device.application.mgt.common.services.LifecycleStateManager; +import org.wso2.carbon.device.application.mgt.common.services.PlatformManager; +import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager; +import org.wso2.carbon.device.application.mgt.common.services.VisibilityManager; +import org.wso2.carbon.device.application.mgt.common.services.VisibilityTypeManager; import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService; import org.wso2.carbon.user.core.service.RealmService; @@ -49,8 +58,6 @@ public class DataHolder { private VisibilityManager visibilityManager; - private ApplicationUploadManager applicationUploadManager; - private ApplicationStorageManager applicationStorageManager; private static final DataHolder applicationMgtDataHolder = new DataHolder(); @@ -143,14 +150,6 @@ public class DataHolder { this.visibilityManager = visibilityManager; } - public void setApplicationUploadManager(ApplicationUploadManager applicationUploadManager) { - this.applicationUploadManager = applicationUploadManager; - } - - public ApplicationUploadManager getApplicationUploadManager() { - return applicationUploadManager; - } - public RealmService getRealmService() { return realmService; } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ServiceComponent.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ServiceComponent.java index 68bb3a9af2..1a808090ef 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ServiceComponent.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/internal/ServiceComponent.java @@ -23,7 +23,16 @@ import org.apache.commons.logging.LogFactory; import org.osgi.framework.BundleContext; import org.osgi.service.component.ComponentContext; import org.wso2.carbon.device.application.mgt.common.exception.InvalidConfigurationException; -import org.wso2.carbon.device.application.mgt.common.services.*; +import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager; +import org.wso2.carbon.device.application.mgt.common.services.ApplicationReleaseManager; +import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager; +import org.wso2.carbon.device.application.mgt.common.services.CategoryManager; +import org.wso2.carbon.device.application.mgt.common.services.CommentsManager; +import org.wso2.carbon.device.application.mgt.common.services.LifecycleStateManager; +import org.wso2.carbon.device.application.mgt.common.services.PlatformManager; +import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager; +import org.wso2.carbon.device.application.mgt.common.services.VisibilityManager; +import org.wso2.carbon.device.application.mgt.common.services.VisibilityTypeManager; import org.wso2.carbon.device.application.mgt.core.config.ConfigurationManager; import org.wso2.carbon.device.application.mgt.core.dao.common.DAOFactory; import org.wso2.carbon.device.application.mgt.core.exception.ApplicationManagementDAOException; @@ -69,7 +78,7 @@ public class ServiceComponent { String datasourceName = ConfigurationManager.getInstance().getConfiguration().getDatasourceName(); DAOFactory.init(datasourceName); - Constants.ARTIFACT_PATH = ConfigurationManager.getInstance().getConfiguration().getArtifacts() + Constants.artifactPath = ConfigurationManager.getInstance().getConfiguration().getArtifacts() .getBinaryLocation(); ApplicationManager applicationManager = ApplicationManagementUtil.getApplicationManagerInstance(); DataHolder.getInstance().setApplicationManager(applicationManager); @@ -108,10 +117,6 @@ public class ServiceComponent { DataHolder.getInstance().setVisibilityTypeManager(visibilityTypeManager); bundleContext.registerService(VisibilityTypeManager.class.getName(), visibilityTypeManager, null); - ApplicationUploadManager uploadManager = ApplicationManagementUtil.getApplicationUploadManagerInstance(); - DataHolder.getInstance().setApplicationUploadManager(uploadManager); - bundleContext.registerService(ApplicationUploadManager.class.getName(), uploadManager, null); - ApplicationStorageManager applicationStorageManager = ApplicationManagementUtil .getApplicationStorageManagerInstance(); DataHolder.getInstance().setApplicationStorageManager(applicationStorageManager); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/ApplicationManagementUtil.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/ApplicationManagementUtil.java index ca43e84807..de1a03255b 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/ApplicationManagementUtil.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/ApplicationManagementUtil.java @@ -21,7 +21,16 @@ package org.wso2.carbon.device.application.mgt.core.util; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.wso2.carbon.device.application.mgt.common.exception.InvalidConfigurationException; -import org.wso2.carbon.device.application.mgt.common.services.*; +import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager; +import org.wso2.carbon.device.application.mgt.common.services.ApplicationReleaseManager; +import org.wso2.carbon.device.application.mgt.common.services.ApplicationStorageManager; +import org.wso2.carbon.device.application.mgt.common.services.CategoryManager; +import org.wso2.carbon.device.application.mgt.common.services.CommentsManager; +import org.wso2.carbon.device.application.mgt.common.services.LifecycleStateManager; +import org.wso2.carbon.device.application.mgt.common.services.PlatformManager; +import org.wso2.carbon.device.application.mgt.common.services.SubscriptionManager; +import org.wso2.carbon.device.application.mgt.common.services.VisibilityManager; +import org.wso2.carbon.device.application.mgt.common.services.VisibilityTypeManager; import org.wso2.carbon.device.application.mgt.core.config.ConfigurationManager; import org.wso2.carbon.device.application.mgt.core.config.Extension; @@ -90,12 +99,6 @@ public class ApplicationManagementUtil { return getInstance(extension, SubscriptionManager.class); } - public static ApplicationUploadManager getApplicationUploadManagerInstance() throws InvalidConfigurationException { - ConfigurationManager configurationManager = ConfigurationManager.getInstance(); - Extension extension = configurationManager.getExtension(Extension.Name.ApplicationUploadManager); - return getInstance(extension, ApplicationUploadManager.class); - } - public static ApplicationStorageManager getApplicationStorageManagerInstance() throws InvalidConfigurationException { ConfigurationManager configurationManager = ConfigurationManager.getInstance(); diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/Constants.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/Constants.java index 7b28b499f4..467be38824 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/Constants.java +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/util/Constants.java @@ -54,5 +54,8 @@ public class Constants { public static final String[] LIFE_CYCLES = {"CREATED", "IN REVIEW", "APPROVED", "REJECTED", "PUBLISHED", "UNPUBLISHED", "RETIRED"}; - public static String ARTIFACT_PATH = ""; + /** + * Path to save the Application related artifacts. + */ + public static String artifactPath = ""; }