mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Adding Maven Code style check
This commit is contained in:
parent
f3bca0f88c
commit
4140e212d7
@ -36,13 +36,6 @@
|
|||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<source>1.7</source>
|
|
||||||
<target>1.7</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
@ -132,6 +125,10 @@
|
|||||||
<groupId>org.codehaus.jackson</groupId>
|
<groupId>org.codehaus.jackson</groupId>
|
||||||
<artifactId>jackson-jaxrs</artifactId>
|
<artifactId>jackson-jaxrs</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.codehaus.jackson</groupId>
|
||||||
|
<artifactId>jackson-core-asl</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.ws.rs</groupId>
|
<groupId>javax.ws.rs</groupId>
|
||||||
<artifactId>jsr311-api</artifactId>
|
<artifactId>jsr311-api</artifactId>
|
||||||
@ -228,5 +225,6 @@
|
|||||||
<groupId>javax.ws.rs</groupId>
|
<groupId>javax.ws.rs</groupId>
|
||||||
<artifactId>javax.ws.rs-api</artifactId>
|
<artifactId>javax.ws.rs-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
@ -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
|
|
||||||
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -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);
|
||||||
|
|
||||||
|
}
|
||||||
@ -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.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
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.exception.ApplicationManagementException;
|
||||||
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
|
import org.wso2.carbon.device.application.mgt.common.services.ApplicationManager;
|
||||||
import org.wso2.carbon.device.application.mgt.api.APIUtil;
|
import org.wso2.carbon.device.application.mgt.api.APIUtil;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
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 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";
|
public static final String APPLICATION_UPLOAD_EXTENSION = "ApplicationUploadExtension";
|
||||||
|
private static Log log = LogFactory.getLog(ApplicationManagementServiceImpl.class);
|
||||||
private static Log log = LogFactory.getLog(ApplicationManagementAPIImpl.class);
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Consumes("application/json")
|
@Override
|
||||||
@Path("applications")
|
public Response getApplications(@HeaderParam("If-Modified-Since") String ifModifiedSince,
|
||||||
public Response getApplications(@QueryParam("offset") int offset, @QueryParam("limit") int limit,
|
@QueryParam("offset") int offset, @QueryParam("limit") int limit, @QueryParam("query") String searchQuery) {
|
||||||
@QueryParam("query") String searchQuery) {
|
|
||||||
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Received a query for getting applications : offset - " + offset + " limit - " + limit + " "
|
||||||
|
+ "searchQuery - " + searchQuery);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (limit == 0) {
|
if (limit == 0) {
|
||||||
limit = DEFAULT_LIMIT;
|
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 filter = new Filter();
|
||||||
filter.setOffset(offset);
|
filter.setOffset(offset);
|
||||||
filter.setLimit(limit);
|
filter.setLimit(limit);
|
||||||
filter.setSearchQuery(searchQuery);
|
filter.setSearchQuery(searchQuery);
|
||||||
|
|
||||||
ApplicationList applications = applicationManager.getApplications(filter);
|
ApplicationList applications = applicationManager.getApplications(filter);
|
||||||
return Response.status(Response.Status.OK).entity(applications).build();
|
return Response.status(Response.Status.OK).entity(applications).build();
|
||||||
} catch (ApplicationManagementException e) {
|
} catch (ApplicationManagementException e) {
|
||||||
String msg = "Error occurred while getting the application list";
|
String msg = "Error occurred while getting the application list";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
return Response.status(Response.Status.NOT_FOUND).build();
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Consumes("application/json")
|
@Consumes("application/json")
|
||||||
@Path("applications")
|
|
||||||
public Response createApplication(@Valid Application application) {
|
public Response createApplication(@Valid Application application) {
|
||||||
|
|
||||||
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
||||||
|
|
||||||
//TODO : Get username and tenantId
|
//TODO : Get username and tenantId
|
||||||
User user = new User("admin", -1234);
|
ApplicationUser applicationUser = new ApplicationUser(PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername(),
|
||||||
application.setUser(user);
|
PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId(true));
|
||||||
|
application.setUser(applicationUser);
|
||||||
|
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Create Application request received from the user : " + applicationUser.toString());
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
application = applicationManager.createApplication(application);
|
application = applicationManager.createApplication(application);
|
||||||
|
|
||||||
} catch (ApplicationManagementException e) {
|
} catch (ApplicationManagementException e) {
|
||||||
String msg = "Error occurred while creating the application";
|
String msg = "Error occurred while creating the application";
|
||||||
log.error(msg, e);
|
log.error(msg, e);
|
||||||
return Response.status(Response.Status.BAD_REQUEST).build();
|
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
|
@PUT
|
||||||
@Consumes("application/json")
|
@Consumes("application/json")
|
||||||
@Path("applications")
|
@Path("applications")
|
||||||
public Response editApplication(@Valid Application application) {
|
public Response editApplication(@Valid Application application) {
|
||||||
|
|
||||||
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
ApplicationManager applicationManager = APIUtil.getApplicationManager();
|
||||||
|
|
||||||
//TODO : Get username and tenantId
|
//TODO : Get username and tenantId
|
||||||
User user = new User("admin", -1234);
|
ApplicationUser user = new ApplicationUser("admin", -1234);
|
||||||
application.setUser(user);
|
application.setUser(user);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -108,5 +120,5 @@ public class ApplicationManagementAPIImpl {
|
|||||||
}
|
}
|
||||||
return Response.status(Response.Status.OK).entity(application).build();
|
return Response.status(Response.Status.OK).entity(application).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -31,4 +31,16 @@
|
|||||||
<APIVersion></APIVersion>
|
<APIVersion></APIVersion>
|
||||||
<!--Permission Tree Name-->
|
<!--Permission Tree Name-->
|
||||||
<!--End of Permission Tree-->
|
<!--End of Permission Tree-->
|
||||||
|
<Permission>
|
||||||
|
<name>Get Application</name>
|
||||||
|
<path>/device-mgt/application/get</path>
|
||||||
|
<url>/application-mgt/applications</url>
|
||||||
|
<method>GET</method>
|
||||||
|
</Permission>
|
||||||
|
<Permission>
|
||||||
|
<name>Create Application</name>
|
||||||
|
<path>/device-mgt/application/create</path>
|
||||||
|
<url>/application-mgt/applications</url>
|
||||||
|
<method>POST</method>
|
||||||
|
</Permission>
|
||||||
</PermissionConfiguration>
|
</PermissionConfiguration>
|
||||||
|
|||||||
@ -32,7 +32,10 @@ http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
|
|||||||
</jaxrs:providers>
|
</jaxrs:providers>
|
||||||
</jaxrs:server>
|
</jaxrs:server>
|
||||||
|
|
||||||
<bean id="applicationMgtServiceBean" class="org.wso2.carbon.device.application.mgt.api.services.impl.ApplicationManagementAPIImpl"/>
|
<bean id="applicationMgtServiceBean" class="org.wso2.carbon.device.application.mgt.api.services.impl.ApplicationManagementServiceImpl"/>
|
||||||
|
<!--<bean id="platformManagementAPIBean" class="org.wso2.carbon.device.application.mgt.api.services.impl.PlatformManagementAPIImpl" />-->
|
||||||
<bean id="jsonProvider" class="org.wso2.carbon.device.application.mgt.api.JSONMessageHandler"/>
|
<bean id="jsonProvider" class="org.wso2.carbon.device.application.mgt.api.JSONMessageHandler"/>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -37,7 +37,7 @@
|
|||||||
</session-config>
|
</session-config>
|
||||||
<context-param>
|
<context-param>
|
||||||
<param-name>doAuthentication</param-name>
|
<param-name>doAuthentication</param-name>
|
||||||
<param-value>false</param-value>
|
<param-value>true</param-value>
|
||||||
</context-param>
|
</context-param>
|
||||||
|
|
||||||
<!--publish to apim-->
|
<!--publish to apim-->
|
||||||
@ -55,20 +55,8 @@
|
|||||||
</context-param>
|
</context-param>
|
||||||
|
|
||||||
<filter>
|
<filter>
|
||||||
<filter-name>CorsFilter</filter-name>
|
<filter-name>ApiOriginFilter</filter-name>
|
||||||
<filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
|
<filter-class>org.wso2.carbon.device.application.mgt.api.util.ApiOriginFilter</filter-class>
|
||||||
<init-param>
|
|
||||||
<param-name>cors.allowed.origins</param-name>
|
|
||||||
<param-value>*</param-value>
|
|
||||||
</init-param>
|
|
||||||
<init-param>
|
|
||||||
<param-name>cors.allowed.methods</param-name>
|
|
||||||
<param-value>GET,POST,DELETE,PUT</param-value>
|
|
||||||
</init-param>
|
|
||||||
<init-param>
|
|
||||||
<param-name>cors.allowed.headers</param-name>
|
|
||||||
<param-value>Content-Type</param-value>
|
|
||||||
</init-param>
|
|
||||||
</filter>
|
</filter>
|
||||||
|
|
||||||
<filter>
|
<filter>
|
||||||
@ -108,7 +96,7 @@
|
|||||||
</filter-mapping>
|
</filter-mapping>
|
||||||
|
|
||||||
<filter-mapping>
|
<filter-mapping>
|
||||||
<filter-name>CorsFilter</filter-name>
|
<filter-name>ApiOriginFilter</filter-name>
|
||||||
<url-pattern>/*</url-pattern>
|
<url-pattern>/*</url-pattern>
|
||||||
</filter-mapping>
|
</filter-mapping>
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,9 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Application represents the an Application in Application Store
|
||||||
|
*/
|
||||||
public class Application {
|
public class Application {
|
||||||
|
|
||||||
@Exclude
|
@Exclude
|
||||||
@ -70,7 +73,7 @@ public class Application {
|
|||||||
|
|
||||||
private Visibility visibility;
|
private Visibility visibility;
|
||||||
|
|
||||||
private User user;
|
private ApplicationUser user;
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
@ -240,11 +243,11 @@ public class Application {
|
|||||||
this.visibility = visibility;
|
this.visibility = visibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
public User getUser() {
|
public ApplicationUser getUser() {
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUser(User user) {
|
public void setUser(ApplicationUser user) {
|
||||||
this.user = user;
|
this.user = user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,6 +20,9 @@ package org.wso2.carbon.device.application.mgt.common;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a list of {@link Application}.
|
||||||
|
*/
|
||||||
public class ApplicationList {
|
public class ApplicationList {
|
||||||
|
|
||||||
private List<Application> applications;
|
private List<Application> applications;
|
||||||
|
|||||||
@ -21,6 +21,9 @@ package org.wso2.carbon.device.application.mgt.common;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class holds the details when releasing an Application to application store.
|
||||||
|
*/
|
||||||
public class ApplicationRelease {
|
public class ApplicationRelease {
|
||||||
|
|
||||||
private enum Channel {
|
private enum Channel {
|
||||||
|
|||||||
@ -18,13 +18,16 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.application.mgt.common;
|
package org.wso2.carbon.device.application.mgt.common;
|
||||||
|
|
||||||
public class User {
|
/**
|
||||||
|
* Represents an user of {@link Application}.
|
||||||
|
*/
|
||||||
|
public class ApplicationUser {
|
||||||
|
|
||||||
private String userName;
|
private String userName;
|
||||||
|
|
||||||
private int tenantId;
|
private int tenantId;
|
||||||
|
|
||||||
public User(String userName, int tenantId) {
|
public ApplicationUser(String userName, int tenantId) {
|
||||||
this.userName = userName;
|
this.userName = userName;
|
||||||
this.tenantId = tenantId;
|
this.tenantId = tenantId;
|
||||||
}
|
}
|
||||||
@ -44,4 +47,9 @@ public class User {
|
|||||||
public void setTenantId(int tenantId) {
|
public void setTenantId(int tenantId) {
|
||||||
this.tenantId = tenantId;
|
this.tenantId = tenantId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ApplicationUser-name : " + userName + "\t Tenant-ID : " + tenantId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -18,8 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.application.mgt.common;
|
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 {
|
public class Category {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
|
|||||||
@ -18,6 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.application.mgt.common;
|
package org.wso2.carbon.device.application.mgt.common;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a comment for an {@link Application}.
|
||||||
|
*/
|
||||||
public class Comment {
|
public class Comment {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
|
|||||||
@ -19,10 +19,15 @@
|
|||||||
package org.wso2.carbon.device.application.mgt.common;
|
package org.wso2.carbon.device.application.mgt.common;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter represents a criteria that can be used for searching applications.
|
||||||
|
*/
|
||||||
public class Filter {
|
public class Filter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Order which the search results should be shown. Ascending or Descending.
|
||||||
|
*/
|
||||||
public enum SortingOrder {
|
public enum SortingOrder {
|
||||||
ASC, DESC
|
ASC, DESC
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,8 +19,15 @@
|
|||||||
package org.wso2.carbon.device.application.mgt.common;
|
package org.wso2.carbon.device.application.mgt.common;
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
|
|
||||||
|
/**
|
||||||
|
* FilterProperty defines the property that can be used to filter the Application.
|
||||||
|
*/
|
||||||
public class FilterProperty {
|
public class FilterProperty {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Operators that can be used in search.
|
||||||
|
*/
|
||||||
public enum Operator {
|
public enum Operator {
|
||||||
EQUALS ("="),
|
EQUALS ("="),
|
||||||
GRATER_THAN (">"),
|
GRATER_THAN (">"),
|
||||||
|
|||||||
@ -19,6 +19,9 @@ package org.wso2.carbon.device.application.mgt.common;
|
|||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an lifecycle of an {@link Application}.
|
||||||
|
*/
|
||||||
public class Lifecycle {
|
public class Lifecycle {
|
||||||
|
|
||||||
private LifecycleState lifecycleState;
|
private LifecycleState lifecycleState;
|
||||||
|
|||||||
@ -18,6 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.application.mgt.common;
|
package org.wso2.carbon.device.application.mgt.common;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a state in {@link Lifecycle}.
|
||||||
|
*/
|
||||||
public class LifecycleState {
|
public class LifecycleState {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
|
|||||||
@ -18,6 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.application.mgt.common;
|
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 {
|
public class Pagination {
|
||||||
|
|
||||||
private int offset;
|
private int offset;
|
||||||
|
|||||||
@ -17,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.application.mgt.common;
|
package org.wso2.carbon.device.application.mgt.common;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the payment related information for the {@link Application}.
|
||||||
|
*/
|
||||||
public class Payment {
|
public class Payment {
|
||||||
private boolean freeApp;
|
private boolean freeApp;
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,9 @@ import org.wso2.carbon.device.application.mgt.common.jaxrs.Exclude;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the platform of an {@link Application}.
|
||||||
|
*/
|
||||||
public class Platform {
|
public class Platform {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -175,6 +178,9 @@ public class Platform {
|
|||||||
return !(name == null || identifier == null);
|
return !(name == null || identifier == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a property of a {@link Platform}.
|
||||||
|
*/
|
||||||
public static class Property implements Cloneable {
|
public static class Property implements Cloneable {
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|||||||
@ -20,6 +20,9 @@ package org.wso2.carbon.device.application.mgt.common;
|
|||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents subscription of an {@link Application}
|
||||||
|
*/
|
||||||
public class Subscription {
|
public class Subscription {
|
||||||
|
|
||||||
private Visibility.Type type;
|
private Visibility.Type type;
|
||||||
|
|||||||
@ -18,7 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.application.mgt.common;
|
package org.wso2.carbon.device.application.mgt.common;
|
||||||
|
|
||||||
//TODO: move to app
|
/**
|
||||||
|
* This class represents the visibility details of an Application.
|
||||||
|
*/
|
||||||
public class Visibility {
|
public class Visibility {
|
||||||
|
|
||||||
private Type type;
|
private Type type;
|
||||||
@ -61,6 +63,9 @@ public class Visibility {
|
|||||||
this.applicationRelease = applicationRelease;
|
this.applicationRelease = applicationRelease;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type of the visibility of the application.
|
||||||
|
*/
|
||||||
public class Type {
|
public class Type {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
|
|||||||
@ -18,9 +18,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.application.mgt.common.exception;
|
package org.wso2.carbon.device.application.mgt.common.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents the exception thrown during application management.
|
||||||
|
*/
|
||||||
public abstract class ApplicationManagementException extends Exception {
|
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);
|
super(message, throwable);
|
||||||
@ -35,6 +37,7 @@ public abstract class ApplicationManagementException extends Exception {
|
|||||||
public ApplicationManagementException() {
|
public ApplicationManagementException() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return message;
|
return message;
|
||||||
|
|||||||
@ -17,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.application.mgt.common.exception;
|
package org.wso2.carbon.device.application.mgt.common.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception thrown due to Database Connection issues.
|
||||||
|
*/
|
||||||
public class DBConnectionException extends ApplicationManagementException {
|
public class DBConnectionException extends ApplicationManagementException {
|
||||||
|
|
||||||
private static final long serialVersionUID = -3151279331929070297L;
|
private static final long serialVersionUID = -3151279331929070297L;
|
||||||
|
|||||||
@ -17,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.application.mgt.common.exception;
|
package org.wso2.carbon.device.application.mgt.common.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception thrown due to an issue in database transactions.
|
||||||
|
*/
|
||||||
public class IllegalTransactionStateException extends RuntimeException {
|
public class IllegalTransactionStateException extends RuntimeException {
|
||||||
|
|
||||||
private static final long serialVersionUID = -3151279331929070297L;
|
private static final long serialVersionUID = -3151279331929070297L;
|
||||||
|
|||||||
@ -17,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.application.mgt.common.exception;
|
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 class InvalidConfigurationException extends ApplicationManagementException {
|
||||||
|
|
||||||
public InvalidConfigurationException(String message, Throwable throwable) {
|
public InvalidConfigurationException(String message, Throwable throwable) {
|
||||||
|
|||||||
@ -17,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.application.mgt.common.exception;
|
package org.wso2.carbon.device.application.mgt.common.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception caused during the platform management.
|
||||||
|
*/
|
||||||
public class PlatformManagementException extends ApplicationManagementException {
|
public class PlatformManagementException extends ApplicationManagementException {
|
||||||
|
|
||||||
public PlatformManagementException(String message, Throwable ex) {
|
public PlatformManagementException(String message, Throwable ex) {
|
||||||
|
|||||||
@ -17,6 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.application.mgt.common.exception;
|
package org.wso2.carbon.device.application.mgt.common.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exception thrown due to an issue in TransactionManagement of Database.
|
||||||
|
*/
|
||||||
public class TransactionManagementException extends ApplicationManagementException {
|
public class TransactionManagementException extends ApplicationManagementException {
|
||||||
|
|
||||||
private static final long serialVersionUID = -3151279321929070297L;
|
private static final long serialVersionUID = -3151279321929070297L;
|
||||||
|
|||||||
@ -21,6 +21,9 @@ package org.wso2.carbon.device.application.mgt.common.jaxrs;
|
|||||||
import com.google.gson.ExclusionStrategy;
|
import com.google.gson.ExclusionStrategy;
|
||||||
import com.google.gson.FieldAttributes;
|
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 {
|
public class AnnotationExclusionStrategy implements ExclusionStrategy {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -23,6 +23,9 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class is the representation of custom developed Exclude annotation.
|
||||||
|
*/
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(ElementType.FIELD)
|
@Target(ElementType.FIELD)
|
||||||
public @interface Exclude {
|
public @interface Exclude {
|
||||||
|
|||||||
@ -19,17 +19,43 @@
|
|||||||
package org.wso2.carbon.device.application.mgt.common.services;
|
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.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.ApplicationList;
|
||||||
|
import org.wso2.carbon.device.application.mgt.common.Filter;
|
||||||
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
|
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface manages the application creation, deletion and editing of the application.
|
||||||
|
*/
|
||||||
public interface ApplicationManager {
|
public interface ApplicationManager {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 createApplication(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 Application editApplication(Application application) 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 void deleteApplication(int uuid) 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;
|
public ApplicationList getApplications(Filter filter) throws ApplicationManagementException;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,11 +18,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.application.mgt.common.services;
|
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;
|
* ApplicationReleaseManager is responsible for handling all the operations related with
|
||||||
import org.wso2.carbon.device.application.mgt.common.Filter;
|
* {@link org.wso2.carbon.device.application.mgt.common.ApplicationRelease} which involving addition, updation ,
|
||||||
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
|
* deletion and viewing.
|
||||||
|
*
|
||||||
|
*/
|
||||||
public interface ApplicationReleaseManager {
|
public interface ApplicationReleaseManager {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.application.mgt.common.services;
|
package org.wso2.carbon.device.application.mgt.common.services;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface manages all the operations related with Application Upload.
|
||||||
|
*/
|
||||||
public interface ApplicationUploadManager {
|
public interface ApplicationUploadManager {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,12 +18,13 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.application.mgt.common.services;
|
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.Category;
|
||||||
import org.wso2.carbon.device.application.mgt.common.Filter;
|
import org.wso2.carbon.device.application.mgt.common.Filter;
|
||||||
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
|
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CategoryManager is responsible for handling add, delete, update opertaions related with {@link Category}
|
||||||
|
*/
|
||||||
public interface CategoryManager {
|
public interface CategoryManager {
|
||||||
|
|
||||||
public Category createCategory(Category application) throws ApplicationManagementException;
|
public Category createCategory(Category application) throws ApplicationManagementException;
|
||||||
|
|||||||
@ -18,5 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.application.mgt.common.services;
|
package org.wso2.carbon.device.application.mgt.common.services;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 {
|
public interface CommentsManager {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.application.mgt.common.services;
|
package org.wso2.carbon.device.application.mgt.common.services;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface manages all the operations related with lifecycle state.
|
||||||
|
*/
|
||||||
public interface LifecycleStateManager {
|
public interface LifecycleStateManager {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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.
|
* 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 {
|
public interface PlatformManager {
|
||||||
|
|
||||||
@ -37,9 +37,11 @@ public interface PlatformManager {
|
|||||||
|
|
||||||
void register(String tenantDomain, Platform platform) throws PlatformManagementException;
|
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<String> platformIdentifiers) throws PlatformManagementException;
|
void addMapping(String tenantDomain, List<String> platformIdentifiers) throws PlatformManagementException;
|
||||||
|
|
||||||
|
|||||||
@ -18,5 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.application.mgt.common.services;
|
package org.wso2.carbon.device.application.mgt.common.services;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface manages all the operations related with Application Subscription.
|
||||||
|
*/
|
||||||
public interface SubscriptionManager {
|
public interface SubscriptionManager {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,9 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.device.application.mgt.common.services;
|
package org.wso2.carbon.device.application.mgt.common.services;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface manages all the operations related with Application Visibility.
|
||||||
|
*/
|
||||||
public interface VisibilityManager {
|
public interface VisibilityManager {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,5 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.application.mgt.common.services;
|
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 {
|
public interface VisibilityTypeManager {
|
||||||
}
|
}
|
||||||
|
|||||||
@ -335,7 +335,12 @@ public class MySQLApplicationDAOImpl extends AbstractApplicationDAOImpl {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Application createApplication(Application application) throws ApplicationManagementDAOException {
|
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;
|
Connection conn = null;
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
|
|||||||
@ -21,6 +21,9 @@ import javax.xml.bind.annotation.XmlAttribute;
|
|||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
import javax.xml.bind.annotation.XmlValue;
|
import javax.xml.bind.annotation.XmlValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a property of the {@link Platform}.
|
||||||
|
*/
|
||||||
@XmlRootElement(name = "Property")
|
@XmlRootElement(name = "Property")
|
||||||
public class Property {
|
public class Property {
|
||||||
|
|
||||||
|
|||||||
@ -18,6 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.wso2.carbon.device.application.mgt.core.impl;
|
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.*;
|
||||||
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
|
import org.wso2.carbon.device.application.mgt.common.exception.ApplicationManagementException;
|
||||||
import org.wso2.carbon.device.application.mgt.common.exception.DBConnectionException;
|
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;
|
import java.util.Date;
|
||||||
|
|
||||||
public class ApplicationManagerImpl implements ApplicationManager {
|
public class ApplicationManagerImpl implements ApplicationManager {
|
||||||
|
|
||||||
|
|
||||||
public static final String CREATED = "created";
|
public static final String CREATED = "created";
|
||||||
|
private static Log log = LogFactory.getLog(ApplicationManagerImpl.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Application createApplication(Application application) throws ApplicationManagementException {
|
public Application createApplication(Application application) throws ApplicationManagementException {
|
||||||
|
|
||||||
validateApplication(application, false);
|
validateApplication(application, false);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ConnectionManagerUtil.openConnection();
|
ConnectionManagerUtil.openConnection();
|
||||||
ApplicationDAO applicationDAO = DAOFactory.getApplicationDAO();
|
ApplicationDAO applicationDAO = DAOFactory.getApplicationDAO();
|
||||||
|
|
||||||
application.setUuid(HelperUtil.generateApplicationUuid());
|
application.setUuid(HelperUtil.generateApplicationUuid());
|
||||||
|
|
||||||
application.setCreatedAt(new Date());
|
application.setCreatedAt(new Date());
|
||||||
application.setModifiedAt(new Date());
|
application.setModifiedAt(new Date());
|
||||||
|
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Creating Application " + application.getName() + " with UUID " + application.getUuid());
|
||||||
|
}
|
||||||
LifecycleStateDAO lifecycleStateDAO = DAOFactory.getLifecycleStateDAO();
|
LifecycleStateDAO lifecycleStateDAO = DAOFactory.getLifecycleStateDAO();
|
||||||
LifecycleState lifecycleState = lifecycleStateDAO.getLifeCycleStateByIdentifier(CREATED);
|
LifecycleState lifecycleState = lifecycleStateDAO.getLifeCycleStateByIdentifier(CREATED);
|
||||||
if (lifecycleState == null) {
|
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 lifecycle = new Lifecycle();
|
||||||
lifecycle.setLifecycleState(lifecycleState);
|
lifecycle.setLifecycleState(lifecycleState);
|
||||||
lifecycle.setLifecycleState(lifecycleState);
|
|
||||||
lifecycle.setLifecycleStateModifiedAt(new Date());
|
lifecycle.setLifecycleStateModifiedAt(new Date());
|
||||||
lifecycle.setGetLifecycleStateModifiedBy(application.getUser().getUserName());
|
lifecycle.setGetLifecycleStateModifiedBy(application.getUser().getUserName());
|
||||||
application.setCurrentLifecycle(lifecycle);
|
application.setCurrentLifecycle(lifecycle);
|
||||||
@ -68,10 +74,14 @@ public class ApplicationManagerImpl implements ApplicationManager {
|
|||||||
PlatformDAO platformDAO = DAOFactory.getPlatformDAO();
|
PlatformDAO platformDAO = DAOFactory.getPlatformDAO();
|
||||||
Platform platform = platformDAO.getPlatform(application.getUser().getTenantId(), application.getPlatform().getIdentifier());
|
Platform platform = platformDAO.getPlatform(application.getUser().getTenantId(), application.getPlatform().getIdentifier());
|
||||||
if (platform == null) {
|
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);
|
application.setPlatform(platform);
|
||||||
|
|
||||||
return applicationDAO.createApplication(application);
|
return applicationDAO.createApplication(application);
|
||||||
} finally {
|
} finally {
|
||||||
ConnectionManagerUtil.closeConnection();
|
ConnectionManagerUtil.closeConnection();
|
||||||
|
|||||||
@ -43,6 +43,12 @@
|
|||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
<pluginManagement>
|
<pluginManagement>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -62,4 +68,5 @@
|
|||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
32
pom.xml
32
pom.xml
@ -1748,6 +1748,33 @@
|
|||||||
<artifactId>carbon-p2-plugin</artifactId>
|
<artifactId>carbon-p2-plugin</artifactId>
|
||||||
<version>${carbon.p2.plugin.version}</version>
|
<version>${carbon.p2.plugin.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
<version>${maven.checkstyle.plugin.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>validate</id>
|
||||||
|
<phase>validate</phase>
|
||||||
|
<configuration>
|
||||||
|
<configLocation>
|
||||||
|
https://raw.githubusercontent.com/wso2/code-quality-tools/master/checkstyle/checkstyle.xml
|
||||||
|
</configLocation>
|
||||||
|
<suppressionsLocation>
|
||||||
|
https://raw.githubusercontent.com/wso2/code-quality-tools/master/checkstyle/suppressions.xml
|
||||||
|
</suppressionsLocation>
|
||||||
|
<encoding>UTF-8</encoding>
|
||||||
|
<consoleOutput>true</consoleOutput>
|
||||||
|
<failsOnError>false</failsOnError>
|
||||||
|
<failOnViolation>false</failOnViolation>
|
||||||
|
<includeTestSourceDirectory>true</includeTestSourceDirectory>
|
||||||
|
</configuration>
|
||||||
|
<goals>
|
||||||
|
<goal>check</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
</build>
|
</build>
|
||||||
@ -2026,6 +2053,11 @@
|
|||||||
<commons.codec.verision.range>(1.9,2.0]</commons.codec.verision.range>
|
<commons.codec.verision.range>(1.9,2.0]</commons.codec.verision.range>
|
||||||
<javassist.version>3.12.1.GA</javassist.version>
|
<javassist.version>3.12.1.GA</javassist.version>
|
||||||
<maven.javadoc.skip>true</maven.javadoc.skip>
|
<maven.javadoc.skip>true</maven.javadoc.skip>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Following two properties should be removed once the versions are added the wso2 parent pom CARBON-15729 -->
|
||||||
|
<maven.checkstyle.plugin.version>2.17</maven.checkstyle.plugin.version>
|
||||||
|
<maven.findbugs.plugin.version>3.0.3</maven.findbugs.plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user