public Response getEntityDefinitionByAttribute ( String entityType , String attribute , String value ) { try { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Fetching entity definition for type={}, qualified name={}" , entityType , value ) ; } entityType = ParamChecker . notEmpty ( entityType , "Entity type cannot be null" ) ; attribute = ParamChecker . notEmpty ( attribute , "attribute name cannot be null" ) ; value = ParamChecker . notEmpty ( value , "attribute value cannot be null" ) ; Map < String , Object > attributes = new HashMap <> ( ) ; attributes . put ( attribute , value ) ; AtlasEntityWithExtInfo entityInfo ; try { entityInfo = entitiesStore . getByUniqueAttributes ( getEntityType ( entityType ) , attributes ) ; } catch ( AtlasBaseException e ) { LOG . error ( "Cannot find entity with type: {}, attribute: {} and value: {}" , entityType , attribute , value ) ; throw toWebApplicationException ( e ) ; } String entityDefinition = null ; if ( entityInfo != null ) { AtlasEntity entity = entityInfo . getEntity ( ) ; final ITypedReferenceableInstance instance = restAdapters . getITypedReferenceable ( entity ) ; entityDefinition = InstanceSerialization . toJson ( instance , true ) ; } JSONObject response = new JSONObject ( ) ; response . put ( AtlasClient . REQUEST_ID , Servlets . getRequestId ( ) ) ; Response . Status status = Response . Status . NOT_FOUND ; if ( entityDefinition != null ) { response . put ( AtlasClient . DEFINITION , new JSONObject ( entityDefinition ) ) ; status = Response . Status . OK ; } else { response . put ( AtlasClient . ERROR , Servlets . escapeJsonString ( String . format ( "An entity with type={%s}, " + "qualifiedName={%s} does not exist" , entityType , value ) ) ) ; } return Response . status ( status ) . entity ( response ) . build ( ) ; } catch ( AtlasBaseException e ) { LOG . error ( "Unable to get instance definition for type={}, qualifiedName={}" , entityType , value , e ) ; throw toWebApplicationException ( e ) ; } catch ( IllegalArgumentException e ) { LOG . error ( "Bad type={}, qualifiedName={}" , entityType , value , e ) ; throw new WebApplicationException ( Servlets . getErrorResponse ( e , Response . Status . BAD_REQUEST ) ) ; } catch ( WebApplicationException e ) { LOG . error ( "Unable to get instance definition for type={}, qualifiedName={}" , entityType , value , e ) ; throw e ; } catch ( Throwable e ) { LOG . error ( "Unable to get instance definition for type={}, qualifiedName={}" , entityType , value , e ) ; throw new WebApplicationException ( Servlets . getErrorResponse ( e , Response . Status . INTERNAL_SERVER_ERROR ) ) ; } }
Fetch the complete definition of an entity given its qualified name .