diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/pom.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/pom.xml
index c9e28a7c479..85d7e5d014d 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/pom.xml
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/pom.xml
@@ -36,13 +36,6 @@
-
- maven-compiler-plugin
-
-
- 1.7
-
-
maven-war-plugin
@@ -132,6 +125,10 @@
org.codehaus.jackson
jackson-jaxrs
+
+ org.codehaus.jackson
+ jackson-core-asl
+
javax.ws.rs
jsr311-api
@@ -228,5 +225,6 @@
javax.ws.rs
javax.ws.rs-api
+
\ No newline at end of file
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
deleted file mode 100644
index 0bf9ac8eec0..00000000000
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ApplicationManagementAPI.java
+++ /dev/null
@@ -1,93 +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.api.services;
-
-import io.swagger.annotations.*;
-import org.wso2.carbon.device.application.mgt.api.beans.ErrorResponse;
-import org.wso2.carbon.device.application.mgt.common.ApplicationList;
-
-import javax.ws.rs.*;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-@Api(value = "Application Management", description = "This API carries all application management related operations " +
- "such as get all the applications, add application, etc.")
-@Produces(MediaType.APPLICATION_JSON)
-@Consumes(MediaType.APPLICATION_JSON)
-public interface ApplicationManagementAPI {
-
- public final static String SCOPE = "scope";
-
- @GET
- @Path("applications")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- @ApiOperation(
- consumes = MediaType.APPLICATION_JSON,
- produces = MediaType.APPLICATION_JSON,
- httpMethod = "POST",
- value = "get all applications",
- notes = "This will get all applications",
- tags = "Application Management",
- extensions = {
- @Extension(properties = {
- @ExtensionProperty(name = SCOPE, value = "perm:get-application")
- })
- }
- )
- @ApiResponses(
- value = {
- @ApiResponse(
- code = 200,
- message = "OK. \n Successfully got application list.",
- response = ApplicationList.class),
- @ApiResponse(
- code = 304,
- message = "Not Modified. \n " +
- "Empty body because the client already has the latest version of the requested resource."),
- @ApiResponse(
- code = 500,
- message = "Internal Server Error. \n Error occurred while getting the application list.",
- response = ErrorResponse.class)
- })
- Response getApplications(
-
- @ApiParam(
- name = "If-Modified-Since",
- value = "Validates if the requested variant has not been modified since the time specified",
- required = false)
- @HeaderParam("If-Modified-Since") String ifModifiedSince,
-
- @ApiParam(
- name = "offset",
- value = "Provide from which position apps should return",
- required = false,
- defaultValue = "20")
- @QueryParam("offset") int offset,
-
- @ApiParam(
- name = "limit",
- value = "Provide how many apps it should return",
- required = false,
- defaultValue = "0")
- @QueryParam("limit") int limit
-
- );
-
-}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ApplicationManagementService.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ApplicationManagementService.java
new file mode 100644
index 00000000000..1fa4cc374da
--- /dev/null
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/ApplicationManagementService.java
@@ -0,0 +1,179 @@
+/*
+ * 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.services;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import io.swagger.annotations.Extension;
+import io.swagger.annotations.ExtensionProperty;
+import io.swagger.annotations.Info;
+import io.swagger.annotations.SwaggerDefinition;
+import io.swagger.annotations.Tag;
+import org.wso2.carbon.apimgt.annotations.api.Scope;
+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.ApplicationList;
+
+import javax.validation.Valid;
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+
+@SwaggerDefinition(
+ info = @Info(
+ version = "1.0.0",
+ title = "Application Management Service",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = "name", value = "ApplicationManagementService"),
+ @ExtensionProperty(name = "context", value = "/api/application-mgt/v1.0/applications"),
+ })
+ }
+ ),
+ tags = {
+ @Tag(name = "application_management", description = "Application Management related APIs")
+ }
+)
+@Scopes(
+ scopes = {
+ @Scope(
+ name = "Get Application Details",
+ description = "Get application details",
+ key = "perm:application:get",
+ permissions = {"/device-mgt/application/get"}
+ ),
+ @Scope(
+ name = "Create an Application",
+ description = "Create an application",
+ key = "perm:application:create",
+ permissions = {"/device-mgt/application/create"}
+ ),
+ }
+)
+@Path("/applications")
+@Api(value = "Application Management", description = "This API carries all application management related operations " +
+ "such as get all the applications, add application, etc.")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+public interface ApplicationManagementService {
+
+ public final static String SCOPE = "scope";
+
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ApiOperation(
+ consumes = MediaType.APPLICATION_JSON,
+ produces = MediaType.APPLICATION_JSON,
+ httpMethod = "GET",
+ value = "get all applications",
+ notes = "This will get all applications",
+ tags = "Application Management",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = SCOPE, value = "perm:application:get")
+ })
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(
+ code = 200,
+ message = "OK. \n Successfully got application list.",
+ response = ApplicationList.class),
+ @ApiResponse(
+ code = 304,
+ message = "Not Modified. \n " +
+ "Empty body because the client already has the latest version of the requested resource."),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n Error occurred while getting the application list.",
+ response = ErrorResponse.class)
+ })
+ Response getApplications(
+
+ @ApiParam(
+ name = "If-Modified-Since",
+ value = "Validates if the requested variant has not been modified since the time specified",
+ required = false)
+ @HeaderParam("If-Modified-Since") String ifModifiedSince,
+ @ApiParam(
+ name = "offset",
+ value = "Provide from which position apps should return",
+ required = false,
+ defaultValue = "20")
+ @QueryParam("offset") int offset,
+ @ApiParam(
+ name = "limit",
+ value = "Provide how many apps it should return",
+ required = false,
+ defaultValue = "0")
+ @QueryParam("limit") int limit,
+ @ApiParam(
+ name = "searchQuery",
+ value = "Relevant search query to search on",
+ required = false,
+ defaultValue = "*")
+ @QueryParam("searchQuery") String searchQuery
+ );
+
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ @ApiOperation(
+ consumes = MediaType.APPLICATION_JSON,
+ produces = MediaType.APPLICATION_JSON,
+ httpMethod = "POST",
+ value = "Create an application",
+ notes = "This will create a new application",
+ tags = "Application Management",
+ extensions = {
+ @Extension(properties = {
+ @ExtensionProperty(name = SCOPE, value = "perm:application:create")
+ })
+ }
+ )
+ @ApiResponses(
+ value = {
+ @ApiResponse(
+ code = 201,
+ message = "OK. \n Successfully created an application.",
+ response = Application.class),
+ @ApiResponse(
+ code = 304,
+ message = "Not Modified. \n " +
+ "Empty body because the client already has the latest version of the requested resource."),
+ @ApiResponse(
+ code = 500,
+ message = "Internal Server Error. \n Error occurred while getting the application list.",
+ response = ErrorResponse.class)
+ })
+ Response createApplication(
+ @ApiParam(
+ name = "application",
+ value = "The application that need to be created.",
+ required = true)
+ @Valid Application application);
+
+}
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/ApplicationManagementServiceImpl.java
similarity index 60%
rename from components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementAPIImpl.java
rename to components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/services/impl/ApplicationManagementServiceImpl.java
index c6dde79ab15..42b6fe0d638 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/ApplicationManagementServiceImpl.java
@@ -20,82 +20,94 @@ package org.wso2.carbon.device.application.mgt.api.services.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.device.application.mgt.common.*;
+import org.wso2.carbon.context.PrivilegedCarbonContext;
+import org.wso2.carbon.device.application.mgt.api.services.ApplicationManagementService;
+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.ApplicationUser;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
import org.wso2.carbon.device.application.mgt.api.APIUtil;
import javax.validation.Valid;
-import javax.ws.rs.*;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
-import java.util.Date;
-
-@Produces({"application/json"})
-@Consumes({"application/json"})
-public class ApplicationManagementAPIImpl {
-
- public static final int DEFAULT_LIMIT = 20;
+@Path("/applications")
+public class ApplicationManagementServiceImpl implements ApplicationManagementService {
+ private static final int DEFAULT_LIMIT = 20;
public static final String APPLICATION_UPLOAD_EXTENSION = "ApplicationUploadExtension";
-
- private static Log log = LogFactory.getLog(ApplicationManagementAPIImpl.class);
+ private static Log log = LogFactory.getLog(ApplicationManagementServiceImpl.class);
@GET
- @Consumes("application/json")
- @Path("applications")
- public Response getApplications(@QueryParam("offset") int offset, @QueryParam("limit") int limit,
- @QueryParam("query") String searchQuery) {
+ @Override
+ public Response getApplications(@HeaderParam("If-Modified-Since") String ifModifiedSince,
+ @QueryParam("offset") int offset, @QueryParam("limit") int limit, @QueryParam("query") String searchQuery) {
ApplicationManager applicationManager = APIUtil.getApplicationManager();
+ if (log.isDebugEnabled()) {
+ log.debug("Received a query for getting applications : offset - " + offset + " limit - " + limit + " "
+ + "searchQuery - " + searchQuery);
+ }
try {
if (limit == 0) {
limit = DEFAULT_LIMIT;
+ if (log.isDebugEnabled()) {
+ log.debug("Received a search query with the limit 0, hence using " + DEFAULT_LIMIT + " as limit "
+ + "for getting applications");
+ }
}
Filter filter = new Filter();
filter.setOffset(offset);
filter.setLimit(limit);
filter.setSearchQuery(searchQuery);
-
ApplicationList applications = applicationManager.getApplications(filter);
return Response.status(Response.Status.OK).entity(applications).build();
} catch (ApplicationManagementException e) {
String msg = "Error occurred while getting the application list";
log.error(msg, e);
- return Response.status(Response.Status.NOT_FOUND).build();
+ return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
@POST
@Consumes("application/json")
- @Path("applications")
public Response createApplication(@Valid Application application) {
-
ApplicationManager applicationManager = APIUtil.getApplicationManager();
//TODO : Get username and tenantId
- User user = new User("admin", -1234);
- application.setUser(user);
+ ApplicationUser applicationUser = new ApplicationUser(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(),
+ PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true));
+ application.setUser(applicationUser);
+ if (log.isDebugEnabled()) {
+ log.debug("Create Application request received from the user : " + applicationUser.toString());
+ }
try {
application = applicationManager.createApplication(application);
-
} catch (ApplicationManagementException e) {
String msg = "Error occurred while creating the application";
log.error(msg, e);
return Response.status(Response.Status.BAD_REQUEST).build();
}
- return Response.status(Response.Status.OK).entity(application).build();
+ return Response.status(Response.Status.CREATED).entity(application).build();
}
-
@PUT
@Consumes("application/json")
@Path("applications")
public Response editApplication(@Valid Application application) {
-
ApplicationManager applicationManager = APIUtil.getApplicationManager();
//TODO : Get username and tenantId
- User user = new User("admin", -1234);
+ ApplicationUser user = new ApplicationUser("admin", -1234);
application.setUser(user);
try {
@@ -108,5 +120,5 @@ public class ApplicationManagementAPIImpl {
}
return Response.status(Response.Status.OK).entity(application).build();
}
-
}
+
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/util/ApiOriginFilter.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/util/ApiOriginFilter.java
new file mode 100644
index 00000000000..5bc593eca0d
--- /dev/null
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/java/org/wso2/carbon/device/application/mgt/api/util/ApiOriginFilter.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2016, 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.util;
+
+import javax.servlet.*;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+public class ApiOriginFilter implements Filter {
+
+ public void doFilter(ServletRequest request, ServletResponse response,
+ FilterChain chain) throws IOException, ServletException {
+ HttpServletResponse res = (HttpServletResponse) response;
+ res.addHeader("Access-Control-Allow-Origin", "*");
+ res.addHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
+ res.addHeader("Access-Control-Allow-Headers", "Content-Type");
+ chain.doFilter(request, response);
+ }
+
+ public void destroy() {
+ //do nothing
+ }
+
+ public void init(FilterConfig filterConfig) throws ServletException {
+ //do nothing
+ }
+
+}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/META-INF/permissions.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/META-INF/permissions.xml
index 1b99f2dc8d2..2ea4cb20185 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/META-INF/permissions.xml
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/META-INF/permissions.xml
@@ -31,4 +31,16 @@
+
+ Get Application
+ /device-mgt/application/get
+ /application-mgt/applications
+ GET
+
+
+ Create Application
+ /device-mgt/application/create
+ /application-mgt/applications
+ POST
+
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml
index 57b99b85863..b3fcf91262d 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml
@@ -32,7 +32,10 @@ http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
-
+
+
+
+
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/WEB-INF/web.xml b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/WEB-INF/web.xml
index db708d84b9e..a3bf334047c 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/WEB-INF/web.xml
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.api/src/main/webapp/WEB-INF/web.xml
@@ -37,7 +37,7 @@
doAuthentication
- false
+ true
@@ -55,20 +55,8 @@
- CorsFilter
- org.apache.catalina.filters.CorsFilter
-
- cors.allowed.origins
- *
-
-
- cors.allowed.methods
- GET,POST,DELETE,PUT
-
-
- cors.allowed.headers
- Content-Type
-
+ ApiOriginFilter
+ org.wso2.carbon.device.application.mgt.api.util.ApiOriginFilter
@@ -108,7 +96,7 @@
- CorsFilter
+ ApiOriginFilter
/*
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 71a304fb969..f07259f36f5 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
@@ -25,6 +25,9 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
+/**
+ * Application represents the an Application in Application Store
+ */
public class Application {
@Exclude
@@ -70,7 +73,7 @@ public class Application {
private Visibility visibility;
- private User user;
+ private ApplicationUser user;
public int getId() {
return id;
@@ -240,11 +243,11 @@ public class Application {
this.visibility = visibility;
}
- public User getUser() {
+ public ApplicationUser getUser() {
return user;
}
- public void setUser(User user) {
+ public void setUser(ApplicationUser user) {
this.user = user;
}
}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationList.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationList.java
index 6b01563899b..74f48c62147 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationList.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationList.java
@@ -20,6 +20,9 @@ package org.wso2.carbon.device.application.mgt.common;
import java.util.List;
+/**
+ * Represents a list of {@link Application}.
+ */
public class ApplicationList {
private List applications;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationRelease.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationRelease.java
index a1cedc98825..e78d3e8926a 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationRelease.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationRelease.java
@@ -21,6 +21,9 @@ package org.wso2.carbon.device.application.mgt.common;
import java.util.Date;
import java.util.Map;
+/**
+ * This class holds the details when releasing an Application to application store.
+ */
public class ApplicationRelease {
private enum Channel {
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/User.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationUser.java
similarity index 80%
rename from components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/User.java
rename to components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationUser.java
index 2a8fd8224ea..898f9ec9eee 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/User.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/ApplicationUser.java
@@ -18,13 +18,16 @@
*/
package org.wso2.carbon.device.application.mgt.common;
-public class User {
+/**
+ * Represents an user of {@link Application}.
+ */
+public class ApplicationUser {
private String userName;
private int tenantId;
- public User(String userName, int tenantId) {
+ public ApplicationUser(String userName, int tenantId) {
this.userName = userName;
this.tenantId = tenantId;
}
@@ -44,4 +47,9 @@ public class User {
public void setTenantId(int tenantId) {
this.tenantId = tenantId;
}
+
+ @Override
+ public String toString() {
+ return "ApplicationUser-name : " + userName + "\t Tenant-ID : " + tenantId;
+ }
}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Category.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Category.java
index b0c0fbdf32b..f4fc5a0721e 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Category.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Category.java
@@ -18,8 +18,9 @@
*/
package org.wso2.carbon.device.application.mgt.common;
-import org.wso2.carbon.device.application.mgt.common.jaxrs.Exclude;
-
+/**
+ * Represents the category a particular {@link Application} belongs to.
+ */
public class Category {
private int id;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Comment.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Comment.java
index bde08834915..6d6d61cdefa 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Comment.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Comment.java
@@ -18,6 +18,9 @@
*/
package org.wso2.carbon.device.application.mgt.common;
+/**
+ * Represents a comment for an {@link Application}.
+ */
public class Comment {
private String id;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Filter.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Filter.java
index 5a83306ea0b..1834d9c83fd 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Filter.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Filter.java
@@ -19,10 +19,15 @@
package org.wso2.carbon.device.application.mgt.common;
import java.util.List;
-import java.util.Map;
+/**
+ * Filter represents a criteria that can be used for searching applications.
+ */
public class Filter {
+ /**
+ * Order which the search results should be shown. Ascending or Descending.
+ */
public enum SortingOrder {
ASC, DESC
}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/FilterProperty.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/FilterProperty.java
index f9dfece8d6a..49d6f2d83fa 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/FilterProperty.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/FilterProperty.java
@@ -19,8 +19,15 @@
package org.wso2.carbon.device.application.mgt.common;
//TODO
+
+/**
+ * FilterProperty defines the property that can be used to filter the Application.
+ */
public class FilterProperty {
+ /**
+ * Operators that can be used in search.
+ */
public enum Operator {
EQUALS ("="),
GRATER_THAN (">"),
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Lifecycle.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Lifecycle.java
index 3db7d20e88d..bf365e8488b 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Lifecycle.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Lifecycle.java
@@ -19,6 +19,9 @@ package org.wso2.carbon.device.application.mgt.common;
import java.util.Date;
+/**
+ * Represents an lifecycle of an {@link Application}.
+ */
public class Lifecycle {
private LifecycleState lifecycleState;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/LifecycleState.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/LifecycleState.java
index 0f74a8f829e..337ca3bbe1d 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/LifecycleState.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/LifecycleState.java
@@ -18,6 +18,9 @@
*/
package org.wso2.carbon.device.application.mgt.common;
+/**
+ * Represents a state in {@link Lifecycle}.
+ */
public class LifecycleState {
private int id;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Pagination.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Pagination.java
index a21a9915cf7..69164a55451 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Pagination.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Pagination.java
@@ -18,6 +18,9 @@
*/
package org.wso2.carbon.device.application.mgt.common;
+/**
+ * This class represents the pagination details that will be used when fetching application details from database.
+ */
public class Pagination {
private int offset;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Payment.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Payment.java
index e73802df1ca..bbb96fbb306 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Payment.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Payment.java
@@ -17,6 +17,9 @@
*/
package org.wso2.carbon.device.application.mgt.common;
+/**
+ * Represents the payment related information for the {@link Application}.
+ */
public class Payment {
private boolean freeApp;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Platform.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Platform.java
index eadae94bcc1..af7dc7133e8 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Platform.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Platform.java
@@ -23,6 +23,9 @@ import org.wso2.carbon.device.application.mgt.common.jaxrs.Exclude;
import java.util.ArrayList;
import java.util.List;
+/**
+ * Represents the platform of an {@link Application}.
+ */
public class Platform {
/**
@@ -175,6 +178,9 @@ public class Platform {
return !(name == null || identifier == null);
}
+ /**
+ * Represents a property of a {@link Platform}.
+ */
public static class Property implements Cloneable {
private String name;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Subscription.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Subscription.java
index 75c3fc57fa3..42d942664d2 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Subscription.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Subscription.java
@@ -20,6 +20,9 @@ package org.wso2.carbon.device.application.mgt.common;
import java.util.Date;
+/**
+ * Represents subscription of an {@link Application}
+ */
public class Subscription {
private Visibility.Type type;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Visibility.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Visibility.java
index 20ea959353c..e8d361d5b85 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Visibility.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/Visibility.java
@@ -18,7 +18,9 @@
*/
package org.wso2.carbon.device.application.mgt.common;
-//TODO: move to app
+/**
+ * This class represents the visibility details of an Application.
+ */
public class Visibility {
private Type type;
@@ -61,6 +63,9 @@ public class Visibility {
this.applicationRelease = applicationRelease;
}
+ /**
+ * Type of the visibility of the application.
+ */
public class Type {
private String id;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/ApplicationManagementException.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/ApplicationManagementException.java
index 723e3a07a21..f6c6a9e7458 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/ApplicationManagementException.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/ApplicationManagementException.java
@@ -18,16 +18,18 @@
*/
package org.wso2.carbon.device.application.mgt.common.exception;
+/**
+ * Represents the exception thrown during application management.
+ */
public abstract class ApplicationManagementException extends Exception {
+ private String message;
- String message;
-
- public ApplicationManagementException(String message, Throwable throwable){
+ public ApplicationManagementException(String message, Throwable throwable) {
super(message, throwable);
setMessage(message);
}
- public ApplicationManagementException(String message){
+ public ApplicationManagementException(String message) {
super(message);
setMessage(message);
}
@@ -35,6 +37,7 @@ public abstract class ApplicationManagementException extends Exception {
public ApplicationManagementException() {
}
+
@Override
public String getMessage() {
return message;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/DBConnectionException.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/DBConnectionException.java
index da22385c94d..2532bbea696 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/DBConnectionException.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/DBConnectionException.java
@@ -17,6 +17,9 @@
*/
package org.wso2.carbon.device.application.mgt.common.exception;
+/**
+ * Exception thrown due to Database Connection issues.
+ */
public class DBConnectionException extends ApplicationManagementException {
private static final long serialVersionUID = -3151279331929070297L;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/IllegalTransactionStateException.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/IllegalTransactionStateException.java
index b0550fd2d8d..90f4121b691 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/IllegalTransactionStateException.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/IllegalTransactionStateException.java
@@ -17,6 +17,9 @@
*/
package org.wso2.carbon.device.application.mgt.common.exception;
+/**
+ * Exception thrown due to an issue in database transactions.
+ */
public class IllegalTransactionStateException extends RuntimeException {
private static final long serialVersionUID = -3151279331929070297L;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/InvalidConfigurationException.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/InvalidConfigurationException.java
index 2a8f9aca42c..b8f1adb0837 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/InvalidConfigurationException.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/InvalidConfigurationException.java
@@ -17,6 +17,9 @@
*/
package org.wso2.carbon.device.application.mgt.common.exception;
+/**
+ * Exception thrown due to invalid configurations provided for Application Management.
+ */
public class InvalidConfigurationException extends ApplicationManagementException {
public InvalidConfigurationException(String message, Throwable throwable) {
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/PlatformManagementException.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/PlatformManagementException.java
index b7daea0c29c..de76af02e0e 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/PlatformManagementException.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/PlatformManagementException.java
@@ -17,6 +17,9 @@
*/
package org.wso2.carbon.device.application.mgt.common.exception;
+/**
+ * Exception caused during the platform management.
+ */
public class PlatformManagementException extends ApplicationManagementException {
public PlatformManagementException(String message, Throwable ex) {
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/TransactionManagementException.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/TransactionManagementException.java
index 584f6fa045c..71fc6d68c81 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/TransactionManagementException.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/exception/TransactionManagementException.java
@@ -17,6 +17,9 @@
*/
package org.wso2.carbon.device.application.mgt.common.exception;
+/**
+ * Exception thrown due to an issue in TransactionManagement of Database.
+ */
public class TransactionManagementException extends ApplicationManagementException {
private static final long serialVersionUID = -3151279321929070297L;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/jaxrs/AnnotationExclusionStrategy.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/jaxrs/AnnotationExclusionStrategy.java
index c2f151b5521..3b35a8aeacd 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/jaxrs/AnnotationExclusionStrategy.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/jaxrs/AnnotationExclusionStrategy.java
@@ -21,6 +21,9 @@ package org.wso2.carbon.device.application.mgt.common.jaxrs;
import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
+/**
+ * This class is used to exclude certain fields when serializing and de-serializing based on the annotation.
+ */
public class AnnotationExclusionStrategy implements ExclusionStrategy {
@Override
@@ -32,4 +35,4 @@ public class AnnotationExclusionStrategy implements ExclusionStrategy {
public boolean shouldSkipClass(Class> clazz) {
return false;
}
-}
\ No newline at end of file
+}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/jaxrs/Exclude.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/jaxrs/Exclude.java
index 2f36acb4c87..81ed5ae202d 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/jaxrs/Exclude.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/jaxrs/Exclude.java
@@ -23,7 +23,10 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+/**
+ * This class is the representation of custom developed Exclude annotation.
+ */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Exclude {
-}
\ No newline at end of file
+}
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 7fbcb9a1c39..5dc5e271a3d 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
@@ -19,17 +19,43 @@
package org.wso2.carbon.device.application.mgt.common.services;
import org.wso2.carbon.device.application.mgt.common.Application;
-import org.wso2.carbon.device.application.mgt.common.Filter;
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.exception.ApplicationManagementException;
-public interface ApplicationManager{
+/**
+ * This interface manages the application creation, deletion and editing of the application.
+ */
+public interface ApplicationManager {
- public Application createApplication(Application application) throws ApplicationManagementException;
+ /**
+ * Creates an application.
+ * @param application Application that need to be created.
+ * @return Created application
+ * @throws ApplicationManagementException Application Management Exception
+ */
+ public Application createApplication(Application application) throws ApplicationManagementException;
- public Application editApplication(Application application) throws ApplicationManagementException;
+ /**
+ * Updates an already existing application.
+ * @param application Application that need to be updated.
+ * @return Updated Application
+ * @throws ApplicationManagementException Application Management Exception
+ */
+ public Application editApplication(Application application) throws ApplicationManagementException;
- public void deleteApplication(int uuid) throws ApplicationManagementException;
+ /**
+ * Delete an application identified by the unique ID.
+ * @param uuid Unique ID for tha application
+ * @throws ApplicationManagementException Application Management Exception
+ */
+ public void deleteApplication(int uuid) throws ApplicationManagementException;
- public ApplicationList getApplications(Filter filter) throws ApplicationManagementException;
+ /**
+ * To get the applications based on the search filter.
+ * @param filter Search filter
+ * @return Applications that matches the given filter criteria.
+ * @throws ApplicationManagementException Application Management Exception
+ */
+ public ApplicationList getApplications(Filter filter) 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 7760d6205e5..129404c8218 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
@@ -18,11 +18,12 @@
*/
package org.wso2.carbon.device.application.mgt.common.services;
-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.exception.ApplicationManagementException;
-
-public interface ApplicationReleaseManager{
+/**
+ * ApplicationReleaseManager is responsible for handling all the operations related with
+ * {@link org.wso2.carbon.device.application.mgt.common.ApplicationRelease} which involving addition, updation ,
+ * deletion and viewing.
+ *
+ */
+public interface ApplicationReleaseManager {
}
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
index 027a87dfbf6..997342bd5a6 100644
--- 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
@@ -18,6 +18,9 @@
*/
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.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/CategoryManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/CategoryManager.java
index 32082c865bb..824ac9ca426 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/CategoryManager.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/CategoryManager.java
@@ -18,13 +18,14 @@
*/
package org.wso2.carbon.device.application.mgt.common.services;
-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.Category;
import org.wso2.carbon.device.application.mgt.common.Filter;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
-public interface CategoryManager{
+/**
+ * CategoryManager is responsible for handling add, delete, update opertaions related with {@link Category}
+ */
+public interface CategoryManager {
public Category createCategory(Category application) 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/CommentsManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/CommentsManager.java
index 02403a03a64..b0e0f4bd822 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/CommentsManager.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/CommentsManager.java
@@ -18,5 +18,9 @@
*/
package org.wso2.carbon.device.application.mgt.common.services;
-public interface CommentsManager{
+/**
+ * CommentsManager is responsible for handling all the add/update/delete/get operations related with
+ * {@link org.wso2.carbon.device.application.mgt.common.Comment}.
+ */
+public interface CommentsManager {
}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/LifecycleStateManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/LifecycleStateManager.java
index 36e772f7e8d..fa3bb75a69a 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/LifecycleStateManager.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/LifecycleStateManager.java
@@ -18,6 +18,9 @@
*/
package org.wso2.carbon.device.application.mgt.common.services;
+/**
+ * This interface manages all the operations related with lifecycle state.
+ */
public interface LifecycleStateManager {
}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/PlatformManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/PlatformManager.java
index 8c228c8bfd4..ca2fc379a9a 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/PlatformManager.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/PlatformManager.java
@@ -25,7 +25,7 @@ import java.util.List;
/**
* Platform manager is responsible for handling platforms, which will be used to as a registry of platforms.
- * And will be able to provide the platforms related informations to other classes which requires.
+ * And will be able to provide the platforms related information to other classes which requires.
*/
public interface PlatformManager {
@@ -37,9 +37,11 @@ public interface PlatformManager {
void register(String tenantDomain, Platform platform) throws PlatformManagementException;
- void update(String tenantDomain, String oldPlatformIdentifier, Platform platform) throws PlatformManagementException;
+ void update(String tenantDomain, String oldPlatformIdentifier, Platform platform)
+ throws PlatformManagementException;
- void unregister(String tenantDomain, String platformIdentifier, boolean isFileBased) throws PlatformManagementException;
+ void unregister(String tenantDomain, String platformIdentifier, boolean isFileBased)
+ throws PlatformManagementException;
void addMapping(String tenantDomain, List platformIdentifiers) throws PlatformManagementException;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java
index 1067c3bcb9c..3babe0f8147 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/SubscriptionManager.java
@@ -18,5 +18,8 @@
*/
package org.wso2.carbon.device.application.mgt.common.services;
+/**
+ * This interface manages all the operations related with Application Subscription.
+ */
public interface SubscriptionManager {
}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/VisibilityManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/VisibilityManager.java
index c45fbe3c47f..3e22b6f4de3 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/VisibilityManager.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/VisibilityManager.java
@@ -18,6 +18,9 @@
package org.wso2.carbon.device.application.mgt.common.services;
+/**
+ * This interface manages all the operations related with Application Visibility.
+ */
public interface VisibilityManager {
}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/VisibilityTypeManager.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/VisibilityTypeManager.java
index 5584cbd8f46..83018ad1d48 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/VisibilityTypeManager.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.common/src/main/java/org/wso2/carbon/device/application/mgt/common/services/VisibilityTypeManager.java
@@ -18,5 +18,9 @@
*/
package org.wso2.carbon.device.application.mgt.common.services;
+/**
+ * VisibilityTypeManager is responsible for handling all the operations related to VisibilityType, this includes
+ * creating, updating and viewing the {@link org.wso2.carbon.device.application.mgt.common.Visibility.Type}
+ */
public interface VisibilityTypeManager {
}
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/MySQLApplicationDAOImpl.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/MySQLApplicationDAOImpl.java
index 90cf14b8da6..c7bca776d7d 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/MySQLApplicationDAOImpl.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/dao/impl/application/MySQLApplicationDAOImpl.java
@@ -335,7 +335,12 @@ public class MySQLApplicationDAOImpl extends AbstractApplicationDAOImpl {
@Override
public Application createApplication(Application application) throws ApplicationManagementDAOException {
-
+ if (log.isDebugEnabled()) {
+ log.debug("Request received in DAO Layer to create an application");
+ log.debug("Application Details : ");
+ log.debug("UUID : " + application.getUuid() + " Name : " + application.getName() + " User name : " +
+ application.getUser().getUserName());
+ }
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/deployer/Property.java b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/deployer/Property.java
index 4290253fb78..2b017daf3cb 100644
--- a/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/deployer/Property.java
+++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.core/src/main/java/org/wso2/carbon/device/application/mgt/core/deployer/Property.java
@@ -21,6 +21,9 @@ import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlValue;
+/**
+ * Represents a property of the {@link Platform}.
+ */
@XmlRootElement(name = "Property")
public class Property {
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 e75ebaae061..43fd7dd9318 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
@@ -18,6 +18,8 @@
*/
package org.wso2.carbon.device.application.mgt.core.impl;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.device.application.mgt.common.*;
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
@@ -34,33 +36,37 @@ import org.wso2.carbon.device.application.mgt.core.util.HelperUtil;
import java.util.Date;
public class ApplicationManagerImpl implements ApplicationManager {
-
-
public static final String CREATED = "created";
+ private static Log log = LogFactory.getLog(ApplicationManagerImpl.class);
@Override
public Application createApplication(Application application) throws ApplicationManagementException {
-
validateApplication(application, false);
try {
ConnectionManagerUtil.openConnection();
ApplicationDAO applicationDAO = DAOFactory.getApplicationDAO();
-
application.setUuid(HelperUtil.generateApplicationUuid());
-
application.setCreatedAt(new Date());
application.setModifiedAt(new Date());
+ if (log.isDebugEnabled()) {
+ log.debug("Creating Application " + application.getName() + " with UUID " + application.getUuid());
+ }
LifecycleStateDAO lifecycleStateDAO = DAOFactory.getLifecycleStateDAO();
LifecycleState lifecycleState = lifecycleStateDAO.getLifeCycleStateByIdentifier(CREATED);
if (lifecycleState == null) {
- throw new NotFoundException("Invalid lifecycle state.");
+ throw new NotFoundException("Invalid lifecycle state. There is no lifecycle state connected with "
+ + "'CREATED'");
}
+ if (log.isDebugEnabled()) {
+ log.debug("Life cycle state of the application " + application.getName() + " set as name - " +
+ lifecycleState.getName() + " id - " + lifecycleState.getId() + " identifier - " +
+ lifecycleState.getIdentifier());
+ }
Lifecycle lifecycle = new Lifecycle();
lifecycle.setLifecycleState(lifecycleState);
- lifecycle.setLifecycleState(lifecycleState);
lifecycle.setLifecycleStateModifiedAt(new Date());
lifecycle.setGetLifecycleStateModifiedBy(application.getUser().getUserName());
application.setCurrentLifecycle(lifecycle);
@@ -68,10 +74,14 @@ public class ApplicationManagerImpl implements ApplicationManager {
PlatformDAO platformDAO = DAOFactory.getPlatformDAO();
Platform platform = platformDAO.getPlatform(application.getUser().getTenantId(), application.getPlatform().getIdentifier());
if (platform == null) {
- throw new NotFoundException("Invalid platform");
+ throw new NotFoundException("Invalid platform. No platform details found for " + application
+ .getPlatform().getName());
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Application '" + application.getName() + "' platform is set to (platform name , platform "
+ + "id)- ( " + platform.getName() + ", " + platform.getIdentifier() + ", " + platform.getId());
}
application.setPlatform(platform);
-
return applicationDAO.createApplication(application);
} finally {
ConnectionManagerUtil.closeConnection();
diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml
index e8446736c55..3bdbff11801 100644
--- a/components/application-mgt/pom.xml
+++ b/components/application-mgt/pom.xml
@@ -43,6 +43,12 @@
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+
+
@@ -62,4 +68,5 @@
+
diff --git a/pom.xml b/pom.xml
index a4431f1d00e..287f537f006 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1748,6 +1748,33 @@
carbon-p2-plugin
${carbon.p2.plugin.version}
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+ ${maven.checkstyle.plugin.version}
+
+
+ validate
+ validate
+
+
+ https://raw.githubusercontent.com/wso2/code-quality-tools/master/checkstyle/checkstyle.xml
+
+
+ https://raw.githubusercontent.com/wso2/code-quality-tools/master/checkstyle/suppressions.xml
+
+ UTF-8
+ true
+ false
+ false
+ true
+
+
+ check
+
+
+
+
@@ -2026,6 +2053,11 @@
(1.9,2.0]
3.12.1.GA
true
+
+
+
+ 2.17
+ 3.0.3