Adding swagger annotations to beans
revert-70aa11f8
Madhawa Perera 9 years ago
commit 43648e4692

@ -207,6 +207,24 @@
<dependency> <dependency>
<groupId>io.swagger</groupId> <groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId> <artifactId>swagger-annotations</artifactId>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-core</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jaxrs</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>

@ -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.mgt.jaxrs;
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
}
}

@ -1,34 +0,0 @@
/*
* 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.mgt.jaxrs.api;
import io.swagger.annotations.Api;
import javax.ws.rs.Consumes;
import javax.ws.rs.Produces;
/**
* Authentication related REST-API interface.
*/
@Api(value = "Authentication")
@Produces({ "application/json", "application/xml" })
@Consumes({ "application/json", "application/xml" })
public interface Authentication {
}

@ -18,15 +18,10 @@
package org.wso2.carbon.device.mgt.jaxrs.api; package org.wso2.carbon.device.mgt.jaxrs.api;
import io.swagger.annotations.Api; import io.swagger.annotations.*;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.wso2.carbon.certificate.mgt.core.dto.CertificateResponse; import org.wso2.carbon.certificate.mgt.core.dto.CertificateResponse;
import org.wso2.carbon.device.mgt.common.PaginationResult; import org.wso2.carbon.device.mgt.common.PaginationResult;
import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException; import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException;
import org.wso2.carbon.device.mgt.jaxrs.api.util.ResponsePayload;
import org.wso2.carbon.device.mgt.jaxrs.beans.EnrollmentCertificate; import org.wso2.carbon.device.mgt.jaxrs.beans.EnrollmentCertificate;
import javax.ws.rs.*; import javax.ws.rs.*;
@ -39,6 +34,7 @@ import javax.ws.rs.core.Response;
@Api(value = "Certificate", description = "Certificate related tasks such as saving certificates, " + @Api(value = "Certificate", description = "Certificate related tasks such as saving certificates, " +
"can be done through this API") "can be done through this API")
@SuppressWarnings("NonJaxWsWebServices") @SuppressWarnings("NonJaxWsWebServices")
@Path("/certificates")
@Produces({ "application/json", "application/xml" }) @Produces({ "application/json", "application/xml" })
@Consumes({ "application/json", "application/xml" }) @Consumes({ "application/json", "application/xml" })
public interface Certificate { public interface Certificate {
@ -83,7 +79,7 @@ public interface Certificate {
notes = "Get the client side SSL certificate details", notes = "Get the client side SSL certificate details",
response = CertificateResponse.class) response = CertificateResponse.class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 200, message = "OK", response = CertificateResponse.class),
@ApiResponse(code = 400, message = "Notification status updated successfully"), @ApiResponse(code = 400, message = "Notification status updated successfully"),
@ApiResponse(code = 500, message = "Error occurred while converting PEM file to X509Certificate") @ApiResponse(code = 500, message = "Error occurred while converting PEM file to X509Certificate")
}) })
@ -112,7 +108,7 @@ public interface Certificate {
+ "page therefore the details are paginated", + "page therefore the details are paginated",
response = PaginationResult.class) response = PaginationResult.class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 200, message = "OK", response = PaginationResult.class),
@ApiResponse(code = 400, message = "Invalid start index"), @ApiResponse(code = 400, message = "Invalid start index"),
@ApiResponse(code = 400, message = "Invalid length value"), @ApiResponse(code = 400, message = "Invalid length value"),
@ApiResponse(code = 500, message = "Error occurred while fetching all certificates") @ApiResponse(code = 500, message = "Error occurred while fetching all certificates")

@ -18,13 +18,8 @@
package org.wso2.carbon.device.mgt.jaxrs.api; package org.wso2.carbon.device.mgt.jaxrs.api;
import io.swagger.annotations.Api; import io.swagger.annotations.*;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration; import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration;
import org.wso2.carbon.device.mgt.jaxrs.api.util.ResponsePayload;
import javax.ws.rs.*; import javax.ws.rs.*;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
@ -34,9 +29,9 @@ import javax.ws.rs.core.Response;
* General Tenant Configuration REST-API implementation. * General Tenant Configuration REST-API implementation.
* All end points support JSON, XMl with content negotiation. * All end points support JSON, XMl with content negotiation.
*/ */
@Path("/configuration")
@Api(value = "Configuration", description = "General Tenant Configuration management capabilities are exposed " + @Api(value = "Configuration", description = "General Tenant Configuration management capabilities are exposed " +
"through " + "through this API")
"this API")
@SuppressWarnings("NonJaxWsWebServices") @SuppressWarnings("NonJaxWsWebServices")
@Produces({ "application/json", "application/xml" }) @Produces({ "application/json", "application/xml" })
@Consumes({ "application/json", "application/xml" }) @Consumes({ "application/json", "application/xml" })

@ -29,7 +29,7 @@ import javax.ws.rs.core.Response;
/** /**
* Device related operations such as get all the available devices, etc. * Device related operations such as get all the available devices, etc.
*/ */
@Path("/devices")
@Api(value = "Device", description = "Device related operations such as get all the available devices, etc.") @Api(value = "Device", description = "Device related operations such as get all the available devices, etc.")
@SuppressWarnings("NonJaxWsWebServices") @SuppressWarnings("NonJaxWsWebServices")
public interface Device { public interface Device {
@ -41,6 +41,7 @@ public interface Device {
* @return Device List * @return Device List
*/ */
@GET @GET
@Path("devices")
@ApiOperation( @ApiOperation(
consumes = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
@ -95,7 +96,7 @@ public interface Device {
*/ */
@GET @GET
@Path("user/{user}") @Path("user/{user}")
Response getDevice(@PathParam("user") String user); Response getDeviceOfUser(@PathParam("user") String user);
/** /**
* Fetch device count of a given user. * Fetch device count of a given user.
@ -105,7 +106,7 @@ public interface Device {
*/ */
@GET @GET
@Path("user/{user}/count") @Path("user/{user}/count")
Response getDeviceCount(@PathParam("user") String user); Response getDeviceCountOfUser(@PathParam("user") String user);
/** /**
* Get current device count * Get current device count
@ -118,7 +119,7 @@ public interface Device {
httpMethod = "GET", httpMethod = "GET",
value = "Getting the Device Count", value = "Getting the Device Count",
notes = "Get the number of devices that are registered with WSO2 EMM.", notes = "Get the number of devices that are registered with WSO2 EMM.",
response = Integer.class) response = int.class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "Device count"), @ApiResponse(code = 200, message = "Device count"),
@ApiResponse(code = 500, message = "Error occurred while fetching the device count") @ApiResponse(code = 500, message = "Error occurred while fetching the device count")

@ -18,14 +18,9 @@
package org.wso2.carbon.device.mgt.jaxrs.api; package org.wso2.carbon.device.mgt.jaxrs.api;
import io.swagger.annotations.Api; import io.swagger.annotations.*;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo; import org.wso2.carbon.device.mgt.common.device.details.DeviceInfo;
import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation; import org.wso2.carbon.device.mgt.common.device.details.DeviceLocation;
import org.wso2.carbon.device.mgt.jaxrs.beans.UserCredentialWrapper;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.Path; import javax.ws.rs.Path;
@ -36,7 +31,7 @@ import javax.ws.rs.core.Response;
/** /**
* Device information related operations. * Device information related operations.
*/ */
@Path("/information")
@Api(value = "DeviceInformation", description = "Device information related operations can be found here.") @Api(value = "DeviceInformation", description = "Device information related operations can be found here.")
@SuppressWarnings("NonJaxWsWebServices") @SuppressWarnings("NonJaxWsWebServices")
public interface DeviceInformation { public interface DeviceInformation {

@ -42,8 +42,9 @@ import javax.ws.rs.core.Response;
*/ */
@Api(value = "DeviceNotification", description = "Device notification related operations can be found here.") @Api(value = "DeviceNotification", description = "Device notification related operations can be found here.")
@SuppressWarnings("NonJaxWsWebServices") @SuppressWarnings("NonJaxWsWebServices")
@Path("/notifications")
@Produces({"application/json", "application/xml"}) @Produces({"application/json", "application/xml"})
@Consumes({ "application/json", "application/xml" }) @Consumes({"application/json", "application/xml"})
public interface DeviceNotification { public interface DeviceNotification {
@GET @GET
@ -57,9 +58,10 @@ public interface DeviceNotification {
response = Notification.class, response = Notification.class,
responseContainer = "List") responseContainer = "List")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "List of Notifications"), @ApiResponse(code = 200, message = "List of Notifications", response = Notification.class,
responseContainer = "List"),
@ApiResponse(code = 500, message = "Error occurred while retrieving the notification list") @ApiResponse(code = 500, message = "Error occurred while retrieving the notification list")
}) })
Response getNotifications(); Response getNotifications();
@GET @GET
@ -74,12 +76,13 @@ public interface DeviceNotification {
response = Notification.class, response = Notification.class,
responseContainer = "List") responseContainer = "List")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "List of Notifications"), @ApiResponse(code = 200, message = "List of Notifications", response = Notification.class,
responseContainer = "List"),
@ApiResponse(code = 500, message = "Error occurred while retrieving the notification list") @ApiResponse(code = 500, message = "Error occurred while retrieving the notification list")
}) })
Response getNotificationsByStatus(@ApiParam(name = "status", value = "Provide the notification status as" Response getNotificationsByStatus(@ApiParam(name = "status", value = "Provide the notification status as"
+ " the value for {status}", required = true) + " the value for {status}", required = true)
@PathParam("status") Notification.Status status); @PathParam("status") Notification.Status status);
@PUT @PUT
@Path("{id}/{status}") @Path("{id}/{status}")
@ -93,12 +96,12 @@ public interface DeviceNotification {
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 201, message = "Notification status updated successfully"), @ApiResponse(code = 201, message = "Notification status updated successfully"),
@ApiResponse(code = 500, message = "Error occurred while updating notification status") @ApiResponse(code = 500, message = "Error occurred while updating notification status")
}) })
Response updateNotificationStatus( @ApiParam(name = "id", value = "Provide the ID of the notification" Response updateNotificationStatus(@ApiParam(name = "id", value = "Provide the ID of the notification"
+ " you wish you update", required = true) @PathParam("id") int id, + " you wish you update", required = true) @PathParam("id") int id,
@ApiParam(name = "status", value = "Provide the notification status as" @ApiParam(name = "status", value = "Provide the notification status as"
+ " the value", required = true) @PathParam("status") + " the value", required = true) @PathParam("status")
Notification.Status status); Notification.Status status);
@POST @POST
@ApiOperation( @ApiOperation(
@ -110,7 +113,7 @@ public interface DeviceNotification {
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 201, message = "NNotification has added successfully"), @ApiResponse(code = 201, message = "NNotification has added successfully"),
@ApiResponse(code = 500, message = "Error occurred while updating notification status") @ApiResponse(code = 500, message = "Error occurred while updating notification status")
}) })
Response addNotification(Notification notification); Response addNotification(Notification notification);
} }

@ -18,23 +18,19 @@
package org.wso2.carbon.device.mgt.jaxrs.api; package org.wso2.carbon.device.mgt.jaxrs.api;
import io.swagger.annotations.Api; import io.swagger.annotations.*;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.wso2.carbon.device.mgt.common.PaginationResult;
import org.wso2.carbon.device.mgt.common.device.details.DeviceWrapper; import org.wso2.carbon.device.mgt.common.device.details.DeviceWrapper;
import org.wso2.carbon.device.mgt.common.search.SearchContext; import org.wso2.carbon.device.mgt.common.search.SearchContext;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
/** /**
* Device search related operations such as getting device information. * Device search related operations such as getting device information.
*/ */
@Path("/search")
@Api(value = "DeviceSearch", description = "Device searching related operations can be found here.") @Api(value = "DeviceSearch", description = "Device searching related operations can be found here.")
@SuppressWarnings("NonJaxWsWebServices") @SuppressWarnings("NonJaxWsWebServices")
public interface DeviceSearch { public interface DeviceSearch {
@ -48,9 +44,9 @@ public interface DeviceSearch {
response = DeviceWrapper.class, response = DeviceWrapper.class,
responseContainer = "List") responseContainer = "List")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 200, message = "OK", response = DeviceWrapper.class, responseContainer = "List"),
@ApiResponse(code = 500, message = "Error occurred while searching the device information") @ApiResponse(code = 500, message = "Error occurred while searching the device information")
}) })
Response getDeviceInfo(@ApiParam(name = "enrollmentCertificates", value = "List of search conditions", Response getFilteredDeviceInfo(@ApiParam(name = "enrollmentCertificates", value = "List of search conditions",
required = true) SearchContext searchContext); required = true) SearchContext searchContext);
} }

@ -34,6 +34,7 @@ import javax.ws.rs.core.Response;
@Api(value = "Feature", description = "Feature management related operations can be found here.") @Api(value = "Feature", description = "Feature management related operations can be found here.")
@SuppressWarnings("NonJaxWsWebServices") @SuppressWarnings("NonJaxWsWebServices")
@Path("/features")
@Produces({"application/json", "application/xml"}) @Produces({"application/json", "application/xml"})
@Consumes({"application/json", "application/xml"}) @Consumes({"application/json", "application/xml"})
public interface Feature { public interface Feature {

@ -28,6 +28,7 @@ import javax.ws.rs.core.Response;
* This class represents license related operations. * This class represents license related operations.
*/ */
@Api(value = "License") @Api(value = "License")
@Path("/license")
@SuppressWarnings("NonJaxWsWebServices") @SuppressWarnings("NonJaxWsWebServices")
public interface License { public interface License {

@ -19,25 +19,19 @@
package org.wso2.carbon.device.mgt.jaxrs.api; package org.wso2.carbon.device.mgt.jaxrs.api;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.wso2.carbon.device.mgt.common.PaginationResult;
import org.wso2.carbon.device.mgt.common.app.mgt.Application; import org.wso2.carbon.device.mgt.common.app.mgt.Application;
import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException; import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException;
import org.wso2.carbon.device.mgt.jaxrs.api.context.DeviceOperationContext; import org.wso2.carbon.device.mgt.jaxrs.api.context.DeviceOperationContext;
import org.wso2.carbon.device.mgt.jaxrs.api.util.ResponsePayload;
import org.wso2.carbon.device.mgt.jaxrs.beans.ApplicationWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.ApplicationWrapper;
import javax.ws.rs.GET; import javax.ws.rs.*;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
/** /**
* *
*/ */
@Path("/operations")
@Api(value = "Operation", description = "Operation management related operations can be found here.") @Api(value = "Operation", description = "Operation management related operations can be found here.")
public interface Operation { public interface Operation {
@ -51,7 +45,7 @@ public interface Operation {
consumes = MediaType.APPLICATION_JSON + ", " + MediaType.APPLICATION_XML, consumes = MediaType.APPLICATION_JSON + ", " + MediaType.APPLICATION_XML,
produces = MediaType.APPLICATION_JSON + ", " + MediaType.APPLICATION_XML, produces = MediaType.APPLICATION_JSON + ", " + MediaType.APPLICATION_XML,
httpMethod = "GET", httpMethod = "GET",
value = "Getting Pagination Details for Operations on a Device.", value = "Getting Paginated Details for Operations on a Device.",
notes = "You will carry out many operations on a device. In a situation where you wish to view the all" + notes = "You will carry out many operations on a device. In a situation where you wish to view the all" +
" the operations carried out on a device it is not feasible to show all the details on one page" + " the operations carried out on a device it is not feasible to show all the details on one page" +
" therefore the details are paginated." + " therefore the details are paginated." +
@ -59,23 +53,23 @@ public interface Operation {
"carried out, the details of the 21 operations will be broken down into 3 pages with 10 operation" + "carried out, the details of the 21 operations will be broken down into 3 pages with 10 operation" +
" details per page.", " details per page.",
response = org.wso2.carbon.device.mgt.common.operation.mgt.Operation.class) response = org.wso2.carbon.device.mgt.common.operation.mgt.Operation.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "List of Operations on a device."), @ApiResponses(value = {@ApiResponse(code = 200, message = "List of Operations on a device."),
@ApiResponse(code = 500, message = "Error occurred while fetching the operations for the " + @ApiResponse(code = 500, message = "Error occurred while fetching the operations for the " +
"device.") }) "device.")})
Response getDeviceOperations(@ApiParam(name = "type", value = "Define the device type as the value for {type}. " + Response getDeviceOperations(@ApiParam(name = "type", value = "Define the device type as the value for {type}. " +
"Example: ios, android or windows.", "Example: ios, android or windows.",
required = true) @PathParam("type") String type, required = true) @PathParam("type") String type,
@ApiParam(name = "id", value = "Define the device ID", @ApiParam(name = "id", value = "Define the device ID",
required = true) @PathParam("id") String id, required = true) @PathParam("id") String id,
@ApiParam(name = "start", value = "Provide the starting pagination index. Example 10", @ApiParam(name = "start", value = "Provide the starting pagination index. Example 10",
required = true) @QueryParam("start") int startIdx, required = true) @QueryParam("start") int startIdx,
@ApiParam(name = "length", value = "Provide how many device details you require from" + @ApiParam(name = "length", value = "Provide how many device details you require from" +
" the starting pagination index. For example if " + " the starting pagination index. For example if " +
"you require the device details from the 10th " + "you require the device details from the 10th " +
"pagination index to the 15th, " + "pagination index to the 15th, " +
"you must define 10 as the value for start and 5 " + "you must define 10 as the value for start and 5 " +
"as the value for length.", "as the value for length.",
required = true) @QueryParam("length") int length, required = true) @QueryParam("length") int length,
@QueryParam("search") String search); @QueryParam("search") String search);
@GET @GET
@ -88,14 +82,14 @@ public interface Operation {
responseContainer = "List", responseContainer = "List",
notes = "Get the details of operations carried out on a selected device.", notes = "Get the details of operations carried out on a selected device.",
response = org.wso2.carbon.device.mgt.common.operation.mgt.Operation.class) response = org.wso2.carbon.device.mgt.common.operation.mgt.Operation.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "List of Operations on a device."), @ApiResponses(value = {@ApiResponse(code = 200, message = "List of Operations on a device."),
@ApiResponse(code = 500, message = "Error occurred while fetching the operations for the " + @ApiResponse(code = 500, message = "Error occurred while fetching the operations for the " +
"device.") }) "device.")})
Response getDeviceOperations(@ApiParam(name = "type", value = "Define the device type as the value for {type}. " + Response getAllDeviceOperations(@ApiParam(name = "type", value = "Define the device type as the value for {type}. " +
"Example: ios, android or windows.", "Example: ios, android or windows.",
required = true) @PathParam("type") String type, required = true) @PathParam("type") String type,
@ApiParam(name = "id", value = "Define the device ID", @ApiParam(name = "id", value = "Define the device ID",
required = true) @PathParam("id") String id); required = true) @PathParam("id") String id);
/* @deprecated */ /* @deprecated */
@POST @POST
@ -111,14 +105,14 @@ public interface Operation {
responseContainer = "List", responseContainer = "List",
notes = "Get the list of applications that a device has subscribed.", notes = "Get the list of applications that a device has subscribed.",
response = Application.class) response = Application.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "List of installed application details of a device."), @ApiResponses(value = {@ApiResponse(code = 200, message = "List of installed application details of a device.", response = Application.class, responseContainer = "List"),
@ApiResponse(code = 500, message = "Error occurred while fetching the apps of the device" + @ApiResponse(code = 500, message = "Error occurred while fetching the apps of the device" +
".") }) ".")})
Response getInstalledApps(@ApiParam(name = "type", value = "Define the device type as the value for {type}. " + Response getInstalledApps(@ApiParam(name = "type", value = "Define the device type as the value for {type}. " +
"Example: ios, android or windows.", "Example: ios, android or windows.",
required = true) @PathParam("type") String type, required = true) @PathParam("type") String type,
@ApiParam(name = "id", value = "Define the device ID", @ApiParam(name = "id", value = "Define the device ID",
required = true) @PathParam("id") String id); required = true) @PathParam("id") String id);
@POST @POST
@Path("installApp/{tenantDomain}") @Path("installApp/{tenantDomain}")
@ -128,16 +122,16 @@ public interface Operation {
httpMethod = "POST", httpMethod = "POST",
value = "Installing an Application on a Device.", value = "Installing an Application on a Device.",
notes = "Install a selected application on a device.") notes = "Install a selected application on a device.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Operation was successfully added to the queue."), @ApiResponses(value = {@ApiResponse(code = 200, message = "Operation was successfully added to the queue."),
@ApiResponse(code = 500, message = "Error occurred while saving the operation.") }) @ApiResponse(code = 500, message = "Error occurred while saving the operation.")})
Response installApplication(@ApiParam(name = "applicationWrapper", value = "Details about the application and the" + Response installApplication(@ApiParam(name = "applicationWrapper", value = "Details about the application and the" +
" users and roles it should be " + " users and roles it should be " +
"installed on.", "installed on.",
required = true) ApplicationWrapper applicationWrapper, required = true) ApplicationWrapper applicationWrapper,
@ApiParam(name = "tenantDomain", value = "Provide the tenant domain as the value for " + @ApiParam(name = "tenantDomain", value = "Provide the tenant domain as the value for " +
"{tenantDomain}. The default tenant domain " + "{tenantDomain}. The default tenant domain " +
"of WSO2 EMM is carbon.super.", "of WSO2 EMM is carbon.super.",
required = true) @PathParam("tenantDomain") String tenantDomain); required = true) @PathParam("tenantDomain") String tenantDomain);
@POST @POST
@Path("uninstallApp/{tenantDomain}") @Path("uninstallApp/{tenantDomain}")
@ -147,16 +141,16 @@ public interface Operation {
httpMethod = "POST", httpMethod = "POST",
value = "Uninstalling an Application from a Device.", value = "Uninstalling an Application from a Device.",
notes = "Uninstall a selected application from a device.") notes = "Uninstall a selected application from a device.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Operation was successfully added to the queue."), @ApiResponses(value = {@ApiResponse(code = 200, message = "Operation was successfully added to the queue."),
@ApiResponse(code = 500, message = "Error occurred while saving the operation.") }) @ApiResponse(code = 500, message = "Error occurred while saving the operation.")})
Response uninstallApplication(@ApiParam(name = "applicationWrapper", value = "Details about the application and" + Response uninstallApplication(@ApiParam(name = "applicationWrapper", value = "Details about the application and" +
" the users and roles it should be " + " the users and roles it should be " +
"uninstalled.", "uninstalled.",
required = true) ApplicationWrapper applicationWrapper, required = true) ApplicationWrapper applicationWrapper,
@ApiParam(name = "tenantDomain", value = "Provide the tenant domain as the value for " + @ApiParam(name = "tenantDomain", value = "Provide the tenant domain as the value for " +
"{tenantDomain}. The default tenant domain " + "{tenantDomain}. The default tenant domain " +
"of WSO2 EMM is carbon.super.", "of WSO2 EMM is carbon.super.",
required = true) @PathParam("tenantDomain") String tenantDomain); required = true) @PathParam("tenantDomain") String tenantDomain);
@GET @GET
@ -167,8 +161,8 @@ public interface Operation {
httpMethod = "POST", httpMethod = "POST",
value = "Retrieving the operation details.", value = "Retrieving the operation details.",
notes = "This will return the operation details including the responses from the devices") notes = "This will return the operation details including the responses from the devices")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Activity details provided successfully.."), @ApiResponses(value = {@ApiResponse(code = 200, message = "Activity details provided successfully.."),
@ApiResponse(code = 500, message = "Error occurred while fetching the activity for the supplied id.") }) @ApiResponse(code = 500, message = "Error occurred while fetching the activity for the supplied id.")})
Response getActivity(@ApiParam(name = "id", value = "Provide activity id {id} as ACTIVITY_(number)", Response getActivity(@ApiParam(name = "id", value = "Provide activity id {id} as ACTIVITY_(number)",
required = true) @PathParam("id") String id) required = true) @PathParam("id") String id)
throws MDMAPIException; throws MDMAPIException;

@ -20,25 +20,15 @@ package org.wso2.carbon.device.mgt.jaxrs.api;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException; import org.wso2.carbon.device.mgt.jaxrs.api.common.MDMAPIException;
import org.wso2.carbon.device.mgt.jaxrs.api.util.ResponsePayload;
import org.wso2.carbon.device.mgt.jaxrs.beans.PolicyWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.PolicyWrapper;
import org.wso2.carbon.device.mgt.jaxrs.beans.PriorityUpdatedPolicyWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.PriorityUpdatedPolicyWrapper;
import javax.ws.rs.Consumes; import javax.ws.rs.*;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.List; import java.util.List;
/** @Path("/policies")
*
*/
@Api(value = "Policy", description = "Policy management related operations can be found here.") @Api(value = "Policy", description = "Policy management related operations can be found here.")
public interface Policy { public interface Policy {
@ -52,11 +42,11 @@ public interface Policy {
notes = "Add a policy using this REST API command. When adding a policy you will have the option of " + notes = "Add a policy using this REST API command. When adding a policy you will have the option of " +
"saving the policy or saving and publishing the policy. Using the REST API command given below " + "saving the policy or saving and publishing the policy. Using the REST API command given below " +
"you are able to save a created Policy and this policy will be in the inactive state") "you are able to save a created Policy and this policy will be in the inactive state")
@ApiResponses(value = { @ApiResponse(code = 201, message = "Created the policy."), @ApiResponses(value = {@ApiResponse(code = 201, message = "Created the policy."),
@ApiResponse(code = 500, message = "Policy Management related error occurred when " + @ApiResponse(code = 500, message = "Policy Management related error occurred when " +
"adding the policy") }) "adding the policy")})
Response addPolicy(@ApiParam(name = "policyWrapper", value = "Policy details related to the operation.", Response addPolicy(@ApiParam(name = "policyWrapper", value = "Policy details related to the operation.",
required = true) PolicyWrapper policyWrapper); required = true) PolicyWrapper policyWrapper);
@POST @POST
@Path("active-policy") @Path("active-policy")
@ -69,14 +59,14 @@ public interface Policy {
"will have the option of saving the policy or saving and publishing the policy. Using the REST " + "will have the option of saving the policy or saving and publishing the policy. Using the REST " +
"API command given below you are able to save and publish a created policy and this policy will " + "API command given below you are able to save and publish a created policy and this policy will " +
"be in the active state.") "be in the active state.")
@ApiResponses(value = { @ApiResponse(code = 201, message = "Created the policy."), @ApiResponses(value = {@ApiResponse(code = 201, message = "Created the policy."),
@ApiResponse(code = 500, message = "Policy Management related error occurred when " + @ApiResponse(code = 500, message = "Policy Management related error occurred when " +
"adding the policy") }) "adding the policy")})
Response addActivePolicy(@ApiParam(name = "policyWrapper", value = "Policy details related to the operation.", Response addActivePolicy(@ApiParam(name = "policyWrapper", value = "Policy details related to the operation.",
required = true) PolicyWrapper policyWrapper); required = true) PolicyWrapper policyWrapper);
@GET @GET
@Produces({ MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON})
@ApiOperation( @ApiOperation(
consumes = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
@ -85,9 +75,10 @@ public interface Policy {
responseContainer = "List", responseContainer = "List",
notes = "Retrieve the details of all the policies that you have created in WSO2 EMM.", notes = "Retrieve the details of all the policies that you have created in WSO2 EMM.",
response = org.wso2.carbon.policy.mgt.common.Policy.class) response = org.wso2.carbon.policy.mgt.common.Policy.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Fetched all policies."), @ApiResponses(value = {@ApiResponse(code = 200, message = "Fetched all policies.",
@ApiResponse(code = 500, message = "Policy Management related error occurred when " + response = org.wso2.carbon.policy.mgt.common.Policy.class, responseContainer = "List"),
"fetching the policies.") }) @ApiResponse(code = 500, message = "Policy Management related error occurred when " +
"fetching the policies.")})
Response getAllPolicies(); Response getAllPolicies();
@GET @GET
@ -100,11 +91,11 @@ public interface Policy {
value = "Getting Details of a Policy.", value = "Getting Details of a Policy.",
notes = "Retrieve the details of a selected policy in WSO2 EMM.", notes = "Retrieve the details of a selected policy in WSO2 EMM.",
response = org.wso2.carbon.policy.mgt.common.Policy.class) response = org.wso2.carbon.policy.mgt.common.Policy.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Fetched policy details."), @ApiResponses(value = {@ApiResponse(code = 200, message = "Fetched policy details."),
@ApiResponse(code = 500, message = "Policy Management related error occurred when " + @ApiResponse(code = 500, message = "Policy Management related error occurred when " +
"fetching the policies.") }) "fetching the policies.")})
Response getPolicy(@ApiParam(name = "id", value = "Policy ID value to identify a policy uniquely.", Response getPolicy(@ApiParam(name = "id", value = "Policy ID value to identify a policy uniquely.",
required = true) @PathParam("id") int policyId); required = true) @PathParam("id") int policyId);
@GET @GET
@Path("count") @Path("count")
@ -114,9 +105,9 @@ public interface Policy {
httpMethod = "GET", httpMethod = "GET",
value = "Getting the Policy Count.", value = "Getting the Policy Count.",
notes = "Get the number of policies that are created in WSO2 EMM.", notes = "Get the number of policies that are created in WSO2 EMM.",
response = Integer.class) response = int.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Fetched the policy count."), @ApiResponses(value = {@ApiResponse(code = 200, message = "Fetched the policy count."),
@ApiResponse(code = 500, message = "Error while Fetching the policy count.") }) @ApiResponse(code = 500, message = "Error while Fetching the policy count.")})
Response getPolicyCount(); Response getPolicyCount();
@PUT @PUT
@ -128,13 +119,13 @@ public interface Policy {
value = "Updating a Policy.", value = "Updating a Policy.",
notes = "If you wish to make changes to an existing policy, you can do so by updating the policy using " + notes = "If you wish to make changes to an existing policy, you can do so by updating the policy using " +
"this API") "this API")
@ApiResponses(value = { @ApiResponse(code = 201, message = "Policy has been updated successfully."), @ApiResponses(value = {@ApiResponse(code = 201, message = "Policy has been updated successfully."),
@ApiResponse(code = 500, message = "Policy Management related exception in policy " + @ApiResponse(code = 500, message = "Policy Management related exception in policy " +
"update") }) "update")})
Response updatePolicy(@ApiParam(name = "policyWrapper", value = "Policy details related to the operation.", Response updatePolicy(@ApiParam(name = "policyWrapper", value = "Policy details related to the operation.",
required = true) PolicyWrapper policyWrapper, required = true) PolicyWrapper policyWrapper,
@ApiParam(name = "id", value = "Policy ID value to identify a policy uniquely.", @ApiParam(name = "id", value = "Policy ID value to identify a policy uniquely.",
required = true) @PathParam("id") int policyId); required = true) @PathParam("id") int policyId);
@PUT @PUT
@Path("priorities") @Path("priorities")
@ -147,12 +138,12 @@ public interface Policy {
value = "Updating the Policy Priority.", value = "Updating the Policy Priority.",
notes = "If you wish to make changes to the existing policy priority order, " + notes = "If you wish to make changes to the existing policy priority order, " +
"you can do so by updating the priority order using this API") "you can do so by updating the priority order using this API")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Policy Priorities successfully updated."), @ApiResponses(value = {@ApiResponse(code = 200, message = "Policy Priorities successfully updated."),
@ApiResponse(code = 400, message = "Policy priorities did not update."), @ApiResponse(code = 400, message = "Policy priorities did not update."),
@ApiResponse(code = 500, message = "Error in updating policy priorities.") }) @ApiResponse(code = 500, message = "Error in updating policy priorities.")})
Response updatePolicyPriorities(@ApiParam(name = "priorityUpdatedPolicies", Response updatePolicyPriorities(@ApiParam(name = "priorityUpdatedPolicies",
value = "List of policy update details..", value = "List of policy update details..",
required = true) List<PriorityUpdatedPolicyWrapper> priorityUpdatedPolicies); required = true) List<PriorityUpdatedPolicyWrapper> priorityUpdatedPolicies);
@POST @POST
@Path("bulk-remove") @Path("bulk-remove")
@ -164,11 +155,11 @@ public interface Policy {
httpMethod = "POST", httpMethod = "POST",
value = "Removing Multiple Policies.", value = "Removing Multiple Policies.",
notes = "In situations where you need to delete more than one policy you can do so using this API.") notes = "In situations where you need to delete more than one policy you can do so using this API.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Policies have been successfully deleted."), @ApiResponses(value = {@ApiResponse(code = 200, message = "Policies have been successfully deleted."),
@ApiResponse(code = 400, message = "Policy does not exist."), @ApiResponse(code = 400, message = "Policy does not exist."),
@ApiResponse(code = 500, message = "Error in deleting policies.") }) @ApiResponse(code = 500, message = "Error in deleting policies.")})
Response bulkRemovePolicy(@ApiParam(name = "policyIds", value = "Policy ID list to be deleted.", Response bulkRemovePolicy(@ApiParam(name = "policyIds", value = "Policy ID list to be deleted.",
required = true) List<Integer> policyIds); required = true) List<Integer> policyIds);
@PUT @PUT
@Produces("application/json") @Produces("application/json")
@ -180,10 +171,10 @@ public interface Policy {
value = "Activating Policies.", value = "Activating Policies.",
notes = "Using the REST API command you are able to publish a policy in order to bring a policy that is " + notes = "Using the REST API command you are able to publish a policy in order to bring a policy that is " +
"in the inactive state to the active state.") "in the inactive state to the active state.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Policies have been successfully activated."), @ApiResponses(value = {@ApiResponse(code = 200, message = "Policies have been successfully activated."),
@ApiResponse(code = 500, message = "Error in activating policies.") }) @ApiResponse(code = 500, message = "Error in activating policies.")})
Response activatePolicy(@ApiParam(name = "policyIds", value = "Policy ID list to be activated.", Response activatePolicy(@ApiParam(name = "policyIds", value = "Policy ID list to be activated.",
required = true) List<Integer> policyIds); required = true) List<Integer> policyIds);
@PUT @PUT
@Produces("application/json") @Produces("application/json")
@ -195,10 +186,10 @@ public interface Policy {
value = "Deactivating Policies.", value = "Deactivating Policies.",
notes = "Using the REST API command you are able to unpublish a policy in order to bring a policy that " + notes = "Using the REST API command you are able to unpublish a policy in order to bring a policy that " +
"is in the active state to the inactive state.") "is in the active state to the inactive state.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Policies have been successfully deactivated."), @ApiResponses(value = {@ApiResponse(code = 200, message = "Policies have been successfully deactivated."),
@ApiResponse(code = 500, message = "Error in deactivating policies.") }) @ApiResponse(code = 500, message = "Error in deactivating policies.")})
Response inactivatePolicy(@ApiParam(name = "policyIds", value = "Policy ID list to be deactivated.", Response inactivatePolicy(@ApiParam(name = "policyIds", value = "Policy ID list to be deactivated.",
required = true) List<Integer> policyIds) throws MDMAPIException; required = true) List<Integer> policyIds) throws MDMAPIException;
@PUT @PUT
@Produces("application/json") @Produces("application/json")
@ -213,8 +204,8 @@ public interface Policy {
" policies (removing, activating, deactivating and updating) or add new policies, the existing" + " policies (removing, activating, deactivating and updating) or add new policies, the existing" +
" devices will not receive these changes immediately. Once all the required changes are made" + " devices will not receive these changes immediately. Once all the required changes are made" +
" you need to apply the changes to push the policy changes to the existing devices.") " you need to apply the changes to push the policy changes to the existing devices.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Changes have been successfully updated."), @ApiResponses(value = {@ApiResponse(code = 200, message = "Changes have been successfully updated."),
@ApiResponse(code = 500, message = "Error in updating policies.") }) @ApiResponse(code = 500, message = "Error in updating policies.")})
Response applyChanges(); Response applyChanges();
@GET @GET
@ -229,11 +220,11 @@ public interface Policy {
"It will monitor the device based on the policy monitoring frequency that you define in " + "It will monitor the device based on the policy monitoring frequency that you define in " +
"milliseconds.Using this REST API to start the policy monitoring task is optional as " + "milliseconds.Using this REST API to start the policy monitoring task is optional as " +
"WSO2 EMM uses an OSGI call to start the monitoring task") "WSO2 EMM uses an OSGI call to start the monitoring task")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Policy monitoring service started successfully."), @ApiResponses(value = {@ApiResponse(code = 200, message = "Policy monitoring service started successfully."),
@ApiResponse(code = 500, message = "Policy Management related exception when starting " + @ApiResponse(code = 500, message = "Policy Management related exception when starting " +
"monitoring service.") }) "monitoring service.")})
Response startTaskService(@ApiParam(name = "milliseconds", value = "Policy monitoring frequency in milliseconds.", Response startTaskService(@ApiParam(name = "milliseconds", value = "Policy monitoring frequency in milliseconds.",
required = true) @PathParam("milliseconds") int monitoringFrequency); required = true) @PathParam("milliseconds") int monitoringFrequency);
@GET @GET
@Path("update-task/{milliseconds}") @Path("update-task/{milliseconds}")
@ -258,11 +249,11 @@ public interface Policy {
"filters the policies based on the Platform (device type), filters based on the device ownership" + "filters the policies based on the Platform (device type), filters based on the device ownership" +
" type , filters based on the user role or name and finally the policy is enforced on the device.", " type , filters based on the user role or name and finally the policy is enforced on the device.",
response = org.wso2.carbon.policy.mgt.common.Policy.class) response = org.wso2.carbon.policy.mgt.common.Policy.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Fetched current policy."), @ApiResponses(value = {@ApiResponse(code = 200, message = "Fetched current policy."),
@ApiResponse(code = 500, message = "Error occurred while getting the current policy.") }) @ApiResponse(code = 500, message = "Error occurred while getting the current policy.")})
Response getDeviceActivePolicy(@ApiParam(name = "type", value = "Define the device type as the value for {type}." + Response getDeviceActivePolicy(@ApiParam(name = "type", value = "Define the device type as the value for {type}." +
" Example: ios, android, windows..", " Example: ios, android, windows..",
required = true) @PathParam("type") String type, required = true) @PathParam("type") String type,
@ApiParam(name = "id", value = "Define the device ID as the value for {id}.", @ApiParam(name = "id", value = "Define the device ID as the value for {id}.",
required = true) @PathParam("id") String id); required = true) @PathParam("id") String id);
} }

@ -30,6 +30,7 @@ import javax.ws.rs.core.Response;
* These end points provide profile related operations. * These end points provide profile related operations.
*/ */
@Api(value = "Profile") @Api(value = "Profile")
@Path("/profiles")
@SuppressWarnings("NonJaxWsWebServices") @SuppressWarnings("NonJaxWsWebServices")
public interface Profile { public interface Profile {

@ -19,26 +19,15 @@
package org.wso2.carbon.device.mgt.jaxrs.api; package org.wso2.carbon.device.mgt.jaxrs.api;
import io.swagger.annotations.*; import io.swagger.annotations.*;
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
import org.wso2.carbon.device.mgt.jaxrs.api.util.ResponsePayload;
import org.wso2.carbon.device.mgt.jaxrs.beans.RoleWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.RoleWrapper;
import org.wso2.carbon.user.mgt.common.UIPermissionNode; import org.wso2.carbon.user.mgt.common.UIPermissionNode;
import javax.ws.rs.DELETE; import javax.ws.rs.*;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.List; import java.util.List;
/** @Path("/roles")
*
*/
@Api(value = "Role", description = "Role management related operations can be found here.") @Api(value = "Role", description = "Role management related operations can be found here.")
public interface Role { public interface Role {
@ -54,7 +43,7 @@ public interface Role {
response = String.class) response = String.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "List of available roles"), @ApiResponses(value = { @ApiResponse(code = 200, message = "List of available roles"),
@ApiResponse(code = 500, message = "Error occurred while fetching the role list.") }) @ApiResponse(code = 500, message = "Error occurred while fetching the role list.") })
Response getRoles(); Response getAllRoles();
@GET @GET
@Path("{userStore}") @Path("{userStore}")
@ -69,7 +58,7 @@ public interface Role {
response = String.class) response = String.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "List of available roles"), @ApiResponses(value = { @ApiResponse(code = 200, message = "List of available roles"),
@ApiResponse(code = 500, message = "Error occurred while fetching the role list.") }) @ApiResponse(code = 500, message = "Error occurred while fetching the role list.") })
Response getRoles(@ApiParam(name = "userStore", value = "Provide the name of the UserStore you wish to get the" + Response getRolesOfUserStore(@ApiParam(name = "userStore", value = "Provide the name of the UserStore you wish to get the" +
" details from ", " details from ",
required = true) @PathParam("userStore") String userStore); required = true) @PathParam("userStore") String userStore);
@ -203,9 +192,10 @@ public interface Role {
produces = MediaType.APPLICATION_JSON, produces = MediaType.APPLICATION_JSON,
httpMethod = "GET", httpMethod = "GET",
value = "Getting the Role Count.", value = "Getting the Role Count.",
response = Integer.class, response = int.class,
notes = "Get the number of roles in WSO2 EMM.") notes = "Get the number of roles in WSO2 EMM.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "Retrieved the role count."), @ApiResponses(value = { @ApiResponse(code = 200, message = "Retrieved the role count."),
@ApiResponse(code = 500, message = "Error occurred while retrieving the role count.") }) @ApiResponse(code = 500, message = "Error occurred while retrieving the role count.") })
Response getRoleCount(); Response getRoleCount();
} }

@ -18,25 +18,12 @@
package org.wso2.carbon.device.mgt.jaxrs.api; package org.wso2.carbon.device.mgt.jaxrs.api;
import io.swagger.annotations.Api; import io.swagger.annotations.*;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.apache.axis2.databinding.types.soapencoding.Integer; import org.apache.axis2.databinding.types.soapencoding.Integer;
import org.wso2.carbon.device.mgt.jaxrs.api.util.ResponsePayload;
import org.wso2.carbon.device.mgt.jaxrs.beans.UserCredentialWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.UserCredentialWrapper;
import org.wso2.carbon.device.mgt.jaxrs.beans.UserWrapper; import org.wso2.carbon.device.mgt.jaxrs.beans.UserWrapper;
import javax.ws.rs.Consumes; import javax.ws.rs.*;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.List; import java.util.List;
@ -44,6 +31,7 @@ import java.util.List;
/** /**
* This represents the JAX-RS services of User related functionality. * This represents the JAX-RS services of User related functionality.
*/ */
@Path("/users")
@Api(value = "User", description = "User management related operations can be found here.") @Api(value = "User", description = "User management related operations can be found here.")
public interface User { public interface User {
@ -138,7 +126,7 @@ public interface User {
@ApiResponse(code = 400, message = "User by username: 'username' does not exist for role retrieval"), @ApiResponse(code = 400, message = "User by username: 'username' does not exist for role retrieval"),
@ApiResponse(code = 500, message = "Exception in trying to retrieve roles for user by username: 'username'") @ApiResponse(code = 500, message = "Exception in trying to retrieve roles for user by username: 'username'")
}) })
Response getRoles(@ApiParam(name = "username", value = "Provide the user name of the user you wish to get" Response getRolesOfUser(@ApiParam(name = "username", value = "Provide the user name of the user you wish to get"
+ " the role details", required = true) @QueryParam("username") String username); + " the role details", required = true) @QueryParam("username") String username);
@GET @GET
@ -253,7 +241,7 @@ public interface User {
httpMethod = "GET", httpMethod = "GET",
value = "Getting the User Count", value = "Getting the User Count",
notes = "Get the number of users in WSO2 EMM", notes = "Get the number of users in WSO2 EMM",
response = Integer.class) response = int.class)
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 200, message = "OK"),
@ApiResponse(code = 500, message = "Error occurred while retrieving the list of users that exist" @ApiResponse(code = 500, message = "Error occurred while retrieving the list of users that exist"
@ -264,7 +252,7 @@ public interface User {
@PUT @PUT
@Path("{roleName}/users") @Path("{roleName}/users")
@Produces({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON})
Response updateRoles(@PathParam("username") String username, List<String> userList); Response updateRoles(@PathParam("roleName") String roleName, List<String> userList);
@POST @POST
@Path("change-password") @Path("change-password")

@ -1,36 +0,0 @@
/*
* 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.mgt.jaxrs.api.impl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.ws.rs.Consumes;
import javax.ws.rs.Produces;
/**
* Authentication related REST-API implementation.
*/
@Produces({ "application/json", "application/xml" })
@Consumes({ "application/json", "application/xml" })
public class AuthenticationImpl {
private static Log log = LogFactory.getLog(AuthenticationImpl.class);
}

@ -142,7 +142,7 @@ public class DeviceImpl implements Device{
*/ */
@GET @GET
@Path("user/{user}") @Path("user/{user}")
public Response getDevice(@PathParam("user") String user) { public Response getDeviceOfUser(@PathParam("user") String user) {
List<org.wso2.carbon.device.mgt.common.Device> devices; List<org.wso2.carbon.device.mgt.common.Device> devices;
try { try {
devices = DeviceMgtAPIUtils.getDeviceManagementService().getDevicesOfUser(user); devices = DeviceMgtAPIUtils.getDeviceManagementService().getDevicesOfUser(user);
@ -165,7 +165,7 @@ public class DeviceImpl implements Device{
*/ */
@GET @GET
@Path("user/{user}/count") @Path("user/{user}/count")
public Response getDeviceCount(@PathParam("user") String user) { public Response getDeviceCountOfUser(@PathParam("user") String user) {
try { try {
Integer count = DeviceMgtAPIUtils.getDeviceManagementService().getDeviceCount(user); Integer count = DeviceMgtAPIUtils.getDeviceManagementService().getDeviceCount(user);
return Response.status(Response.Status.OK).entity(count).build(); return Response.status(Response.Status.OK).entity(count).build();

@ -38,7 +38,7 @@ public class DeviceSearchImpl implements DeviceSearch {
private static Log log = LogFactory.getLog(DeviceSearchImpl.class); private static Log log = LogFactory.getLog(DeviceSearchImpl.class);
@GET @GET
public Response getDeviceInfo(SearchContext searchContext) { public Response getFilteredDeviceInfo(SearchContext searchContext) {
SearchManagerService searchManagerService; SearchManagerService searchManagerService;
List<DeviceWrapper> devices; List<DeviceWrapper> devices;
try { try {

@ -103,7 +103,7 @@ public class OperationImpl implements org.wso2.carbon.device.mgt.jaxrs.api.Opera
@Override @Override
@GET @GET
@Path("{type}/{id}") @Path("{type}/{id}")
public Response getDeviceOperations(@PathParam("type") String type, @PathParam("id") String id) { public Response getAllDeviceOperations(@PathParam("type") String type, @PathParam("id") String id) {
List<? extends org.wso2.carbon.device.mgt.common.operation.mgt.Operation> operations; List<? extends org.wso2.carbon.device.mgt.common.operation.mgt.Operation> operations;
DeviceManagementProviderService dmService; DeviceManagementProviderService dmService;
DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); DeviceIdentifier deviceIdentifier = new DeviceIdentifier();

@ -65,7 +65,7 @@ public class RoleImpl implements org.wso2.carbon.device.mgt.jaxrs.api.Role {
@Override @Override
@GET @GET
@Produces({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON})
public Response getRoles() { public Response getAllRoles() {
List<String> filteredRoles; List<String> filteredRoles;
try { try {
filteredRoles = getRolesFromUserStore(); filteredRoles = getRolesFromUserStore();
@ -89,7 +89,7 @@ public class RoleImpl implements org.wso2.carbon.device.mgt.jaxrs.api.Role {
@GET @GET
@Path("{userStore}") @Path("{userStore}")
@Produces({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON})
public Response getRoles(@PathParam("userStore") String userStore) { public Response getRolesOfUserStore(@PathParam("userStore") String userStore) {
String[] roles; String[] roles;
try { try {
AbstractUserStoreManager abstractUserStoreManager = AbstractUserStoreManager abstractUserStoreManager =

@ -371,7 +371,7 @@ public class UserImpl implements org.wso2.carbon.device.mgt.jaxrs.api.User {
@GET @GET
@Path("roles") @Path("roles")
@Produces({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON})
public Response getRoles(@QueryParam("username") String username) { public Response getRolesOfUser(@QueryParam("username") String username) {
ResponsePayload responsePayload = new ResponsePayload(); ResponsePayload responsePayload = new ResponsePayload();
try { try {
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
@ -716,7 +716,7 @@ public class UserImpl implements org.wso2.carbon.device.mgt.jaxrs.api.User {
@PUT @PUT
@Path("{roleName}/users") @Path("{roleName}/users")
@Produces({MediaType.APPLICATION_JSON}) @Produces({MediaType.APPLICATION_JSON})
public Response updateRoles(@PathParam("username") String username, List<String> userList) { public Response updateRoles(@PathParam("roleName") String username, List<String> userList) {
try { try {
final UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); final UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {

@ -21,51 +21,54 @@ package org.wso2.carbon.device.mgt.jaxrs.beans;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import java.util.List; import java.util.List;
@ApiModel(value = "ApplicationWrapper", description = "Application details together with user, " + @ApiModel(value = "ApplicationWrapper", description = "Application details together with user, " +
"role or devices the application is associated with.") "role or devices the application is associated with.")
public class ApplicationWrapper { public class ApplicationWrapper {
@ApiModelProperty(name = "userNameList", value = "List of user names.", required = true ) @ApiModelProperty(name = "userNameList", value = "List of user names.", required = true)
private List<String> userNameList; private List<String> userNameList;
@ApiModelProperty(name = "roleNameList", value = "List of role names.", required = true ) @ApiModelProperty(name = "roleNameList", value = "List of role names.", required = true)
private List<String> roleNameList; private List<String> roleNameList;
@ApiModelProperty(name = "deviceIdentifiers", value = "List of device identifiers.", required = true ) @ApiModelProperty(name = "deviceIdentifiers", value = "List of device identifiers.", required = true,
private List<DeviceIdentifier> deviceIdentifiers; dataType = "List[org.wso2.carbon.device.mgt.common.DeviceIdentifier]")
@ApiModelProperty(name = "application", value = "Details of the mobile application.", required = true ) private List<DeviceIdentifier> deviceIdentifiers;
private MobileApp application; @ApiModelProperty(name = "application", value = "Details of the mobile application.", required = true)
private MobileApp application;
public MobileApp getApplication() {
return application;
}
public MobileApp getApplication() { public void setApplication(MobileApp application) {
return application; this.application = application;
} }
public void setApplication(MobileApp application) { public List<String> getUserNameList() {
this.application = application; return userNameList;
} }
public List<String> getUserNameList() {
return userNameList;
}
public void setUserNameList(List<String> userNameList) { public void setUserNameList(List<String> userNameList) {
this.userNameList = userNameList; this.userNameList = userNameList;
} }
public List<String> getRoleNameList() { public List<String> getRoleNameList() {
return roleNameList; return roleNameList;
} }
public void setRoleNameList(List<String> roleNameList) { public void setRoleNameList(List<String> roleNameList) {
this.roleNameList = roleNameList; this.roleNameList = roleNameList;
} }
public List<DeviceIdentifier> getDeviceIdentifiers() { public List<DeviceIdentifier> getDeviceIdentifiers() {
return deviceIdentifiers; return deviceIdentifiers;
} }
public void setDeviceIdentifiers(List<DeviceIdentifier> deviceIdentifiers) { public void setDeviceIdentifiers(List<DeviceIdentifier> deviceIdentifiers) {
this.deviceIdentifiers = deviceIdentifiers; this.deviceIdentifiers = deviceIdentifiers;
} }
} }

@ -27,42 +27,42 @@ import java.util.Properties;
* This class represents the generic mobile AuthenticationImpl information * This class represents the generic mobile AuthenticationImpl information
* which is used by AppM. * which is used by AppM.
*/ */
@ApiModel(value = "ApplicationWrapper", description = "Details of a mobile application.") @ApiModel(value = "MobileApp", description = "Details of a mobile application.")
public class MobileApp { public class MobileApp {
@ApiModelProperty(name = "id", value = "Id of the app used internally.", required = true ) @ApiModelProperty(name = "id", value = "Id of the app used internally.", required = true)
private String id; private String id;
@ApiModelProperty(name = "name", value = "The name of the application.", required = true ) @ApiModelProperty(name = "name", value = "The name of the application.", required = true)
private String name; private String name;
@ApiModelProperty(name = "type", value = "The type of the application. The following types of applications are " + @ApiModelProperty(name = "type", value = "The type of the application. The following types of applications are " +
"supported: enterprise, public and webapp..", required = true ) "supported: enterprise, public and webapp..", required = true)
private MobileAppTypes type; private MobileAppTypes type;
@ApiModelProperty(name = "platform", value = "Platform the app can be installed on .", required = true ) @ApiModelProperty(name = "platform", value = "Platform the app can be installed on .", required = true)
private String platform; private String platform;
@ApiModelProperty(name = "version", value = "Version of the application.", required = true ) @ApiModelProperty(name = "version", value = "Version of the application.", required = true)
private String version; private String version;
@ApiModelProperty(name = "identifier", value = "The package name of the application.", required = true ) @ApiModelProperty(name = "identifier", value = "The package name of the application.", required = true)
private String identifier; private String identifier;
@ApiModelProperty(name = "iconImage", value = "Link to the icon of the app.", required = true ) @ApiModelProperty(name = "iconImage", value = "Link to the icon of the app.", required = true)
private String iconImage; private String iconImage;
@ApiModelProperty(name = "packageName", value = "Define the exact name of the application package. You can use one " + @ApiModelProperty(name = "packageName", value = "Define the exact name of the application package. You can use one " +
"of the following methods to get the package name.\n" + "of the following methods to get the package name.\n" +
"Go to the respective application in the play store and copy the" + "Go to the respective application in the play store and copy the" +
" ID or package name from the URL.\n" + " ID or package name from the URL.\n" +
"Example: The play store application URL for the Viber app is " + "Example: The play store application URL for the Viber app is " +
"https://play.google.com/store/apps/details?id=com.viber.voip&hl=en." + "https://play.google.com/store/apps/details?id=com.viber.voip&hl=en." +
" Therefore, the package name or " + " Therefore, the package name or " +
"the application ID is: id=com.viber.voip \n" + "the application ID is: id=com.viber.voip \n" +
"Download the System Info for Android to your device from the" + "Download the System Info for Android to your device from the" +
" play store. \n" + " play store. \n" +
"Once the application is successfully installed go to the Tasks " + "Once the application is successfully installed go to the Tasks " +
"tab and you will see the package name under the respective " + "tab and you will see the package name under the respective " +
"application..", required = true ) "application..", required = true)
private String packageName; private String packageName;
@ApiModelProperty(name = "appIdentifier", value = "The package name of the application.", required = true ) @ApiModelProperty(name = "appIdentifier", value = "The package name of the application.", required = true)
private String appIdentifier; private String appIdentifier;
private String location; private String location;
@ApiModelProperty(name = "properties", value = "List of meta data.", required = true ) @ApiModelProperty(name = "properties", value = "List of meta data.", required = true)
private Properties properties; private Properties properties;
public MobileAppTypes getType() { public MobileAppTypes getType() {

@ -18,11 +18,10 @@
package org.wso2.carbon.device.mgt.jaxrs.beans; package org.wso2.carbon.device.mgt.jaxrs.beans;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import org.wso2.carbon.device.mgt.core.dto.DeviceType; import org.wso2.carbon.device.mgt.core.dto.DeviceType;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlRootElement;
import java.sql.Timestamp; import java.sql.Timestamp;
@ -118,4 +117,5 @@ public class Profile {
public void setProfileFeaturesList(List<ProfileFeature> profileFeaturesList) { public void setProfileFeaturesList(List<ProfileFeature> profileFeaturesList) {
this.profileFeaturesList = profileFeaturesList; this.profileFeaturesList = profileFeaturesList;
} }
} }

@ -23,54 +23,54 @@ import io.swagger.annotations.ApiModelProperty;
import org.wso2.carbon.user.mgt.common.UIPermissionNode; import org.wso2.carbon.user.mgt.common.UIPermissionNode;
@ApiModel(value = "RoleWrapper", description = "Role details including permission and the users in the roles are " + @ApiModel(value = "RoleWrapper", description = "Role details including permission and the users in the roles are " +
"wrapped here.") "wrapped here.")
public class RoleWrapper { public class RoleWrapper {
@ApiModelProperty(name = "roleName", value = "The name of the role.", required = true) @ApiModelProperty(name = "roleName", value = "The name of the role.", required = true)
private String roleName; private String roleName;
@ApiModelProperty(name = "permissions", value = "Lists out all the permissions associated with roles.", @ApiModelProperty(name = "permissions", value = "Lists out all the permissions associated with roles.",
required = true) required = true, dataType = "List[java.lang.String]")
private String[] permissions; private String[] permissions;
@ApiModelProperty(name = "users", value = "The list of users assigned to the selected role.", @ApiModelProperty(name = "users", value = "The list of users assigned to the selected role.",
required = true) required = true, dataType = "List[java.lang.String]")
private String[] users; private String[] users;
@ApiModelProperty(name = "permissionList", value = "This contain the following, " + @ApiModelProperty(name = "permissionList", value = "This contain the following, " +
"\n resourcePath\tThe path related to the API.\n " + "\n resourcePath\tThe path related to the API.\n " +
"displayName\tThe name of the permission that is shown " + "displayName\tThe name of the permission that is shown " +
"in the UI.\n" + "in the UI.\n" +
"nodeList\tLists out the nested permissions.", "nodeList\tLists out the nested permissions.",
required = true) required = true)
private UIPermissionNode permissionList; private UIPermissionNode permissionList;
public String getRoleName() { public String getRoleName() {
return roleName; return roleName;
} }
public void setRoleName(String roleName) { public void setRoleName(String roleName) {
this.roleName = roleName; this.roleName = roleName;
} }
public String[] getPermissions() { public String[] getPermissions() {
return permissions; return permissions;
} }
public void setPermissions(String[] permissions) { public void setPermissions(String[] permissions) {
this.permissions = permissions; this.permissions = permissions;
} }
public String[] getUsers() { public String[] getUsers() {
return users; return users;
} }
public void setUsers(String[] users) { public void setUsers(String[] users) {
this.users = users; this.users = users;
} }
public UIPermissionNode getPermissionList() { public UIPermissionNode getPermissionList() {
return permissionList; return permissionList;
} }
public void setPermissionList(UIPermissionNode permissionList) { public void setPermissionList(UIPermissionNode permissionList) {
this.permissionList = permissionList; this.permissionList = permissionList;
} }
} }

@ -24,145 +24,46 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd"> http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
<jaxrs:server id="operationService" address="/operations"> <jaxrs:server id="services" address="/">
<jaxrs:serviceBeans> <jaxrs:serviceBeans>
<ref bean="operationServiceBean"/> <ref bean="operationServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="featureService" address="/features">
<jaxrs:serviceBeans>
<ref bean="featureServiceBean"/> <ref bean="featureServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="deviceService" address="/devices">
<jaxrs:serviceBeans>
<ref bean="deviceServiceBean"/> <ref bean="deviceServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="deviceGroupService" address="/groups">
<jaxrs:serviceBeans>
<ref bean="groupServiceBean"/> <ref bean="groupServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="userService" address="/users">
<jaxrs:serviceBeans>
<ref bean="userServiceBean"/> <ref bean="userServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="roleService" address="/roles">
<jaxrs:serviceBeans>
<ref bean="roleServiceBean"/> <ref bean="roleServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="policyService" address="/policies">
<jaxrs:serviceBeans>
<ref bean="policyServiceBean"/> <ref bean="policyServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="profileService" address="/profiles">
<jaxrs:serviceBeans>
<ref bean="profileServiceBean"/> <ref bean="profileServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="configurationService" address="/configuration">
<jaxrs:serviceBeans>
<ref bean="configurationServiceBean"/> <ref bean="configurationServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="licenseService" address="/license">
<jaxrs:serviceBeans>
<ref bean="licenseServiceBean"/> <ref bean="licenseServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="certificateService" address="/certificates">
<jaxrs:serviceBeans>
<ref bean="certificateServiceBean"/> <ref bean="certificateServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="notificationService" address="/notifications">
<jaxrs:serviceBeans>
<ref bean="notificationServiceBean"/> <ref bean="notificationServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="informationService" address="/information">
<jaxrs:serviceBeans>
<ref bean="informationServiceBean"/> <ref bean="informationServiceBean"/>
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="jsonProvider"/>
<ref bean="errorHandler"/>
</jaxrs:providers>
</jaxrs:server>
<jaxrs:server id="searchService" address="/search">
<jaxrs:serviceBeans>
<ref bean="searchingServiceBean"/> <ref bean="searchingServiceBean"/>
<ref bean="swaggerResource"/>
</jaxrs:serviceBeans> </jaxrs:serviceBeans>
<jaxrs:providers> <jaxrs:providers>
<ref bean="jsonProvider"/> <ref bean="jsonProvider"/>
<ref bean="errorHandler"/> <ref bean="errorHandler"/>
<ref bean="swaggerWriter"/>
</jaxrs:providers> </jaxrs:providers>
</jaxrs:server> </jaxrs:server>
<!--
<jaxrs:server id="authenticationService" address="/authentication"> <bean id="swaggerWriter" class="io.swagger.jaxrs.listing.SwaggerSerializers" />
<jaxrs:serviceBeans> <bean id="swaggerResource" class="io.swagger.jaxrs.listing.ApiListingResource" />
<ref bean="authenticationServiceBean"/>
</jaxrs:serviceBeans> <bean id="swaggerConfig" class="io.swagger.jaxrs.config.BeanConfig">
<jaxrs:providers> <property name="resourcePackage" value="org.wso2.carbon.device.mgt.jaxrs"/>
<ref bean="jsonProvider"/> <property name="version" value="1.0.0"/>
<ref bean="errorHandler"/> <property name="host" value="localhost:9443"/>
</jaxrs:providers> <property name="basePath" value="/"/>
</jaxrs:server> <property name="title" value="Device Management Admin Service API Definitions"/>
--> <property name="contact" value="dev@wso2.org"/>
<property name="license" value="Apache 2.0"/>
<property name="licenseUrl" value="http://www.apache.org/licenses/LICENSE-2.0.html"/>
<property name="scan" value="true"/>
</bean>
<bean id="operationServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.OperationImpl"/> <bean id="operationServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.OperationImpl"/>
<bean id="deviceServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.DeviceImpl"/> <bean id="deviceServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.DeviceImpl"/>
<bean id="groupServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.GroupImpl"/> <bean id="groupServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.GroupImpl"/>
@ -175,9 +76,6 @@
<bean id="certificateServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.CertificateImpl"/> <bean id="certificateServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.CertificateImpl"/>
<bean id="informationServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.DeviceInformationImpl"/> <bean id="informationServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.DeviceInformationImpl"/>
<bean id="searchingServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.DeviceSearchImpl"/> <bean id="searchingServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.DeviceSearchImpl"/>
<!--
<bean id="authenticationServiceBean" class="AuthenticationImpl"/>
-->
<bean id="policyServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.PolicyImpl"/> <bean id="policyServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.PolicyImpl"/>
<bean id="profileServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.ProfileImpl"/> <bean id="profileServiceBean" class="org.wso2.carbon.device.mgt.jaxrs.api.impl.ProfileImpl"/>
<bean id="jsonProvider" class="org.wso2.carbon.device.mgt.jaxrs.common.GsonMessageBodyHandler"/> <bean id="jsonProvider" class="org.wso2.carbon.device.mgt.jaxrs.common.GsonMessageBodyHandler"/>

@ -25,6 +25,16 @@
<servlet-class> <servlet-class>
org.apache.cxf.transport.servlet.CXFServlet org.apache.cxf.transport.servlet.CXFServlet
</servlet-class> </servlet-class>
<!--<init-param>-->
<!--<param-name>swagger.api.basepath</param-name>-->
<!--<param-value>http://localhost:9763/test</param-value>-->
<!--</init-param>-->
<!-- configure a security filter -->
<init-param>
<param-name>swagger.security.filter</param-name>
<param-value>ApiAuthorizationFilterImpl</param-value>
</init-param>
<load-on-startup>1</load-on-startup> <load-on-startup>1</load-on-startup>
</servlet> </servlet>
<servlet-mapping> <servlet-mapping>
@ -41,7 +51,7 @@
</context-param> </context-param>
<context-param> <context-param>
<param-name>doAuthentication</param-name> <param-name>doAuthentication</param-name>
<param-value>true</param-value> <param-value>false</param-value>
</context-param> </context-param>
<!--context-param> <!--context-param>
<param-name>managed-api-enabled</param-name> <param-name>managed-api-enabled</param-name>
@ -71,4 +81,13 @@
</user-data-constraint> </user-data-constraint>
</security-constraint> </security-constraint>
<filter>
<filter-name>ApiOriginFilter</filter-name>
<filter-class>org.wso2.carbon.device.mgt.jaxrs.ApiOriginFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>ApiOriginFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app> </web-app>

@ -24,35 +24,36 @@ import java.io.Serializable;
import java.util.List; import java.util.List;
@ApiModel(value = "Device", description = "This class carries all information related to a managed device.") @ApiModel(value = "Device", description = "This class carries all information related to a managed device.")
public class Device implements Serializable{ public class Device implements Serializable {
private static final long serialVersionUID = 1998101711L; private static final long serialVersionUID = 1998101711L;
@ApiModelProperty(name = "id", value = "ID of the device in the WSO2 EMM device information database.", @ApiModelProperty(name = "id", value = "ID of the device in the WSO2 EMM device information database.",
required = true) required = true)
private int id; private int id;
@ApiModelProperty(name = "name", value = "The device name that can be set on the device by the device user.", @ApiModelProperty(name = "name", value = "The device name that can be set on the device by the device user.",
required = true) required = true)
private String name; private String name;
@ApiModelProperty(name = "type", value = "The OS type of the device.", required = true) @ApiModelProperty(name = "type", value = "The OS type of the device.", required = true)
private String type; private String type;
@ApiModelProperty(name = "description", value = "Additional information on the device.", required = true) @ApiModelProperty(name = "description", value = "Additional information on the device.", required = true)
private String description; private String description;
@ApiModelProperty(name = "deviceIdentifier", value = "This is a 64-bit number (as a hex string) that is randomly" + @ApiModelProperty(name = "deviceIdentifier", value = "This is a 64-bit number (as a hex string) that is randomly" +
" generated when the user first sets up the device and should" + " generated when the user first sets up the device and should" +
" remain constant for the lifetime of the user's device." + " remain constant for the lifetime of the user's device." +
" The value may change if a factory reset is performed on " + " The value may change if a factory reset is performed on " +
"the device.", "the device.",
required = true) required = true)
private String deviceIdentifier; private String deviceIdentifier;
@ApiModelProperty(name = "enrolmentInfo", value = "This defines the device registration related information. " + @ApiModelProperty(name = "enrolmentInfo", value = "This defines the device registration related information. " +
"It is mandatory to define this information.", required = true) "It is mandatory to define this information.", required = true)
private EnrolmentInfo enrolmentInfo; private EnrolmentInfo enrolmentInfo;
@ApiModelProperty(name = "features", value = "List of features.", required = true) @ApiModelProperty(name = "features", value = "List of features.", required = true)
private List<Feature> features; private List<Feature> features;
private List<Device.Property> properties; private List<Device.Property> properties;
public Device() {} public Device() {
}
public Device(String name, String type, String description, String deviceId, EnrolmentInfo enrolmentInfo, public Device(String name, String type, String description, String deviceId, EnrolmentInfo enrolmentInfo,
List<Feature> features, List<Property> properties) { List<Feature> features, List<Property> properties) {
@ -65,13 +66,13 @@ public class Device implements Serializable{
this.properties = properties; this.properties = properties;
} }
public int getId() { public int getId() {
return id; return id;
} }
public void setId(int id) { public void setId(int id) {
this.id = id; this.id = id;
} }
public String getName() { public String getName() {
return name; return name;
@ -89,21 +90,21 @@ public class Device implements Serializable{
this.type = type; this.type = type;
} }
public String getDescription() { public String getDescription() {
return description; return description;
} }
public void setDescription(String description) { public void setDescription(String description) {
this.description = description; this.description = description;
} }
public String getDeviceIdentifier() { public String getDeviceIdentifier() {
return deviceIdentifier; return deviceIdentifier;
} }
public void setDeviceIdentifier(String deviceIdentifier) { public void setDeviceIdentifier(String deviceIdentifier) {
this.deviceIdentifier = deviceIdentifier; this.deviceIdentifier = deviceIdentifier;
} }
public EnrolmentInfo getEnrolmentInfo() { public EnrolmentInfo getEnrolmentInfo() {
return enrolmentInfo; return enrolmentInfo;
@ -113,43 +114,43 @@ public class Device implements Serializable{
this.enrolmentInfo = enrolmentInfo; this.enrolmentInfo = enrolmentInfo;
} }
public List<Feature> getFeatures() { public List<Feature> getFeatures() {
return features; return features;
} }
public void setFeatures(List<Feature> features) { public void setFeatures(List<Feature> features) {
this.features = features; this.features = features;
} }
public List<Device.Property> getProperties() { public List<Device.Property> getProperties() {
return properties; return properties;
} }
public void setProperties(List<Device.Property> properties) { public void setProperties(List<Device.Property> properties) {
this.properties = properties; this.properties = properties;
} }
public static class Property { public static class Property {
private String name; private String name;
private String value; private String value;
public String getName() { public String getName() {
return name; return name;
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
public String getValue() { public String getValue() {
return value; return value;
} }
public void setValue(String value) { public void setValue(String value) {
this.value = value; this.value = value;
} }
} }
@Override @Override
public String toString() { public String toString() {
@ -166,22 +167,22 @@ public class Device implements Serializable{
"]"; "]";
} }
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) if (this == o)
return true; return true;
if (!(o instanceof Device)) if (!(o instanceof Device))
return false; return false;
Device device = (Device) o; Device device = (Device) o;
return getDeviceIdentifier().equals(device.getDeviceIdentifier()); return getDeviceIdentifier().equals(device.getDeviceIdentifier());
} }
@Override @Override
public int hashCode() { public int hashCode() {
return getDeviceIdentifier().hashCode(); return getDeviceIdentifier().hashCode();
} }
} }

@ -25,13 +25,13 @@ import org.wso2.carbon.device.mgt.common.Device;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
@ApiModel(value = "DeviceWrapper", description = "This contains device details including, " + @ApiModel(value = "DeviceWrapper", description = "This contains device details including, " +
"location and device meta information.") "location and device meta information.")
public class DeviceWrapper { public class DeviceWrapper {
@ApiModelProperty(name = "device", value = "Device's basic information", required = true) @ApiModelProperty(name = "device", value = "Device's basic information", required = true)
private Device device; private Device device;
@ApiModelProperty(name = "deviceIdentifier", value = "Device identifier used to identify a device.", @ApiModelProperty(name = "deviceIdentifier", value = "Device identifier used to identify a device.",
required = true) required = true)
private DeviceIdentifier deviceIdentifier; private DeviceIdentifier deviceIdentifier;
@ApiModelProperty(name = "deviceInfo", value = "Device's runtime information", required = true) @ApiModelProperty(name = "deviceInfo", value = "Device's runtime information", required = true)
private DeviceInfo deviceInfo; private DeviceInfo deviceInfo;

@ -1456,10 +1456,23 @@
<artifactId>swagger-annotations</artifactId> <artifactId>swagger-annotations</artifactId>
<version>${swagger.version}</version> <version>${swagger.version}</version>
</dependency> </dependency>
</dependencies> <dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-core</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jaxrs</artifactId>
<version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${servlet-api.version}</version>
</dependency>
</dependencies>
</dependencyManagement> </dependencyManagement>
<scm> <scm>
@ -1823,6 +1836,7 @@
<nimbus.orbit.version.range>[2.26.1, 3.0.0)</nimbus.orbit.version.range> <nimbus.orbit.version.range>[2.26.1, 3.0.0)</nimbus.orbit.version.range>
<swagger.version>1.5.8</swagger.version> <swagger.version>1.5.8</swagger.version>
<servlet-api.version>2.5</servlet-api.version>
</properties> </properties>
</project> </project>

Loading…
Cancel
Save