fixed comment issues

merge-requests/1/head
ayyoob 8 years ago
parent 2dab109ad3
commit abacc0ce2a

@ -140,7 +140,7 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
try { try {
device = DeviceMgtAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier); device = DeviceMgtAPIUtils.getDeviceManagementService().getDevice(deviceIdentifier);
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
String msg = "Error occurred while getting enrollment details of the Android device that carries the id '" + String msg = "Error occurred while getting enrollment details of the device that carries the id '" +
id + "'"; id + "'";
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
@ -226,7 +226,7 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
boolean authorized = DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized boolean authorized = DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized
(new DeviceIdentifier(type, deviceId)); (new DeviceIdentifier(type, deviceId));
if (!authorized) { if (!authorized) {
String msg = "does not have permission to access the device."; String msg = "Does not have permission to access the device.";
return Response.status(Response.Status.UNAUTHORIZED).entity(msg).build(); return Response.status(Response.Status.UNAUTHORIZED).entity(msg).build();
} }
} }
@ -249,7 +249,7 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
} }
if (payload.size() != attributes.size()) { if (payload.size() != attributes.size()) {
String msg = "payload does not match with the stream definition"; String msg = "Payload does not match with the stream definition";
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} }
eventAttributeList = new EventAttributeList(); eventAttributeList = new EventAttributeList();
@ -288,7 +288,7 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (AxisFault e) { } catch (AxisFault e) {
log.error("failed to retrieve event definitions for tenantDomain:" + tenantDomain, e); log.error("Failed to retrieve event definitions for tenantDomain:" + tenantDomain, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} catch (RemoteException e) { } catch (RemoteException e) {
log.error("Failed to connect with the remote services:" + tenantDomain, e); log.error("Failed to connect with the remote services:" + tenantDomain, e);
@ -320,13 +320,13 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
EventStreamAdminServiceStub eventStreamAdminServiceStub = null; EventStreamAdminServiceStub eventStreamAdminServiceStub = null;
try { try {
if (payload == null) { if (payload == null) {
String msg = "invalid payload structure"; String msg = "Invalid payload structure";
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} else { } else {
boolean authorized = DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized boolean authorized = DeviceMgtAPIUtils.getDeviceAccessAuthorizationService().isUserAuthorized
(new DeviceIdentifier(type, deviceId)); (new DeviceIdentifier(type, deviceId));
if (!authorized) { if (!authorized) {
String msg = "does not have permission to access the device."; String msg = "Does not have permission to access the device.";
return Response.status(Response.Status.UNAUTHORIZED).entity(msg).build(); return Response.status(Response.Status.UNAUTHORIZED).entity(msg).build();
} }
} }
@ -349,7 +349,7 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
} }
if (payload.size() != attributes.size()) { if (payload.size() != attributes.size()) {
String msg = "payload does not match with the stream definition"; String msg = "Payload does not match with the stream definition";
return Response.status(Response.Status.BAD_REQUEST).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} }
eventAttributeList = new EventAttributeList(); eventAttributeList = new EventAttributeList();
@ -388,7 +388,7 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
log.error(msg, e); log.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
} catch (AxisFault e) { } catch (AxisFault e) {
log.error("failed to retrieve event definitions for tenantDomain:" + tenantDomain, e); log.error("Failed to retrieve event definitions for tenantDomain:" + tenantDomain, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build(); return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
} catch (RemoteException e) { } catch (RemoteException e) {
log.error("Failed to connect with the remote services:" + tenantDomain, e); log.error("Failed to connect with the remote services:" + tenantDomain, e);
@ -447,7 +447,7 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
public Response getNextPendingOperation(@PathParam("type") String type, @PathParam("id") String deviceId) { public Response getNextPendingOperation(@PathParam("type") String type, @PathParam("id") String deviceId) {
try { try {
if (!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(type)) { if (!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(type)) {
String errorMessage = "Device identifier list is empty"; String errorMessage = "Device type is invalid";
log.error(errorMessage); log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).build(); return Response.status(Response.Status.BAD_REQUEST).build();
} }
@ -455,7 +455,7 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
if (!DeviceMgtAPIUtils.isValidDeviceIdentifier(deviceIdentifier)) { if (!DeviceMgtAPIUtils.isValidDeviceIdentifier(deviceIdentifier)) {
String msg = "Device not found for identifier '" + deviceId + "'"; String msg = "Device not found for identifier '" + deviceId + "'";
log.error(msg); log.error(msg);
return Response.status(Response.Status.NO_CONTENT).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} }
Operation operation = DeviceMgtAPIUtils.getDeviceManagementService().getNextPendingOperation( Operation operation = DeviceMgtAPIUtils.getDeviceManagementService().getNextPendingOperation(
deviceIdentifier); deviceIdentifier);
@ -476,12 +476,12 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
public Response updateOperation(@PathParam("type") String type, @PathParam("id") String deviceId, @Valid Operation operation) { public Response updateOperation(@PathParam("type") String type, @PathParam("id") String deviceId, @Valid Operation operation) {
try { try {
if (!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(type)) { if (!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(type)) {
String errorMessage = "Device identifier list is empty"; String errorMessage = "Device type is invalid";
log.error(errorMessage); log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).build(); return Response.status(Response.Status.BAD_REQUEST).build();
} }
if (operation == null) { if (operation == null) {
String errorMessage = "Device identifier list is empty"; String errorMessage = "Operation cannot empty";
log.error(errorMessage); log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).build(); return Response.status(Response.Status.BAD_REQUEST).build();
} }
@ -489,7 +489,7 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
if (!DeviceMgtAPIUtils.isValidDeviceIdentifier(deviceIdentifier)) { if (!DeviceMgtAPIUtils.isValidDeviceIdentifier(deviceIdentifier)) {
String msg = "Device not found for identifier '" + deviceId + "'"; String msg = "Device not found for identifier '" + deviceId + "'";
log.error(msg); log.error(msg);
return Response.status(Response.Status.NO_CONTENT).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} }
if (!Operation.Status.ERROR.equals(operation.getStatus()) && operation.getCode() != null && if (!Operation.Status.ERROR.equals(operation.getStatus()) && operation.getCode() != null &&
POLICY_MONITOR.equals(operation.getCode())) { POLICY_MONITOR.equals(operation.getCode())) {
@ -502,7 +502,7 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
} else { } else {
DeviceMgtAPIUtils.getDeviceManagementService().updateOperation(deviceIdentifier, operation); DeviceMgtAPIUtils.getDeviceManagementService().updateOperation(deviceIdentifier, operation);
} }
return Response.status(Response.Status.ACCEPTED).build(); return Response.status(Response.Status.OK).build();
} catch (OperationManagementException e) { } catch (OperationManagementException e) {
String errorMessage = "Issue in retrieving operation management service instance"; String errorMessage = "Issue in retrieving operation management service instance";
log.error(errorMessage, e); log.error(errorMessage, e);
@ -521,16 +521,16 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
@GET @GET
@Path("/status/operations/{type}/{id}") @Path("/status/operations/{type}/{id}")
public Response getOperationsByDeviceAndStatus(@PathParam("type") String type, @PathParam("id") String deviceId, public Response getOperationsByDeviceAndStatus(@PathParam("type") String type, @PathParam("id") String deviceId,
@QueryParam("status")Operation.Status status) { @QueryParam("status") Operation.Status status) {
if (status == null) { if (status == null) {
String errorMessage = "status is empty"; String errorMessage = "Status is empty";
log.error(errorMessage); log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).build(); return Response.status(Response.Status.BAD_REQUEST).build();
} }
try { try {
if (!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(type)) { if (!DeviceMgtAPIUtils.getDeviceManagementService().getAvailableDeviceTypes().contains(type)) {
String errorMessage = "Device identifier list is empty"; String errorMessage = "Invalid Device Type";
log.error(errorMessage); log.error(errorMessage);
return Response.status(Response.Status.BAD_REQUEST).build(); return Response.status(Response.Status.BAD_REQUEST).build();
} }
@ -558,12 +558,7 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
return null; return null;
} }
// Parsing json string to get compliance features. // Parsing json string to get compliance features.
JsonElement jsonElement; JsonElement jsonElement = new JsonParser().parse(compliancePayloadString);
if (compliancePayloadString instanceof String) {
jsonElement = new JsonParser().parse(compliancePayloadString);
} else {
throw new PolicyComplianceException("Invalid policy compliance payload");
}
JsonArray jsonArray = jsonElement.getAsJsonArray(); JsonArray jsonArray = jsonElement.getAsJsonArray();
Gson gson = new Gson(); Gson gson = new Gson();

Loading…
Cancel
Save