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);
}
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);
}
}
}
Aggregations