+ private Collection<SourceIdentifier> handleMissingSchemaSourceException(final Collection<SourceIdentifier> requiredSources, final MissingSchemaSourceException t) {
+ // In case source missing, try without it
+ final SourceIdentifier missingSource = t.getSourceId();
+ LOG.warn("{}: Unable to build schema context, missing source {}, will reattempt without it", id, missingSource);
+ LOG.debug("{}: Unable to build schema context, missing source {}, will reattempt without it", t);
+ final Collection<QName> qNameOfMissingSource = getQNameFromSourceIdentifiers(Sets.newHashSet(missingSource));
+ if (!qNameOfMissingSource.isEmpty()) {
+ capabilities.addUnresolvedCapabilities(qNameOfMissingSource, UnavailableCapability.FailureReason.MissingSource);
+ }
+ return stripUnavailableSource(requiredSources, missingSource);
+ }
+
+ private Collection<SourceIdentifier> handleSchemaResolutionException(final Collection<SourceIdentifier> requiredSources, final SchemaResolutionException resolutionException) {
+ // In case resolution error, try only with resolved sources
+ // There are two options why schema resolution exception occurred : unsatisfied imports or flawed model
+ // FIXME Do we really have assurance that these two cases cannot happen at once?
+ if (resolutionException.getFailedSource() != null) {
+ // flawed model - exclude it
+ final SourceIdentifier failedSourceId = resolutionException.getFailedSource();
+ LOG.warn("{}: Unable to build schema context, failed to resolve source {}, will reattempt without it", id, failedSourceId);
+ LOG.warn("{}: Unable to build schema context, failed to resolve source {}, will reattempt without it", id, resolutionException);
+ capabilities.addUnresolvedCapabilities(getQNameFromSourceIdentifiers(Collections.singleton(failedSourceId)),
+ UnavailableCapability.FailureReason.UnableToResolve);
+ return stripUnavailableSource(requiredSources, resolutionException.getFailedSource());
+ }
+ // unsatisfied imports
+ final Set<SourceIdentifier> unresolvedSources = resolutionException.getUnsatisfiedImports().keySet();
+ capabilities.addUnresolvedCapabilities(getQNameFromSourceIdentifiers(unresolvedSources), UnavailableCapability.FailureReason.UnableToResolve);
+ LOG.warn("{}: Unable to build schema context, unsatisfied imports {}, will reattempt with resolved only", id, resolutionException.getUnsatisfiedImports());
+ LOG.debug("{}: Unable to build schema context, unsatisfied imports {}, will reattempt with resolved only", resolutionException);
+ return resolutionException.getResolvedSources();
+ }