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 2011/08/03 18:47:27 UTC

svn commit: r1153575 [1/2] - in /incubator/stanbol/trunk: enhancer/engines/refactor/src/main/java/org/apache/stanbol/enhancer/engines/refactor/ ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/ ontologymanag...

Author: alexdma
Date: Wed Aug  3 16:47:20 2011
New Revision: 1153575

URL: http://svn.apache.org/viewvc?rev=1153575&view=rev
Log:
STANBOL-196 :
- Ontology spaces now rewrite import statements of managed ontologies internally.
STANBOL-304 :
- Space top ontologies are no longer managed explicitly
- OntologyScope now has its own independent asOWLOntology() method.
- Temporarily disabled methods for attaching spaces (use OntologyScope#asOWLOntology() for the time being).
- ScopeOntologyResource now supports retrieval of implicit space top ontologies straight from their ID.
- Eliminated deprecated ontology space factory methods.
- Changed OntologySpace#getOntologies() signature so that it can be parametrized to return only managed ontologies or their imports closure as well.

Removed:
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/util/OntologyLoaderPrinter.java
Modified:
    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/ontology/OntologyScope.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpace.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpaceFactory.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpaceModificationException.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/ScopeEventListenable.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/ontology/AbstractOntologySpaceImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/CustomOntologySpaceImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OntologyIndexImpl.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/ontology/OntologySpaceFactoryImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/SessionOntologySpaceImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/session/SessionManagerImpl.java
    incubator/stanbol/trunk/ontologymanager/ontonet/src/test/java/org/apache/stanbol/ontologymanager/ontonet/ontology/TestOntologySpaces.java
    incubator/stanbol/trunk/ontologymanager/registry/src/test/java/org/apache/stanbol/ontologymanager/registry/TestOntologyRegistry.java
    incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/ONMScopeOntologyResource.java
    incubator/stanbol/trunk/ontologymanager/web/src/main/java/org/apache/stanbol/ontologymanager/web/resources/ONMScopeResource.java
    incubator/stanbol/trunk/reasoners/web/src/main/java/org/apache/stanbol/reasoners/web/resources/Classify.java
    incubator/stanbol/trunk/reasoners/web/src/main/java/org/apache/stanbol/reasoners/web/resources/ConsistencyCheck.java
    incubator/stanbol/trunk/reasoners/web/src/main/java/org/apache/stanbol/reasoners/web/resources/Enrichment.java

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=1153575&r1=1153574&r2=1153575&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 Wed Aug  3 16:47:20 2011
@@ -1,19 +1,19 @@
 /*
-* 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.enhancer.engines.refactor;
 
 import java.io.BufferedReader;
@@ -266,7 +266,7 @@ public class RefactorEnhancementEngine i
 
                 Set<OWLOntology> ontologies = new HashSet<OWLOntology>();
                 OntologySpace sessionSpace = scope.getSessionSpace(sessionIRI);
-                ontologies.addAll(sessionSpace.getOntologies());
+                ontologies.addAll(sessionSpace.getOntologies(true));
 
                 /*
                  * We add to the set the graph containing the metadata generated by previous enhancement
@@ -546,7 +546,7 @@ public class RefactorEnhancementEngine i
         ontologySpace.setUp();
 
         log.debug("The set of ontologies loaded in the core scope space is: "
-                  + ontologySpace.getOntologies()
+                  + ontologySpace.getOntologies(true)
                   + "\nN.B. The root.owl ontology is the first (on the list) ontology added when the scope is created.");
 
         /*

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologyScope.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologyScope.java?rev=1153575&r1=1153574&r2=1153575&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologyScope.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologyScope.java Wed Aug  3 16:47:20 2011
@@ -1,38 +1,36 @@
 /*
-* 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.ontology;
 
 import java.util.Set;
 
 import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLOntology;
 
 /**
- * Represents an ontology network that is used by KReS for modelling a given
- * knowledge component or domain, e.g. workflows, organisations, devices,
- * content or business domain.<br>
+ * Represents an ontology network that is used by KReS for modelling a given knowledge component or domain,
+ * e.g. workflows, organisations, devices, content or business domain.<br>
  * <br>
- * Each ontology scope comprises in turn a number of ontology spaces of three
- * kinds.
+ * Each ontology scope comprises in turn a number of ontology spaces of three kinds.
  * <ul>
- * <li>Exactly one core space, which defines the immutable components of the
- * scope.
+ * <li>Exactly one core space, which defines the immutable components of the scope.
  * <li>At most one custom space, which contains user-defined components.
- * <li>Zero or more session spaces, which contains (potentially volatile)
- * components specific for user sessions.
+ * <li>Zero or more session spaces, which contains (potentially volatile) components specific for user
+ * sessions.
  * </ul>
  * An ontology scope can thus be seen as a fa&ccedil;ade for ontology spaces.
  * 
@@ -42,102 +40,100 @@ import org.semanticweb.owlapi.model.IRI;
  */
 public interface OntologyScope extends ScopeOntologyListenable {
 
-	/**
-	 * Adds a new ontology space to the list of user session spaces for this
-	 * scope.
-	 * 
-	 * @param sessionSpace
-	 *            the ontology space to be added.
-	 * @throws UnmodifiableOntologySpaceException 
-	 */
+    /**
+     * Returns an ontological form of this scope.
+     * 
+     * @return an OWL ontology that represents this scope.
+     */
+    OWLOntology asOWLOntology();
+
+    /**
+     * Adds a new ontology space to the list of user session spaces for this scope.
+     * 
+     * @param sessionSpace
+     *            the ontology space to be added.
+     * @throws UnmodifiableOntologySpaceException
+     */
     void addSessionSpace(OntologySpace sessionSpace, IRI sessionID) throws UnmodifiableOntologySpaceException;
 
-	/**
-	 * Returns the core ontology space for this ontology scope. The core space
-	 * should never be null for any scope.
-	 * 
-	 * @return the core ontology space
-	 */
+    /**
+     * Returns the core ontology space for this ontology scope. The core space should never be null for any
+     * scope.
+     * 
+     * @return the core ontology space
+     */
     OntologySpace getCoreSpace();
 
-	/**
-	 * Returns the custom ontology space for this ontology scope.
-	 * 
-	 * @return the custom ontology space, or null if no custom space is
-	 *         registered for this scope.
-	 */
+    /**
+     * Returns the custom ontology space for this ontology scope.
+     * 
+     * @return the custom ontology space, or null if no custom space is registered for this scope.
+     */
     OntologySpace getCustomSpace();
 
-	/**
-	 * Returns an object that uniquely identifies this ontology scope.
-	 * 
-	 * TODO : check if we'd rather use another class for identifiers.
-	 * 
-	 * @return the unique identifier for this ontology scope
-	 */
+    /**
+     * Returns an object that uniquely identifies this ontology scope.
+     * 
+     * TODO : check if we'd rather use another class for identifiers.
+     * 
+     * @return the unique identifier for this ontology scope
+     */
     IRI getID();
 
-	/**
-	 * Return the ontology space for this scope that is identified by the
-	 * supplied IRI.
-	 * 
-	 * @param sessionID
-	 *            the unique identifier of the KReS session.
-	 * @return the ontology space identified by <code>sessionID</code>, or null
-	 *         if no such space is registered for this scope and session.
-	 */
+    /**
+     * Return the ontology space for this scope that is identified by the supplied IRI.
+     * 
+     * @param sessionID
+     *            the unique identifier of the KReS session.
+     * @return the ontology space identified by <code>sessionID</code>, or null if no such space is registered
+     *         for this scope and session.
+     */
     SessionOntologySpace getSessionSpace(IRI sessionID);
 
-	/**
-	 * Returns all the active ontology spaces for this scope.
-	 * 
-	 * @return a set of active ontology spaces for this scope.
-	 */
+    /**
+     * Returns all the active ontology spaces for this scope.
+     * 
+     * @return a set of active ontology spaces for this scope.
+     */
     Set<OntologySpace> getSessionSpaces();
 
-	/**
-	 * Sets an ontology space as the custom space for this scope.
-	 * 
-	 * @param customSpace
-	 *            the custom ontology space.
-	 * @throws UnmodifiableOntologySpaceException
-	 *             if either the scope or the supplied space are locked.
-	 */
-    void setCustomSpace(OntologySpace customSpace)
-			throws UnmodifiableOntologySpaceException;
-
-	/**
-	 * Performs the operations required for activating the ontology scope. It
-	 * should be possible to perform them <i>after</i> the constructor has been
-	 * invoked.<br>
-	 * <br>
-	 * When the core ontology space is created for this scope, this should be
-	 * set in the scope constructor. It can be changed in the
-	 * <code>setUp()</code> method though.
-	 */
+    /**
+     * Sets an ontology space as the custom space for this scope.
+     * 
+     * @param customSpace
+     *            the custom ontology space.
+     * @throws UnmodifiableOntologySpaceException
+     *             if either the scope or the supplied space are locked.
+     */
+    void setCustomSpace(OntologySpace customSpace) throws UnmodifiableOntologySpaceException;
+
+    /**
+     * Performs the operations required for activating the ontology scope. It should be possible to perform
+     * them <i>after</i> the constructor has been invoked.<br>
+     * <br>
+     * When the core ontology space is created for this scope, this should be set in the scope constructor. It
+     * can be changed in the <code>setUp()</code> method though.
+     */
     void setUp();
 
-	/**
-	 * Performs whatever operations are required for making sure the custom
-	 * space of this scope is aware of changes occurring in its core space, that
-	 * all session spaces are aware of changes in the custom space, and so on.
-	 * Typically, this includes updating all import statements in the top
-	 * ontologies for each space.<br>
-	 * <br>
-	 * This method is not intended for usage by ontology managers. Since its
-	 * invocation is supposed to be automatic, it should be invoked by whatever
-	 * classes are responsible for listening to changes in an ontology
-	 * scope/space. In the default implementation, it is the scope itself, yet
-	 * the method is left public in order to allow for external controllers.
-	 */
+    /**
+     * Performs whatever operations are required for making sure the custom space of this scope is aware of
+     * changes occurring in its core space, that all session spaces are aware of changes in the custom space,
+     * and so on. Typically, this includes updating all import statements in the top ontologies for each
+     * space.<br>
+     * <br>
+     * This method is not intended for usage by ontology managers. Since its invocation is supposed to be
+     * automatic, it should be invoked by whatever classes are responsible for listening to changes in an
+     * ontology scope/space. In the default implementation, it is the scope itself, yet the method is left
+     * public in order to allow for external controllers.
+     */
     void synchronizeSpaces();
 
-	/**
-	 * Performs the operations required for deactivating the ontology scope. In
-	 * general, this is not equivalent to finalizing the object for garbage
-	 * collection. It should be possible to activate the same ontology scope
-	 * again if need be.
-	 */
+    /**
+     * Performs the operations required for deactivating the ontology scope. In general, this is not
+     * equivalent to finalizing the object for garbage collection. It should be possible to activate the same
+     * ontology scope again if need be.
+     */
     void tearDown();
 
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpace.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpace.java?rev=1153575&r1=1153574&r2=1153575&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpace.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpace.java Wed Aug  3 16:47:20 2011
@@ -44,6 +44,8 @@ public interface OntologySpace {
 
     void clearOntologySpaceListeners();
 
+    boolean containsOntology(IRI ontologyIri);
+
     /**
      * Returns a Unique Resource Identifier (URI) that identifies this ontology space. For instance, this URI
      * could be the parent of (some/most of) the base URIs for the ontologies within this space.<br/>
@@ -56,11 +58,14 @@ public interface OntologySpace {
     IRI getID();
 
     /**
-     * Returns all the ontologies encompassed by this ontology space.
+     * Returns the ontologies managed by this ontology space.
      * 
+     * @param withClosure
+     *            if true, also the ontologies imported by those directly managed by this space will be
+     *            included.
      * @return the set of ontologies in the ontology space
      */
-    Set<OWLOntology> getOntologies();
+    Set<OWLOntology> getOntologies(boolean withClosure);
 
     /**
      * Returns the ontology identified by the supplied <i>logical</i> IRI, if such an ontology has been loaded
@@ -76,8 +81,6 @@ public interface OntologySpace {
      */
     OWLOntology getOntology(IRI ontologyIri);
 
-    boolean containsOntology(IRI ontologyIri);
-
     Collection<OntologySpaceListener> getOntologyScopeListeners();
 
     /**
@@ -126,38 +129,6 @@ public interface OntologySpace {
     void setSilentMissingOntologyHandling(boolean silent);
 
     /**
-     * Sets the supplied ontology as the root ontology that (recursively) references the whole underlying
-     * ontology network. This actually <i>replaces</i> the ontology to be obtained by a call to
-     * <code>getTopOntology()</code> with this one, i.e. it is <code>not</code> equivalent to adding this
-     * ontology to a blank network!<br>
-     * <br>
-     * Implementations can arbitrarily behave with respect to the unset <code>createParent</code> parameter
-     * from the other method signature.
-     * 
-     * @param ontology
-     *            the new top ontology.
-     * @throws OntologySpaceModificationException
-     *             if the ontology space is read-only or the ontology could not be removed.
-     */
-    void setTopOntology(OntologyInputSource ontologySource) throws UnmodifiableOntologySpaceException;
-
-    /**
-     * Sets the supplied ontology as the root ontology that (recursively) references the whole underlying
-     * ontology network. This actually <i>replaces</i> the ontology to be obtained by a call to
-     * <code>getTopOntology()</code> with this one, i.e. it is <code>not</code> equivalent to adding this
-     * ontology to a blank network!
-     * 
-     * @param ontology
-     *            the new top ontology.
-     * @param createParent
-     *            if true, a new ontology will be created and set as the top ontology that will import this
-     *            one.
-     * @throws UnmodifiableOntologySpaceException
-     *             if the ontology space is read-only.
-     */
-    void setTopOntology(OntologyInputSource ontologySource, boolean createParent) throws UnmodifiableOntologySpaceException;
-
-    /**
      * Bootstraps the ontology space. In some cases (such as with core and custom spaces) this also implies
      * write-locking its ontologies.
      */

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpaceFactory.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpaceFactory.java?rev=1153575&r1=1153574&r2=1153575&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpaceFactory.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpaceFactory.java Wed Aug  3 16:47:20 2011
@@ -32,22 +32,6 @@ public interface OntologySpaceFactory {
      * Creates and sets up a default core ontology space. Equivalent to calling
      * <code>createOntologySpace(IRI, SpaceTypes.CORE, OntologyInputSource...)</code>.
      * 
-     * @deprecated Please use the varargs version of this method
-     *             {@link #createCoreOntologySpace(IRI, OntologyInputSource...)}.
-     * 
-     * @param scopeId
-     *            the unique identifier of the ontology scope that will reference this space. It can be used
-     *            for generating the identifier for this ontology space.
-     * @param coreSource
-     *            the input source for the ontologies in this space.
-     * @return the generated ontology space.
-     */
-    CoreOntologySpace createCoreOntologySpace(IRI scopeId, OntologyInputSource coreSource);
-
-    /**
-     * Creates and sets up a default core ontology space. Equivalent to calling
-     * <code>createOntologySpace(IRI, SpaceTypes.CORE, OntologyInputSource...)</code>.
-     * 
      * @param scopeId
      *            the unique identifier of the ontology scope that will reference this space. It can be used
      *            for generating the identifier for this ontology space.
@@ -61,22 +45,6 @@ public interface OntologySpaceFactory {
      * Creates and sets up a default custom ontology space. Equivalent to calling
      * <code>createOntologySpace(IRI, SpaceTypes.CUSTOM, OntologyInputSource...)</code>.
      * 
-     * @deprecated Please use the varargs version of this method
-     *             {@link #createCustomOntologySpace(IRI, OntologyInputSource...)}.
-     * 
-     * @param scopeId
-     *            the unique identifier of the ontology scope that will reference this space. It can be used
-     *            for generating the identifier for this ontology space.
-     * @param customSource
-     *            the input source for the ontologies in this space.
-     * @return the generated ontology space.
-     */
-    CustomOntologySpace createCustomOntologySpace(IRI scopeId, OntologyInputSource customSource);
-
-    /**
-     * Creates and sets up a default custom ontology space. Equivalent to calling
-     * <code>createOntologySpace(IRI, SpaceTypes.CUSTOM, OntologyInputSource...)</code>.
-     * 
      * 
      * @param scopeId
      *            the unique identifier of the ontology scope that will reference this space. It can be used
@@ -103,20 +71,6 @@ public interface OntologySpaceFactory {
 
     /**
      * Creates and sets up a default session ontology space. Equivalent to calling
-     * <code>createOntologySpace(IRI, SpaceTypes.SESSION)</code>.
-     * 
-     * @deprecated Please use the varargs version of this method
-     *             {@link #createSessionOntologySpace(IRI, OntologyInputSource...)}.
-     * 
-     * @param scopeId
-     *            the unique identifier of the ontology scope that will reference this space. It can be used
-     *            for generating the identifier for this ontology space.
-     * @return the generated ontology space.
-     */
-    SessionOntologySpace createSessionOntologySpace(IRI scopeId);
-
-    /**
-     * Creates and sets up a default session ontology space. Equivalent to calling
      * <code>createOntologySpace(IRI, SpaceTypes.SESSION, OntologyInputSource...)</code>.
      * 
      * @param scopeId

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpaceModificationException.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpaceModificationException.java?rev=1153575&r1=1153574&r2=1153575&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpaceModificationException.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpaceModificationException.java Wed Aug  3 16:47:20 2011
@@ -1,55 +1,61 @@
 /*
-* 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.ontology;
 
 /**
- * Thrown whenever an illegal operation that modifies an ontology space is
- * detected and denied.
- * 
- * @author alessandro
- * 
+ * Thrown whenever an illegal operation that modifies an ontology space is detected and denied.
  */
 public class OntologySpaceModificationException extends Exception {
 
-	/**
+    /**
 	 * 
 	 */
-	private static final long serialVersionUID = -5147080356192253724L;
+    private static final long serialVersionUID = -5147080356192253724L;
 
-	protected OntologySpace space;
+    protected OntologySpace space;
 
-	/**
-	 * Creates a new instance of OntologySpaceModificationException.
-	 * 
-	 * @param space
-	 *            the ontology space whose modification was attempted.
-	 */
-	public OntologySpaceModificationException(OntologySpace space) {
-		this.space = space;
-	}
-
-	/**
-	 * Returns the ontology space that threw the exception (presumably after a
-	 * failed modification attempt).
-	 * 
-	 * @return the ontology space on which the exception was thrown.
-	 */
-	public OntologySpace getSpace() {
-		return space;
-	}
+    /**
+     * Creates a new instance of OntologySpaceModificationException.
+     * 
+     * @param space
+     *            the ontology space whose modification was attempted.
+     */
+    public OntologySpaceModificationException(OntologySpace space) {
+        this.space = space;
+    }
+
+    /**
+     * Creates a new instance of OntologySpaceModificationException.
+     * 
+     * @param space
+     *            the ontology space whose modification was attempted.
+     */
+    public OntologySpaceModificationException(OntologySpace space, Throwable cause) {
+        this(space);
+        initCause(cause);
+    }
+
+    /**
+     * Returns the ontology space that threw the exception (presumably after a failed modification attempt).
+     * 
+     * @return the ontology space on which the exception was thrown.
+     */
+    public OntologySpace getSpace() {
+        return space;
+    }
 
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/ScopeEventListenable.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/ScopeEventListenable.java?rev=1153575&r1=1153574&r2=1153575&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/ScopeEventListenable.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/ScopeEventListenable.java Wed Aug  3 16:47:20 2011
@@ -1,38 +1,59 @@
 /*
-* 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.ontology;
 
 import java.util.Collection;
 
 /**
- * Implementations of this interface are able to fire events related to the
- * modification of an ontology scope, not necessarily including its ontologies.
- * 
- * @author alessandro
+ * Implementations of this interface are able to fire events related to the modification of an ontology scope,
+ * not necessarily including its ontologies.<br/>
+ * <br/>
+ * This interface adds support for CRUD operations on scope event listeners.
  * 
  */
 public interface ScopeEventListenable {
 
-	void addScopeEventListener(ScopeEventListener listener);
-
-	void clearScopeEventListeners();
-
-	Collection<ScopeEventListener> getScopeEventListeners();
-
-	void removeScopeEventListener(ScopeEventListener listener);
+    /**
+     * Registers a listener to scope-related events fired by this object.
+     * 
+     * @param listener
+     *            the listener to be registered.
+     */
+    void addScopeEventListener(ScopeEventListener listener);
+
+    /**
+     * Unregisters all the scope event listeners registered with this object.
+     */
+    void clearScopeEventListeners();
+
+    /**
+     * Gets all the scope event listeners registered with this object.
+     * 
+     * @return the registered scope event listeners.
+     */
+    Collection<ScopeEventListener> getScopeEventListeners();
+
+    /**
+     * Unregisters a listener to scope-related events fired by this object. Has no effect if the supplied
+     * listener was not registered with this object in the first place.
+     * 
+     * @param listener
+     *            the listener to be unregistered.
+     */
+    void removeScopeEventListener(ScopeEventListener listener);
 
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ONManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ONManagerImpl.java?rev=1153575&r1=1153574&r2=1153575&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ONManagerImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ONManagerImpl.java Wed Aug  3 16:47:20 2011
@@ -61,6 +61,7 @@ import org.apache.stanbol.ontologymanage
 import org.apache.stanbol.ontologymanager.ontonet.impl.ontology.ScopeRegistryImpl;
 import org.apache.stanbol.ontologymanager.ontonet.impl.session.ScopeSessionSynchronizer;
 import org.apache.stanbol.ontologymanager.ontonet.impl.session.SessionManagerImpl;
+import org.apache.stanbol.owl.OWLOntologyManagerFactory;
 import org.osgi.service.component.ComponentContext;
 import org.semanticweb.owlapi.apibinding.OWLManager;
 import org.semanticweb.owlapi.io.FileDocumentSource;
@@ -137,9 +138,6 @@ public class ONManagerImpl implements ON
 
     public static final String _ONTOLOGY_NETWORK_NS_DEFAULT = "http://stanbol.apache.org/";
 
-    @Reference
-    private OfflineConfiguration config;
-
     @Property(name = ONManager.CONFIG_ONTOLOGY_PATH, value = _CONFIG_ONTOLOGY_PATH_DEFAULT)
     private String configPath;
 
@@ -147,6 +145,9 @@ public class ONManagerImpl implements ON
 
     private final Logger log = LoggerFactory.getLogger(getClass());
 
+    @Reference
+    private OfflineConfiguration offline;
+
     /**
      * The {@link OfflineMode} is used by Stanbol to indicate that no external service should be referenced.
      * For this engine that means it is necessary to check if the used {@link ReferencedSite} can operate
@@ -241,7 +242,7 @@ public class ONManagerImpl implements ON
         // Assume this.tcm this.wtcp and this.wtcp were not filled in by OSGi-DS.
         this.tcm = tcm;
         this.wtcp = wtcp;
-        this.config = onmconfig;
+        this.offline = onmconfig;
         try {
             activate(configuration);
         } catch (IOException e) {
@@ -287,7 +288,7 @@ public class ONManagerImpl implements ON
         // Bind components, starting with the local directories.
         List<String> dirs = new ArrayList<String>();
         try {
-            for (IRI iri : config.getOntologySourceLocations())
+            for (IRI iri : offline.getOntologySourceLocations())
                 dirs.add(iri.toString());
         } catch (NullPointerException ex) {
             // Ok, go empty
@@ -295,7 +296,8 @@ public class ONManagerImpl implements ON
 
         omgrFactory = new OWLOntologyManagerFactoryImpl(dirs);
         owlFactory = OWLManager.getOWLDataFactory();
-        owlCacheManager = omgrFactory.createOntologyManager(true);
+        owlCacheManager = OWLOntologyManagerFactory.createOWLOntologyManager(offline
+                .getOntologySourceLocations().toArray(new IRI[0]));
 
         // These depend on one another
         scopeRegistry = new ScopeRegistryImpl();
@@ -381,7 +383,7 @@ public class ONManagerImpl implements ON
         // Now create everything that depends on the Storage object.
 
         // These may require the OWL cache manager
-        ontologySpaceFactory = new OntologySpaceFactoryImpl(scopeRegistry, storage, omgrFactory);
+        ontologySpaceFactory = new OntologySpaceFactoryImpl(scopeRegistry, storage, offline);
         ontologyScopeFactory = new OntologyScopeFactoryImpl(scopeRegistry, ontologySpaceFactory);
         ontologyScopeFactory.addScopeEventListener(oIndex);
 

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/AbstractOntologySpaceImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/AbstractOntologySpaceImpl.java?rev=1153575&r1=1153574&r2=1153575&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/AbstractOntologySpaceImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/AbstractOntologySpaceImpl.java Wed Aug  3 16:47:20 2011
@@ -1,29 +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.impl.ontology;
 
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
 import java.util.Set;
 
 import org.apache.stanbol.ontologymanager.ontonet.api.io.OntologyInputSource;
 import org.apache.stanbol.ontologymanager.ontonet.api.io.RootOntologySource;
-import org.apache.stanbol.ontologymanager.ontonet.api.ontology.IrremovableOntologyException;
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.MissingOntologyException;
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologySpace;
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologySpaceListener;
@@ -34,19 +36,21 @@ import org.apache.stanbol.ontologymanage
 import org.apache.stanbol.ontologymanager.ontonet.impl.io.ClerezzaOntologyStorage;
 import org.apache.stanbol.ontologymanager.ontonet.impl.util.OntologyUtils;
 import org.apache.stanbol.ontologymanager.ontonet.impl.util.StringUtils;
+import org.apache.stanbol.owl.util.URIUtils;
 import org.semanticweb.owlapi.apibinding.OWLManager;
 import org.semanticweb.owlapi.io.RDFXMLOntologyFormat;
 import org.semanticweb.owlapi.io.StringDocumentSource;
 import org.semanticweb.owlapi.io.StringDocumentTarget;
+import org.semanticweb.owlapi.model.AddImport;
 import org.semanticweb.owlapi.model.IRI;
-import org.semanticweb.owlapi.model.OWLImportsDeclaration;
+import org.semanticweb.owlapi.model.OWLDataFactory;
 import org.semanticweb.owlapi.model.OWLOntology;
 import org.semanticweb.owlapi.model.OWLOntologyAlreadyExistsException;
+import org.semanticweb.owlapi.model.OWLOntologyChange;
 import org.semanticweb.owlapi.model.OWLOntologyCreationException;
 import org.semanticweb.owlapi.model.OWLOntologyID;
 import org.semanticweb.owlapi.model.OWLOntologyManager;
 import org.semanticweb.owlapi.model.OWLOntologyStorageException;
-import org.semanticweb.owlapi.model.RemoveImport;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -85,8 +89,13 @@ public abstract class AbstractOntologySp
 
     protected IRI parentID = null;
 
-    // public static String SUFFIX = "";
+    /**
+     * The identifier of the ontologies directly managed by this space (i.e. that were directly added to this
+     * space, hence not including those just pulled in via import statements).
+     */
+    protected Set<OWLOntology> managedOntologies;
 
+    @Deprecated
     protected OWLOntology rootOntology = null;
 
     protected boolean silent = false;
@@ -125,6 +134,7 @@ public abstract class AbstractOntologySp
         if (ontologyManager != null) this.ontologyManager = ontologyManager;
         else this.ontologyManager = OWLManager.createOWLOntologyManager();
 
+        this.managedOntologies = new HashSet<OWLOntology>();
     }
 
     /**
@@ -137,22 +147,25 @@ public abstract class AbstractOntologySp
 
         if (locked) throw new UnmodifiableOntologySpaceException(this);
 
-        if (getTopOntology() == null) {
-            // If no top ontology has been set, we must create one first.
-            IRI rootIri = null;
-            try {
-                rootIri = IRI.create(StringUtils.stripIRITerminator(getID()) + "/root.owl");
-                OntologyInputSource src = new RootOntologySource(ontologyManager.createOntology(rootIri),
-                        null);
-                // Don't bother about the ontology to be added right now.
-                setTopOntology(src, false);
-            } catch (OWLOntologyCreationException e) {
-                log.error("KReS :: Exception caught when creating top ontology " + rootIri + " for space "
-                          + this.getID() + ".", e);
-                // No point in continuing if we can't even create the root...
-                return;
-            }
-        }
+        // if (getTopOntology() == null) {
+        // log.warn("Root ontology for ontology space {} was found to be null. This should not happen.",
+        // this.getID());
+        // // If no top ontology has been set, we must create one first.
+        // IRI rootIri = null;
+        // try {
+        // rootIri = IRI.create(StringUtils.stripIRITerminator(this.getID()) + "/root.owl");
+        // OntologyInputSource src = new RootOntologySource(ontologyManager.createOntology(rootIri),
+        // null);
+        // // Don't bother about the ontology to be added right now.
+        // setTopOntology(src, false);
+        // } catch (OWLOntologyCreationException e) {
+        // log.error(
+        // "Exception caught when creating top ontology " + rootIri + " for space " + this.getID()
+        // + ".", e);
+        // // No point in continuing if we can't even create the root...
+        // return;
+        // }
+        // }
 
         // Now add the new ontology.
         if (ontologySource != null && ontologySource.hasRootOntology()) {
@@ -177,11 +190,23 @@ public abstract class AbstractOntologySp
         return ontologyManager.contains(ontologyIri);
     }
 
+    /**
+     * Notifies all ontology space listeners that an ontology has been added to this space.
+     * 
+     * @param ontologyIri
+     *            the identifier of the ontology that was added to this space.
+     */
     protected void fireOntologyAdded(IRI ontologyIri) {
         for (OntologySpaceListener listener : listeners)
             listener.onOntologyAdded(this.getID(), ontologyIri);
     }
 
+    /**
+     * Notifies all ontology space listeners that an ontology has been removed from this space.
+     * 
+     * @param ontologyIri
+     *            the identifier of the ontology that was removed from this space.
+     */
     protected void fireOntologyRemoved(IRI ontologyIri) {
         for (OntologySpaceListener listener : listeners)
             listener.onOntologyRemoved(this.getID(), ontologyIri);
@@ -193,13 +218,20 @@ public abstract class AbstractOntologySp
     }
 
     @Override
-    public synchronized Set<OWLOntology> getOntologies() {
-        return ontologyManager.getOntologies();
+    public synchronized Set<OWLOntology> getOntologies(boolean withClosure) {
+        return withClosure ? ontologyManager.getOntologies() : managedOntologies;
     }
 
     @Override
     public OWLOntology getOntology(IRI ontologyIri) {
-        return ontologyManager.getOntology(ontologyIri);
+        OWLOntology o = null;
+        Iterator<OWLOntology> it = managedOntologies.iterator();
+        while (it.hasNext() && o == null) {
+            OWLOntology temp = it.next();
+            if (!temp.isAnonymous() && ontologyIri.equals(temp.getOntologyID().getOntologyIRI())) o = temp;
+        }
+        if (o == null) o = ontologyManager.getOntology(ontologyIri);
+        return o;
     }
 
     @Override
@@ -209,7 +241,52 @@ public abstract class AbstractOntologySp
 
     @Override
     public OWLOntology getTopOntology() {
-        return rootOntology;
+        OWLOntology root;
+        try {
+            root = ontologyManager.createOntology(_id);
+        } catch (OWLOntologyAlreadyExistsException e) {
+            ontologyManager.removeOntology(ontologyManager.getOntology(_id));
+            try {
+                root = ontologyManager.createOntology(_id);
+            } catch (OWLOntologyAlreadyExistsException e1) {
+                root = ontologyManager.getOntology(_id);
+            } catch (OWLOntologyCreationException e1) {
+                log.error("Failed to assemble root ontology for scope " + _id, e);
+                root = null;
+            }
+        } catch (OWLOntologyCreationException e) {
+            log.error("Failed to assemble root ontology for scope " + _id, e);
+            root = null;
+        }
+
+        // Add the import declarations for directly managed ontologies.
+        if (root != null) {
+            List<OWLOntologyChange> changes = new LinkedList<OWLOntologyChange>();
+            OWLDataFactory df = ontologyManager.getOWLDataFactory();
+            for (OWLOntology o : getOntologies(false)) {
+                if (o == null) continue;
+
+                String base = URIUtils.upOne(getID()) + "/";
+
+                IRI ontologyIri;
+
+                if (o.isAnonymous()) try {
+                    ontologyIri = ontologyManager.getOntologyDocumentIRI(o);
+                } catch (Exception ex) {
+                    ontologyIri = o.getOWLOntologyManager().getOntologyDocumentIRI(o);
+                }
+                else {
+                    ontologyIri = o.getOntologyID().getDefaultDocumentIRI();
+                }
+
+                IRI physIRI = IRI.create(base + ontologyIri);
+
+                changes.add(new AddImport(root, df.getOWLImportsDeclaration(physIRI)));
+            }
+            ontologyManager.applyChanges(changes);
+        }
+        // return rootOntology;
+        return root;
     }
 
     @Override
@@ -233,6 +310,39 @@ public abstract class AbstractOntologySp
 
         // Should not modify the child ontology in any way.
         // TODO implement transaction control.
+        // OntologyUtils.appendOntology(new RootOntologySource(getTopOntology(), null), ontSrc,
+        // ontologyManager);
+
+        // See to it that the ontology is copied to this manager
+        reload(ontology, ontologyManager, true, false);
+
+        OWLOntology newOnt = ontologyManager.getOntology(id);
+        managedOntologies.add(newOnt);
+
+        try {
+            // Store the top ontology
+            if (!(this instanceof SessionOntologySpace)) {
+                if (storage == null) log.warn("No ontology storage found. Ontology "
+                                              + ontology.getOntologyID() + " will be stored in-memory only.");
+                else {
+                    // storage = new ClerezzaOntologyStorage(tcManager, wtcProvider)
+                    storage.store(ontology);
+                }
+            }
+            // ONManager.get().getOntologyStore().load(rootOntology.getOntologyID().getOntologyIRI());
+        } catch (Exception ex) {
+            log.warn("An error occurred while storing ontology " + ontology
+                     + " . Ontology management will be volatile.", ex);
+        }
+        fireOntologyAdded(id.getOntologyIRI());
+    }
+
+    private void performAddOld(OntologyInputSource ontSrc) {
+        OWLOntology ontology = ontSrc.getRootOntology();
+        OWLOntologyID id = ontology.getOntologyID();
+
+        // Should not modify the child ontology in any way.
+        // TODO implement transaction control.
         OntologyUtils.appendOntology(new RootOntologySource(getTopOntology(), null), ontSrc, ontologyManager);
 
         // StringDocumentTarget tgt = new StringDocumentTarget();
@@ -266,9 +376,8 @@ public abstract class AbstractOntologySp
         try {
             // Store the top ontology
             if (!(this instanceof SessionOntologySpace)) {
-                if (storage == null) log
-                        .error("KReS :: [NONFATAL] no ontology storage found. Ontology "
-                               + ontology.getOntologyID() + " will be stored in-memory only.");
+                if (storage == null) log.warn("No ontology storage found. Ontology "
+                                              + ontology.getOntologyID() + " will be stored in-memory only.");
                 else {
                     // storage = new ClerezzaOntologyStorage(tcManager, wtcProvider)
                     storage.store(ontology);
@@ -276,8 +385,8 @@ public abstract class AbstractOntologySp
             }
             // ONManager.get().getOntologyStore().load(rootOntology.getOntologyID().getOntologyIRI());
         } catch (Exception ex) {
-            log.error("KReS :: [NONFATAL] An error occurred while storing ontology " + ontology
-                      + " . Ontology management will be volatile!", ex);
+            log.warn("An error occurred while storing ontology " + ontology
+                     + " . Ontology management will be volatile.", ex);
         }
         fireOntologyAdded(id.getOntologyIRI());
     }
@@ -303,17 +412,17 @@ public abstract class AbstractOntologySp
                 if (isSilentMissingOntologyHandling()) return;
                 else throw new MissingOntologyException(this, null);
             }
-            if (o.equals(getTopOntology()))
-            // setTopOntology(null, false);
-            throw new IrremovableOntologyException(this, logicalID);
+            // if (o.equals(getTopOntology()))
+            // // setTopOntology(null, false);
+            // throw new IrremovableOntologyException(this, logicalID);
             try {
-                OWLImportsDeclaration imp = ontologyManager.getOWLDataFactory().getOWLImportsDeclaration(
-                    physicalIRI);
-                ontologyManager.applyChange(new RemoveImport(getTopOntology(), imp));
+                // OWLImportsDeclaration imp = ontologyManager.getOWLDataFactory().getOWLImportsDeclaration(
+                // physicalIRI);
+                // ontologyManager.applyChange(new RemoveImport(getTopOntology(), imp));
                 ontologyManager.removeOntology(o);
                 fireOntologyRemoved(logicalID);
             } catch (RuntimeException ex) {
-                throw new OntologySpaceModificationException(this);
+                throw new OntologySpaceModificationException(this, ex);
             }
         }
     }
@@ -336,6 +445,12 @@ public abstract class AbstractOntologySp
      *            <code>withClosure</code> is set to false.
      */
     protected void reload(OWLOntology ontology, OWLOntologyManager mgr, boolean withClosure, boolean merge) {
+        if (ontology == null) throw new IllegalArgumentException("ontology cannot be null");
+        if (ontology.getOWLOntologyManager() == ontologyManager) {
+            log.warn("Ontology {} is already managed by the supplied OWLOntologyManager. Skipping copy.",
+                ontology);
+            return;
+        }
         if (mgr == null) mgr = ontologyManager;
         Set<OWLOntology> closure = withClosure ? ontology.getOWLOntologyManager().getImportsClosure(ontology)
                 : Collections.singleton(ontology);
@@ -347,9 +462,12 @@ public abstract class AbstractOntologySp
                       + " across managers", e1);
         }
         else {
+
             for (OWLOntology o : closure) {
                 OWLOntologyID id = o.getOntologyID();
-                if (mgr.contains(id)) mgr.removeOntology(mgr.getOntology(id));
+                if (mgr.contains(id)) {
+                    mgr.removeOntology(mgr.getOntology(id));
+                }
                 try {
                     mgr.createOntology(id.getOntologyIRI(), Collections.singleton(o));
                 } catch (OWLOntologyAlreadyExistsException e) {
@@ -383,15 +501,10 @@ public abstract class AbstractOntologySp
         this.silent = silent;
     }
 
-    @Override
-    public synchronized void setTopOntology(OntologyInputSource ontologySource) throws UnmodifiableOntologySpaceException {
-        setTopOntology(ontologySource, true);
-    }
-
     /**
      * TODO 1 : Attention: the ontology from <code>ontologySource</code> is NOT added to the ontology manager!
      */
-    @Override
+    @Deprecated
     public synchronized void setTopOntology(OntologyInputSource ontologySource, boolean createParent) throws UnmodifiableOntologySpaceException {
 
         // TODO : implement or avoid passing of OWLOntology objects across managers
@@ -446,12 +559,12 @@ public abstract class AbstractOntologySp
             // reload(oParent, ontologyManager, true, false);
 
         } catch (OWLOntologyAlreadyExistsException e) {
-            log.warn("KReS : [NONFATAL] Tried to copy ontology " + id + " to existing one.", e);
+            log.warn("Tried to copy ontology " + id + " to existing one.", e);
         } catch (OWLOntologyCreationException e) {
-            log.error("KReS : [FATAL] Failed to create ontology " + id, e);
+            log.error("Failed to create ontology " + id, e);
         } catch (OWLOntologyStorageException e) {
             // Shouldn't be a problem to save it in memory as RDF/XML...
-            log.error("KReS : [FATAL] In-memory store failed for ontology " + id, e);
+            log.error("In-memory store failed for ontology " + id, e);
         }
 
         // Assign the ontology and fire the corresponding event.

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/CustomOntologySpaceImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/CustomOntologySpaceImpl.java?rev=1153575&r1=1153574&r2=1153575&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/CustomOntologySpaceImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/CustomOntologySpaceImpl.java Wed Aug  3 16:47:20 2011
@@ -48,18 +48,18 @@ public class CustomOntologySpaceImpl ext
 
     @Override
     public void attachCoreSpace(CoreOntologySpace coreSpace, boolean skipRoot) throws UnmodifiableOntologySpaceException {
-
-        OWLOntology o = coreSpace.getTopOntology();
-        // This does the append thingy
-        log.debug("Attaching " + o + " TO " + getTopOntology() + " ...");
-        try {
-            // It is in fact the addition of the core space top ontology to the
-            // custom space, with import statements and all.
-            addOntology(new RootOntologySource(o, null));
-            // log.debug("ok");
-        } catch (Exception ex) {
-            log.error("FAILED", ex);
-        }
+// FIXME re-implement!
+//        OWLOntology o = coreSpace.getTopOntology();
+//        // This does the append thingy
+//        log.debug("Attaching " + o + " TO " + getTopOntology() + " ...");
+//        try {
+//            // It is in fact the addition of the core space top ontology to the
+//            // custom space, with import statements and all.
+//            addOntology(new RootOntologySource(o, null));
+//            // log.debug("ok");
+//        } catch (Exception ex) {
+//            log.error("FAILED", ex);
+//        }
 
     }
 

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OntologyIndexImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OntologyIndexImpl.java?rev=1153575&r1=1153574&r2=1153575&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OntologyIndexImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OntologyIndexImpl.java Wed Aug  3 16:47:20 2011
@@ -78,10 +78,10 @@ public class OntologyIndexImpl implement
         Set<OWLOntology> ontologies = new HashSet<OWLOntology>();
         try {
             // ontologies.add(scope.getCoreSpace().getTopOntology());
-            ontologies.addAll(scope.getCoreSpace().getOntologies());
+            ontologies.addAll(scope.getCoreSpace().getOntologies(true));
         } catch (Exception ex) {}
         try {
-            ontologies.addAll(scope.getCustomSpace().getOntologies());
+            ontologies.addAll(scope.getCustomSpace().getOntologies(true));
         } catch (Exception ex) {}
         // for (OWLOntology o : ontologies) {
         // System.out.println(o.getOntologyID());

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OntologyScopeImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OntologyScopeImpl.java?rev=1153575&r1=1153574&r2=1153575&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OntologyScopeImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OntologyScopeImpl.java Wed Aug  3 16:47:20 2011
@@ -1,24 +1,26 @@
 /*
-* 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.impl.ontology;
 
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
@@ -32,7 +34,15 @@ import org.apache.stanbol.ontologymanage
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.ScopeOntologyListener;
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.SessionOntologySpace;
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.UnmodifiableOntologySpaceException;
+import org.semanticweb.owlapi.apibinding.OWLManager;
+import org.semanticweb.owlapi.model.AddImport;
 import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLDataFactory;
+import org.semanticweb.owlapi.model.OWLOntology;
+import org.semanticweb.owlapi.model.OWLOntologyChange;
+import org.semanticweb.owlapi.model.OWLOntologyCreationException;
+import org.semanticweb.owlapi.model.OWLOntologyManager;
+import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
@@ -66,6 +76,8 @@ public class OntologyScopeImpl implement
      */
     protected boolean locked = false;
 
+    private Logger log = LoggerFactory.getLogger(getClass());
+
     /**
      * Maps session IDs to ontology space. A single scope has at most one space per session.
      */
@@ -92,55 +104,58 @@ public class OntologyScopeImpl implement
         } catch (UnmodifiableOntologySpaceException e) {
             // Can't happen unless the factory or space implementations are
             // really naughty.
-            LoggerFactory
-                    .getLogger(getClass())
-                    .warn(
-                        "KReS :: Ontology scope "
-                                + id
-                                + " was denied creation of its own custom space upon initialization! This should not happen.",
-                        e);
+            log.warn(
+                "Ontology scope "
+                        + id
+                        + " was denied creation of its own custom space upon initialization! This should not happen.",
+                e);
         }
         this.customSpace.addOntologySpaceListener(this);
         // }
         sessionSpaces = new HashMap<IRI,SessionOntologySpace>();
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @seeeu.iksproject.kres.api.manager.ontology.OntologyScope# addOntologyScopeListener
-     * (eu.iksproject.kres.api.manager.ontology.ScopeOntologyListener)
-     */
     @Override
     public void addOntologyScopeListener(ScopeOntologyListener listener) {
         listeners.add(listener);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see eu.iksproject.kres.api.manager.ontology.OntologyScope#addSessionSpace
-     * (eu.iksproject.kres.api.manager.ontology.OntologySpace, org.semanticweb.owlapi.model.IRI)
-     */
     @Override
     public synchronized void addSessionSpace(OntologySpace sessionSpace, IRI sessionId) throws UnmodifiableOntologySpaceException {
         if (sessionSpace instanceof SessionOntologySpace) {
             sessionSpaces.put(sessionId, (SessionOntologySpace) sessionSpace);
             sessionSpace.addOntologySpaceListener(this);
 
-            if (this.getCustomSpace() != null)
-                ((SessionOntologySpace) sessionSpace).attachSpace(this.getCustomSpace(), true);
-            else
-                ((SessionOntologySpace) sessionSpace).attachSpace(this.getCoreSpace(), true);
+            if (this.getCustomSpace() != null) ((SessionOntologySpace) sessionSpace).attachSpace(
+                this.getCustomSpace(), true);
+            else ((SessionOntologySpace) sessionSpace).attachSpace(this.getCoreSpace(), true);
 
         }
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @seeeu.iksproject.kres.api.manager.ontology.OntologyScope# clearOntologyScopeListeners()
-     */
+    @Override
+    public OWLOntology asOWLOntology() {
+        // Create an ontology manager on the fly. We don't really need a permanent one.
+        OWLOntologyManager mgr = OWLManager.createOWLOntologyManager();
+        OWLDataFactory df = mgr.getOWLDataFactory();
+        OWLOntology ont;
+        try {
+            ont = mgr.createOntology(getID());
+            List<OWLOntologyChange> additions = new LinkedList<OWLOntologyChange>();
+            OntologySpace spc = getCustomSpace();
+            if (spc != null && !spc.getOntologies(false).isEmpty()) additions.add(new AddImport(ont, df
+                    .getOWLImportsDeclaration(spc.getID())));
+            spc = getCoreSpace();
+            if (spc != null && !spc.getOntologies(false).isEmpty()) additions.add(new AddImport(ont, df
+                    .getOWLImportsDeclaration(spc.getID())));
+            mgr.applyChanges(additions);
+        } catch (OWLOntologyCreationException e) {
+            log.error("Failed to generate an OWL form of scope " + getID(), e);
+            ont = null;
+        }
+        return ont;
+    }
+
     @Override
     public void clearOntologyScopeListeners() {
         listeners.clear();
@@ -156,85 +171,42 @@ public class OntologyScopeImpl implement
             listener.onOntologyRemoved(this.getID(), ontologyIri);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see eu.iksproject.kres.api.manager.ontology.OntologyScope#getCoreSpace()
-     */
     @Override
     public OntologySpace getCoreSpace() {
         return coreSpace;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see eu.iksproject.kres.api.manager.ontology.OntologyScope#getCustomSpace()
-     */
     @Override
     public OntologySpace getCustomSpace() {
         return customSpace;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see eu.iksproject.kres.api.manager.ontology.OntologyScope#getID()
-     */
     @Override
     public IRI getID() {
         return id;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @seeeu.iksproject.kres.api.manager.ontology.OntologyScope# getOntologyScopeListeners()
-     */
     @Override
     public Collection<ScopeOntologyListener> getOntologyScopeListeners() {
         return listeners;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see eu.iksproject.kres.api.manager.ontology.OntologyScope#getSessionSpace
-     * (org.semanticweb.owlapi.model.IRI)
-     */
     @Override
     public SessionOntologySpace getSessionSpace(IRI sessionID) {
         return sessionSpaces.get(sessionID);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see eu.iksproject.kres.api.manager.ontology.OntologyScope#getSessionSpaces()
-     */
     @Override
     public Set<OntologySpace> getSessionSpaces() {
         return new HashSet<OntologySpace>(sessionSpaces.values());
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see eu.iksproject.kres.api.manager.ontology.OntologySpaceListener#onOntologyAdded
-     * (org.semanticweb.owlapi.model.IRI, org.semanticweb.owlapi.model.IRI)
-     */
     @Override
     public void onOntologyAdded(IRI spaceId, IRI addedOntology) {
         // Propagate events to scope listeners
         fireOntologyAdded(addedOntology);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @seeeu.iksproject.kres.api.manager.ontology.OntologySpaceListener#
-     * onOntologyRemoved(org.semanticweb.owlapi.model.IRI, org.semanticweb.owlapi.model.IRI)
-     */
     @Override
     public void onOntologyRemoved(IRI spaceId, IRI removedOntology) {
         // Propagate events to scope listeners
@@ -246,12 +218,6 @@ public class OntologyScopeImpl implement
         listeners.remove(listener);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see eu.iksproject.kres.api.manager.ontology.OntologyScope#setCustomSpace(
-     * eu.iksproject.kres.api.manager.ontology.OntologySpace)
-     */
     @Override
     public synchronized void setCustomSpace(OntologySpace customSpace) throws UnmodifiableOntologySpaceException {
         if (this.customSpace != null && this.customSpace.isLocked()) throw new UnmodifiableOntologySpaceException(
@@ -266,11 +232,6 @@ public class OntologyScopeImpl implement
 
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see eu.iksproject.kres.api.manager.ontology.OntologyScope#setUp()
-     */
     @Override
     public synchronized void setUp() {
         if (locked || (customSpace != null && !customSpace.isLocked())) return;
@@ -283,11 +244,12 @@ public class OntologyScopeImpl implement
         locked = true;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see eu.iksproject.kres.api.manager.ontology.OntologyScope#tearDown()
-     */
+    @Override
+    public void synchronizeSpaces() {
+        // TODO Auto-generated method stub
+
+    }
+
     @Override
     public synchronized void tearDown() {
         // this.coreSpace.addOntologySpaceListener(this);
@@ -299,20 +261,9 @@ public class OntologyScopeImpl implement
         locked = false;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.lang.Object#toString()
-     */
     @Override
     public String toString() {
         return getID().toString();
     }
 
-    @Override
-    public void synchronizeSpaces() {
-        // TODO Auto-generated method stub
-
-    }
-
 }

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OntologySpaceFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OntologySpaceFactoryImpl.java?rev=1153575&r1=1153574&r2=1153575&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OntologySpaceFactoryImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/OntologySpaceFactoryImpl.java Wed Aug  3 16:47:20 2011
@@ -29,6 +29,7 @@ import org.apache.stanbol.ontologymanage
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.SpaceType;
 import org.apache.stanbol.ontologymanager.ontonet.api.ontology.UnmodifiableOntologySpaceException;
 import org.apache.stanbol.ontologymanager.ontonet.impl.io.ClerezzaOntologyStorage;
+import org.apache.stanbol.owl.OWLOntologyManagerFactory;
 import org.semanticweb.owlapi.model.IRI;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -41,8 +42,6 @@ public class OntologySpaceFactoryImpl im
 
     protected Logger log = LoggerFactory.getLogger(getClass());
 
-    protected OWLOntologyManagerFactoryImpl mgrFactory;
-
     protected OfflineConfiguration offline;
 
     protected ScopeRegistry registry;
@@ -55,10 +54,10 @@ public class OntologySpaceFactoryImpl im
 
     public OntologySpaceFactoryImpl(ScopeRegistry registry,
                                     ClerezzaOntologyStorage storage,
-                                    OWLOntologyManagerFactoryImpl mgrFactory) {
+                                    OfflineConfiguration offline) {
         this.registry = registry;
         this.storage = storage;
-        this.mgrFactory = mgrFactory;
+        this.offline = offline;
     }
 
     /**
@@ -68,7 +67,7 @@ public class OntologySpaceFactoryImpl im
      * @param scopeID
      * @param rootSource
      */
-    private void configureSpace(OntologySpace s, IRI scopeID, OntologyInputSource... rootSource) {
+    private void configureSpace(OntologySpace s, IRI scopeID, OntologyInputSource... ontologySources) {
         // FIXME: ensure that this is not null
         OntologyScope parentScope = registry.getScope(scopeID);
 
@@ -76,8 +75,8 @@ public class OntologySpaceFactoryImpl im
                 .addOntologySpaceListener((OntologySpaceListener) parentScope);
         // Set the supplied ontology's parent as the root for this space.
         try {
-            // FIXME USE THE WHOLE ARRAY
-            s.setTopOntology(rootSource[0], true);
+            for (OntologyInputSource src : ontologySources)
+                s.addOntology(src);
         } catch (UnmodifiableOntologySpaceException e) {
             log.error("Ontology space " + s.getID() + " was found locked at creation time!", e);
         }
@@ -85,27 +84,19 @@ public class OntologySpaceFactoryImpl im
     }
 
     @Override
-    public CoreOntologySpace createCoreOntologySpace(IRI scopeId, OntologyInputSource coreSource) {
-        return createCoreOntologySpace(scopeId, new OntologyInputSource[] {coreSource});
-    }
-
-    @Override
     public CoreOntologySpace createCoreOntologySpace(IRI scopeId, OntologyInputSource... coreSources) {
         CoreOntologySpace s = new CoreOntologySpaceImpl(scopeId, storage,
-                mgrFactory.createOntologyManager(true));
+                OWLOntologyManagerFactory.createOWLOntologyManager(offline.getOntologySourceLocations()
+                        .toArray(new IRI[0])));
         configureSpace(s, scopeId, coreSources);
         return s;
     }
 
     @Override
-    public CustomOntologySpace createCustomOntologySpace(IRI scopeId, OntologyInputSource customSource) {
-        return createCustomOntologySpace(scopeId, new OntologyInputSource[] {customSource});
-    }
-
-    @Override
     public CustomOntologySpace createCustomOntologySpace(IRI scopeId, OntologyInputSource... customSources) {
         CustomOntologySpace s = new CustomOntologySpaceImpl(scopeId, storage,
-                mgrFactory.createOntologyManager(true));
+                OWLOntologyManagerFactory.createOWLOntologyManager(offline.getOntologySourceLocations()
+                        .toArray(new IRI[0])));
         configureSpace(s, scopeId, customSources);
         return s;
     }
@@ -127,14 +118,10 @@ public class OntologySpaceFactoryImpl im
     }
 
     @Override
-    public SessionOntologySpace createSessionOntologySpace(IRI scopeId) {
-        return createSessionOntologySpace(scopeId, new OntologyInputSource[] {});
-    }
-
-    @Override
     public SessionOntologySpace createSessionOntologySpace(IRI scopeId, OntologyInputSource... sessionSources) {
         SessionOntologySpace s = new SessionOntologySpaceImpl(scopeId, storage,
-                mgrFactory.createOntologyManager(true));
+                OWLOntologyManagerFactory.createOWLOntologyManager(offline.getOntologySourceLocations()
+                        .toArray(new IRI[0])));
         for (OntologyInputSource src : sessionSources)
             try {
                 s.addOntology(src);

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/SessionOntologySpaceImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/SessionOntologySpaceImpl.java?rev=1153575&r1=1153574&r2=1153575&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/SessionOntologySpaceImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ontology/SessionOntologySpaceImpl.java Wed Aug  3 16:47:20 2011
@@ -27,10 +27,7 @@ import org.apache.stanbol.ontologymanage
 import org.apache.stanbol.ontologymanager.ontonet.impl.util.StringUtils;
 import org.semanticweb.owlapi.model.IRI;
 import org.semanticweb.owlapi.model.OWLOntology;
-import org.semanticweb.owlapi.model.OWLOntologyCreationException;
 import org.semanticweb.owlapi.model.OWLOntologyManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 /**
  * Default implementation of the session ontology space.
@@ -44,16 +41,16 @@ public class SessionOntologySpaceImpl ex
         super(IRI.create(StringUtils.stripIRITerminator(scopeID) + "/" + SpaceType.SESSION.getIRISuffix()
                          + "-" + new Random().nextLong()), SpaceType.SESSION, store/* , scopeID */);
 
-        IRI iri = IRI.create(StringUtils.stripIRITerminator(getID()) + "/root.owl");
-        try {
-            setTopOntology(new RootOntologySource(ontologyManager.createOntology(iri), null), false);
-        } catch (OWLOntologyCreationException e) {
-            log.error("Could not create session space root ontology " + iri, e);
-        } catch (UnmodifiableOntologySpaceException e) {
-            // Should not happen...
-            log.error("Session space ontology " + iri
-                      + " was denied modification by the space itself. This should not happen.", e);
-        }
+        // IRI iri = IRI.create(StringUtils.stripIRITerminator(getID()) + "/root.owl");
+        // try {
+        // setTopOntology(new RootOntologySource(ontologyManager.createOntology(iri), null), false);
+        // } catch (OWLOntologyCreationException e) {
+        // log.error("Could not create session space root ontology " + iri, e);
+        // } catch (UnmodifiableOntologySpaceException e) {
+        // // Should not happen...
+        // log.error("Session space ontology " + iri
+        // + " was denied modification by the space itself. This should not happen.", e);
+        // }
     }
 
     public SessionOntologySpaceImpl(IRI scopeID,
@@ -63,36 +60,37 @@ public class SessionOntologySpaceImpl ex
         // FIXME : sync session id with session space ID
         super(IRI.create(StringUtils.stripIRITerminator(scopeID) + "/" + SpaceType.SESSION.getIRISuffix()
                          + "-" + new Random().nextLong()), SpaceType.SESSION, store, /* scopeID, */
-                ontologyManager);
+        ontologyManager);
 
-        Logger log = LoggerFactory.getLogger(getClass());
-        IRI iri = IRI.create(StringUtils.stripIRITerminator(getID()) + "/root.owl");
-        try {
-            setTopOntology(new RootOntologySource(ontologyManager.createOntology(iri), null), false);
-        } catch (OWLOntologyCreationException e) {
-            log.error("Could not create session space root ontology " + iri, e);
-        } catch (UnmodifiableOntologySpaceException e) {
-            // Should not happen...
-            log.error("Session space ontology " + iri
-                      + " was denied modification by the space itself. This should not happen.", e);
-        }
+        // Logger log = LoggerFactory.getLogger(getClass());
+        // IRI iri = IRI.create(StringUtils.stripIRITerminator(getID()) + "/root.owl");
+        // try {
+        // setTopOntology(new RootOntologySource(ontologyManager.createOntology(iri), null), false);
+        // } catch (OWLOntologyCreationException e) {
+        // log.error("Could not create session space root ontology " + iri, e);
+        // } catch (UnmodifiableOntologySpaceException e) {
+        // // Should not happen...
+        // log.error("Session space ontology " + iri
+        // + " was denied modification by the space itself. This should not happen.", e);
+        // }
     }
 
     @Override
     public void attachSpace(OntologySpace space, boolean skipRoot) throws UnmodifiableOntologySpaceException {
-        if (!(space instanceof SessionOntologySpace)) {
-            OWLOntology o = space.getTopOntology();
-            // This does the append thingy
-            log.debug("Attaching " + o + " TO " + getTopOntology() + " ...");
-            try {
-                // It is in fact the addition of the core space top ontology to the
-                // custom space, with import statements and all.
-                addOntology(new RootOntologySource(o, null));
-                // log.debug("ok");
-            } catch (Exception ex) {
-                log.error("FAILED", ex);
-            }
-        }
+        // FIXME re-implement!
+//        if (!(space instanceof SessionOntologySpace)) {
+//            OWLOntology o = space.getTopOntology();
+//            // This does the append thingy
+//            log.debug("Attaching " + o + " TO " + getTopOntology() + " ...");
+//            try {
+//                // It is in fact the addition of the core space top ontology to the
+//                // custom space, with import statements and all.
+//                addOntology(new RootOntologySource(o, null));
+//                // log.debug("ok");
+//            } catch (Exception ex) {
+//                log.error("FAILED", ex);
+//            }
+//        }
     }
 
     @Override

Modified: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/session/SessionManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/session/SessionManagerImpl.java?rev=1153575&r1=1153574&r2=1153575&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/session/SessionManagerImpl.java (original)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/session/SessionManagerImpl.java Wed Aug  3 16:47:20 2011
@@ -265,7 +265,7 @@ public class SessionManagerImpl implemen
          * For each gession space in the session save all the ontologies contained in the space.
          */
         for (SessionOntologySpace so : getSessionSpaces(sessionID)) {
-            for (OWLOntology owlOntology : so.getOntologies()) {
+            for (OWLOntology owlOntology : so.getOntologies(true)) {
 
                 store.store(owlOntology);