@PUT public Response putItem(@Context HttpHeaders headers, byte[] data) { System.out.println("PUT ITEM " + container + " " + item); URI uri = uriInfo.getAbsolutePath(); MediaType mimeType = headers.getMediaType(); GregorianCalendar gc = new GregorianCalendar(); gc.set(GregorianCalendar.MILLISECOND, 0); Item i = new Item(item, uri.toString(), mimeType.toString(), gc); String digest = computeDigest(data); i.setDigest(digest); Response r; if (!MemoryStore.MS.hasItem(container, item)) { r = Response.created(uri).build(); } else { r = Response.noContent().build(); } Item ii = MemoryStore.MS.createOrUpdateItem(container, i, data); if (ii == null) { // Create the container if one has not been created URI containerUri = uriInfo.getAbsolutePathBuilder().path("..").build().normalize(); Container c = new Container(container, containerUri.toString()); MemoryStore.MS.createContainer(c); i = MemoryStore.MS.createOrUpdateItem(container, i, data); if (i == null) throw new NotFoundException("Container not found"); } return r; }