/** * Gets the identified roles from an EntityDescriptor. This method should not check if the provider is initialized, * if arguments are null, if the roles are valid, etc. All of this is done by the invoker of this method. * * @param entityID ID of the entity from which to retrieve the roles, never null * @param roleName name of the roles to search for, never null * * @return the modifiable list of identified roles or an empty list if no roles exists * * @throws MetadataProviderException thrown if there is a problem searching for the roles */ protected List<RoleDescriptor> doGetRole(String entityID, QName roleName) throws MetadataProviderException { EntityDescriptor entity = doGetEntityDescriptor(entityID); if (entity == null) { log.debug("Metadata document did not contain a descriptor for entity {}", entityID); return Collections.emptyList(); } List<RoleDescriptor> descriptors = entity.getRoleDescriptors(roleName); if (descriptors != null && !descriptors.isEmpty()) { return new ArrayList<RoleDescriptor>(descriptors); } return Collections.emptyList(); }
/** {@inheritDoc} */ public EntityDescriptor getEntityDescriptor(String entityID) throws MetadataProviderException { if (!isInitialized()) { throw new MetadataProviderException("Metadata provider has not been initialized"); } if (DatatypeHelper.isEmpty(entityID)) { log.debug("EntityDescriptor entityID was null or empty, skipping search for it"); return null; } EntityDescriptor descriptor = doGetEntityDescriptor(entityID); if (descriptor == null) { log.debug("Metadata document does not contain an EntityDescriptor with the ID {}", entityID); return null; } else if (!isValid(descriptor)) { log.debug("Metadata document contained an EntityDescriptor with the ID {}, but it was no longer valid", entityID); return null; } return descriptor; }