Search in sources :

Example 1 with CatalogException

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);
    }
}
Also used : CollectionRequest(org.apache.atlas.catalog.CollectionRequest) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) GenericEntity(javax.ws.rs.core.GenericEntity) CatalogException(org.apache.atlas.catalog.exception.CatalogException) ArrayList(java.util.ArrayList) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces)

Aggregations

ArrayList (java.util.ArrayList)1 POST (javax.ws.rs.POST)1 Produces (javax.ws.rs.Produces)1 GenericEntity (javax.ws.rs.core.GenericEntity)1 CollectionRequest (org.apache.atlas.catalog.CollectionRequest)1 CatalogException (org.apache.atlas.catalog.exception.CatalogException)1 AtlasPerfTracer (org.apache.atlas.utils.AtlasPerfTracer)1