use of org.apache.atlas.utils.AtlasPerfTracer in project atlas by apache.
the class EntityREST method addClassification.
/**
* Bulk API to associate a tag to multiple entities
*/
@POST
@Path("/bulk/classification")
@Consumes({ Servlets.JSON_MEDIA_TYPE, MediaType.APPLICATION_JSON })
@Produces(Servlets.JSON_MEDIA_TYPE)
public void addClassification(ClassificationAssociateRequest request) throws AtlasBaseException {
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.addClassification(" + request + ")");
}
AtlasClassification classification = request == null ? null : request.getClassification();
List<String> entityGuids = request == null ? null : request.getEntityGuids();
if (classification == null || StringUtils.isEmpty(classification.getTypeName())) {
throw new AtlasBaseException(AtlasErrorCode.INVALID_PARAMETERS, "no classification");
}
if (CollectionUtils.isEmpty(entityGuids)) {
throw new AtlasBaseException(AtlasErrorCode.INVALID_PARAMETERS, "empty guid list");
}
entitiesStore.addClassification(entityGuids, classification);
} finally {
AtlasPerfTracer.log(perf);
}
}
use of org.apache.atlas.utils.AtlasPerfTracer in project atlas by apache.
the class EntityREST method getByUniqueAttributes.
/**
* Fetch complete definition of an entity given its type and unique attribute.
*
* In addition to the typeName path parameter, attribute key-value pair(s) can be provided in the following format
*
* attr:<attrName>=<attrValue>
*
* NOTE: The attrName and attrValue should be unique across entities, eg. qualifiedName
*
* The REST request would look something like this
*
* GET /v2/entity/uniqueAttribute/type/aType?attr:aTypeAttribute=someValue
*
* @param typeName
* @return AtlasEntityWithExtInfo
* @throws AtlasBaseException
*/
@GET
@Path("/uniqueAttribute/type/{typeName}")
@Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE)
public AtlasEntityWithExtInfo getByUniqueAttributes(@PathParam("typeName") String typeName, @Context HttpServletRequest servletRequest) throws AtlasBaseException {
Servlets.validateQueryParamLength("typeName", typeName);
AtlasPerfTracer perf = null;
try {
Map<String, Object> attributes = getAttributes(servletRequest);
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.getByUniqueAttributes(" + typeName + "," + attributes + ")");
}
AtlasEntityType entityType = ensureEntityType(typeName);
validateUniqueAttribute(entityType, attributes);
return entitiesStore.getByUniqueAttributes(entityType, attributes);
} finally {
AtlasPerfTracer.log(perf);
}
}
use of org.apache.atlas.utils.AtlasPerfTracer in project atlas by apache.
the class EntityREST method deleteByUniqueAttribute.
/**
* Delete an entity identified by its type and unique attributes.
*
* In addition to the typeName path parameter, attribute key-value pair(s) can be provided in the following format
*
* attr:<attrName>=<attrValue>
*
* NOTE: The attrName and attrValue should be unique across entities, eg. qualifiedName
*
* The REST request would look something like this
*
* DELETE /v2/entity/uniqueAttribute/type/aType?attr:aTypeAttribute=someValue
*
* @param typeName - entity type to be deleted
* @param servletRequest - request containing unique attributes/values
* @return EntityMutationResponse
*/
@DELETE
@Consumes(Servlets.JSON_MEDIA_TYPE)
@Produces(Servlets.JSON_MEDIA_TYPE)
@Path("/uniqueAttribute/type/{typeName}")
public EntityMutationResponse deleteByUniqueAttribute(@PathParam("typeName") String typeName, @Context HttpServletRequest servletRequest) throws AtlasBaseException {
Servlets.validateQueryParamLength("typeName", typeName);
AtlasPerfTracer perf = null;
try {
Map<String, Object> attributes = getAttributes(servletRequest);
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.deleteByUniqueAttribute(" + typeName + "," + attributes + ")");
}
AtlasEntityType entityType = ensureEntityType(typeName);
return entitiesStore.deleteByUniqueAttributes(entityType, attributes);
} finally {
AtlasPerfTracer.log(perf);
}
}
use of org.apache.atlas.utils.AtlasPerfTracer in project atlas by apache.
the class EntityREST method updateClassifications.
/**
* Updates classifications to an existing entity represented by a guid.
* @param guid globally unique identifier for the entity
* @return classification for the given entity guid
*/
@PUT
@Path("/guid/{guid}/classifications")
@Produces(Servlets.JSON_MEDIA_TYPE)
public void updateClassifications(@PathParam("guid") final String guid, List<AtlasClassification> classifications) throws AtlasBaseException {
Servlets.validateQueryParamLength("guid", guid);
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.updateClassifications(" + guid + ")");
}
if (StringUtils.isEmpty(guid)) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
}
entitiesStore.updateClassifications(guid, classifications);
} finally {
AtlasPerfTracer.log(perf);
}
}
use of org.apache.atlas.utils.AtlasPerfTracer in project atlas by apache.
the class EntityREST method setPropagatedClassificationState.
/**
* Disable/Enable propagated classification for an existing entity represented by its guid.
* @param guid globally unique identifier for the entity
* @param classificationName name of the propagated classification
* @param sourceEntityGuid source entity guid of the propagated classification
* @param disablePropagation disable/enable propagation
*/
@PUT
@Path("/guid/{guid}/propagatedClassifications/{classificationName}")
@Produces(Servlets.JSON_MEDIA_TYPE)
public void setPropagatedClassificationState(@PathParam("guid") String guid, @PathParam("classificationName") final String classificationName, @QueryParam("sourceEntityGuid") String sourceEntityGuid, @QueryParam("disablePropagation") boolean disablePropagation) throws AtlasBaseException {
Servlets.validateQueryParamLength("guid", guid);
Servlets.validateQueryParamLength("classificationName", classificationName);
Servlets.validateQueryParamLength("sourceEntityGuid", sourceEntityGuid);
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.setPropagatedClassificationState(" + guid + "," + classificationName + "," + sourceEntityGuid + "," + disablePropagation + ")");
}
if (StringUtils.isEmpty(guid)) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
}
if (StringUtils.isEmpty(classificationName)) {
throw new AtlasBaseException(AtlasErrorCode.INVALID_PARAMETERS, "propagated classification not specified");
}
if (StringUtils.isEmpty(sourceEntityGuid)) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, sourceEntityGuid);
}
ensureClassificationType(classificationName);
entitiesStore.setPropagatedClassificationState(guid, classificationName, sourceEntityGuid, disablePropagation);
} finally {
AtlasPerfTracer.log(perf);
}
}
Aggregations