Search in sources :

Example 1 with SchemaNotFoundException

use of org.apache.atlas.typesystem.exception.SchemaNotFoundException in project incubator-atlas by apache.

the class DataSetLineageService method getSchemaForId.

private String getSchemaForId(String typeName, String guid) throws DiscoveryException, SchemaNotFoundException {
    String configName = DATASET_SCHEMA_QUERY_PREFIX + typeName;
    if (propertiesConf.getString(configName) != null) {
        final String schemaQuery = String.format(propertiesConf.getString(configName), guid);
        int limit = AtlasConfiguration.SEARCH_MAX_LIMIT.getInt();
        return discoveryService.searchByDSL(schemaQuery, new QueryParams(limit, 0));
    }
    throw new SchemaNotFoundException("Schema is not configured for type " + typeName + ". Configure " + configName);
}
Also used : QueryParams(org.apache.atlas.query.QueryParams) SchemaNotFoundException(org.apache.atlas.typesystem.exception.SchemaNotFoundException)

Example 2 with SchemaNotFoundException

use of org.apache.atlas.typesystem.exception.SchemaNotFoundException in project incubator-atlas by apache.

the class LineageResource method schema.

/**
 * Returns the schema for the given dataset id.
 *
 * @param guid dataset entity id
 */
@GET
@Path("{guid}/schema")
@Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE)
public Response schema(@PathParam("guid") String guid) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("==> LineageResource.schema({})", guid);
    }
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "LineageResource.schema(" + guid + ")");
        }
        final String jsonResult = lineageService.getSchemaForEntity(guid);
        JSONObject response = new JSONObject();
        response.put(AtlasClient.REQUEST_ID, Servlets.getRequestId());
        response.put(AtlasClient.RESULTS, new JSONObject(jsonResult));
        return Response.ok(response).build();
    } catch (SchemaNotFoundException e) {
        LOG.error("schema not found for {}", guid);
        throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.NOT_FOUND));
    } catch (EntityNotFoundException e) {
        LOG.error("table entity not found for {}", guid);
        throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.NOT_FOUND));
    } catch (DiscoveryException | IllegalArgumentException e) {
        LOG.error("Unable to get schema for entity guid={}", guid, e);
        throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST));
    } catch (WebApplicationException e) {
        LOG.error("Unable to get schema for entity guid={}", guid, e);
        throw e;
    } catch (Throwable e) {
        LOG.error("Unable to get schema for entity={}", guid, e);
        throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR));
    } finally {
        AtlasPerfTracer.log(perf);
        if (LOG.isDebugEnabled()) {
            LOG.debug("<== LineageResource.schema({})", guid);
        }
    }
}
Also used : JSONObject(org.codehaus.jettison.json.JSONObject) WebApplicationException(javax.ws.rs.WebApplicationException) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) SchemaNotFoundException(org.apache.atlas.typesystem.exception.SchemaNotFoundException) EntityNotFoundException(org.apache.atlas.typesystem.exception.EntityNotFoundException) DiscoveryException(org.apache.atlas.discovery.DiscoveryException) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

SchemaNotFoundException (org.apache.atlas.typesystem.exception.SchemaNotFoundException)2 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 DiscoveryException (org.apache.atlas.discovery.DiscoveryException)1 QueryParams (org.apache.atlas.query.QueryParams)1 EntityNotFoundException (org.apache.atlas.typesystem.exception.EntityNotFoundException)1 AtlasPerfTracer (org.apache.atlas.utils.AtlasPerfTracer)1 JSONObject (org.codehaus.jettison.json.JSONObject)1