Search in sources :

Example 26 with Timed

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

the class GlossaryREST method partialUpdateGlossaryTerm.

/**
 * Partially update the glossary term
 * @param termGuid unique identifier for glossary term
 * @param partialUpdates Map containing keys as attribute names and values as corresponding attribute values
 * @return Updated glossary term
 * @throws AtlasBaseException
 * @HTTP 200 If glossary partial update was successful
 * @HTTP 404 If glossary term guid in invalid
 * @HTTP 400 If partial attributes are invalid
 */
@PUT
@Path("/term/{termGuid}/partial")
@Timed
public AtlasGlossaryTerm partialUpdateGlossaryTerm(@PathParam("termGuid") String termGuid, Map<String, String> partialUpdates) throws AtlasBaseException {
    Servlets.validateQueryParamLength("termGuid", termGuid);
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "GlossaryREST.partialUpdateGlossaryTerm()");
        }
        if (MapUtils.isEmpty(partialUpdates)) {
            throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "PartialUpdates missing or empty");
        }
        AtlasGlossaryTerm glossaryTerm = glossaryService.getTerm(termGuid);
        for (Map.Entry<String, String> entry : partialUpdates.entrySet()) {
            try {
                glossaryTerm.setAttribute(entry.getKey(), entry.getValue());
            } catch (IllegalArgumentException e) {
                throw new AtlasBaseException(AtlasErrorCode.INVALID_PARTIAL_UPDATE_ATTR, "Glossary Term", entry.getKey());
            }
        }
        return glossaryService.updateTerm(glossaryTerm);
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) AtlasGlossaryTerm(org.apache.atlas.model.glossary.AtlasGlossaryTerm) Map(java.util.Map) Path(javax.ws.rs.Path) Timed(org.apache.atlas.annotation.Timed) PUT(javax.ws.rs.PUT)

Example 27 with Timed

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

the class GlossaryREST method getGlossaryTerm.

/**
 * Get specific glossary term
 * @param termGuid unique identifier for glossary term
 * @return Glossary term
 * @throws AtlasBaseException
 * @HTTP 200 If glossary term exists for given GUID
 * @HTTP 404 If glossary term GUID is invalid
 */
@GET
@Path("/term/{termGuid}")
@Timed
public AtlasGlossaryTerm getGlossaryTerm(@PathParam("termGuid") String termGuid) throws AtlasBaseException {
    Servlets.validateQueryParamLength("termGuid", termGuid);
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "GlossaryREST.getGlossaryTerm(" + termGuid + ")");
        }
        AtlasGlossaryTerm ret = glossaryService.getTerm(termGuid);
        if (ret == null) {
            throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND);
        }
        return ret;
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) AtlasGlossaryTerm(org.apache.atlas.model.glossary.AtlasGlossaryTerm) Path(javax.ws.rs.Path) Timed(org.apache.atlas.annotation.Timed) GET(javax.ws.rs.GET)

Example 28 with Timed

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

the class GlossaryREST method getGlossary.

/**
 * Get a specific Glossary
 * @param glossaryGuid unique glossary identifier
 * @return Glossary
 * @throws AtlasBaseException
 * @HTTP 200 If glossary with given guid exists
 * @HTTP 404 If glossary GUID is invalid
 */
@GET
@Path("/{glossaryGuid}")
@Timed
public AtlasGlossary getGlossary(@PathParam("glossaryGuid") String glossaryGuid) throws AtlasBaseException {
    Servlets.validateQueryParamLength("glossaryGuid", glossaryGuid);
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "GlossaryREST.getGlossary(" + glossaryGuid + ")");
        }
        AtlasGlossary ret = glossaryService.getGlossary(glossaryGuid);
        if (ret == null) {
            throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND);
        }
        return ret;
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasGlossary(org.apache.atlas.model.glossary.AtlasGlossary) 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)

Example 29 with Timed

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

the class GlossaryREST method updateGlossaryTerm.

/**
 * Update the given glossary term
 * @param termGuid unique identifier for glossary term
 * @param glossaryTerm updated glossary term
 * @return Updated glossary term
 * @throws AtlasBaseException
 * @HTTP 200 If glossary term update was successful
 * @HTTP 404 If glossary term guid in invalid
 * @HTTP 400 If Glossary temr definition has invalid or missing information
 */
@PUT
@Path("/term/{termGuid}")
@Timed
public AtlasGlossaryTerm updateGlossaryTerm(@PathParam("termGuid") String termGuid, AtlasGlossaryTerm glossaryTerm) throws AtlasBaseException {
    Servlets.validateQueryParamLength("termGuid", termGuid);
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "GlossaryREST.updateGlossaryTerm()");
        }
        glossaryTerm.setGuid(termGuid);
        return glossaryService.updateTerm(glossaryTerm);
    } 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 30 with Timed

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

the class GlossaryREST method partialUpdateGlossary.

/**
 * Partially update the glossary
 * @param glossaryGuid unique identifier for glossary term
 * @param partialUpdates Map containing keys as attribute names and values as corresponding attribute values
 * @return Updated glossary
 * @throws AtlasBaseException
 * @HTTP 200 If glossary partial update was successful
 * @HTTP 404 If glossary guid in invalid
 * @HTTP 400 If partial update parameters are invalid
 */
@PUT
@Path("/{glossaryGuid}/partial")
@Timed
public AtlasGlossary partialUpdateGlossary(@PathParam("glossaryGuid") String glossaryGuid, Map<String, String> partialUpdates) throws AtlasBaseException {
    Servlets.validateQueryParamLength("glossaryGuid", glossaryGuid);
    AtlasPerfTracer perf = null;
    try {
        if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
            perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "GlossaryREST.partialUpdateGlossary()");
        }
        if (MapUtils.isEmpty(partialUpdates)) {
            throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "PartialUpdates missing or empty");
        }
        AtlasGlossary glossary = glossaryService.getGlossary(glossaryGuid);
        for (Map.Entry<String, String> entry : partialUpdates.entrySet()) {
            try {
                glossary.setAttribute(entry.getKey(), entry.getValue());
            } catch (IllegalArgumentException e) {
                throw new AtlasBaseException(AtlasErrorCode.INVALID_PARTIAL_UPDATE_ATTR, entry.getKey(), "Glossary");
            }
        }
        return glossaryService.updateGlossary(glossary);
    } finally {
        AtlasPerfTracer.log(perf);
    }
}
Also used : AtlasGlossary(org.apache.atlas.model.glossary.AtlasGlossary) AtlasBaseException(org.apache.atlas.exception.AtlasBaseException) AtlasPerfTracer(org.apache.atlas.utils.AtlasPerfTracer) Map(java.util.Map) Path(javax.ws.rs.Path) Timed(org.apache.atlas.annotation.Timed) PUT(javax.ws.rs.PUT)

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