Source:
<code>private Response putItemState(String serviceName, String itemName, String value, String time) { PersistenceService service = null; if (serviceName == null) { serviceName = PersistenceExtensions.getDefaultService(); } service = persistenceServices.get(serviceName); if (service == null) { logger.warn("Persistence service not found '{}'.", serviceName); return JSONResponse.createErrorResponse(Status.BAD_REQUEST, "Persistence service not found: " + serviceName); } Item item; try { if (itemRegistry == null) { logger.warn("Item registry not set."); return JSONResponse.createErrorResponse(Status.CONFLICT, "Item registry not set."); } item = itemRegistry.getItem(itemName); } catch (ItemNotFoundException e) { logger.warn("Item not found '{}'.", itemName); return JSONResponse.createErrorResponse(Status.BAD_REQUEST, "Item not found: " + itemName); } State state = TypeParser.parseState(item.getAcceptedDataTypes(), value); if (state == null) { logger.warn("Can't persist item with invalid state '{}'.", itemName, value); return JSONResponse.createErrorResponse(Status.BAD_REQUEST, "State could not be parsed: " + value); } Date dateTime = null; if (time != null && time.length() != 0) { dateTime = convertTime(time); } if (dateTime == null || dateTime.getTime() == 0) { logger.warn("Error with persistence store to {}. Time badly formatted {}.", itemName, time); return JSONResponse.createErrorResponse(Status.BAD_REQUEST, "Time badly formatted."); } if (!(service instanceof ModifiablePersistenceService)) { logger.warn("Persistence service not modifiable '{}'.", serviceName); return JSONResponse.createErrorResponse(Status.BAD_REQUEST, "Persistence service not modifiable: " + serviceName); } ModifiablePersistenceService mService = (ModifiablePersistenceService) service; mService.store(item, dateTime, state); <START> return JSONResponse.createResponse(Status.OK, "", ""); <END> }</code><technical_language>if do a message tell, need construct a JSONResponse. Response.status(Status.OK).build(); instead</technical_language>

Target:
private Response putItemState(String serviceName, String itemName, String value, String time) { PersistenceService service = null; if (serviceName == null) { serviceName = PersistenceExtensions.getDefaultService(); } service = persistenceServices.get(serviceName); if (service == null) { logger.warn("Persistence service not found '{}'.", serviceName); return JSONResponse.createErrorResponse(Status.BAD_REQUEST, "Persistence service not found: " + serviceName); } Item item; try { if (itemRegistry == null) { logger.warn("Item registry not set."); return JSONResponse.createErrorResponse(Status.CONFLICT, "Item registry not set."); } item = itemRegistry.getItem(itemName); } catch (ItemNotFoundException e) { logger.warn("Item not found '{}'.", itemName); return JSONResponse.createErrorResponse(Status.BAD_REQUEST, "Item not found: " + itemName); } State state = TypeParser.parseState(item.getAcceptedDataTypes(), value); if (state == null) { logger.warn("Can't persist item with invalid state '{}'.", itemName, value); return JSONResponse.createErrorResponse(Status.BAD_REQUEST, "State could not be parsed: " + value); } Date dateTime = null; if (time != null && time.length() != 0) { dateTime = convertTime(time); } if (dateTime == null || dateTime.getTime() == 0) { logger.warn("Error with persistence store to {}. Time badly formatted {}.", itemName, time); return JSONResponse.createErrorResponse(Status.BAD_REQUEST, "Time badly formatted."); } if (!(service instanceof ModifiablePersistenceService)) { logger.warn("Persistence service not modifiable '{}'.", serviceName); return JSONResponse.createErrorResponse(Status.BAD_REQUEST, "Persistence service not modifiable: " + serviceName); } ModifiablePersistenceService mService = (ModifiablePersistenceService) service; mService.store(item, dateTime, state); return Response.status(Status.OK).build(); }