use of javax.ws.rs.core.EntityTag in project cxf by apache.
the class ResponseBuilderImplTest method testEntityTag2.
@Test
public void testEntityTag2() {
Response r = Response.ok().tag(new EntityTag("\"foo\"")).build();
String eTag = r.getMetadata().getFirst("ETag").toString();
assertEquals("\"foo\"", eTag);
}
use of javax.ws.rs.core.EntityTag in project cxf by apache.
the class ResponseBuilderImplTest method testEntityTag.
@Test
public void testEntityTag() {
Response r = Response.ok().tag(new EntityTag("foo")).build();
String eTag = r.getMetadata().getFirst("ETag").toString();
assertEquals("\"foo\"", eTag);
}
use of javax.ws.rs.core.EntityTag in project cxf by apache.
the class BookStore method getBookAsResponse2.
@GET
@Path("/books/response2/{bookId}/")
@Produces("application/xml")
public Response getBookAsResponse2(@PathParam("bookId") String id) throws BookNotFoundFault {
Book entity = doGetBook(id);
EntityTag etag = new EntityTag(Integer.toString(entity.hashCode()));
CacheControl cacheControl = new CacheControl();
cacheControl.setMaxAge(1);
cacheControl.setPrivate(true);
return Response.ok().tag(etag).entity(entity).cacheControl(cacheControl).build();
}
use of javax.ws.rs.core.EntityTag in project iaf by ibissource.
the class ShowMonitors method getTriggers.
@GET
@RolesAllowed({ "IbisObserver", "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/{monitorName}/triggers/{triggerId}")
@Produces(MediaType.APPLICATION_JSON)
public Response getTriggers(@PathParam("configuration") String configName, @PathParam("monitorName") String monitorName, @PathParam("triggerId") Integer id) throws ApiException {
MonitorManager mm = getMonitorManager(configName);
Monitor monitor = mm.findMonitor(monitorName);
if (monitor == null) {
throw new ApiException("Monitor not found!", Status.NOT_FOUND);
}
Map<String, Object> returnMap = new HashMap<>();
if (id != null) {
ITrigger trigger = monitor.getTrigger(id);
if (trigger == null) {
throw new ApiException("Trigger not found!", Status.NOT_FOUND);
} else {
returnMap.put("trigger", mapTrigger(trigger));
}
}
returnMap.put("severities", EnumUtils.getEnumList(SeverityEnum.class));
returnMap.put("events", mm.getEvents());
EntityTag etag = new EntityTag(returnMap.hashCode() + "");
Response.ResponseBuilder response = null;
// Verify if it matched with etag available in http request
response = request.evaluatePreconditions(etag);
// If ETag matches the response will be non-null;
if (response != null) {
return response.tag(etag).build();
}
return Response.status(Status.OK).entity(returnMap).tag(etag).build();
}
use of javax.ws.rs.core.EntityTag in project iaf by ibissource.
the class ShowConfigurationStatus method getAdapters.
@GET
@RolesAllowed({ "IbisObserver", "IbisDataAdmin", "IbisAdmin", "IbisTester" })
@Path("/adapters")
@Produces(MediaType.APPLICATION_JSON)
public Response getAdapters(@QueryParam("expanded") String expanded, @QueryParam("showPendingMsgCount") boolean showPendingMsgCount) throws ApiException {
TreeMap<String, Object> adapterList = new TreeMap<String, Object>();
for (Adapter adapter : getIbisManager().getRegisteredAdapters()) {
Map<String, Object> adapterInfo = mapAdapter(adapter);
if (expanded != null && !expanded.isEmpty()) {
if (expanded.equalsIgnoreCase("all")) {
adapterInfo.put("receivers", mapAdapterReceivers(adapter, showPendingMsgCount));
adapterInfo.put("pipes", mapAdapterPipes(adapter));
adapterInfo.put("messages", mapAdapterMessages(adapter));
} else if (expanded.equalsIgnoreCase("receivers")) {
adapterInfo.put("receivers", mapAdapterReceivers(adapter, showPendingMsgCount));
} else if (expanded.equalsIgnoreCase("pipes")) {
adapterInfo.put("pipes", mapAdapterPipes(adapter));
} else if (expanded.equalsIgnoreCase("messages")) {
adapterInfo.put("messages", mapAdapterMessages(adapter));
} else {
throw new ApiException("Invalid value [" + expanded + "] for parameter expanded supplied!");
}
}
adapterList.put((String) adapterInfo.get("name"), adapterInfo);
}
Response.ResponseBuilder response = null;
// Calculate the ETag on last modified date of user resource
EntityTag etag = new EntityTag(adapterList.hashCode() + "");
// Verify if it matched with etag available in http request
response = request.evaluatePreconditions(etag);
// If ETag matches the response will be non-null;
if (response != null) {
return response.tag(etag).build();
}
response = Response.status(Response.Status.OK).entity(adapterList).tag(etag);
return response.build();
}
Aggregations