private EvaluationResult getGenericAttributes ( URI type , URI id , URI issuer , Map < String , List < Attribute > > map , URI category , int designatorType ) { // try to find the id List < Attribute > attrList = ( List ) ( map . get ( id . toString ( ) ) ) ; if ( attrList == null ) { // the request didn't have an attribute with that id, so we should // try asking the wrapped context Attribute contextValue = checkContext ( type , id , issuer , category , designatorType ) ; if ( contextValue != null ) { attrList = Collections . singletonList ( contextValue ) ; // cache the context values map . put ( id . toString ( ) , attrList ) ; } else { // the context didn't have an attribute with that id, so we should // try asking the attribute finder attrList = Collections . emptyList ( ) ; } } // now go through each, considering each Attribute object final List < AttributeValue > attributes ; Attribute attr = null ; switch ( attrList . size ( ) ) { case 0 : attributes = Collections . emptyList ( ) ; break ; case 1 : attr = attrList . get ( 0 ) ; // make sure the type and issuer are correct if ( ( attr . getType ( ) . equals ( type ) ) && ( ( issuer == null ) || ( ( attr . getIssuer ( ) != null ) && ( attr . getIssuer ( ) . equals ( issuer . toString ( ) ) ) ) ) ) { attributes = new ArrayList < AttributeValue > ( attrList . get ( 0 ) . getValues ( ) ) ; } else { attributes = Collections . emptyList ( ) ; } break ; default : Iterator it = attrList . iterator ( ) ; attributes = new ArrayList < AttributeValue > ( ) ; while ( it . hasNext ( ) ) { attr = ( Attribute ) ( it . next ( ) ) ; // make sure the type and issuer are correct if ( ( attr . getType ( ) . equals ( type ) ) && ( ( issuer == null ) || ( ( attr . getIssuer ( ) != null ) && ( attr . getIssuer ( ) . equals ( issuer . toString ( ) ) ) ) ) ) { // if we got here, then we found a match, so we want to pull // out the values and put them in out list attributes . addAll ( attr . getValues ( ) ) ; } } } // see if we found any acceptable attributes if ( attributes . size ( ) == 0 ) { // we failed to find any that matched the type/issuer, or all the // Attribute types were empty...so ask the finder logger . debug ( "Attribute not in request: {} ... querying AttributeFinder" , id ) ; return callHelper ( type , id , issuer , category , designatorType ) ; } else { // if we got here, then we found at least one useful AttributeValue return new EvaluationResult ( new BagAttribute ( type , attributes ) ) ; } }
Helper function for the resource action and environment methods to get an attribute .