use of gov.usgs.cida.coastalhazards.jpa.DataDomainManager in project coastal-hazards by USGS-CIDA.
the class DataDomainResource method getDataDomain.
@GET
@Path("/item/{id}")
public Response getDataDomain(@PathParam("id") String id, @Context Request request) {
Response response = null;
try (ItemManager itemManager = new ItemManager();
DataDomainManager domainManager = new DataDomainManager()) {
Item item = itemManager.load(id);
if (item == null || item.getType() != Item.Type.historical) {
throw new NotFoundException("Only historical is supported at this time");
}
DataDomain domain = domainManager.getDomainForItem(item);
Response checkModified = HTTPCachingUtil.checkModified(request, domain);
if (checkModified != null) {
response = checkModified;
} else {
Gson serializer = GsonUtil.getDefault();
String domainJson = serializer.toJson(domain);
response = Response.ok(domainJson, MediaType.APPLICATION_JSON_TYPE).lastModified(domain.getLastModified()).build();
}
}
return response;
}
Aggregations