BUG-432: Start fixing the Registration contract
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / impl / util / URLSchemaContextResolver.java
index fc75f3f506b94cc9bc7c011e71ecf70e4e457885..fe32493b120efbe97cd3df5a3b7f426a8c6c4e51 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.yangtools.yang.parser.impl.util;
 
+import static com.google.common.base.Preconditions.checkArgument;
+
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URL;
@@ -18,7 +20,7 @@ import java.util.concurrent.ConcurrentMap;
 
 import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
 import org.opendaylight.yangtools.concepts.Identifiable;
-import org.opendaylight.yangtools.concepts.Registration;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.util.repo.AdvancedSchemaSourceProvider;
@@ -30,9 +32,6 @@ import org.slf4j.LoggerFactory;
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableMap.Builder;
-import com.google.common.collect.ImmutableSet;
-
-import static com.google.common.base.Preconditions.checkArgument;
 
 public class URLSchemaContextResolver implements AdvancedSchemaSourceProvider<InputStream> {
 
@@ -41,8 +40,8 @@ public class URLSchemaContextResolver implements AdvancedSchemaSourceProvider<In
 
     private YangSourceContext currentSourceContext;
     private Optional<SchemaContext> currentSchemaContext = Optional.absent();
-    
-    public Registration<URL> registerSource(URL source) {
+
+    public ObjectRegistration<URL> registerSource(URL source) {
         checkArgument(source != null, "Supplied source must not be null");
         InputStream yangStream = getInputStream(source);
         YangModelDependencyInfo modelInfo = YangModelDependencyInfo.fromInputStream(yangStream);
@@ -94,6 +93,7 @@ public class URLSchemaContextResolver implements AdvancedSchemaSourceProvider<In
             this.dependencyInfo = modelInfo;
         }
 
+        @Override
         public SourceIdentifier getIdentifier() {
             return identifier;
         }
@@ -127,8 +127,12 @@ public class URLSchemaContextResolver implements AdvancedSchemaSourceProvider<In
         ImmutableMap<SourceIdentifier, YangModelDependencyInfo> sourcesMap = builder.build();
         YangSourceContext context = YangSourceContext.createFrom(sourcesMap);
         LOG.debug("Trying to create schema context from {}",sourcesMap.keySet());
-        LOG.debug("Ommiting {} because of unresolved dependencies",context.getMissingDependencies().keySet());
-        
+
+        if (context.getMissingDependencies().size() != 0) {
+            LOG.debug("Omitting {} because of unresolved dependencies", context.getMissingDependencies().keySet());
+            LOG.debug("Missing model sources for {}", context.getMissingSources());
+        }
+
         try {
             if(currentSourceContext == null || !context.getValidSources().equals(currentSourceContext.getValidSources())) {
                 List<InputStream> streams = YangSourceContext.getValidInputStreams(context, this);
@@ -138,7 +142,7 @@ public class URLSchemaContextResolver implements AdvancedSchemaSourceProvider<In
                 currentSchemaContext = Optional.of(schemaContext);
                 currentSourceContext = context;
                 return currentSchemaContext;
-            } 
+            }
             currentSourceContext = context;
         } catch (Exception e) {
             LOG.error("Could not create schema context for {} ",context.getValidSources());