Improving swagger annotations

revert-dabc3590
prabathabey 9 years ago
parent 631d57e70d
commit 63bb616e9c

@ -45,15 +45,47 @@ public interface DeviceManagementService {
tags = "Android Device Management" tags = "Android Device Management"
) )
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "OK. \n " + @ApiResponse(
"Application list of the device has successfully been updated"), code = 200,
@ApiResponse(code = 500, message = "Internal Server Error. \n " + message = "OK. \n Application list has been updated successfully",
"Sever error occurred while modifying the application list") responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "The URL of the updated application list."),
@ResponseHeader(
name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 404,
message = "Not Found. \n Resource to be deleted does not exist."),
@ApiResponse(
code = 415,
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while updating the application list.")
}) })
Response updateApplicationList(@ApiParam(name = "id", value = "Device Identifier") @PathParam("id") String id, Response updateApplicationList(
@ApiParam(name = "applications", value = "List of applications that need to be " + @ApiParam(
"persisted against the device") name = "id",
List<Application> applications); value = "Device Identifier")
@PathParam("id") String id,
@ApiParam(
name = "applications",
value = "List of applications that need to be persisted against the device")
List<Application> applications);
@GET @GET
@Path("/{id}/pending-operations") @Path("/{id}/pending-operations")
@ -67,33 +99,52 @@ public interface DeviceManagementService {
response = Operation.class, response = Operation.class,
tags = "Android Device Management") tags = "Android Device Management")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "OK. \n List of pending operations of the device is returned", @ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the pending application list of the Android device.",
response = Operation.class,
responseContainer = "List",
responseHeaders = { responseHeaders = {
@ResponseHeader(name = "Content-Type", description = "The content type of the body"), @ResponseHeader(
@ResponseHeader(name = "ETag", description = "Entity Tag of the response resource.\n" + name = "Content-Type",
"Used by caches, or in conditional requests."), description = "The content type of the body"),
@ResponseHeader(name = "Last-Modified", @ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" + description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests.")}), "Used by caches, or in conditional requests.")
@ApiResponse(code = 303, message = "See Other. \n " + }),
"Source can be retrieved from the URL specified at the Location header.", @ApiResponse(
responseHeaders = { code = 304,
@ResponseHeader(name = "Location", description = "The Source URL of the document.")}), message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ApiResponse(code = 304, message = "Not Modified. \n " + @ApiResponse(
"Empty body because the client already has the latest version of the requested resource."), code = 406,
@ApiResponse(code = 400, message = "Bad Request. \n Invalid request or validation error."), message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(code = 404, message = "Not Found. \n Requested device not found."), @ApiResponse(
@ApiResponse(code = 406, message = "Not Acceptable. \n The requested media type is not supported."), code = 500,
@ApiResponse(code = 500, message = "Internal Server Error. \n " + message = "Internal Server Error. \n Server error occurred while fetching policies.")
"Server error occurred while retrieving the pending operation list of the device.")
}) })
Response getPendingOperations( Response getPendingOperations(
@ApiParam(name = "id", value = "Device Identifier") @PathParam("id") String id, @ApiParam(
@ApiParam(name = "resultOperations", value = "Device Operation Status") name = "id",
value = "Device Identifier")
@PathParam("id") String id,
@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 = "resultOperations",
value = "Device Operation Status")
List<? extends Operation> resultOperations); List<? extends Operation> resultOperations);
@POST @POST
@ApiOperation( @ApiOperation(
produces = MediaType.APPLICATION_JSON,
consumes = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST", httpMethod = "POST",
value = "Register an Android Device", value = "Register an Android Device",
@ -104,13 +155,41 @@ public interface DeviceManagementService {
tags = "Android Device Management" tags = "Android Device Management"
) )
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 201, message = "Created. \n Device has successfully been enrolled. Location header " + @ApiResponse(
"contains URL of newly enrolled device", code = 201,
message = "Created. \n Device enrollment has successfully been created",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "URL of the added device enrollment."),
@ResponseHeader(
name = "Content-Type",
description = "Content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 303,
message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
responseHeaders = { responseHeaders = {
@ResponseHeader(name = "Location", description = "URL of the device enrolled")}), @ResponseHeader(
@ApiResponse(code = 400, message = "Bad Request. \n Invalid request or validation error."), name = "Content-Location",
@ApiResponse(code = 500, message = "Internal Server Error. \n " + description = "The Source URL of the document.")}),
"Server error occurred while enrolling the device.") @ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while adding a new policy.")
}) })
Response enrollDevice(@ApiParam(name = "device", value = "Device Information to be enroll") Device device); Response enrollDevice(@ApiParam(name = "device", value = "Device Information to be enroll") Device device);
@ -123,25 +202,42 @@ public interface DeviceManagementService {
tags = "Android Device Management" tags = "Android Device Management"
) )
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "Device has already enrolled", @ApiResponse(
code = 200,
message = "OK. \n Successfully fetched the status of the Android device enrollment.",
responseHeaders = { responseHeaders = {
@ResponseHeader(name = "Content-Type", description = "The content type of the body"), @ResponseHeader(
@ResponseHeader(name = "ETag", description = "Entity Tag of the response resource.\n" + name = "Content-Type",
"Used by caches, or in conditional requests."), description = "The content type of the body"),
@ResponseHeader(name = "Last-Modified", @ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" + description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests.")}), "Used by caches, or in conditional requests."),
@ApiResponse(code = 404, message = "Not Found. \n Requested device not found."), }),
@ApiResponse(code = 303, message = "See Other. \n " + @ApiResponse(
"Source can be retrieved from the URL specified at the Location header.", code = 304,
responseHeaders = { message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ResponseHeader(name = "Location", description = "The Source URL of the document.")}), @ApiResponse(
@ApiResponse(code = 304, message = "Not Modified. \n " + code = 406,
"Empty body because the client already has the latest version of the requested resource."), message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(code = 500, message = "Internal Server Error. \n " + @ApiResponse(
"Server error occurred while retrieving the enrollment status of the device."), code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the enrollment status of the Android device.")
}) })
Response isEnrolled(@ApiParam(name = "id", value = "Device Identifier") @PathParam("id") String id); Response isEnrolled(
@ApiParam(
name = "id",
value = "Device Identifier")
@PathParam("id") String id,
@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);
@PUT @PUT
@Path("/{id}") @Path("/{id}")
@ -151,47 +247,73 @@ public interface DeviceManagementService {
notes = "Use this REST API to update the registration details of an Android device", notes = "Use this REST API to update the registration details of an Android device",
tags = "Android Device Management" tags = "Android Device Management"
) )
@ApiResponses(value = { @ApiResponses(
@ApiResponse(code = 200, message = "OK. \n Device enrollment has been updated successfully", value = {
responseHeaders = { @ApiResponse(
@ResponseHeader(name = "Content-Location", description = "The URL of the updated device."), code = 200,
@ResponseHeader(name = "Content-Type", description = "The content type of the body"), message = "OK. \n Device enrollment has been updated successfully",
@ResponseHeader(name = "ETag", description = "Entity Tag of the response resource.\n" + responseHeaders = {
"Used by caches, or in conditional requests."), @ResponseHeader(
@ResponseHeader(name = "Last-Modified", name = "Content-Location",
description = "Date and time the resource has been modified the last time.\n" + description = "URL of the updated device enrollment."),
"Used by caches, or in conditional requests.")}), @ResponseHeader(
@ApiResponse( name = "Content-Type",
code = 204, description = "Content type of the body"),
message = "No Content. \n Enrollment of the device has not been updated"), @ResponseHeader(
@ApiResponse( name = "ETag",
code = 400, description = "Entity Tag of the response resource.\n" +
message = "Bad Request. \n Invalid request or validation error."), "Used by caches, or in conditional requests."),
@ApiResponse( @ResponseHeader(
code = 404, name = "Last-Modified",
message = "Not Found. \n Resource to be deleted does not exist."), description = "Date and time the resource has been modified the last time.\n" +
@ApiResponse( "Used by caches, or in conditional requests.")}),
code = 500, @ApiResponse(
message = "Internal Server Error. \n " + code = 400,
"Server error occurred while modifying the current enrollment of the device.") message = "Bad Request. \n Invalid request or validation error."),
}) @ApiResponse(
Response modifyEnrollment(@ApiParam(name = "id", value = "Device Identifier") @PathParam("id") String id, code = 404,
@ApiParam(name = "device", value = "Device information to be modify") Device device); message = "Not Found. \n Resource to be deleted does not exist."),
@ApiResponse(
code = 415,
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while updating the device enrollment.")
})
Response modifyEnrollment(
@ApiParam(
name = "id",
value = "Device Identifier")
@PathParam("id") String id,
@ApiParam(
name = "device",
value = "Device information to be modify") Device device);
@DELETE @DELETE
@Path("/{id}") @Path("/{id}")
@ApiOperation( @ApiOperation(
httpMethod = "DELETE", httpMethod = "DELETE",
value = "Un-registering an Android Device", value = "Un-register an Android Device",
notes = "Use this REST API to un-register a specific Android device", notes = "Use this REST API to un-register a specific Android device",
tags = "Android Device Management" tags = "Android Device Management"
) )
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "OK. \n Device has successfully been dis-enrolled"), @ApiResponse(
@ApiResponse(code = 404, message = "Not Found. \n Device requested to be dis-enrolled does not exist."), code = 200,
@ApiResponse(code = 500, message = "Internal Server Error. \n " + message = "OK. \n Device has successfully been dis-enrolled"),
"Server error occurred while dis-enrolling the the device."), @ApiResponse(
code = 404,
message = "Not Found. \n Resource to be deleted does not exist."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while dis-enrolling the device.")
}) })
Response disEnrollDevice(@ApiParam(name = "id", value = "Device Identifier") @PathParam("id") String id); Response disEnrollDevice(
@ApiParam(
name = "id",
value = "Device Identifier")
@PathParam("id") String id);
} }

@ -33,28 +33,9 @@ import javax.ws.rs.core.Response;
@Consumes(MediaType.APPLICATION_JSON) @Consumes(MediaType.APPLICATION_JSON)
public interface DeviceTypeConfigurationService { public interface DeviceTypeConfigurationService {
@POST
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Configuring Android platform settings.",
notes = "Configure the Android platform settings using this REST API.",
tags = "Android Configuration Management"
)
@ApiResponses(value = {
@ApiResponse(code = 201, message = "Created. \n Android platform configuration saved successfully",
responseHeaders = {
@ResponseHeader(name = "Location", description = "URL of the configuration added.")
}),
@ApiResponse(code = 400, message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(code = 500, message = "Internal Server Error. \n" +
" Error occurred while saving configurations for the android platform.")
})
Response addConfiguration(@ApiParam(name = "configuration",
value = "Android platform related configurations that must be added.")
PlatformConfiguration configuration);
@GET @GET
@ApiOperation( @ApiOperation(
produces = MediaType.APPLICATION_JSON,
httpMethod = "GET", httpMethod = "GET",
value = "Getting Android Platform Configurations", value = "Getting Android Platform Configurations",
notes = "Get the Android platform configuration details using this REST API", notes = "Get the Android platform configuration details using this REST API",
@ -62,18 +43,42 @@ public interface DeviceTypeConfigurationService {
tags = "Android Configuration Management" tags = "Android Configuration Management"
) )
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "Get Android Configuration."), @ApiResponse(
@ApiResponse(code = 303, message = "See Other. \n " + code = 200,
"Source can be retrieved from the URL specified at the Location header.", message = "OK. \n Successfully fetched Android platform configuration.",
response = PlatformConfiguration.class,
responseHeaders = { responseHeaders = {
@ResponseHeader(name = "Location", description = "The Source URL of the document.")}), @ResponseHeader(
@ApiResponse(code = 304, message = "Not Modified. \n " + name = "Content-Type",
"Empty body because the client already has the latest version of the requested resource."), description = "Content type of the body"),
@ApiResponse(code = 404, message = "Not Found. \n Resource requested does not exist."), @ResponseHeader(
@ApiResponse(code = 500, message = "Internal Server Error. \n Error occurred while fetching " + name = "ETag",
"configuration settings of Android platform.") description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ApiResponse(
code = 404,
message = "Not Found. \n Resource to be deleted does not exist."),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching Android platform configuration.")
}) })
Response getConfiguration() throws AndroidAgentException; Response getConfiguration(
@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);
@PUT @PUT
@ApiOperation( @ApiOperation(
@ -85,20 +90,48 @@ public interface DeviceTypeConfigurationService {
tags = "Android Configuration Management" tags = "Android Configuration Management"
) )
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "Created. \n Configurations was updated successfully."), @ApiResponse(
@ApiResponse(code = 400, message = "Bad Request. \n Invalid request or validation error."), code = 200,
@ApiResponse(code = 404, message = "Not Found. \n Resource to be changed does not exist."), message = "OK. \n Android platform configuration has been updated successfully",
@ApiResponse(code = 500, message = "Internal Server Error. \n Error occurred while modifying " + responseHeaders = {
"configuration settings of Android platform.") @ResponseHeader(
name = "Content-Location",
description = "URL of the updated Android platform configuration."),
@ResponseHeader(
name = "Content-Type",
description = "Content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests.")}),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 404,
message = "Not Found. \n Resource to be deleted does not exist."),
@ApiResponse(
code = 415,
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while modifying Android platform configuration.")
}) })
Response updateConfiguration(@ApiParam(name = "configuration", value = "AndroidPlatformConfiguration") Response updateConfiguration(
PlatformConfiguration configuration) throws AndroidAgentException; @ApiParam(name = "configuration",
value = "AndroidPlatformConfiguration")
PlatformConfiguration configuration);
@GET @GET
@Path("license") @Path("license")
@Produces("text/plain") @Produces(MediaType.TEXT_PLAIN)
@ApiOperation( @ApiOperation(
produces = MediaType.APPLICATION_JSON, produces = MediaType.TEXT_PLAIN,
httpMethod = "GET", httpMethod = "GET",
value = "Getting the License Agreement for Android Device Registration", value = "Getting the License Agreement for Android Device Registration",
notes = "Use this REST API to retrieve the license agreement that is used for the Android device " + notes = "Use this REST API to retrieve the license agreement that is used for the Android device " +
@ -106,10 +139,41 @@ public interface DeviceTypeConfigurationService {
response = String.class, response = String.class,
tags = "Android Configuration Management") tags = "Android Configuration Management")
@ApiResponses(value = { @ApiResponses(value = {
@ApiResponse(code = 200, message = "Licence agreement"), @ApiResponse(
@ApiResponse(code = 500, message = "Error occurred while retrieving the license configured for Android " + code = 200,
"device enrolment") message = "OK. \n Successfully fetched Android license configuration.",
response = PlatformConfiguration.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Type",
description = "Content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests."),
}),
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of the requested resource."),
@ApiResponse(
code = 404,
message = "Not Found. \n Resource to be deleted does not exist."),
@ApiResponse(
code = 406,
message = "Not Acceptable.\n The requested media type is not supported"),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching Android license configuration.")
}) })
Response getLicense() throws AndroidAgentException; Response getLicense(
@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) throws AndroidAgentException;
} }

@ -35,24 +35,55 @@ public interface EventReceiverService {
@POST @POST
@Path("/publish") @Path("/publish")
@ApiOperation( @ApiOperation(
produces = MediaType.APPLICATION_JSON,
consumes = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON,
httpMethod = "POST", httpMethod = "POST",
value = "Event publishing via REST API.", value = "Event publishing via REST API.",
notes = "Publish events received by the EMM Android client to WSO2 DAS using this API.", notes = "Publish events received by the EMM Android client to WSO2 DAS using this API.",
tags = "Event Receiver" tags = "Event Receiver"
) )
@ApiResponses(value = { @ApiResponses(
@ApiResponse(code = 201, message = "Created. \n Event is published successfully. Location header " + value = {
"contains URL of newly enrolled device", @ApiResponse(code = 201, message = "Created. \n Event is published successfully. Location header " +
responseHeaders = { "contains URL of newly enrolled device",
@ResponseHeader(name = "Location", description = "URL of the newly published event.") responseHeaders = {
}), @ResponseHeader(
@ApiResponse(code = 400, message = "Bad Request. \n Invalid request or validation error."), name = "Content-Location",
@ApiResponse(code = 500, message = "Internal Server Error. \n" + description = "The URL of the added policy."),
" Error occurred while publishing the events from Android agent.") @ResponseHeader(
}) name = "Content-Type",
description = "The content type of the body"),
@ResponseHeader(
name = "ETag",
description = "Entity Tag of the response resource.\n" +
"Used by caches, or in conditional requests."),
@ResponseHeader(
name = "Last-Modified",
description = "Date and time the resource has been modified the last time.\n" +
"Used by caches, or in conditional requests.")
}),
@ApiResponse(
code = 303,
message = "See Other. \n Source can be retrieved from the URL specified at the Location header.",
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "The Source URL of the document.")}),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error."),
@ApiResponse(
code = 415,
message = "Unsupported media type. \n The entity of the request was in a not supported format."),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n " +
"Server error occurred while publishing events.")
})
Response publishEvents( Response publishEvents(
@ApiParam(name = "eventBeanWrapper", value = "Information of the agent event to be published on DAS.") @ApiParam(
name = "eventBeanWrapper",
value = "Information of the agent event to be published on DAS.")
EventBeanWrapper eventBeanWrapper); EventBeanWrapper eventBeanWrapper);
@GET @GET
@ -68,30 +99,57 @@ public interface EventReceiverService {
responseContainer = "List", responseContainer = "List",
tags = "Event Receiver" tags = "Event Receiver"
) )
@ApiResponses(value = { @ApiResponses(
@ApiResponse(code = 200, message = "Created \n Event details of a device for a given time duration", value = {
response = DeviceState.class, responseContainer = "List"), @ApiResponse(
@ApiResponse(code = 303, message = "See Other. \n Source can be retrieved from the URL specified at" + code = 200,
" the Location header.", message = "OK. \n Event details of a device for a given time duration have been successfully fetched",
responseHeaders = { response = DeviceState.class, responseContainer = "List"),
@ResponseHeader(name = "Location", description = "The Source URL of the document.") @ApiResponse(
}), code = 303,
@ApiResponse(code = 304, message = "Not Modified. \n " + message = "See Other. \n Source can be retrieved from the URL specified at" +
"Empty body because the client already has the latest version of the requested resource."), " the Location header.",
@ApiResponse(code = 400, message = "Bad Request. \n Invalid request or validation error. You must provide" + responseHeaders = {
" the device identifier. Additionally, the device identifier can be combined with either the type" + @ResponseHeader(name = "Content-Location", description = "Source URL of the document.")
" OR date from and to."), }),
@ApiResponse(code = 404, message = "Not Found. \n Resource requested does not exist."), @ApiResponse(
@ApiResponse(code = 500, message = "Error occurred while getting published events for specific device.") code = 304,
}) message = "Not Modified. \n " +
"Empty body because the client already has the latest version of the requested resource."),
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error. You must provide" +
" the device identifier. Additionally, the device identifier can be combined with either the type" +
" OR date from and to."),
@ApiResponse(
code = 404,
message = "Not Found. \n Resource requested does not exist."),
@ApiResponse(
code = 500,
message = "Error occurred while getting published events for specific device.")
})
Response retrieveAlerts( Response retrieveAlerts(
@ApiParam(name = "id", value = "Device Identifier to be need to retrieve events.", required = true) @ApiParam(
name = "id",
value = "Device Identifier to be need to retrieve events.",
required = true)
@QueryParam("id") String deviceId, @QueryParam("id") String deviceId,
@ApiParam(name = "from", value = "From Date.") @ApiParam(
name = "from",
value = "From Date.")
@QueryParam("from") long from, @QueryParam("from") long from,
@ApiParam(name = "to", value = "To Date.") @ApiParam(
name = "to",
value = "To Date.")
@QueryParam("to") long to, @QueryParam("to") long to,
@ApiParam(name = "type", value = "Type of the Alert to be need to retrieve events.") @ApiParam(
@QueryParam("type") String type); name = "type",
value = "Type of the Alert to be need to retrieve events.")
@QueryParam("type") String type,
@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);
} }

@ -76,7 +76,9 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
@PUT @PUT
@Path("/{id}/pending-operations") @Path("/{id}/pending-operations")
@Override @Override
public Response getPendingOperations(@PathParam("id") String id, List<? extends Operation> resultOperations) { public Response getPendingOperations(@PathParam("id") String id,
@HeaderParam("If-Modified-Since") String ifModifiedSince,
List<? extends Operation> resultOperations) {
if (id == null || id.isEmpty()) { if (id == null || id.isEmpty()) {
String msg = "Device identifier is null or empty, hence returning device not found"; String msg = "Device identifier is null or empty, hence returning device not found";
log.error(msg); log.error(msg);
@ -189,7 +191,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
@GET @GET
@Path("/{id}/status") @Path("/{id}/status")
@Override @Override
public Response isEnrolled(@PathParam("id") String id) { public Response isEnrolled(@PathParam("id") String id, @HeaderParam("If-Modified-Since") String ifModifiedSince) {
boolean result; boolean result;
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id); DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
try { try {

@ -44,50 +44,12 @@ public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurati
private static final Log log = LogFactory.getLog(DeviceTypeConfigurationServiceImpl.class); private static final Log log = LogFactory.getLog(DeviceTypeConfigurationServiceImpl.class);
@POST
@Override
public Response addConfiguration(PlatformConfiguration configuration){
Message responseMsg = new Message();
String msg;
ConfigurationEntry licenseEntry = null;
try {
configuration.setType(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
List<ConfigurationEntry> configs = configuration.getConfiguration();
for (ConfigurationEntry entry : configs) {
if (AndroidConstants.TenantConfigProperties.LICENSE_KEY.equals(entry.getName())) {
License license = new License();
license.setName(DeviceManagementConstants.MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID);
license.setLanguage(AndroidConstants.TenantConfigProperties.LANGUAGE_US);
license.setVersion("1.0.0");
license.setText(entry.getValue().toString());
AndroidAPIUtils.getDeviceManagementService().addLicense(DeviceManagementConstants.
MobileDeviceTypes.MOBILE_DEVICE_TYPE_ANDROID, license);
licenseEntry = entry;
break;
}
}
if (licenseEntry != null) {
configs.remove(licenseEntry);
}
configuration.setConfiguration(configs);
AndroidAPIUtils.getDeviceManagementService().saveConfiguration(configuration);
Response.status(Response.Status.CREATED);
responseMsg.setResponseMessage("Android platform configuration saved successfully.");
responseMsg.setResponseCode(Response.Status.CREATED.toString());
} catch (DeviceManagementException e) {
msg = "Error occurred while configuring the android platform";
log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
return Response.status(Response.Status.CREATED).entity(responseMsg).build();
}
@GET @GET
@Override @Override
public Response getConfiguration() throws AndroidAgentException { public Response getConfiguration(
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
String msg; String msg;
PlatformConfiguration PlatformConfiguration = null; PlatformConfiguration PlatformConfiguration;
List<ConfigurationEntry> configs; List<ConfigurationEntry> configs;
try { try {
PlatformConfiguration = AndroidAPIUtils.getDeviceManagementService(). PlatformConfiguration = AndroidAPIUtils.getDeviceManagementService().
@ -121,7 +83,7 @@ public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurati
@PUT @PUT
@Override @Override
public Response updateConfiguration(PlatformConfiguration configuration) throws AndroidAgentException { public Response updateConfiguration(PlatformConfiguration configuration) {
String msg; String msg;
Message responseMsg = new Message(); Message responseMsg = new Message();
ConfigurationEntry licenseEntry = null; ConfigurationEntry licenseEntry = null;
@ -161,9 +123,10 @@ public class DeviceTypeConfigurationServiceImpl implements DeviceTypeConfigurati
@GET @GET
@Path("license") @Path("license")
@Produces("text/plain") @Produces(MediaType.TEXT_PLAIN)
public Response getLicense() throws AndroidAgentException { public Response getLicense(
License license = null; @HeaderParam("If-Modified-Since") String ifModifiedSince) {
License license;
try { try {
license = license =

@ -71,10 +71,11 @@ public class EventReceiverServiceImpl implements EventReceiverService {
@GET @GET
@Override @Override
public Response retrieveAlerts(@QueryParam("id") String deviceId, @QueryParam ("from") long from, public Response retrieveAlerts(@QueryParam("id") String deviceId, @QueryParam("from") long from,
@QueryParam ("to") long to, @QueryParam("type") String type) { @QueryParam("to") long to, @QueryParam("type") String type,
@HeaderParam("If-Modified-Since") String ifModifiedSince) {
if(from != 0l && to != 0l && deviceId != null) { if (from != 0l && to != 0l && deviceId != null) {
return retrieveAlertFromDate(deviceId, from, to); return retrieveAlertFromDate(deviceId, from, to);
} else if (deviceId != null && type != null) { } else if (deviceId != null && type != null) {
return retrieveAlertByType(deviceId, type); return retrieveAlertByType(deviceId, type);

@ -45,7 +45,7 @@
<property name="resourcePackage" value="org.wso2.carbon.mdm.services.android.services"/> <property name="resourcePackage" value="org.wso2.carbon.mdm.services.android.services"/>
<property name="version" value="1.0"/> <property name="version" value="1.0"/>
<property name="host" value="device-mgt.wso2.com"/> <property name="host" value="device-mgt.wso2.com"/>
<property name="basePath" value="/device-mgt/android/v1.0"/> <property name="basePath" value="api/device-mgt/android/v1.0"/>
<property name="title" value="Android Device Management API Definitions"/> <property name="title" value="Android Device Management API Definitions"/>
<property name="contact" value="dev@wso2.org"/> <property name="contact" value="dev@wso2.org"/>
<property name="license" value="Apache 2.0"/> <property name="license" value="Apache 2.0"/>

Loading…
Cancel
Save