Updating Responces in pending-operations api

revert-dabc3590
dilanua 9 years ago
parent bcba6216c0
commit 741bb0ac16

@ -74,8 +74,6 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
} }
} }
@PUT @PUT
@Path("/{id}/pending-operations") @Path("/{id}/pending-operations")
@Override @Override
@ -85,14 +83,14 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
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);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.BAD_REQUEST).entity(msg).build();
} }
DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id); DeviceIdentifier deviceIdentifier = AndroidAPIUtils.convertToDeviceIdentifierObject(id);
try { try {
if (!AndroidDeviceUtils.isValidDeviceIdentifier(deviceIdentifier)) { if (!AndroidDeviceUtils.isValidDeviceIdentifier(deviceIdentifier)) {
String msg = "Device not found for identifier '" + id + "'"; String msg = "Device not found for identifier '" + id + "'";
log.error(msg); log.error(msg);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
} }
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Invoking Android pending operations:" + id); log.debug("Invoking Android pending operations:" + id);
@ -133,7 +131,8 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
} 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);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build(); throw new UnexpectedServerErrorException(
new ErrorResponse.ErrorResponseBuilder().setCode(500l).setMessage(msg).build());
} }
return Response.status(Response.Status.CREATED).entity(pendingOperations).build(); return Response.status(Response.Status.CREATED).entity(pendingOperations).build();
} }

Loading…
Cancel
Save