/** * Gets the role which supports the given protocol. * * @param entityID ID of the entity from which to retrieve roles, never null * @param roleName name of the role to search for, never null * @param supportedProtocol protocol to search for, never null * * @return the role supporting the protocol or null if no such role exists * * @throws MetadataProviderException thrown if there is a problem search for the roles */ protected RoleDescriptor doGetRole(String entityID, QName roleName, String supportedProtocol) throws MetadataProviderException { List<RoleDescriptor> roles = doGetRole(entityID, roleName); if (roles == null || roles.isEmpty()) { log.debug("Metadata document did not contain any role descriptors of type {} for entity {}", roleName, entityID); return null; } Iterator<RoleDescriptor> rolesItr = roles.iterator(); RoleDescriptor role = null; while (rolesItr.hasNext()) { role = rolesItr.next(); if (role != null && role.isSupportedProtocol(supportedProtocol)) { return role; } } return null; }
List<RoleDescriptor> roleDescriptors = doGetRole(entityID, roleName); if (roleDescriptors == null || roleDescriptors.isEmpty()) { log.debug("Entity descriptor {} did not contain any {} roles", entityID, roleName);
RoleDescriptor role = doGetRole(entityID, roleName, supportedProtocol); if (role == null) { log.debug("Metadata document does not contain a role of type {} supporting protocol {} for entity {}",