You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by al...@apache.org on 2012/07/19 19:10:07 UTC

svn commit: r1363428 [1/4] - in /incubator/stanbol/trunk: commons/owl/src/main/java/org/apache/stanbol/commons/owl/util/ commons/owl/src/test/java/org/apache/stanbol/commons/owl/util/ enhancer/engines/refactor/src/main/java/org/apache/stanbol/enhancer/...

Author: alexdma
Date: Thu Jul 19 17:10:05 2012
New Revision: 1363428

URL: http://svn.apache.org/viewvc?rev=1363428&view=rev
Log:
* Restoring ontology networks, upon reactivation of Stanbol, was not considering scopes attached to sessions. Should be fixed now, sorry (STANBOL-571). Note that scopes and sessions can be restored regardless of the activation order of the ONManagerImpl and SessionManagerImpl.
* The new type Origin in the OntoNet API has replaced physical IRIs in ontology input sources. It can be used to wrap physical URLs on the Web (IRI) as well as Graph names (UriRef) in Clerezza. Input sources now use this wrapper type actively (STANBOL-422). This significanly speeds up ontology loading via REST, as well as restoring ontology network structures (though some work still has to be done in that department) (STANBOL-571). Kudos to US death metal band Origin that I had seen live the night before, for inspiring an appropriate class name ;) .
* RESTful services for exporting ontology and OntoNet artifacts no longer depend on the OSGi settings for default namespaces. Only the Java API does. RESTful services will now always use the request URI for generating artifacts URIs and import targets. Also, the namespace parameters were moved to a single one in the OfflineConfiguration. (STANBOL-649)
* OntologyInputSource<O> has now returned to be a single-parameter generic, no more need to specify the triple store type (STANBOL-422)
* Graph names chosen by GraphContentInputSources are now stored persistently in the metalevel graph. This nearly halves the time taken by ontology loading via REST, and should also prevent graph duplications when ontonet is restored (especially for anonymous ontologies). TODO : implement ontology ID lookahead in input sources, so they can choose a more appropriate graph name before actually loading the whole content. (STANBOL-305 STANBOL-422 STANBOL-426)
* The OWLUtils.guessOntologyIdentifier() methods no longer generate a timestamp-based IDs for anonymous ontologies. This caused trouble with multiple calls to the method for the same ontology, and made it almost impossible to restore ontology network structures. Therefore, the methods now return null IDs, and timestamped IRI generation is deferred to the Clerezza ontology provider for generating the public keys of stored ontologies. (STANBOL-305)
* The OntologyProvider API now exposes "public keys" that identify stored ontologies in the form of OWLOntologyID objects. They may or may not coincide with graph names, but can be used for ontology <-> graph reconciliation. In addition, they are also generated for anonymous ontologies (STANBOL-422 STANBOL-426)
* HTML REST API now shows the direct handles on stored ontologies (STANBOL-695)
* The obsolete OntoNet OWL API implementation is gone (STANBOL-696).
* General API cleanup and javadoc

Added:
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/Origin.java
Removed:
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/GraphImportsClosureSource.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/owlapi/
Modified:
    incubator/stanbol/trunk/commons/owl/src/main/java/org/apache/stanbol/commons/owl/util/OWL2Constants.java
    incubator/stanbol/trunk/commons/owl/src/main/java/org/apache/stanbol/commons/owl/util/OWLUtils.java
    incubator/stanbol/trunk/commons/owl/src/test/java/org/apache/stanbol/commons/owl/util/TestOWLUtils.java
    incubator/stanbol/trunk/enhancer/engines/refactor/src/main/java/org/apache/stanbol/enhancer/engines/refactor/RefactorEnhancementEngine.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/NamedResource.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ONManager.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/OfflineConfiguration.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/OntologyNetworkConfiguration.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/Vocabulary.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/collector/OntologyCollector.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/AbstractClerezzaGraphInputSource.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/AbstractGenericInputSource.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/AbstractOWLOntologyInputSource.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/BlankOntologySource.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/GraphContentInputSource.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/GraphSource.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologyContentInputSource.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologyInputSource.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologyInputSourceHandler.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologySpaceSource.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/ParentPathInputSource.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/RootOntologyIRISource.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/RootOntologySource.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/SetInputSource.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OWLExportable.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologyProvider.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologyScopeFactory.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologySpaceFactory.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/Session.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionListener.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionManager.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ONManagerImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/OfflineConfigurationImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/AbstractOntologyCollectorImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/ClerezzaOntologyProvider.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/CustomSpaceImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/OntologySpaceFactoryImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OntologyScopeImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/session/SessionImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/session/SessionManagerImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/util/OntologyUtils.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/resources/OSGI-INF/metatype/metatype.properties
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/MockOsgiContext.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/TestClerezzaProvider.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/TestOntologyCollectors.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/impl/clerezza/TestOntologyNetworkPersistence.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestClerezzaInputSources.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestOWLAPIInputSources.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/io/TestStorage.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestAxiomInterpretation.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestClerezzaSpaces.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestOntologyScope.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestOntologySpaces.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/session/TestSessions.java
    incubator/stanbol/trunk/ontologymanager/registry/src/main/java/org/apache/stanbol/ontologymanager/registry/io/LibrarySource.java
    incubator/stanbol/trunk/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/TestOntologyLibrary.java
    incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/OntoNetRootResource.java
    incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/ScopeResource.java
    incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/SessionResource.java
    incubator/stanbol/trunk/ontologymanager/web/src/main/resources/org/apache/stanbol/ontologymanager/web/templates/org/apache/stanbol/ontologymanager/web/resources/OntoNetRootResource/webview.ftl
    incubator/stanbol/trunk/ontologymanager/web/src/main/resources/org/apache/stanbol/ontologymanager/web/templates/org/apache/stanbol/ontologymanager/web/resources/OntologyNetworkResource/index.ftl
    incubator/stanbol/trunk/ontologymanager/web/src/main/resources/org/apache/stanbol/ontologymanager/web/templates/org/apache/stanbol/ontologymanager/web/resources/ScopeResource/index.ftl

Modified: incubator/stanbol/trunk/commons/owl/src/main/java/org/apache/stanbol/commons/owl/util/OWL2Constants.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/owl/src/main/java/org/apache/stanbol/commons/owl/util/OWL2Constants.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/owl/src/main/java/org/apache/stanbol/commons/owl/util/OWL2Constants.java (original)
+++ incubator/stanbol/trunk/commons/owl/src/main/java/org/apache/stanbol/commons/owl/util/OWL2Constants.java Thu Jul 19 17:10:05 2012
@@ -16,10 +16,22 @@
  */
 package org.apache.stanbol.commons.owl.util;
 
+/**
+ * A collection of OWL 2 vocabulary terms that integrates those provided by Clerezza.
+ * 
+ * @author alexdma
+ * 
+ */
 public class OWL2Constants {
 
+    /**
+     * The namespace for the OWL language vocabulary.
+     */
     public static final String _OWL_NS = "http://www.w3.org/2002/07/owl#";
 
+    /**
+     * The owl:versionIRI annotation property that applies to resources of type owl:Ontology in OWL 2.
+     */
     public static final String OWL_VERSION_IRI = _OWL_NS + "versionIRI";
 
 }

Modified: incubator/stanbol/trunk/commons/owl/src/main/java/org/apache/stanbol/commons/owl/util/OWLUtils.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/owl/src/main/java/org/apache/stanbol/commons/owl/util/OWLUtils.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/owl/src/main/java/org/apache/stanbol/commons/owl/util/OWLUtils.java (original)
+++ incubator/stanbol/trunk/commons/owl/src/main/java/org/apache/stanbol/commons/owl/util/OWLUtils.java Thu Jul 19 17:10:05 2012
@@ -22,7 +22,6 @@ import org.apache.clerezza.rdf.core.NonL
 import org.apache.clerezza.rdf.core.Triple;
 import org.apache.clerezza.rdf.core.TripleCollection;
 import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.access.TcProvider;
 import org.apache.clerezza.rdf.ontologies.OWL;
 import org.apache.clerezza.rdf.ontologies.RDF;
 import org.semanticweb.owlapi.model.IRI;
@@ -48,11 +47,10 @@ public class OWLUtils {
      * @return
      */
     public static OWLOntologyID guessOntologyIdentifier(OWLOntology o) {
-
         String oiri;
         IRI viri = null;
-        // For named OWL ontologies it is their ontology ID. For anonymous ontologies, it is the URI they were
-        // fetched from, if any.
+        // For named OWL ontologies it is their ontology ID.
+        // For anonymous ontologies, it is the URI they were fetched from, if any.
         if (o.isAnonymous()) oiri = o.getOWLOntologyManager().getOntologyDocumentIRI(o).toString();
         else {
             OWLOntologyID id = o.getOntologyID();
@@ -62,44 +60,41 @@ public class OWLUtils {
         // Strip fragment or query tokens. TODO do proper URL Encoding.
         while (oiri.endsWith("#") || oiri.endsWith("?"))
             oiri = oiri.substring(0, oiri.length() - 1);
-        // try {
-        // if (originalIri.endsWith("#")) originalIri = originalIri.substring(0,
-        // originalIri.length() - 1) + URLEncoder.encode("#", "UTF-8");
-        // else if (originalIri.endsWith("?")) originalIri = originalIri.substring(0,
-        // originalIri.length() - 1)
-        // + URLEncoder.encode("?", "UTF-8");
-        // } catch (UnsupportedEncodingException e) {
-        // // That cannot be.
-        // }
-
         if (viri != null) return new OWLOntologyID(IRI.create(oiri), viri);
         else return new OWLOntologyID(IRI.create(oiri));
     }
 
-    public static OWLOntologyID guessOntologyIdentifier(TripleCollection g) {
+    /**
+     * Returns the logical identifier of the supplied RDF graph, which is interpreted as an OWL ontology.
+     * 
+     * @param graph
+     *            the RDF graph
+     * @return the OWL ontology ID of the supplied graph, or null if it denotes an anonymous ontology.
+     */
+    public static OWLOntologyID guessOntologyIdentifier(TripleCollection graph) {
         IRI ontologyIri = null, versionIri = null;
-        Iterator<Triple> it = g.filter(null, RDF.type, OWL.Ontology);
+        Iterator<Triple> it = graph.filter(null, RDF.type, OWL.Ontology);
         if (it.hasNext()) {
             NonLiteral subj = it.next().getSubject();
-            if (it.hasNext()) log.warn(
-                "RDF Graph {} has multiple OWL ontology definitions! Ignoring all but {}", g, subj);
+            if (it.hasNext()) {
+                log.warn("Multiple OWL ontology definitions found.");
+                log.warn("Ignoring all but {}", subj);
+            }
             if (subj instanceof UriRef) {
                 ontologyIri = IRI.create(((UriRef) subj).getUnicodeString());
-                Iterator<Triple> it2 = g.filter((UriRef) subj, new UriRef(OWL2Constants.OWL_VERSION_IRI),
+                Iterator<Triple> it2 = graph.filter((UriRef) subj, new UriRef(OWL2Constants.OWL_VERSION_IRI),
                     null);
                 if (it2.hasNext()) versionIri = IRI.create(((UriRef) it2.next().getObject())
                         .getUnicodeString());
             }
         }
         if (ontologyIri == null) {
-            ontologyIri = IRI.create(NS_STANBOL + System.currentTimeMillis());
-            log.debug("Ontology is anonymous. Returning generated ID <{}> .", ontologyIri);
+            // Note that OWL 2 does not allow ontologies with a version IRI and no ontology IRI.
+            log.debug("Ontology is anonymous. Returning null ID.");
+            return null;
         }
         if (versionIri == null) return new OWLOntologyID(ontologyIri);
         else return new OWLOntologyID(ontologyIri, versionIri);
     }
 
-    public static OWLOntologyID guessOntologyIdentifier(UriRef key, TcProvider store) {
-        return guessOntologyIdentifier(store.getTriples(key));
-    }
 }

Modified: incubator/stanbol/trunk/commons/owl/src/test/java/org/apache/stanbol/commons/owl/util/TestOWLUtils.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/owl/src/test/java/org/apache/stanbol/commons/owl/util/TestOWLUtils.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/owl/src/test/java/org/apache/stanbol/commons/owl/util/TestOWLUtils.java (original)
+++ incubator/stanbol/trunk/commons/owl/src/test/java/org/apache/stanbol/commons/owl/util/TestOWLUtils.java Thu Jul 19 17:10:05 2012
@@ -17,6 +17,7 @@
 package org.apache.stanbol.commons.owl.util;
 
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 
 import java.io.InputStream;
 
@@ -54,8 +55,7 @@ public class TestOWLUtils {
         InputStream inputStream = getClass().getResourceAsStream("/owl/nameless_ontology.owl");
         MGraph mg = TcManager.getInstance().createMGraph(uri);
         pp.parse(mg, inputStream, "application/rdf+xml", uri);
-        // No longer null!
-        assertNotNull(OWLUtils.guessOntologyIdentifier(mg.getGraph()));
+        assertNull(OWLUtils.guessOntologyIdentifier(mg.getGraph()));
     }
 
     @After

Modified: incubator/stanbol/trunk/enhancer/engines/refactor/src/main/java/org/apache/stanbol/enhancer/engines/refactor/RefactorEnhancementEngine.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/enhancer/engines/refactor/src/main/java/org/apache/stanbol/enhancer/engines/refactor/RefactorEnhancementEngine.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/enhancer/engines/refactor/src/main/java/org/apache/stanbol/enhancer/engines/refactor/RefactorEnhancementEngine.java (original)
+++ incubator/stanbol/trunk/enhancer/engines/refactor/src/main/java/org/apache/stanbol/enhancer/engines/refactor/RefactorEnhancementEngine.java Thu Jul 19 17:10:05 2012
@@ -64,6 +64,7 @@ import org.apache.stanbol.ontologymanage
 import org.apache.stanbol.ontologymanager.ontonet.api.io.GraphContentInputSource;
 import org.apache.stanbol.ontologymanager.ontonet.api.io.GraphSource;
 import org.apache.stanbol.ontologymanager.ontonet.api.io.OntologyInputSource;
+import org.apache.stanbol.ontologymanager.ontonet.api.io.Origin;
 import org.apache.stanbol.ontologymanager.ontonet.api.io.RootOntologyIRISource;
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyProvider;
 import org.apache.stanbol.ontologymanager.ontonet.api.scope.OntologyScope;
@@ -123,7 +124,7 @@ public class RefactorEnhancementEngine e
 
         public GraphContentSourceWithPhysicalIRI(InputStream content, IRI physicalIri) {
             super(content);
-            bindPhysicalIri(physicalIri);
+            bindPhysicalOrigin(Origin.create(physicalIri));
         }
 
     }
@@ -259,7 +260,7 @@ public class RefactorEnhancementEngine e
                              + " New signatures will be discarded.");
                 }
             } else try {
-                OntologyInputSource<TripleCollection,?> source = new GraphContentSourceWithPhysicalIRI(
+                OntologyInputSource<TripleCollection> source = new GraphContentSourceWithPhysicalIRI(
                         dereferencer.resolve(entityReference), IRI.create(entityReference));
                 signaturesGraph.addAll(source.getRootOntology());
             } catch (FileNotFoundException e) {

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/NamedResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/NamedResource.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/NamedResource.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/NamedResource.java Thu Jul 19 17:10:05 2012
@@ -29,6 +29,14 @@ import org.semanticweb.owlapi.model.IRI;
 public interface NamedResource {
 
     /**
+     * Returns the namespace that should prefix the ID of this resource and all the resources managed thereby.
+     * This is also used by ontology collectors to dynamically generate import statements.
+     * 
+     * @return the default namespace for this resources.
+     */
+    IRI getDefaultNamespace();
+
+    /**
      * Returns a string (assumed to be unique in the system) that identifies this resource. For instance, a
      * parent IRI of the base IRIs for the ontologies within an ontology space. Naming schemes are
      * implementation-dependent.<br>
@@ -44,10 +52,8 @@ public interface NamedResource {
     String getID();
 
     /**
-     * Returns the namespace that should prefix the ID of this resource and all the resources managed thereby.
-     * This is also used by ontology collectors to dynamically generate import statements.
-     * 
-     * @return the default namespace for this resources.
+     * @deprecated use {@link #getDefaultNamespace()} instead.
+     * @return
      */
     IRI getNamespace();
 
@@ -58,6 +64,12 @@ public interface NamedResource {
      * @param namespace
      *            the new default namespace for this resources.
      */
+    void setDefaultNamespace(IRI namespace);
+
+    /**
+     * @deprecated use {@link #setDefaultNamespace(IRI)} instead.
+     * @param namespace
+     */
     void setNamespace(IRI namespace);
 
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ONManager.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ONManager.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ONManager.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ONManager.java Thu Jul 19 17:10:05 2012
@@ -50,22 +50,12 @@ public interface ONManager extends Scope
     String CONNECTIVITY_POLICY = "org.apache.stanbol.ontologymanager.ontonet.connectivity";
 
     /**
-     * The key used to configure the ID of the ontology network manager.
-     */
-    String ID = "org.apache.stanbol.ontologymanager.ontonet.id";
-
-    /**
      * The key used to configure the simple identifier of the scope registry (which should also be
      * concatenated with the base namespace to obtain the registry's HTTP endpoint URI).
      */
     String ID_SCOPE_REGISTRY = "org.apache.stanbol.ontologymanager.ontonet.scopeRegistry.id";
 
     /**
-     * The key used to configure the base namespace of the ontology network.
-     */
-    String ONTOLOGY_NETWORK_NS = "org.apache.stanbol.ontologymanager.ontonet.ns";
-
-    /**
      * Returns the offline configuration set for this ontology network manager, if any.
      * 
      * @return the offline configuration, or null if none was set.
@@ -90,7 +80,7 @@ public interface ONManager extends Scope
     /**
      * Returns the ontology scope factory that was created along with the manager context.
      * 
-     * @deprecated returns this object, which is also an {@link OntologyScopeFactory}.
+     * @deprecated This methods now returns the current object, which is also an {@link OntologyScopeFactory}.
      * @return the default ontology scope factory
      */
     OntologyScopeFactory getOntologyScopeFactory();
@@ -107,7 +97,7 @@ public interface ONManager extends Scope
     /**
      * Returns the unique ontology scope registry for this context.
      * 
-     * @deprecated returns this object, which is also a {@link ScopeRegistry}.
+     * @deprecated This methods now returns the current object, which is also a {@link ScopeRegistry}.
      * @return the ontology scope registry.
      */
     ScopeRegistry getScopeRegistry();

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/OfflineConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/OfflineConfiguration.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/OfflineConfiguration.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/OfflineConfiguration.java Thu Jul 19 17:10:05 2012
@@ -30,10 +30,17 @@ import org.semanticweb.owlapi.model.IRI;
 public interface OfflineConfiguration {
 
     /**
+     * The key used to configure the base namespace of the ontology network.
+     */
+    String DEFAULT_NS = "org.apache.stanbol.ontologymanager.ontonet.ns";
+
+    /**
      * The key used to configure the paths of local ontologies.
      */
     String ONTOLOGY_PATHS = "org.apache.stanbol.ontologymanager.ontonet.ontologypaths";
 
+    IRI getDefaultOntologyNetworkNamespace();
+
     /**
      * Returns the paths of all the directories where the ontology network manager will try to locate
      * ontologies. These directories will be prioritaire if the engine is set to run in offline mode. This

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/OntologyNetworkConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/OntologyNetworkConfiguration.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/OntologyNetworkConfiguration.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/OntologyNetworkConfiguration.java Thu Jul 19 17:10:05 2012
@@ -28,14 +28,20 @@ import java.util.Map;
 public class OntologyNetworkConfiguration {
 
     private Map<String,Collection<String>> coreOntologiesForScopes, customOntologiesForScopes,
-            ontologiesForSessions;
+            ontologiesForSessions, scopesForSessions;
 
     public OntologyNetworkConfiguration(Map<String,Collection<String>> coreOntologiesForScopes,
                                         Map<String,Collection<String>> customOntologiesForScopes,
-                                        Map<String,Collection<String>> ontologiesForSessions) {
+                                        Map<String,Collection<String>> ontologiesForSessions,
+                                        Map<String,Collection<String>> scopesForSessions) {
         this.coreOntologiesForScopes = coreOntologiesForScopes;
         this.customOntologiesForScopes = customOntologiesForScopes;
         this.ontologiesForSessions = ontologiesForSessions;
+        this.scopesForSessions = scopesForSessions;
+    }
+
+    public Collection<String> getAttachedScopes(String sessionId) {
+        return scopesForSessions.get(sessionId);
     }
 
     public Collection<String> getCoreOntologyKeysForScope(String scopeId) {

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/Vocabulary.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/Vocabulary.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/Vocabulary.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/Vocabulary.java Thu Jul 19 17:10:05 2012
@@ -34,6 +34,10 @@ public class Vocabulary {
      */
     public static final String _NS_STANBOL_INTERNAL = "http://stanbol.apache.org/ontology/.internal/";
 
+    public static final UriRef APPENDED_TO = new UriRef(_NS_ONTONET + "isAppendedTo");
+
+    public static final UriRef HAS_APPENDED = new UriRef(_NS_ONTONET + "hasAppended");
+
     public static final UriRef HAS_SPACE_CORE = new UriRef(_NS_ONTONET + "hasCoreSpace");
 
     public static final UriRef HAS_SPACE_CUSTOM = new UriRef(_NS_ONTONET + "hasCustomSpace");

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/collector/OntologyCollector.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/collector/OntologyCollector.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/collector/OntologyCollector.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/collector/OntologyCollector.java Thu Jul 19 17:10:05 2012
@@ -43,7 +43,7 @@ public interface OntologyCollector exten
      *            the ontology to be added
      * @return the key that can be used for accessing the stored ontology directly
      */
-    String addOntology(OntologyInputSource<?,?> ontologySource);
+    String addOntology(OntologyInputSource<?> ontologySource);
 
     /**
      * Returns the ontologies managed by this ontology space. This is a shortcut method for iterating
@@ -56,13 +56,6 @@ public interface OntologyCollector exten
      */
     <O> Set<O> getManagedOntologies(Class<O> returnType, boolean withClosure);
 
-    /**
-     * TODO replace with Ontology IDs
-     * 
-     * @return
-     */
-    Set<IRI> listManagedOntologies();
-
     <O> O getOntology(IRI ontologyIri, Class<O> returnType);
 
     /**
@@ -75,6 +68,10 @@ public interface OntologyCollector exten
      */
     <O> O getOntology(IRI ontologyIri, Class<O> returnType, boolean merge);
 
+    <O> O getOntology(IRI ontologyIri, Class<O> returnType, boolean merge, IRI universalPrefix);
+
+    <O> O getOntology(IRI ontologyIri, Class<O> returnType, IRI universalPrefix);
+
     /**
      * Determines if the ontology identified by the supplied <i>logical</i> IRI has been loaded in this space.<br>
      * <br>
@@ -89,6 +86,13 @@ public interface OntologyCollector exten
     boolean hasOntology(IRI ontologyIri);
 
     /**
+     * TODO replace with Ontology IDs
+     * 
+     * @return
+     */
+    Set<IRI> listManagedOntologies();
+
+    /**
      * Removes the given ontology from the ontology space, if the ontology is a direct child of the top
      * ontology.<br/>
      * <u>Note</u> that this will NOT delete the ontology from the store! This method simply states that the

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/AbstractClerezzaGraphInputSource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/AbstractClerezzaGraphInputSource.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/AbstractClerezzaGraphInputSource.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/AbstractClerezzaGraphInputSource.java Thu Jul 19 17:10:05 2012
@@ -27,7 +27,6 @@ import org.apache.clerezza.rdf.core.Trip
 import org.apache.clerezza.rdf.core.TripleCollection;
 import org.apache.clerezza.rdf.core.UriRef;
 import org.apache.clerezza.rdf.core.access.TcManager;
-import org.apache.clerezza.rdf.core.access.TcProvider;
 import org.apache.clerezza.rdf.ontologies.OWL;
 import org.apache.clerezza.rdf.ontologies.RDF;
 import org.slf4j.Logger;
@@ -43,8 +42,7 @@ import org.slf4j.LoggerFactory;
  * @author alexdma
  * 
  */
-public abstract class AbstractClerezzaGraphInputSource extends
-        AbstractGenericInputSource<TripleCollection,TcProvider> {
+public abstract class AbstractClerezzaGraphInputSource extends AbstractGenericInputSource<TripleCollection> {
 
     protected Logger log = LoggerFactory.getLogger(getClass());
 
@@ -60,8 +58,7 @@ public abstract class AbstractClerezzaGr
 
     protected Set<TripleCollection> getImportedGraphs(TripleCollection g, boolean recursive) {
         Set<TripleCollection> result = new HashSet<TripleCollection>();
-        UriRef u = 
-                null;
+        UriRef u = null;
 
         Iterator<Triple> it = g.filter(null, RDF.type, OWL.Ontology);
         if (it.hasNext()) {

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/AbstractGenericInputSource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/AbstractGenericInputSource.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/AbstractGenericInputSource.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/AbstractGenericInputSource.java Thu Jul 19 17:10:05 2012
@@ -16,36 +16,35 @@
  */
 package org.apache.stanbol.ontologymanager.ontonet.api.io;
 
-import org.semanticweb.owlapi.model.IRI;
-
 /**
+ * The abstract implementation of the {@link OntologyInputSource} interface which is inherited by all concrete
+ * implementations.
  * 
  * @author alexdma
  * 
  * @param <O>
- *            the ontologuy returned by this input source.
+ *            the ontology returned by this input source.
  */
-public abstract class AbstractGenericInputSource<O,P> implements OntologyInputSource<O,P> {
-
-    protected String key;
+public abstract class AbstractGenericInputSource<O> implements OntologyInputSource<O> {
 
-    protected IRI physicalIri = null;
-
-    private P provider;
+    /**
+     * Where the ontology object was retrieved from.
+     */
+    protected Origin<?> origin = null;
 
     protected O rootOntology = null;
 
     /**
-     * This method is used to remind developers to bind a physical IRI to the {@link OntologyInputSource} if
-     * intending to do so.
+     * This method is used to remind developers to bind a physical reference to the
+     * {@link OntologyInputSource} if intending to do so.
      * 
-     * Implementation should assign a value to {@link #physicalIri}.
+     * Implementations should assign a value to {@link #origin}.
      * 
-     * @param iri
-     *            the physical ontology IRI.
+     * @param origin
+     *            where the ontology object was obtained from.
      */
-    protected void bindPhysicalIri(IRI iri) {
-        this.physicalIri = iri;
+    protected void bindPhysicalOrigin(Origin<?> origin) {
+        this.origin = origin;
     }
 
     /**
@@ -61,25 +60,16 @@ public abstract class AbstractGenericInp
         this.rootOntology = ontology;
     }
 
-    protected void bindStorageKey(String key) {
-        this.key = key;
-    }
-
-    protected void bindTriplesProvider(P provider) {
-        this.provider = provider;
-    }
-
     @Override
     public boolean equals(Object obj) {
-        if (!(obj instanceof OntologyInputSource<?,?>)) return false;
-        OntologyInputSource<?,?> src = (OntologyInputSource<?,?>) obj;
-        return this.physicalIri.equals(src.getPhysicalIRI())
-               && this.rootOntology.equals(src.getRootOntology());
+        if (!(obj instanceof OntologyInputSource<?>)) return false;
+        OntologyInputSource<?> src = (OntologyInputSource<?>) obj;
+        return this.origin.equals(src.getOrigin()) && this.rootOntology.equals(src.getRootOntology());
     }
 
     @Override
-    public IRI getPhysicalIRI() {
-        return physicalIri;
+    public Origin<?> getOrigin() {
+        return origin;
     }
 
     @Override
@@ -88,18 +78,8 @@ public abstract class AbstractGenericInp
     }
 
     @Override
-    public String getStorageKey() {
-        return key;
-    }
-
-    @Override
-    public P getTriplesProvider() {
-        return provider;
-    }
-
-    @Override
-    public boolean hasPhysicalIRI() {
-        return physicalIri != null;
+    public boolean hasOrigin() {
+        return origin != null;
     }
 
     @Override

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/AbstractOWLOntologyInputSource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/AbstractOWLOntologyInputSource.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/AbstractOWLOntologyInputSource.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/AbstractOWLOntologyInputSource.java Thu Jul 19 17:10:05 2012
@@ -25,17 +25,16 @@ import org.semanticweb.owlapi.model.OWLO
 /**
  * Abstract OWL API implementation of {@link OntologyInputSource} with the basic methods for obtaining root
  * ontologies and their physical IRIs where applicable.<br/>
- * </br> Implementations should either invoke abstract methods {@link #bindPhysicalIri(IRI)} and
+ * </br> Implementations should either invoke abstract methods {@link #bindPhysicalOrigin(IRI)} and
  * {@link #bindRootOntology(OWLOntology)} in their constructors, or override them.
  * 
  */
-public abstract class AbstractOWLOntologyInputSource extends AbstractGenericInputSource<OWLOntology,OWLOntologyManager> {
+public abstract class AbstractOWLOntologyInputSource extends AbstractGenericInputSource<OWLOntology> {
 
     @Override
     public Set<OWLOntology> getImports(boolean recursive) {
         OWLOntologyManager mgr = rootOntology.getOWLOntologyManager();
         return (recursive ? mgr.getImportsClosure(rootOntology) : mgr.getDirectImports(rootOntology));
-        // return rootOntology.getOWLOntologyManager().getImportsClosure(rootOntology);
     }
 
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/BlankOntologySource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/BlankOntologySource.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/BlankOntologySource.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/BlankOntologySource.java Thu Jul 19 17:10:05 2012
@@ -35,13 +35,12 @@ public class BlankOntologySource extends
      */
     public BlankOntologySource() {
         OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
-        bindTriplesProvider(manager);
         try {
             bindRootOntology(manager.createOntology());
         } catch (OWLOntologyCreationException e) {
             bindRootOntology(null);
         }
-        bindPhysicalIri(null);
+        bindPhysicalOrigin(null);
     }
 
     @Override

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/GraphContentInputSource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/GraphContentInputSource.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/GraphContentInputSource.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/GraphContentInputSource.java Thu Jul 19 17:10:05 2012
@@ -30,7 +30,6 @@ import org.apache.clerezza.rdf.core.acce
 import org.apache.clerezza.rdf.core.serializedform.Parser;
 import org.apache.clerezza.rdf.core.serializedform.UnsupportedFormatException;
 import org.apache.stanbol.commons.indexedgraph.IndexedMGraph;
-import org.apache.stanbol.commons.owl.util.OWLUtils;
 import org.apache.stanbol.ontologymanager.ontonet.api.OntologyLoadingException;
 import org.apache.stanbol.ontologymanager.ontonet.impl.util.OntologyUtils;
 import org.slf4j.Logger;
@@ -96,13 +95,14 @@ public class GraphContentInputSource ext
      * @param content
      *            the serialized graph content.
      * @param formatIdentifier
-     *            the format to parse the content as. It cannot be null or blank.
+     *            the format to parse the content as. Blank or null values are allowed, but could cause
+     *            exceptions to be thrown if the supplied input stream cannot be reset.
      * @param tcProvider
      *            the provider that will create the graph where the triples will be stored. If null, an
      *            in-memory graph will be created, in which case any ontology collectors using this input
      *            source will most likely have to copy it to persistent storage.
      * @param parser
-     *            the parser to use for creating the graph. If null, the default one will be used.
+     *            the parser to use for creating the graph. If null, the default one will be used. * @deprecated
      */
     public GraphContentInputSource(InputStream content,
                                    String formatIdentifier,
@@ -112,61 +112,67 @@ public class GraphContentInputSource ext
 
         if (content == null) throw new IllegalArgumentException("No content supplied");
         if (parser == null) parser = Parser.getInstance();
-
-        // No physical IRI
-        bindPhysicalIri(null);
-        bindTriplesProvider(tcProvider);
         boolean loaded = false;
-        if (content.markSupported()) content.mark(Integer.MAX_VALUE);
+
+        // Check if we can make multiple attempts at parsing the data stream.
+        if (content.markSupported()) {
+            log.debug("Stream mark/reset supported. Can try multiple formats if necessary.");
+            content.mark(Integer.MAX_VALUE);
+        }
+
+        // Check for supported formats to try.
         Collection<String> formats;
         if (formatIdentifier == null || "".equals(formatIdentifier.trim())) formats = OntologyUtils
                 .getPreferredSupportedFormats(parser.getSupportedFormats());
         else formats = Collections.singleton(formatIdentifier);
+
+        // TODO guess/lookahead the ontology ID and use it in the graph name.
+        UriRef name = new UriRef("ontonet" + "::" + getClass().getCanonicalName() + "-"
+                                 + System.currentTimeMillis());
+
         TripleCollection graph = null;
-        if (tcProvider != null) {
-            UriRef name = new UriRef(getClass().getCanonicalName() + "-" + System.currentTimeMillis());
+        if (tcProvider != null && tcProvider != null) {
+            // Graph directly stored in the TcProvider prior to using the source
             graph = tcProvider.createMGraph(name);
-        } else graph = new IndexedMGraph();
+            bindPhysicalOrigin(Origin.create(name));
+            // XXX if addition fails, should rollback procedures also delete the graph?
+        } else {
+            // In memory graph, will most likely have to be copied afterwards.
+            graph = new IndexedMGraph();
+            bindPhysicalOrigin(null);
+        }
 
         Iterator<String> itf = formats.iterator();
-        if (itf.hasNext()) {
+        if (!itf.hasNext()) throw new OntologyLoadingException("No suitable format found or defined.");
+        do {
             String f = itf.next();
+            log.debug("Parsing with format {}", f);
             try {
                 parser.parse((MGraph) graph, content, f);
                 loaded = true;
+                log.info("Graph parsed, has {} triples", graph.size());
             } catch (UnsupportedFormatException e) {
                 log.debug("Parsing format {} failed.", f);
             } catch (Exception e) {
                 log.debug("Error parsing format " + f, e);
-            }
-        } else throw new OntologyLoadingException("No suitable format defined.");
-
-        // If the first attempt failed, try all other formats if the streams allows it.
-        if (!loaded) {
-            if (content.markSupported()) for (String format : formats)
-                try {
+            } finally {
+                if (!loaded && content.markSupported()) try {
                     content.reset();
-                    parser.parse((MGraph) graph, content, format);
-                    loaded = true;
-                    break;
-                } catch (UnsupportedFormatException e) {
-                    log.debug("Parsing format {} failed.", format);
-                    continue;
                 } catch (IOException e) {
-                    log.debug("Failed to reset data stream while parsing format {}.", format);
-                    continue;
-                } catch (Exception e) {
-                    log.debug("Error parsing format " + format, e);
-                    continue;
+                    log.debug("Failed to reset data stream while parsing format {}.", f);
                 }
-            else throw new OntologyLoadingException(
-                    "First parsing attempt failed and data stream cannot be reset. Giving up.");
-        }
+            }
+        } while (!loaded && itf.hasNext());
 
         if (loaded) {
             bindRootOntology(graph);
             log.debug("Root ontology is a {}.", getRootOntology().getClass().getCanonicalName());
-        } else throw new OntologyLoadingException("All parsers failed. Giving up.");
+        } else {
+            // Rollback graph creation, if any
+            if (tcProvider != null && tcProvider != null) tcProvider.deleteTripleCollection(name);
+            throw new OntologyLoadingException("All parsers failed. Giving up.");
+        }
+
         log.debug("Input source initialization completed in {} ms.", (System.currentTimeMillis() - before));
     }
 
@@ -178,6 +184,7 @@ public class GraphContentInputSource ext
      *            the serialized graph content.
      * @param tcProvider
      *            the provider that will create the graph where the triples will be stored.
+     * 
      */
     public GraphContentInputSource(InputStream content, TcProvider tcProvider) {
         this(content, null, tcProvider);
@@ -185,7 +192,7 @@ public class GraphContentInputSource ext
 
     @Override
     public String toString() {
-        return "<GRAPH_CONTENT>" + OWLUtils.guessOntologyIdentifier(getRootOntology());
+        return "<GRAPH_CONTENT>" + getOrigin();
     }
 
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/GraphSource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/GraphSource.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/GraphSource.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/GraphSource.java Thu Jul 19 17:10:05 2012
@@ -21,46 +21,83 @@ import org.apache.clerezza.rdf.core.MGra
 import org.apache.clerezza.rdf.core.TripleCollection;
 import org.apache.clerezza.rdf.core.UriRef;
 import org.apache.clerezza.rdf.core.access.TcManager;
+import org.apache.clerezza.rdf.core.access.TcProvider;
 
 /**
- * An {@link OntologyInputSource} that gets ontologies from either a stored Clerezza {@link Graph} (or
- * {@link MGraph} ), or its identifier and an optionally supplied triple collection manager.
+ * An {@link OntologyInputSource} that gets ontologies from either a stored {@link TripleCollection}, or its
+ * identifier and an optionally supplied triple collection manager.
  * 
  * @author alexdma
  * 
  */
 public class GraphSource extends AbstractClerezzaGraphInputSource {
 
+    /**
+     * Creates a new input source by querying the default triple collection manager for a graph named with the
+     * supplied <code>graphId</code>. A {@link UriRef} that represents the graph name will also be set as the
+     * graph origin.
+     * 
+     * @param graphId
+     *            the graph ID.
+     * @throws NullPointerException
+     *             if there is no default triple collection manager available.
+     * @throws org.apache.clerezza.rdf.core.access.NoSuchEntityException
+     *             if no such graph can be found.
+     */
+    public GraphSource(String graphId) {
+        this(new UriRef(graphId));
+    }
+
+    /**
+     * Wraps the supplied <code>graph</code> into a new input source. No origin will be set.
+     * 
+     * @param graph
+     *            the RDF graph
+     * @throws IllegalArgumentException
+     *             if <code>graph</code> is neither a {@link Graph} nor a {@link MGraph}.
+     */
     public GraphSource(TripleCollection graph) {
         if (graph instanceof Graph) bindRootOntology((Graph) graph);
         else if (graph instanceof MGraph) bindRootOntology(((MGraph) graph).getGraph());
         else throw new IllegalArgumentException("GraphSource supports only Graph and MGraph types. "
                                                 + graph.getClass() + " is not supported.");
-        bindPhysicalIri(null);
-    }
-
-    public GraphSource(String graphId) {
-        this(new UriRef(graphId));
+        bindPhysicalOrigin(null);
     }
 
+    /**
+     * Creates a new input source by querying the default triple collection manager for a graph named with the
+     * supplied <code>graphId</code>. The supplied ID will also be set as the graph origin.
+     * 
+     * @param graphId
+     *            the graph ID.
+     * @throws NullPointerException
+     *             if there is no default triple collection manager available.
+     * @throws org.apache.clerezza.rdf.core.access.NoSuchEntityException
+     *             if no such graph can be found.
+     */
     public GraphSource(UriRef graphId) {
         this(graphId, TcManager.getInstance());
     }
 
     /**
-     * This constructor can be used to hijack ontologies using a physical IRI other than their default one.
+     * Creates a new input source by querying the supplied triple collection provider for a graph named with
+     * the supplied <code>graphId</code>. The supplied ID will also be set as the graph origin.
      * 
-     * @param rootOntology
-     * @param phyicalIRI
+     * @param graphId
+     *            the graph ID.
+     * @throws NullPointerException
+     *             if <code>tcProvider</code> is null.
+     * @throws org.apache.clerezza.rdf.core.access.NoSuchEntityException
+     *             if no such graph can be found in <code>tcProvider</code>.
      */
-    public GraphSource(UriRef graphId, TcManager tcManager) {
-        this(tcManager.getTriples(graphId));
-        bindTriplesProvider(tcManager);
+    public GraphSource(UriRef graphId, TcProvider tcProvider) {
+        this(tcProvider.getTriples(graphId));
+        bindPhysicalOrigin(Origin.create(graphId));
     }
 
     @Override
     public String toString() {
-        return "GRAPH<" + rootOntology + ">";
+        return "GRAPH<" + rootOntology.getClass() + "," + getOrigin() + ">";
     }
 
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologyContentInputSource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologyContentInputSource.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologyContentInputSource.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologyContentInputSource.java Thu Jul 19 17:10:05 2012
@@ -42,9 +42,8 @@ public class OntologyContentInputSource 
 
     public OntologyContentInputSource(InputStream content, OWLOntologyManager manager) throws OWLOntologyCreationException {
         long before = System.currentTimeMillis();
-        bindPhysicalIri(null);
+        bindPhysicalOrigin(null);
         bindRootOntology(manager.loadOntologyFromOntologyDocument(content));
-        bindTriplesProvider(manager);
         log.debug("Input source initialization completed in {} ms.", (System.currentTimeMillis() - before));
     }
 

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologyInputSource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologyInputSource.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologyInputSource.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologyInputSource.java Thu Jul 19 17:10:05 2012
@@ -18,15 +18,14 @@ package org.apache.stanbol.ontologymanag
 
 import java.util.Set;
 
-import org.semanticweb.owlapi.model.IRI;
-
 /**
  * An ontology input source provides a point for loading an ontology. Currently it provides two ways of
  * obtaining an ontology document:
  * 
  * <ol>
  * <li>From an OWLOntology.
- * <li>By dereferencing an physical IRI.
+ * <li>By dereferencing a physical IRI.
+ * <li>By querying a triple store.
  * </ol>
  * 
  * Consumers that use an ontology input source will attempt to obtain a concrete representation of an ontology
@@ -37,7 +36,7 @@ import org.semanticweb.owlapi.model.IRI;
  * @author alexdma
  * 
  */
-public interface OntologyInputSource<O,P> {
+public interface OntologyInputSource<O> {
 
     /**
      * Gets the ontology network resulting from the transitive closure of import statements on the root
@@ -48,13 +47,14 @@ public interface OntologyInputSource<O,P
     Set<O> getImports(boolean recursive);
 
     /**
-     * Returns the IRI by dereferencing which it should be possible to obtain the ontology. This method is
-     * supposed to return null if the ontology lives in-memory and was not or is not going to be stored
-     * publicly.
+     * Returns a reference object that can be used for obtaining the supplied ontology. Depending on how the
+     * ontology was obtained, the origin can be a physical URL, the ID of a database or graph in the local
+     * storage, or something else.This method is supposed to return null if the ontology lives in-memory and
+     * was not or is not going to be stored publicly.
      * 
-     * @return the physical location for this ontology source, or null if unknown.
+     * @return a physical reference for this ontology source, or null if unknown.
      */
-    IRI getPhysicalIRI();
+    Origin<?> getOrigin();
 
     /**
      * Returns the OWL Ontology that imports the whole ontology network addressed by this input source.
@@ -63,18 +63,14 @@ public interface OntologyInputSource<O,P
      */
     O getRootOntology();
 
-    String getStorageKey();
-
-    P getTriplesProvider();
-
     /**
-     * Determines if a physical IRI is known for this ontology source. Note that an anonymous ontology may
-     * have been fetched from a physical location, just as a named ontology may have been stored in memory and
-     * have no physical location.
+     * Determines if a physical reference is known for this ontology source. Note that an anonymous ontology
+     * may have been fetched from a physical location, just as a named ontology may have been stored in memory
+     * and have no physical location.
      * 
-     * @return true if a physical location is known for this ontology source.
+     * @return true if a physical reference is known for this ontology source.
      */
-    boolean hasPhysicalIRI();
+    boolean hasOrigin();
 
     /**
      * Determines if a root ontology that imports the entire network is available.

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologyInputSourceHandler.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologyInputSourceHandler.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologyInputSourceHandler.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologyInputSourceHandler.java Thu Jul 19 17:10:05 2012
@@ -18,9 +18,7 @@ package org.apache.stanbol.ontologymanag
 
 import java.util.Set;
 
-
 /**
- * 
  * An object that can manipulate {@link OntologyInputSource} objects;
  * 
  * @author alexdma

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologySpaceSource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologySpaceSource.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologySpaceSource.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/OntologySpaceSource.java Thu Jul 19 17:10:05 2012
@@ -34,10 +34,10 @@ public class OntologySpaceSource extends
         this(space, null);
     }
 
-    public OntologySpaceSource(OntologySpace space, Set<OntologyInputSource<?,?>> subtrees) {
+    public OntologySpaceSource(OntologySpace space, Set<OntologyInputSource<?>> subtrees) {
         this.space = space;
         if (subtrees != null) try {
-            for (OntologyInputSource<?,?> st : subtrees)
+            for (OntologyInputSource<?> st : subtrees)
                 appendSubtree(st);
         } catch (UnmodifiableOntologyCollectorException e) {
             log.error(
@@ -47,7 +47,7 @@ public class OntologySpaceSource extends
         bindRootOntology(space.export(OWLOntology.class, false));
     }
 
-    protected void appendSubtree(OntologyInputSource<?,?> subtree) throws UnmodifiableOntologyCollectorException {
+    protected void appendSubtree(OntologyInputSource<?> subtree) throws UnmodifiableOntologyCollectorException {
         space.addOntology(subtree);
     }
 
@@ -62,7 +62,7 @@ public class OntologySpaceSource extends
 
     @Override
     public String toString() {
-        return "SCOPE_ONT_IRI<" + getPhysicalIRI() + ">";
+        return "SCOPE_ONT_IRI<" + getOrigin() + ">";
     }
 
 }

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/Origin.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/Origin.java?rev=1363428&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/Origin.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/Origin.java Thu Jul 19 17:10:05 2012
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.ontologymanager.ontonet.api.io;
+
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.access.TcProvider;
+import org.semanticweb.owlapi.model.IRI;
+
+/**
+ * A wrapper class for whatever can be used for physically referencing a resource (typically an ontology).
+ * Currently the supported types are:
+ * <ul>
+ * <li> {@link IRI}, which is interpreted as the physical location of the resource.
+ * <li> {@link UriRef}, which is interpreted as the name of a graph to be retrieved from an underlying Clerezza
+ * store (typically a {@link TcProvider}).
+ * </ul>
+ * 
+ * @author alexdma
+ * 
+ * @param <R>
+ *            the resource reference.
+ */
+public class Origin<R> {
+
+    /**
+     * Creates a new Origin for a resource that can be retrieved by dereferencing the given IRI as an URL.
+     * 
+     * @param physicalURL
+     *            the physical location of the resource
+     * @return the origin that wraps this IRI.
+     */
+    public static Origin<IRI> create(IRI physicalURL) {
+        return new Origin<IRI>(physicalURL);
+    }
+
+    /**
+     * Creates a new Origin for a resource that can be retrieved by querying a Clerezza store for a graph with
+     * the given name.
+     * 
+     * @param graphName
+     *            the graph name
+     * @return the origin that wraps this graph name.
+     */
+    public static Origin<UriRef> create(UriRef graphName) {
+        return new Origin<UriRef>(graphName);
+    }
+
+    private R ref;
+
+    /**
+     * Creates a new instance of {@link Origin}.
+     * 
+     * @param reference
+     *            the physical reference. Cannot be null
+     * @throws IllegalArgumentException
+     *             if a null value was supplied for <code>reference</code>.
+     */
+    private Origin(R reference) {
+        if (reference == null) throw new IllegalArgumentException(
+                "Class " + getClass().getCanonicalName() + " does not allow a null reference object." + " "
+                        + "If a null object is needed, developers should use a null Origin instead.");
+        ref = reference;
+    }
+
+    @Override
+    public boolean equals(Object arg0) {
+        if (arg0 == null) return false;
+        if (!(arg0 instanceof Origin<?>)) return false;
+        return this.getReference().equals(((Origin<?>) arg0).getReference());
+    }
+
+    /**
+     * Returns the actual reference object that was wrapped by this Origin.
+     * 
+     * @return
+     */
+    public R getReference() {
+        return ref;
+    }
+
+    @Override
+    public String toString() {
+        return "Origin(" + ref.toString() + ")";
+    }
+
+}

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/ParentPathInputSource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/ParentPathInputSource.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/ParentPathInputSource.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/ParentPathInputSource.java Thu Jul 19 17:10:05 2012
@@ -77,13 +77,12 @@ public class ParentPathInputSource exten
         mgr.addIRIMapper(mapper);
         bindRootOntology(mgr.loadOntologyFromOntologyDocument(rootFile));
         // TODO : do we really want this to happen?
-        bindPhysicalIri(IRI.create(rootFile));
-        bindTriplesProvider(mgr);
+        bindPhysicalOrigin(Origin.create(IRI.create(rootFile)));
     }
 
     @Override
     public String toString() {
-        return "ROOT_ONT_IRI<" + getPhysicalIRI() + ">";
+        return "ROOT_ONT_IRI<" + getOrigin() + ">";
     }
 
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/RootOntologyIRISource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/RootOntologyIRISource.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/RootOntologyIRISource.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/RootOntologyIRISource.java Thu Jul 19 17:10:05 2012
@@ -48,15 +48,14 @@ public class RootOntologyIRISource exten
     }
 
     public RootOntologyIRISource(IRI rootPhysicalIri, OWLOntologyManager manager, boolean ignoreIriMappers) throws OWLOntologyCreationException {
-        bindPhysicalIri(rootPhysicalIri);
+        bindPhysicalOrigin(Origin.create(rootPhysicalIri));
         bindRootOntology(ignoreIriMappers ? manager.loadOntologyFromOntologyDocument(rootPhysicalIri)
                 : manager.loadOntology(rootPhysicalIri));
-        bindTriplesProvider(manager);
     }
 
     @Override
     public String toString() {
-        return "ROOT_ONT_IRI<" + getPhysicalIRI() + ">";
+        return "ROOT_ONT_IRI<" + getOrigin() + ">";
     }
 
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/RootOntologySource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/RootOntologySource.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/RootOntologySource.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/RootOntologySource.java Thu Jul 19 17:10:05 2012
@@ -29,8 +29,7 @@ public class RootOntologySource extends 
     public RootOntologySource(OWLOntology rootOntology) {
         bindRootOntology(rootOntology);
         // Never bind logical IDs as physical IRIs, as they risk overwriting previous bindings.
-        bindPhysicalIri(null);
-        bindTriplesProvider(rootOntology.getOWLOntologyManager());
+        bindPhysicalOrigin(null);
     }
 
     /**
@@ -41,7 +40,7 @@ public class RootOntologySource extends 
      */
     public RootOntologySource(OWLOntology rootOntology, IRI phyicalIRI) {
         this(rootOntology);
-        bindPhysicalIri(phyicalIRI);
+        bindPhysicalOrigin(phyicalIRI == null ? null : Origin.create(phyicalIRI));
     }
 
     /*

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/SetInputSource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/SetInputSource.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/SetInputSource.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/io/SetInputSource.java Thu Jul 19 17:10:05 2012
@@ -1,25 +1,31 @@
 /*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.stanbol.ontologymanager.ontonet.api.io;
 
 import java.util.Set;
 
-import org.semanticweb.owlapi.model.OWLOntology;
-
+/**
+ * An input source for multiple ontologies without a root.
+ * 
+ * @author alexdma
+ * 
+ * @param <O>
+ *            the ontologies in the set.
+ */
 public interface SetInputSource<O> {
 
     Set<O> getOntologies();

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OWLExportable.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OWLExportable.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OWLExportable.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OWLExportable.java Thu Jul 19 17:10:05 2012
@@ -40,6 +40,18 @@ public interface OWLExportable {
      */
     <O> O export(Class<O> returnType, boolean merge);
 
-    IRI getDocumentIRI();
+    /**
+     * Returns an ontological form of this object of the specified return type, if supported. If the supplied
+     * class is not a supported return type, an {@link UnsupportedOperationException} is thrown. <br>
+     * <br>
+     * TODO replace merge parameter with integer for merge level (-1 for infinite).
+     * 
+     * @param returnType
+     *            the desired class of the returned object.
+     * @param merge
+     *            if true, all imported ontologies will be merged and no import statements will appear.
+     * @return the ontology that represents this object.
+     */
+    <O> O export(Class<O> returnType, boolean merge, IRI universalPrefix);
 
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologyProvider.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologyProvider.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologyProvider.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologyProvider.java Thu Jul 19 17:10:05 2012
@@ -27,6 +27,7 @@ import org.apache.clerezza.rdf.core.acce
 import org.apache.clerezza.rdf.core.serializedform.UnsupportedFormatException;
 import org.apache.stanbol.ontologymanager.ontonet.api.OntologyNetworkConfiguration;
 import org.apache.stanbol.ontologymanager.ontonet.api.collector.ImportManagementPolicy;
+import org.apache.stanbol.ontologymanager.ontonet.api.io.Origin;
 import org.semanticweb.owlapi.model.IRI;
 import org.semanticweb.owlapi.model.OWLOntologyID;
 import org.semanticweb.owlapi.model.OWLOntologyManager;
@@ -76,30 +77,28 @@ public interface OntologyProvider<S> {
      * Gets a string that can be used to directly access the ontology whose logical identifier is
      * <tt>ontologyIRI</tt>.
      * 
-     * @param locator
+     * @deprecated Please use {@link #getPublicKey(OWLOntologyID)} instead. To obtain the public keys for all
+     *             the versions of ontologies with this ontology IRI, use {@link #getVersionKeys(IRI)}.
+     * 
+     * @param ontologyIri
      *            the logical identifier of the ontology.
-     * @return the key to access the ontology from the store.
+     * @return the public key (note that it might be different from the graph name).
      */
-    String getKey(IRI locator);
+    String getKey(IRI ontologyIri);
 
     /**
-     * Gets the key of the ontology with the supplied ontology ID. Note that both ontoloeyIRI and versionIRI
-     * (if present) must match, otherwise it will return null. To get the keys for a givemn ontologyIRI, no
-     * matte what its version is, use {@link #getOntologyVersionKeys(IRI)}.
+     * Gets a string that can be used to directly access the ontology whose logical identifier is
+     * <tt>ontologyId</tt>.
+     * 
+     * @deprecated Please use {@link #getPublicKey(OWLOntologyID)} instead.
      * 
      * @param ontologyId
-     * @return
+     *            the logical identifier of the ontology.
+     * @return the public key (note that it might be different from the graph name).
      */
     String getKey(OWLOntologyID ontologyId);
 
     /**
-     * Gets the set of all the strings that can be used to access the ontologies stored by this provider.
-     * 
-     * @return the ontology key set.
-     */
-    Set<String> getKeys();
-
-    /**
      * Returns the graph that stores all the information on stored ontologies. Whether the returned triple
      * collection is a {@link Graph} or a {@link MGraph} depends on the provider's policy on allowing external
      * modifications to the meta-level graph or not.
@@ -109,17 +108,26 @@ public interface OntologyProvider<S> {
      */
     <O extends TripleCollection> O getMetaGraph(Class<O> returnType);
 
-    public OntologyNetworkConfiguration getOntologyNetworkConfiguration();
+    OWLOntologyID getOntologyId(String storageKey);
+
+    OntologyNetworkConfiguration getOntologyNetworkConfiguration();
 
     /**
-     * Will return the keys of all the ontologies whose ontologyIRI is the one provided. These include any
-     * ontologies with that ontologyIRI and a versionIRI, and one ontology with no version IRI (if it exists,
-     * it must be unique).
+     * Gets the key of the ontology with the supplied ontology ID. Note that both ontoloeyIRI and versionIRI
+     * (if present) must match, otherwise it will return null. To get the keys for a given ontologyIRI, no
+     * matte what its version is, use {@link #getVersionKeys(IRI)}.
      * 
-     * @param ontologyIRI
+     * @param ontologyId
      * @return
      */
-    Set<String> getOntologyVersionKeys(IRI ontologyIRI);
+    String getPublicKey(OWLOntologyID ontologyId);
+
+    /**
+     * Gets the set of all the strings that can be used to access the ontologies stored by this provider.
+     * 
+     * @return the ontology key set.
+     */
+    Set<String> getPublicKeys();
 
     /**
      * Returns the storage system used by this ontology provider (e.g. a {@link TcProvider} or an
@@ -214,6 +222,16 @@ public interface OntologyProvider<S> {
     Class<?>[] getSupportedReturnTypes();
 
     /**
+     * Will return the keys of all the ontologies whose ontologyIRI is the one provided. These include any
+     * ontologies with that ontologyIRI and a versionIRI, and one ontology with no version IRI (if it exists,
+     * it must be unique).
+     * 
+     * @param ontologyIRI
+     * @return
+     */
+    Set<String> getVersionKeys(IRI ontologyIRI);
+
+    /**
      * A convenience method for checking the availability of an ontology given its (physical or logical) IRI.
      * It is typically more efficient than calling {@link #getStoredOntology(IRI, Class)} and null-checking
      * the result.
@@ -315,7 +333,16 @@ public interface OntologyProvider<S> {
      *            set on offline mode, this method will fail.
      * @return
      */
-    String loadInStore(Object ontology, boolean force);
+    String loadInStore(Object ontology, boolean force, Origin<?>... references);
+
+    /**
+     * Removes the ontology identified by the supplied public key.
+     * 
+     * @param publicKey
+     *            the public key for accessing the ontology.
+     * @return true iff an ontology with that public key existed and was removed.
+     */
+    boolean removeOntology(String publicKey);
 
     /**
      * Sets the policy adopted by this provider whenever an import statement is found in an ontology <i>that

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologyScopeFactory.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologyScopeFactory.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologyScopeFactory.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologyScopeFactory.java Thu Jul 19 17:10:05 2012
@@ -44,6 +44,6 @@ public interface OntologyScopeFactory ex
      *             if an ontology scope with the given identifier is already <i>registered</i>. The exception
      *             is not thrown if another scope with the same ID has been created but not registered.
      */
-    OntologyScope createOntologyScope(String scopeID, OntologyInputSource<?,?>... coreSources) throws DuplicateIDException;
+    OntologyScope createOntologyScope(String scopeID, OntologyInputSource<?>... coreSources) throws DuplicateIDException;
 
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologySpaceFactory.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologySpaceFactory.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologySpaceFactory.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/scope/OntologySpaceFactory.java Thu Jul 19 17:10:05 2012
@@ -42,7 +42,7 @@ public interface OntologySpaceFactory ex
      *            the sources of the optional ontologies to be immediately loaded upon space creation.
      * @return the generated ontology space.
      */
-    CoreOntologySpace createCoreOntologySpace(String scopeId, OntologyInputSource<?,?>... coreSources);
+    CoreOntologySpace createCoreOntologySpace(String scopeId, OntologyInputSource<?>... coreSources);
 
     /**
      * Creates and sets up a default custom ontology space. Equivalent to calling
@@ -55,7 +55,7 @@ public interface OntologySpaceFactory ex
      *            the sources of the optional ontologies to be immediately loaded upon space creation.
      * @return the generated ontology space.
      */
-    CustomOntologySpace createCustomOntologySpace(String scopeId, OntologyInputSource<?,?>... customSources);
+    CustomOntologySpace createCustomOntologySpace(String scopeId, OntologyInputSource<?>... customSources);
 
     /**
      * Creates an ontology space of the specified type.
@@ -71,6 +71,6 @@ public interface OntologySpaceFactory ex
      */
     OntologySpace createOntologySpace(String scopeId,
                                       SpaceType type,
-                                      OntologyInputSource<?,?>... ontologySources);
+                                      OntologyInputSource<?>... ontologySources);
 
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/Session.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/Session.java?rev=1363428&r1=1363427&r2=1363428&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/Session.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/Session.java Thu Jul 19 17:10:05 2012
@@ -21,7 +21,6 @@ import java.util.Set;
 import org.apache.stanbol.ontologymanager.ontonet.api.collector.Lockable;
 import org.apache.stanbol.ontologymanager.ontonet.api.collector.OntologyCollector;
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OWLExportable;
-import org.apache.stanbol.ontologymanager.ontonet.api.scope.OntologyScope;
 
 /**
  * Note that sessions are possibly disjoint with HTTP sessions or the like.
@@ -63,7 +62,7 @@ public interface Session extends Ontolog
      * @param scope
      *            the ontology scope to be referenced.
      */
-    void attachScope(OntologyScope scope);
+    void attachScope(String scopeId);
 
     /**
      * Removes all references to ontology scopes, thus leaving the session data as standalone.