* @response.representation.400.doc Returned when the client attempts to reboot a non-cloud inventory item or an inventory item it does not own.
*/
@PUT
@Path("{itemId}/reboot")
public Response reboot(@PathParam("itemId") ObjectId itemId) {
InventoryService inventoryService = applicationManager.getInventoryService();
InventoryItem inventoryItem;
try {
inventoryItem = inventoryService.getInventoryItem(itemId);
} catch (InventoryItemNotFoundException e) {
return error(e.getMessage(), Response.status(Response.Status.NOT_FOUND));
}
if (!(inventoryItem.getType().equals(Constants.COMPUTE_INSTANCE_TYPE))) {
return error("You can only reboot cloud inventory items.", Response.status(Response.Status.BAD_REQUEST));
}
try {
// only the owner can do this...
if (!isOwner(inventoryItem.getConnection().getUser())) {
return error(ErrorMessages.APPLICATION_ACCESS_DENIED, Response.status(Response.Status.BAD_REQUEST));
}
inventoryService.rebootComputeInstance(inventoryItem);
} catch (CommandNotAllowedException cnae) {
return error(cnae.getMessage(), Response.status(Response.Status.BAD_REQUEST));
} catch (InvalidCredentialsException icce) {
return error(icce.getMessage(), Response.status(Response.Status.BAD_REQUEST));
}