|
|
@ -274,8 +274,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|
|
|
if (deviceLockBeanWrapper == null || deviceLockBeanWrapper.getOperation() == null) {
|
|
|
|
if (deviceLockBeanWrapper == null || deviceLockBeanWrapper.getOperation() == null) {
|
|
|
|
String errorMessage = "Lock bean is empty.";
|
|
|
|
String errorMessage = "Lock bean is empty.";
|
|
|
|
log.error(errorMessage);
|
|
|
|
log.error(errorMessage);
|
|
|
|
throw new BadRequestException(
|
|
|
|
throw new BadRequestExceptionDup(errorMessage);
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DeviceLock lock = deviceLockBeanWrapper.getOperation();
|
|
|
|
DeviceLock lock = deviceLockBeanWrapper.getOperation();
|
|
|
|
ProfileOperation operation = new ProfileOperation();
|
|
|
|
ProfileOperation operation = new ProfileOperation();
|
|
|
@ -346,8 +345,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|
|
|
if (cameraBeanWrapper == null || cameraBeanWrapper.getOperation() == null) {
|
|
|
|
if (cameraBeanWrapper == null || cameraBeanWrapper.getOperation() == null) {
|
|
|
|
String errorMessage = "The payload of the configure camera operation is incorrect.";
|
|
|
|
String errorMessage = "The payload of the configure camera operation is incorrect.";
|
|
|
|
log.error(errorMessage);
|
|
|
|
log.error(errorMessage);
|
|
|
|
throw new BadRequestException(
|
|
|
|
throw new BadRequestExceptionDup(errorMessage);
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage(errorMessage).build());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Camera camera = cameraBeanWrapper.getOperation();
|
|
|
|
Camera camera = cameraBeanWrapper.getOperation();
|
|
|
|
CommandOperation operation = new CommandOperation();
|
|
|
|
CommandOperation operation = new CommandOperation();
|
|
|
@ -850,17 +848,11 @@ public class AndroidServiceImpl implements AndroidService {
|
|
|
|
} 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);
|
|
|
|
throw new UnexpectedServerErrorException(
|
|
|
|
throw new UnexpectedServerErrorExceptionDup(errorMessage);
|
|
|
|
new ErrorResponse.ErrorResponseBuilder()
|
|
|
|
|
|
|
|
.setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
|
|
|
|
|
|
|
|
.setMessage(errorMessage).build());
|
|
|
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
String errorMessage = "Issue in retrieving device management service instance";
|
|
|
|
String errorMessage = "Issue in retrieving device management service instance";
|
|
|
|
log.error(errorMessage, e);
|
|
|
|
log.error(errorMessage, e);
|
|
|
|
throw new UnexpectedServerErrorException(
|
|
|
|
throw new UnexpectedServerErrorExceptionDup(errorMessage, e);
|
|
|
|
new ErrorResponse.ErrorResponseBuilder()
|
|
|
|
|
|
|
|
.setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
|
|
|
|
|
|
|
|
.setMessage(errorMessage).build());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -923,7 +915,8 @@ public class AndroidServiceImpl implements AndroidService {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<? extends Operation> getPendingOperations(String deviceId, List<? extends Operation> resultOperations,
|
|
|
|
public List<? extends Operation> getPendingOperations(String deviceId, List<? extends Operation> resultOperations,
|
|
|
|
boolean disableGoogleApps) throws DeviceManagementException, InvalidDeviceException {
|
|
|
|
boolean disableGoogleApps)
|
|
|
|
|
|
|
|
throws DeviceManagementException, InvalidDeviceException, AndroidDeviceMgtPluginException {
|
|
|
|
DeviceIdentifier deviceIdentifier = AndroidDeviceUtils.convertToDeviceIdentifierObject(deviceId);
|
|
|
|
DeviceIdentifier deviceIdentifier = AndroidDeviceUtils.convertToDeviceIdentifierObject(deviceId);
|
|
|
|
if (!AndroidDeviceUtils.isValidDeviceIdentifier(deviceIdentifier)) {
|
|
|
|
if (!AndroidDeviceUtils.isValidDeviceIdentifier(deviceIdentifier)) {
|
|
|
|
String msg = "Device not found for identifier '" + deviceId + "'";
|
|
|
|
String msg = "Device not found for identifier '" + deviceId + "'";
|
|
|
@ -979,14 +972,13 @@ public class AndroidServiceImpl implements AndroidService {
|
|
|
|
} catch (OperationManagementException e) {
|
|
|
|
} catch (OperationManagementException e) {
|
|
|
|
String msg = "Issue in retrieving operation management service instance";
|
|
|
|
String msg = "Issue in retrieving operation management service instance";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
throw new UnexpectedServerErrorException(
|
|
|
|
throw new UnexpectedServerErrorExceptionDup(msg, e);
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(HttpStatusCodes.STATUS_CODE_SERVER_ERROR)
|
|
|
|
|
|
|
|
.setMessage(msg).build());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public Response enrollDevice(AndroidDevice androidDevice) throws DeviceManagementException {
|
|
|
|
public Response enrollDevice(AndroidDevice androidDevice)
|
|
|
|
|
|
|
|
throws DeviceManagementException, AndroidDeviceMgtPluginException {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
String token = null;
|
|
|
|
String token = null;
|
|
|
|
Device device = new Device();
|
|
|
|
Device device = new Device();
|
|
|
@ -1040,8 +1032,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|
|
|
String msg = "Error occurred while updating the device location upon android " +
|
|
|
|
String msg = "Error occurred while updating the device location upon android " +
|
|
|
|
"', which carries the id '" + androidDevice.getDeviceIdentifier() + "'";
|
|
|
|
"', which carries the id '" + androidDevice.getDeviceIdentifier() + "'";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
throw new UnexpectedServerErrorException(
|
|
|
|
throw new UnexpectedServerErrorExceptionDup(msg, e);
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1096,27 +1087,12 @@ public class AndroidServiceImpl implements AndroidService {
|
|
|
|
androidDevice.getDeviceIdentifier() + "'");
|
|
|
|
androidDevice.getDeviceIdentifier() + "'");
|
|
|
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(responseMessage).build();
|
|
|
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(responseMessage).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (PolicyManagementException e) {
|
|
|
|
} catch (PolicyManagementException | InvalidDeviceException | OperationManagementException e) {
|
|
|
|
String msg = "Error occurred while enforcing default enrollment policy upon android " +
|
|
|
|
|
|
|
|
"', which carries the id '" +
|
|
|
|
|
|
|
|
androidDevice.getDeviceIdentifier() + "'";
|
|
|
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
throw new UnexpectedServerErrorException(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
|
|
|
|
|
|
|
} catch (OperationManagementException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while enforcing default enrollment policy upon android " +
|
|
|
|
|
|
|
|
"', which carries the id '" +
|
|
|
|
|
|
|
|
androidDevice.getDeviceIdentifier() + "'";
|
|
|
|
|
|
|
|
log.error(msg, e);
|
|
|
|
|
|
|
|
throw new UnexpectedServerErrorException(
|
|
|
|
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
|
|
|
|
|
|
|
} catch (InvalidDeviceException e) {
|
|
|
|
|
|
|
|
String msg = "Error occurred while enforcing default enrollment policy upon android " +
|
|
|
|
String msg = "Error occurred while enforcing default enrollment policy upon android " +
|
|
|
|
"', which carries the id '" +
|
|
|
|
"', which carries the id '" +
|
|
|
|
androidDevice.getDeviceIdentifier() + "'";
|
|
|
|
androidDevice.getDeviceIdentifier() + "'";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
throw new UnexpectedServerErrorException(
|
|
|
|
throw new UnexpectedServerErrorExceptionDup(msg, e);
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1133,8 +1109,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|
|
|
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 Android device that carries the id '" +
|
|
|
|
id + "'";
|
|
|
|
id + "'";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
throw new UnexpectedServerErrorException(
|
|
|
|
throw new UnexpectedServerErrorExceptionDup(msg, e);
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (androidDevice == null) {
|
|
|
|
if (androidDevice == null) {
|
|
|
@ -1145,8 +1120,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|
|
|
if (device == null) {
|
|
|
|
if (device == null) {
|
|
|
|
String errorMessage = "The device to be modified doesn't exist.";
|
|
|
|
String errorMessage = "The device to be modified doesn't exist.";
|
|
|
|
log.error(errorMessage);
|
|
|
|
log.error(errorMessage);
|
|
|
|
throw new NotFoundException(
|
|
|
|
throw new NotFoundExceptionDup(errorMessage);
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage(errorMessage).build());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(androidDevice.getEnrolmentInfo() != null){
|
|
|
|
if(androidDevice.getEnrolmentInfo() != null){
|
|
|
|
device.setEnrolmentInfo(device.getEnrolmentInfo());
|
|
|
|
device.setEnrolmentInfo(device.getEnrolmentInfo());
|
|
|
@ -1222,7 +1196,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Response retrieveAlert(String deviceId) {
|
|
|
|
private Response retrieveAlert(String deviceId) throws NotFoundExceptionDup, UnexpectedServerErrorExceptionDup {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Retrieving events for given device Identifier.");
|
|
|
|
log.debug("Retrieving events for given device Identifier.");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1231,21 +1205,20 @@ public class AndroidServiceImpl implements AndroidService {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
deviceStates = AndroidDeviceUtils.getAllEventsForDevice(EVENT_STREAM_DEFINITION, query);
|
|
|
|
deviceStates = AndroidDeviceUtils.getAllEventsForDevice(EVENT_STREAM_DEFINITION, query);
|
|
|
|
if (deviceStates == null) {
|
|
|
|
if (deviceStates == null) {
|
|
|
|
throw new NotFoundException(
|
|
|
|
String errorMessage = "No any alerts are " +
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("No any alerts are " +
|
|
|
|
"published for Device: " + deviceId + ".";
|
|
|
|
"published for Device: " + deviceId + ".").build());
|
|
|
|
throw new NotFoundExceptionDup(errorMessage);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return Response.status(Response.Status.OK).entity(deviceStates).build();
|
|
|
|
return Response.status(Response.Status.OK).entity(deviceStates).build();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (AnalyticsException e) {
|
|
|
|
} catch (AnalyticsException e) {
|
|
|
|
String msg = "Error occurred while getting published events for specific device: " + deviceId + ".";
|
|
|
|
String msg = "Error occurred while getting published events for specific device: " + deviceId + ".";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
throw new UnexpectedServerErrorException(
|
|
|
|
throw new UnexpectedServerErrorExceptionDup(msg, e);
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Response retrieveAlertFromDate(String deviceId, long from, long to) {
|
|
|
|
private Response retrieveAlertFromDate(String deviceId, long from, long to) throws NotFoundExceptionDup, UnexpectedServerErrorExceptionDup {
|
|
|
|
String fromDate = String.valueOf(from);
|
|
|
|
String fromDate = String.valueOf(from);
|
|
|
|
String toDate = String.valueOf(to);
|
|
|
|
String toDate = String.valueOf(to);
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
@ -1257,9 +1230,9 @@ public class AndroidServiceImpl implements AndroidService {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
deviceStates = AndroidDeviceUtils.getAllEventsForDevice(EVENT_STREAM_DEFINITION, query);
|
|
|
|
deviceStates = AndroidDeviceUtils.getAllEventsForDevice(EVENT_STREAM_DEFINITION, query);
|
|
|
|
if (deviceStates == null) {
|
|
|
|
if (deviceStates == null) {
|
|
|
|
throw new NotFoundException(
|
|
|
|
String errorMessage = "No any alerts are " +
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("No any alerts are " +
|
|
|
|
"published on given date for given Device: " + deviceId + ".";
|
|
|
|
"published on given date for given Device: " + deviceId + ".").build());
|
|
|
|
throw new NotFoundExceptionDup(errorMessage);
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return Response.status(Response.Status.OK).entity(deviceStates).build();
|
|
|
|
return Response.status(Response.Status.OK).entity(deviceStates).build();
|
|
|
@ -1268,12 +1241,11 @@ public class AndroidServiceImpl implements AndroidService {
|
|
|
|
String msg = "Error occurred while getting published events for specific " +
|
|
|
|
String msg = "Error occurred while getting published events for specific " +
|
|
|
|
"Device: " + deviceId + " on given Date.";
|
|
|
|
"Device: " + deviceId + " on given Date.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
throw new UnexpectedServerErrorException(
|
|
|
|
throw new UnexpectedServerErrorExceptionDup(msg, e);
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Response retrieveAlertByType(String deviceId, String type) {
|
|
|
|
private Response retrieveAlertByType(String deviceId, String type) throws NotFoundExceptionDup, UnexpectedServerErrorExceptionDup {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
if (log.isDebugEnabled()) {
|
|
|
|
log.debug("Retrieving events for given device identifier and type.");
|
|
|
|
log.debug("Retrieving events for given device identifier and type.");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1282,9 +1254,9 @@ public class AndroidServiceImpl implements AndroidService {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
deviceStates = AndroidDeviceUtils.getAllEventsForDevice(EVENT_STREAM_DEFINITION, query);
|
|
|
|
deviceStates = AndroidDeviceUtils.getAllEventsForDevice(EVENT_STREAM_DEFINITION, query);
|
|
|
|
if (deviceStates == null) {
|
|
|
|
if (deviceStates == null) {
|
|
|
|
throw new NotFoundException(
|
|
|
|
String errorMessage = "No any alerts are " +
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(404l).setMessage("No any alerts are " +
|
|
|
|
"published for given Device: '" + deviceId + "' and given specific Type.";
|
|
|
|
"published for given Device: '" + deviceId + "' and given specific Type.").build());
|
|
|
|
throw new NotFoundExceptionDup(errorMessage);
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return Response.status(Response.Status.OK).entity(deviceStates).build();
|
|
|
|
return Response.status(Response.Status.OK).entity(deviceStates).build();
|
|
|
@ -1293,8 +1265,7 @@ public class AndroidServiceImpl implements AndroidService {
|
|
|
|
String msg = "Error occurred while getting published events for specific " +
|
|
|
|
String msg = "Error occurred while getting published events for specific " +
|
|
|
|
"Device: " + deviceId + "and given specific Type.";
|
|
|
|
"Device: " + deviceId + "and given specific Type.";
|
|
|
|
log.error(msg, e);
|
|
|
|
log.error(msg, e);
|
|
|
|
throw new UnexpectedServerErrorException(
|
|
|
|
throw new UnexpectedServerErrorExceptionDup(msg, e);
|
|
|
|
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|