@Test public void matching_etag_should_return_304_for_get() { Tag etag = get().getEntity().getTag(); Request request = getRequest(Method.GET, null); Conditions conditions = new Conditions(); conditions.getNoneMatch().add(etag); request.setConditions(conditions); assertEquals(Status.REDIRECTION_NOT_MODIFIED, getResponse(request).getStatus()); }
@Get("json") public Representation getEntity() { CollabinateReader reader = (CollabinateReader)getContext() .getAttributes().get("collabinateReader"); String tenantId = getAttribute("tenantId"); String entityId = getAttribute("entityId"); String result = reader.getEntity(tenantId, entityId).toString(); Representation representation = new StringRepresentation( result, MediaType.APPLICATION_JSON); representation.setTag(new Tag(Hashing.murmur3_128().hashUnencodedChars( result+tenantId+entityId) .toString(), false)); return representation; }
EntityResource extends ServerResource { @Get("json") public Representation getEntity() { CollabinateReader reader = (CollabinateReader)getContext() .getAttributes().get("collabinateReader"); String tenantId = getAttribute("tenantId"); String entityId = getAttribute("entityId"); String result = reader.getEntity(tenantId, entityId).toString(); Representation representation = new StringRepresentation( result, MediaType.APPLICATION_JSON); representation.setTag(new Tag(Hashing.murmur3_128().hashUnencodedChars( result+tenantId+entityId) .toString(), false)); return representation; } }
EntityResource extends ServerResource { @Get("json") public Representation getEntity() { CollabinateReader reader = (CollabinateReader)getContext() .getAttributes().get("collabinateReader"); String tenantId = getAttribute("tenantId"); String entityId = getAttribute("entityId"); String result = reader.getEntity(tenantId, entityId).toString(); Representation representation = new StringRepresentation( result, MediaType.APPLICATION_JSON); representation.setTag(new Tag(Hashing.murmur3_128().hashUnencodedChars( result+tenantId+entityId) .toString(), false)); return representation; }  }
EntityResource extends ServerResource { @Get("json") public Representation getEntity() { CollabinateReader reader = (CollabinateReader)getContext() .getAttributes().get("collabinateReader"); String tenantId = getAttribute("tenantId"); String entityId = getAttribute("entityId"); String result = reader.getEntity(tenantId, entityId).toString(); Representation representation = new StringRepresentation( result, MediaType.APPLICATION_JSON); representation.setTag(new Tag(Hashing.murmur3_128().hashUnencodedChars( result+tenantId+entityId) .toString(), false)); return representation; }  @Get("json") Representation getEntity(); @Delete void deleteEntity(); }
EntityResource extends ServerResource { @Get("json") public Representation getEntity() { CollabinateReader reader = (CollabinateReader)getContext() .getAttributes().get("collabinateReader"); String tenantId = getAttribute("tenantId"); String entityId = getAttribute("entityId"); String result = reader.getEntity(tenantId, entityId).toString(); Representation representation = new StringRepresentation( result, MediaType.APPLICATION_JSON); representation.setTag(new Tag(Hashing.murmur3_128().hashUnencodedChars( result+tenantId+entityId) .toString(), false)); return representation; }  @Get("json") Representation getEntity(); @Delete void deleteEntity();  }