@ GET @ Path ( "{guid}/traitDefinitions/{traitName}" ) @ Produces ( Servlets . JSON_MEDIA_TYPE ) public Response getTraitDefinitionForEntity ( @ PathParam ( "guid" ) String guid , @ PathParam ( "traitName" ) String traitName ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "==> EntityResource.getTraitDefinitionForEntity({}, {})" , guid , traitName ) ; } AtlasPerfTracer perf = null ; try { if ( AtlasPerfTracer . isPerfTraceEnabled ( PERF_LOG ) ) { perf = AtlasPerfTracer . getPerfTracer ( PERF_LOG , "EntityResource.getTraitDefinitionForEntity(" + guid + ", " + traitName + ")" ) ; } if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Fetching trait definition for entity {} and trait name {}" , guid , traitName ) ; } final AtlasClassification classification = entitiesStore . getClassification ( guid , traitName ) ; IStruct traitDefinition = restAdapters . getTrait ( classification ) ; JSONObject response = new JSONObject ( ) ; response . put ( AtlasClient . REQUEST_ID , Servlets . getRequestId ( ) ) ; response . put ( AtlasClient . RESULTS , new JSONObject ( InstanceSerialization . toJson ( traitDefinition , true ) ) ) ; return Response . ok ( response ) . build ( ) ; } catch ( AtlasBaseException e ) { LOG . error ( "Unable to get trait definition for entity {} and trait {}" , guid , traitName , e ) ; throw toWebApplicationException ( e ) ; } catch ( IllegalArgumentException e ) { LOG . error ( "Unable to get trait definition for entity {} and trait {}" , guid , traitName , e ) ; throw new WebApplicationException ( Servlets . getErrorResponse ( e , Response . Status . BAD_REQUEST ) ) ; } catch ( WebApplicationException e ) { LOG . error ( "Unable to get trait definition for entity {} and trait {}" , guid , traitName , e ) ; throw e ; } catch ( Throwable e ) { LOG . error ( "Unable to get trait definition for entity {} and trait {}" , guid , traitName , e ) ; throw new WebApplicationException ( Servlets . getErrorResponse ( e , Response . Status . INTERNAL_SERVER_ERROR ) ) ; } finally { AtlasPerfTracer . log ( perf ) ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "<== EntityResource.getTraitDefinitionForEntity({}, {})" , guid , traitName ) ; } } }
Fetches the trait definition for an entity given its guid and trait name