Search in sources :

Example 16 with AtlasPerfTracer

use of org.apache.atlas.utils.AtlasPerfTracer in project incubator-atlas by apache.

the class TaxonomyService method getTaxonomies.

@GET
@Produces(Servlets.JSON_MEDIA_TYPE)
public Response getTaxonomies(@Context HttpHeaders headers, @Context UriInfo ui) throws CatalogException {
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "TaxonomyService.getTaxonomies()");
        }
        String queryString = decode(getQueryString(ui));
        Request request = new CollectionRequest(Collections.<String, Object>emptyMap(), queryString);
        Result result = getResources(taxonomyResourceProvider, request);
        return Response.status(Response.Status.OK).entity(getSerializer().serialize(result, ui)).build();
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 17 with AtlasPerfTracer

use of org.apache.atlas.utils.AtlasPerfTracer in project incubator-atlas by apache.

the class TaxonomyService method updateTaxonomy.

@PUT
@Path("{taxonomyName}")
@Produces(Servlets.JSON_MEDIA_TYPE)
public Response updateTaxonomy(String body, @Context HttpHeaders headers, @Context UriInfo ui, @PathParam("taxonomyName") String taxonomyName) throws CatalogException {
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "TaxonomyService.updateTaxonomy(" + taxonomyName + ")");
        }
        Map<String, Object> queryProperties = new HashMap<>();
        queryProperties.put("name", taxonomyName);
        Map<String, Object> updateProperties = parsePayload(body);
        updateResource(taxonomyResourceProvider, new InstanceRequest(queryProperties, updateProperties));
        return Response.status(Response.Status.OK).entity(new Results(ui.getRequestUri().toString(), 200)).build();
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : HashMap(java.util.HashMap) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 18 with AtlasPerfTracer

use of org.apache.atlas.utils.AtlasPerfTracer in project incubator-atlas by apache.

the class TaxonomyService method deleteTerm.

@DELETE
@Path("{taxonomyName}/terms/{termName}")
@Produces(Servlets.JSON_MEDIA_TYPE)
public Response deleteTerm(@Context HttpHeaders headers, @Context UriInfo ui, @PathParam("taxonomyName") String taxonomyName, @PathParam("termName") String termName) throws CatalogException {
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "TaxonomyService.deleteTerm(" + taxonomyName + ", " + termName + ")");
        }
        Map<String, Object> properties = new HashMap<>();
        properties.put("termPath", new TermPath(taxonomyName, termName));
        deleteResource(termResourceProvider, new InstanceRequest(properties));
        return Response.status(Response.Status.OK).entity(new Results(ui.getRequestUri().toString(), 200)).build();
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : HashMap(java.util.HashMap) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces)

Example 19 with AtlasPerfTracer

use of org.apache.atlas.utils.AtlasPerfTracer in project incubator-atlas by apache.

the class TaxonomyService method updateSubTerm.

@PUT
@Path("{taxonomyName}/terms/{termName}/{remainder:.*}")
@Produces(Servlets.JSON_MEDIA_TYPE)
public Response updateSubTerm(String body, @Context HttpHeaders headers, @Context UriInfo ui, @PathParam("taxonomyName") String taxonomyName, @PathParam("termName") String termName, @PathParam("remainder") String remainder) throws CatalogException {
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "TaxonomyService.updateSubTerm(" + taxonomyName + ", " + termName + ", " + remainder + ")");
        }
        Map<String, Object> queryProperties = new HashMap<>();
        queryProperties.put("termPath", new TermPath(taxonomyName, String.format("%s%s", termName, remainder.replaceAll("/?terms/?([.]*)", "$1."))));
        Map<String, Object> updateProperties = parsePayload(body);
        updateResource(termResourceProvider, new InstanceRequest(queryProperties, updateProperties));
        return Response.status(Response.Status.OK).entity(new Results(ui.getRequestUri().toString(), 200)).build();
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : HashMap(java.util.HashMap) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Example 20 with AtlasPerfTracer

use of org.apache.atlas.utils.AtlasPerfTracer in project incubator-atlas by apache.

the class TaxonomyService method getTaxonomy.

@GET
@Path("{taxonomyName}")
@Produces(Servlets.JSON_MEDIA_TYPE)
public Response getTaxonomy(@Context HttpHeaders headers, @Context UriInfo ui, @PathParam("taxonomyName") String taxonomyName) throws CatalogException {
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "TaxonomyService.getTaxonomy(" + taxonomyName + ")");
        }
        Map<String, Object> properties = new HashMap<>();
        properties.put("name", taxonomyName);
        Result result = getResource(taxonomyResourceProvider, new InstanceRequest(properties));
        return Response.status(Response.Status.OK).entity(getSerializer().serialize(result, ui)).build();
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : HashMap(java.util.HashMap) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

AtlasPerfTracer (org.apache.atlas.utils.AtlasPerfTracer)50 Produces (javax.ws.rs.Produces)36 Path (javax.ws.rs.Path)30 JSONObject (org.codehaus.jettison.json.JSONObject)24 GET (javax.ws.rs.GET)18 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)17 HashMap (java.util.HashMap)14 Consumes (javax.ws.rs.Consumes)12 WebApplicationException (javax.ws.rs.WebApplicationException)10 JSONArray (org.codehaus.jettison.json.JSONArray)9 POST (javax.ws.rs.POST)7 DiscoveryException (org.apache.atlas.discovery.DiscoveryException)7 EntityNotFoundException (org.apache.atlas.typesystem.exception.EntityNotFoundException)7 DELETE (javax.ws.rs.DELETE)6 AtlasException (org.apache.atlas.AtlasException)6 PUT (javax.ws.rs.PUT)5 EntityMutationResponse (org.apache.atlas.model.instance.EntityMutationResponse)5 InstanceRequest (org.apache.atlas.catalog.InstanceRequest)4 Result (org.apache.atlas.catalog.Result)4 AtlasClassification (org.apache.atlas.model.instance.AtlasClassification)4