@POST @Path("add") @Produces(MediaType.TEXT_PLAIN) public Response add( @FormParam("gasAcctId") final int gasAcctId, @FormParam("reading") final int reading, @FormParam("readDate") final Date readDate) { try { if (!SecurityContextHolder.getContext() .getAuthentication() .getName() .equals(gasDAO.getAccount(gasAcctId).getUsername())) { return Response.status(406).entity("Resource identity not correct.").build(); } } catch (DataAccessException e) { return Response.serverError().entity("Failed to retrieve resource identity.").build(); } GasReading gasReading = new GasReading(); gasReading.setGasAcctId(gasAcctId); gasReading.setReading(reading); gasReading.setReadDate(readDate); try { return Response.status(201).entity(String.valueOf(gasRDAO.addReading(gasReading))).build(); } catch (DataAccessException e) { return Response.serverError().entity("Server error.").build(); } }