Committing VPN operation fixes + logcat operation

revert-dabc3590
Kasun Delgolla 9 years ago
parent 9341faf021
commit 79b1d51643

@ -30,7 +30,7 @@ import java.util.List;
description = "Information related to VPN Configuration.")
public class VpnBeanWrapper {
@ApiModelProperty(name = "operation",
value = "List of device Ids to be need to execute UpgradeFirmware operation.", required = true)
value = "List of device Ids to be need to execute VPN operation.", required = true)
private Vpn operation;
@ApiModelProperty(name = "deviceIDs",
value = "List of device Ids to be need to execute VPN operation.", required = true)

@ -353,6 +353,61 @@ public interface DeviceManagementAdminService {
@ApiParam(name = "deviceIds", value = "Device IDs to be requested to get device information")
List<String> deviceIDs);
@POST
@Path("/info")
@ApiOperation(
consumes = MediaType.APPLICATION_JSON,
produces = MediaType.APPLICATION_JSON,
httpMethod = "POST",
value = "Requesting Information from Android Devices",
notes = "Using this REST API you are able to request for Android device details. Once this REST API is" +
" executed it will be in the Android operation queue until the device calls the server to retrieve " +
"the list of operations that needs to be executed on the device",
response = Activity.class,
tags = "Android Device Management Administrative Service"
)
@ApiResponses(value = {
@ApiResponse(
code = 201,
message = "Created. \n Device logcat operation has successfully been scheduled",
response = Activity.class,
responseHeaders = {
@ResponseHeader(
name = "Content-Location",
description = "URL of the activity instance that refers to the scheduled operation."),
@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 = {
@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 adding a new device logcat operation.")
})
Response getDeviceLogcat(
@ApiParam(name = "deviceIds", value = "Device IDs to be requested to get device logcat")
List<String> deviceIDs);
@POST
@Path("/enterprise-wipe")
@ApiOperation(

@ -221,6 +221,31 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
}
}
@POST
@Path("/logcat")
@Override
public Response getDeviceLogcat(List<String> deviceIDs) {
if (log.isDebugEnabled()) {
log.debug("Invoking get Android device logcat operation");
}
try {
CommandOperation operation = new CommandOperation();
operation.setCode(AndroidConstants.OperationCodes.LOGCAT);
operation.setType(Operation.Type.COMMAND);
return AndroidAPIUtils.getOperationResponse(deviceIDs, operation);
} catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build();
} catch (DeviceManagementException e) {
String errorMessage = "Issue in retrieving device management service instance";
log.error(errorMessage, e);
throw new UnexpectedServerErrorException(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(errorMessage).build());
}
}
@POST
@Path("/enterprise-wipe")
@Override
@ -568,24 +593,24 @@ public class DeviceManagementAdminServiceImpl implements DeviceManagementAdminSe
@POST
@Path("/configure-vpn")
@Override
public Response configureVPN(VpnBeanWrapper vpnBeanWrapper) {
public Response configureVPN(VpnBeanWrapper vpnConfiguration) {
if (log.isDebugEnabled()) {
log.debug("Invoking Android VPN device operation");
}
try {
if (vpnBeanWrapper == null || vpnBeanWrapper.getOperation() == null) {
if (vpnConfiguration == null || vpnConfiguration.getOperation() == null) {
String errorMessage = "The payload of the VPN operation is incorrect";
log.error(errorMessage);
throw new BadRequestException(
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
}
Vpn vpn = vpnBeanWrapper.getOperation();
Vpn vpn = vpnConfiguration.getOperation();
ProfileOperation operation = new ProfileOperation();
operation.setCode(AndroidConstants.OperationCodes.VPN);
operation.setType(Operation.Type.PROFILE);
operation.setPayLoad(vpn.toJSON());
return AndroidAPIUtils.getOperationResponse(vpnBeanWrapper.getDeviceIDs(),
return AndroidAPIUtils.getOperationResponse(vpnConfiguration.getDeviceIDs(),
operation);
} catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance";

@ -96,6 +96,7 @@ public final class AndroidConstants {
public static final String DISENROLL = "DISENROLL";
public static final String MONITOR = "MONITOR";
public static final String VPN = "VPN";
public static final String LOGCAT = "LOGCAT";
public static final String APP_RESTRICTION = "APP-RESTRICTION";
public static final String WORK_PROFILE = "WORK_PROFILE";
}

@ -457,6 +457,12 @@ public class AndroidFeatureManager implements FeatureManager {
feature.setDescription("remove device owner");
supportedFeatures.add(feature);
feature = new Feature();
feature.setCode("LOGCAT");
feature.setName("Fetch Logcat");
feature.setDescription("Fetch device logcat");
supportedFeatures.add(feature);
return supportedFeatures;
}
}
Loading…
Cancel
Save