/** {@inheritDoc} */ public synchronized void destroy() { observers = Collections.emptyList(); super.destroy(); }
/** {@inheritDoc} */ public void onEvent(MetadataProvider provider) { ((AbstractMetadataProvider) provider).clearDescriptorIndex(); } }
/** {@inheritDoc} */ public XMLObject getMetadata() throws MetadataProviderException { if (!isInitialized()) { throw new MetadataProviderException("Metadata provider has not been initialized"); } XMLObject metadata = doGetMetadata(); if (metadata == null) { log.debug("Metadata provider does not currently contain any metadata"); } if (!isValid(metadata)) { log.debug("Metadata document exists, but it is no longer valid"); return null; } return metadata; }
/** * Gets the named EntitiesDescriptor from the metadata. This method should not check if the provider is initialized, * if arguments are null, if metadata is valid, etc. All of this is done by the invoker of this method. * * @param name the name of the EntitiesDescriptor, never null * * @return the named EntitiesDescriptor or null if no such EntitiesDescriptor exists * * @throws MetadataProviderException thrown if there is a problem searching for the EntitiesDescriptor */ protected EntitiesDescriptor doGetEntitiesDescriptor(String name) throws MetadataProviderException { XMLObject metadata = doGetMetadata(); if (metadata == null) { log.debug("Metadata provider does not currently contain any metadata, unable to look for an EntitiesDescriptor with the name {}", name); return null; } EntitiesDescriptor descriptor = null; if (metadata instanceof EntitiesDescriptor) { descriptor = getEntitiesDescriptorByName(name, (EntitiesDescriptor) metadata); } return descriptor; }
/** * Gets the identified EntityDescriptor from the metadata. This method should not check if the provider is * initialized, if arguments are null, if the metadata is valid, etc. All of this is done by the invoker of this * method. * * @param entityID ID of the EntityDescriptor, never null * * @return the identified EntityDescriptor or null if no such EntityDescriptor exists * * @throws MetadataProviderException thrown if there is a problem searching for the EntityDescriptor */ protected EntityDescriptor doGetEntityDescriptor(String entityID) throws MetadataProviderException { XMLObject metadata = doGetMetadata(); if (metadata == null) { log.debug("Metadata document was empty, unable to look for an EntityDescriptor with the ID {}", entityID); return null; } return getEntityDescriptorById(entityID, metadata); }
if (!isInitialized()) { throw new MetadataProviderException("Metadata provider has not been initialized"); List<RoleDescriptor> roleDescriptors = doGetRole(entityID, roleName); if (roleDescriptors == null || roleDescriptors.isEmpty()) { log.debug("Entity descriptor {} did not contain any {} roles", entityID, roleName); if (!isValid(roleDescItr.next())) { log.debug("Metadata document contained a role of type {} for entity {}, but it was invalid", roleName, entityID);
/** {@inheritDoc} */ public EntitiesDescriptor getEntitiesDescriptor(String name) throws MetadataProviderException { if (!isInitialized()) { throw new MetadataProviderException("Metadata provider has not been initialized"); } if (DatatypeHelper.isEmpty(name)) { log.debug("EntitiesDescriptor name was null or empty, skipping search for it"); return null; } EntitiesDescriptor descriptor = doGetEntitiesDescriptor(name); if (descriptor == null) { log.debug("Metadata document does not contain an EntitiesDescriptor with the name {}", name); return null; } else if (!isValid(descriptor)) { log.debug("Metadata document contained an EntitiesDescriptor with the name {}, but it was no longer valid", name); return null; } return descriptor; }
/** {@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; }
if (entityID != null && indexedDescriptors.containsKey(entityID)) { descriptor = indexedDescriptors.get(entityID); if (isValid(descriptor)) { log.trace("Entity descriptor for the ID {} was found in index cache, returning", entityID); return descriptor; } else if (!isValid(descriptor)) { log.trace("Found entity descriptor for entity with ID {} but it is no longer valid, skipping it.", entityID); + "elements is the one we're looking for."); if (metadata instanceof EntitiesDescriptor) { descriptor = getEntityDescriptorById(entityID, (EntitiesDescriptor) metadata);
/** * Gets the entities descriptor with the given name. * * @param name name of the entities descriptor * @param rootDescriptor the root descriptor to search in * * @return the EntitiesDescriptor with the given name */ protected EntitiesDescriptor getEntitiesDescriptorByName(String name, EntitiesDescriptor rootDescriptor) { EntitiesDescriptor descriptor = null; if (DatatypeHelper.safeEquals(name, rootDescriptor.getName()) && isValid(rootDescriptor)) { descriptor = rootDescriptor; } else { List<EntitiesDescriptor> childDescriptors = rootDescriptor.getEntitiesDescriptors(); if (childDescriptors == null || childDescriptors.isEmpty()) { return null; } for (EntitiesDescriptor childDescriptor : childDescriptors) { childDescriptor = getEntitiesDescriptorByName(name, childDescriptor); if (childDescriptor != null) { descriptor = childDescriptor; } } } return descriptor; }
/** * Filters the given metadata. * * @param metadata the metadata to be filtered * * @throws FilterException thrown if there is an error filtering the metadata */ protected void filterMetadata(XMLObject metadata) throws FilterException { if (getMetadataFilter() != null) { log.debug("Applying metadata filter"); getMetadataFilter().doFilter(metadata); } }
/** * Initializes this metadata provider. If called after the metadata provider has already been initialized this * method simply returns. * * @throws MetadataProviderException thrown if there is a problem initializing the problem and fail fast * Initialization is enabled */ public synchronized void initialize() throws MetadataProviderException { if (initialized) { return; } try { doInitialization(); initialized = true; } catch (MetadataProviderException e) { if (failFastInitialization) { log.error("Metadata provider failed to properly initialize, fail-fast=true, halting", e); throw e; } else { log.error("Metadata provider failed to properly initialize, fail-fast=false, " + "continuing on in a degraded state", e); initialized = true; } } }
/** * 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(); }
/** * 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; }
if (!isInitialized()) { throw new MetadataProviderException("Metadata provider has not been initialized"); RoleDescriptor role = doGetRole(entityID, roleName, supportedProtocol); if (role == null) { log.debug("Metadata document does not contain a role of type {} supporting protocol {} for entity {}", if (!isValid(role)) { log .debug(
for (EntityDescriptor entityDescriptor : entityDescriptors) { log.trace("Checking entity descriptor with entity ID {}", entityDescriptor.getEntityID()); if (DatatypeHelper.safeEquals(entityDescriptor.getEntityID(), entityID) && isValid(entityDescriptor)) { return entityDescriptor; if (entitiesDescriptors != null && !entitiesDescriptors.isEmpty()) { for (EntitiesDescriptor entitiesDescriptor : descriptor.getEntitiesDescriptors()) { entityDescriptor = getEntityDescriptorById(entityID, entitiesDescriptor); if (entityDescriptor != null) {
/** * Method destroys the metadata delegate. */ public void destroy() { if (getDelegate() instanceof AbstractMetadataProvider) { log.debug("Destroying delegate"); AbstractMetadataProvider provider = (AbstractMetadataProvider) getDelegate(); provider.destroy(); } else { log.debug("Cannot destroy delegate, doesn't extend AbstractMetadataProvider"); } }