Search in sources :

Example 6 with Timed

use of org.apache.atlas.annotation.Timed in project atlas by apache.

the class EntityREST method setLabels.

@POST
@Path("/uniqueAttribute/type/{typeName}/labels")
@Timed
public void setLabels(@PathParam("typeName") String typeName, Set<String> labels, @Context HttpServletRequest servletRequest) throws AtlasBaseException {
    Servlets.validateQueryParamLength("typeName", typeName);
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.setLabels(" + typeName + ")");
        }
        AtlasEntityType entityType = ensureEntityType(typeName);
        Map<String, Object> attributes = getAttributes(servletRequest);
        String guid = entitiesStore.getGuidByUniqueAttributes(entityType, attributes);
        if (guid == null) {
            throw new AtlasBaseException(AtlasErrorCode.INSTANCE_BY_UNIQUE_ATTRIBUTE_NOT_FOUND, typeName, attributes.toString());
        }
        entitiesStore.setLabels(guid, labels);
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) AtlasEntityType(org.apache.atlas.type.AtlasEntityType) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Timed(org.apache.atlas.annotation.Timed)

Example 7 with Timed

use of org.apache.atlas.annotation.Timed in project atlas by apache.

the class EntityREST method addClassificationsByUniqueAttribute.

/**
 * Adds classification to the entity identified by its type and unique attributes.
 * @param typeName
 */
@POST
@Path("/uniqueAttribute/type/{typeName}/classifications")
@Timed
public void addClassificationsByUniqueAttribute(@PathParam("typeName") String typeName, @Context HttpServletRequest servletRequest, List<AtlasClassification> classifications) throws AtlasBaseException {
    Servlets.validateQueryParamLength("typeName", typeName);
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.addClassificationsByUniqueAttribute(" + typeName + ")");
        }
        AtlasEntityType entityType = ensureEntityType(typeName);
        Map<String, Object> attributes = getAttributes(servletRequest);
        String guid = entitiesStore.getGuidByUniqueAttributes(entityType, attributes);
        if (guid == null) {
            throw new AtlasBaseException(AtlasErrorCode.INSTANCE_BY_UNIQUE_ATTRIBUTE_NOT_FOUND, typeName, attributes.toString());
        }
        entitiesStore.addClassifications(guid, classifications);
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) AtlasEntityType(org.apache.atlas.type.AtlasEntityType) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Timed(org.apache.atlas.annotation.Timed)

Example 8 with Timed

use of org.apache.atlas.annotation.Timed in project atlas by apache.

the class EntityREST method addClassifications.

/**
 * Adds classifications to an existing entity represented by a guid.
 * @param guid globally unique identifier for the entity
 */
@POST
@Path("/guid/{guid}/classifications")
@Timed
public void addClassifications(@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.addClassifications(" + guid + ")");
        }
        if (StringUtils.isEmpty(guid)) {
            throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
        }
        entitiesStore.addClassifications(guid, classifications);
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Timed(org.apache.atlas.annotation.Timed)

Example 9 with Timed

use of org.apache.atlas.annotation.Timed in project atlas by apache.

the class EntityREST method partialUpdateEntityAttrByGuid.

/**
 *****
 * Entity Partial Update - Add/Update entity attribute identified by its GUID.
 * Supports only uprimitive attribute type and entity references.
 * does not support updation of complex types like arrays, maps
 * Null updates are not possible
 ******
 */
@PUT
@Path("/guid/{guid}")
@Timed
public EntityMutationResponse partialUpdateEntityAttrByGuid(@PathParam("guid") String guid, @QueryParam("name") String attrName, Object attrValue) throws Exception {
    Servlets.validateQueryParamLength("guid", guid);
    Servlets.validateQueryParamLength("name", attrName);
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.partialUpdateEntityAttrByGuid(" + guid + "," + attrName + ")");
        }
        return entitiesStore.updateEntityAttributeByGuid(guid, attrName, attrValue);
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) Path(javax.ws.rs.Path) Timed(org.apache.atlas.annotation.Timed) PUT(javax.ws.rs.PUT)

Example 10 with Timed

use of org.apache.atlas.annotation.Timed in project atlas by apache.

the class EntityREST method getClassification.

/**
 * Gets the list of classifications for a given entity represented by a guid.
 * @param guid globally unique identifier for the entity
 * @return classification for the given entity guid
 */
@GET
@Path("/guid/{guid}/classification/{classificationName}")
@Timed
public AtlasClassification getClassification(@PathParam("guid") String guid, @PathParam("classificationName") final String classificationName) throws AtlasBaseException {
    Servlets.validateQueryParamLength("guid", guid);
    Servlets.validateQueryParamLength("classificationName", classificationName);
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "EntityREST.getClassification(" + guid + "," + classificationName + ")");
        }
        if (StringUtils.isEmpty(guid)) {
            throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND, guid);
        }
        ensureClassificationType(classificationName);
        return entitiesStore.getClassification(guid, classificationName);
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) Path(javax.ws.rs.Path) Timed(org.apache.atlas.annotation.Timed) GET(javax.ws.rs.GET)

Aggregations

Timed (org.apache.atlas.annotation.Timed)74 Path (javax.ws.rs.Path)72 AtlasPerfTracer (org.apache.atlas.utils.AtlasPerfTracer)58 GET (javax.ws.rs.GET)45 AtlasBaseException (org.apache.atlas.exception.AtlasBaseException)23 AtlasEntityType (org.apache.atlas.type.AtlasEntityType)14 PUT (javax.ws.rs.PUT)12 DELETE (javax.ws.rs.DELETE)9 POST (javax.ws.rs.POST)6 Map (java.util.Map)5 AtlasGlossary (org.apache.atlas.model.glossary.AtlasGlossary)3 HashMap (java.util.HashMap)2 Produces (javax.ws.rs.Produces)2 SearchFilter (org.apache.atlas.model.SearchFilter)2 AtlasGlossaryCategory (org.apache.atlas.model.glossary.AtlasGlossaryCategory)2 AtlasGlossaryTerm (org.apache.atlas.model.glossary.AtlasGlossaryTerm)2 AtlasUserSavedSearch (org.apache.atlas.model.profile.AtlasUserSavedSearch)2 AtlasBaseTypeDef (org.apache.atlas.model.typedef.AtlasBaseTypeDef)2 AtlasBusinessMetadataDef (org.apache.atlas.model.typedef.AtlasBusinessMetadataDef)2 AtlasClassificationDef (org.apache.atlas.model.typedef.AtlasClassificationDef)2