@ Override @ Path ( "/{ownerType}/{ownerId}" ) @ ApiOperation ( value = "Retrieve attributes for an ownerType and ownerId" , notes = "Response is a generic JSON object with names/values." ) public JSONObject get ( String path , Map < String , String > headers ) throws ServiceException , JSONException { Map < String , String > parameters = getParameters ( headers ) ; String ownerType = getSegment ( path , 1 ) ; if ( ownerType == null ) // fall back to parameter ownerType = parameters . get ( "ownerType" ) ; if ( ownerType == null ) throw new ServiceException ( "Missing path segment: {ownerType}" ) ; String ownerId = getSegment ( path , 2 ) ; if ( ownerId == null ) // fall back to parameter ownerId = parameters . get ( "ownerId" ) ; if ( ownerId == null ) throw new ServiceException ( "Missing path segment: {ownerId}" ) ; try { Map < String , String > attrs = ServiceLocator . getWorkflowServices ( ) . getAttributes ( ownerType , Long . parseLong ( ownerId ) ) ; JSONObject attrsJson = new JsonObject ( ) ; for ( String name : attrs . keySet ( ) ) attrsJson . put ( name , attrs . get ( name ) ) ; return attrsJson ; } catch ( Exception ex ) { throw new ServiceException ( "Error loading attributes for " + ownerType + ": " + ownerId , ex ) ; } }
Retrieve attributes .