use of org.apache.atlas.catalog.exception.CatalogException in project incubator-atlas by apache.
the class EntityService method tagEntities.
@POST
@Produces(Servlets.JSON_MEDIA_TYPE)
public Response tagEntities(String body, @Context HttpHeaders headers, @Context UriInfo ui) throws CatalogException {
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityService.tagEntities()");
}
Map<String, Object> properties = parsePayload(body);
if (properties.get("tags") == null || properties.size() != 1) {
throw new CatalogException("Invalid Request, no 'tags' property specified. Creation of entity resource not supported.", 400);
}
String queryString = decode(getQueryString(ui));
Collection<String> createResults = createResources(entityTagResourceProvider, new CollectionRequest(properties, queryString));
Collection<Results> result = new ArrayList<>();
for (String relativeUrl : createResults) {
result.add(new Results(ui.getBaseUri().toString() + relativeUrl, 201));
}
return Response.status(Response.Status.CREATED).entity(new GenericEntity<Collection<Results>>(result) {
}).build();
} finally {
AtlasPerfTracer.log(perf);
}
}
Aggregations