use of org.apache.atlas.annotation.Timed in project atlas by apache.
the class GlossaryREST method getEntitiesAssignedWithTerm.
/**
* Get all entity headers assigned with the specified term
* @param termGuid GUID of the term
* @param limit page size - by default there is no paging
* @param offset offset for pagination purpose
* @param sort ASC (default) or DESC
* @return
* @throws AtlasBaseException
* @HTTP 200 List of entity headers (if any) for the given glossary or an empty list
* @HTTP 404 If glossary term guid in invalid
*/
@GET
@Path("/terms/{termGuid}/assignedEntities")
@Timed
public List<AtlasRelatedObjectId> getEntitiesAssignedWithTerm(@PathParam("termGuid") String termGuid, @DefaultValue("-1") @QueryParam("limit") String limit, @DefaultValue("0") @QueryParam("offset") String offset, @DefaultValue("ASC") @QueryParam("sort") final String sort) throws AtlasBaseException {
Servlets.validateQueryParamLength("termGuid", termGuid);
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "GlossaryREST.getEntitiesAssignedWithTerm(" + termGuid + ")");
}
return glossaryService.getAssignedEntities(termGuid, Integer.parseInt(offset), Integer.parseInt(limit), toSortOrder(sort));
} finally {
AtlasPerfTracer.log(perf);
}
}
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);
}
}
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);
}
}
use of org.apache.atlas.annotation.Timed in project atlas by apache.
the class GlossaryREST method getGlossaryCategory.
/**
* Get specific glossary category
* @param categoryGuid unique identifier for glossary category
* @return Glossary category
* @throws AtlasBaseException
* @HTTP 200 If glossary category exists for given GUID
* @HTTP 404 If glossary category GUID is invalid
*/
@GET
@Path("/category/{categoryGuid}")
@Timed
public AtlasGlossaryCategory getGlossaryCategory(@PathParam("categoryGuid") String categoryGuid) throws AtlasBaseException {
Servlets.validateQueryParamLength("categoryGuid", categoryGuid);
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "GlossaryREST.getGlossaryCategory(" + categoryGuid + ")");
}
AtlasGlossaryCategory ret = glossaryService.getCategory(categoryGuid);
if (ret == null) {
throw new AtlasBaseException(AtlasErrorCode.INSTANCE_GUID_NOT_FOUND);
}
return ret;
} finally {
AtlasPerfTracer.log(perf);
}
}
use of org.apache.atlas.annotation.Timed in project atlas by apache.
the class GlossaryREST method partialUpdateGlossaryCategory.
/**
* Partially update the glossary category
* @param categoryGuid unique identifier for glossary term
* @param partialUpdates Map containing keys as attribute names and values as corresponding attribute values
* @return Updated glossary category
* @throws AtlasBaseException
* @HTTP 200 If glossary category partial update was successful
* @HTTP 404 If glossary category guid in invalid
* @HTTP 400 If category attributes are invalid
*/
@PUT
@Path("/category/{categoryGuid}/partial")
@Timed
public AtlasGlossaryCategory partialUpdateGlossaryCategory(@PathParam("categoryGuid") String categoryGuid, Map<String, String> partialUpdates) throws AtlasBaseException {
Servlets.validateQueryParamLength("categoryGuid", categoryGuid);
AtlasPerfTracer perf = null;
try {
if (AtlasPerfTracer.isPerfTraceEnabled(PERF_LOG)) {
perf = AtlasPerfTracer.getPerfTracer(PERF_LOG, "GlossaryREST.partialUpdateGlossaryCategory()");
}
if (MapUtils.isEmpty(partialUpdates)) {
throw new AtlasBaseException(AtlasErrorCode.BAD_REQUEST, "PartialUpdates missing or empty");
}
AtlasGlossaryCategory glossaryCategory = glossaryService.getCategory(categoryGuid);
for (Map.Entry<String, String> entry : partialUpdates.entrySet()) {
try {
glossaryCategory.setAttribute(entry.getKey(), entry.getValue());
} catch (IllegalArgumentException e) {
throw new AtlasBaseException(AtlasErrorCode.INVALID_PARTIAL_UPDATE_ATTR, "Glossary Category", entry.getKey());
}
}
return glossaryService.updateCategory(glossaryCategory);
} finally {
AtlasPerfTracer.log(perf);
}
}
Aggregations