You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by en...@apache.org on 2011/04/01 14:08:31 UTC

svn commit: r1087671 [2/13] - in /incubator/stanbol/trunk/ontologymanager: ./ ontonet/ ontonet/.settings/ ontonet/src/ ontonet/src/main/ ontonet/src/main/java/ ontonet/src/main/java/org/ ontonet/src/main/java/org/apache/ ontonet/src/main/java/org/apach...

Added: 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=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologyScope.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologyScope.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,126 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.ontology;
+
+import java.util.Set;
+
+import org.semanticweb.owlapi.model.IRI;
+
+/**
+ * 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.
+ * <ul>
+ * <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.
+ * </ul>
+ * An ontology scope can thus be seen as a fa&ccedil;ade for ontology spaces.
+ * 
+ * 
+ * @author alessandro
+ * 
+ */
+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.
+	 */
+	public void addSessionSpace(OntologySpace sessionSpace, IRI sessionID);
+
+	/**
+	 * Returns the core ontology space for this ontology scope. The core space
+	 * should never be null for any scope.
+	 * 
+	 * @return the core ontology space
+	 */
+	public 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.
+	 */
+	public 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
+	 */
+	public 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.
+	 */
+	public SessionOntologySpace getSessionSpace(IRI sessionID);
+
+	/**
+	 * Returns all the active ontology spaces for this scope.
+	 * 
+	 * @return a set of active ontology spaces for this scope.
+	 */
+	public 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.
+	 */
+	public 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.
+	 */
+	public 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.
+	 */
+	public 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.
+	 */
+	public void tearDown();
+
+}

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologyScopeFactory.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologyScopeFactory.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologyScopeFactory.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologyScopeFactory.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,61 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.ontology;
+
+import org.apache.stanbol.ontologymanager.ontonet.api.DuplicateIDException;
+import org.apache.stanbol.ontologymanager.ontonet.api.io.OntologyInputSource;
+import org.semanticweb.owlapi.model.IRI;
+
+
+/**
+ * An ontology scope factory is responsible for the creation of new ontology
+ * scopes from supplied ontology input sources for their core and custom spaces.<br>
+ * <br>
+ * Factory implementations should not call the setup method of the ontology
+ * scope once it is created, so that its spaces are not locked from editing
+ * since creation time.
+ * 
+ * @author alessandro
+ * 
+ */
+public interface OntologyScopeFactory extends ScopeEventListenable {
+
+	/**
+	 * Creates and returns a new ontology scope with the core space ontologies
+	 * obtained from <code>coreSource</code> and the custom space not set.
+	 * 
+	 * @param scopeID
+	 *            the desired unique identifier for the ontology scope.
+	 * @param coreSource
+	 *            the input source that provides the top ontology for the core
+	 *            space.
+	 * @return the newly created ontology scope.
+	 * @throws DuplicateIDException
+	 *             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.
+	 */
+	public OntologyScope createOntologyScope(IRI scopeID,
+			OntologyInputSource coreSource) throws DuplicateIDException;
+
+	/**
+	 * Creates and returns a new ontology scope with the core space ontologies
+	 * obtained from <code>coreSource</code> and the custom ontologies obtained
+	 * from <code>customSource</code>.
+	 * 
+	 * @param scopeID
+	 *            the desired unique identifier for the ontology scope.
+	 * @param coreSource
+	 *            the input source that provides the top ontology for the core
+	 *            space.
+	 * @param customSource
+	 *            the input source that provides the top ontology for the custom
+	 *            space. If null, no custom space should be created at all.
+	 * @return the newly created ontology scope.
+	 * @throws DuplicateIDException
+	 *             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.
+	 */
+	public OntologyScope createOntologyScope(IRI scopeID,
+			OntologyInputSource coreSource, OntologyInputSource customSource)
+			throws DuplicateIDException;
+}

Added: 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=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpace.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpace.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,174 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.ontology;
+
+import java.util.Collection;
+import java.util.Set;
+
+import org.apache.stanbol.ontologymanager.ontonet.api.io.OntologyInputSource;
+import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLOntology;
+
+
+/**
+ * An ontology space identifies the set of OWL ontologies that should be
+ * "active" in a given context, e.g. for a certain user session or a specific
+ * reasoning service. Each ontology space has an ID and a top ontology that can
+ * be used as a shared resource for mutual exclusion and locking strategies.
+ * 
+ * @author alessandro
+ * 
+ */
+public interface OntologySpace {
+
+	/**
+	 * Adds the given ontology to the ontology space.
+	 * 
+	 * @param ontology
+	 *            the ontology to be added
+	 * @throws UnmodifiableOntologySpaceException
+	 *             if the ontology space is read-only
+	 */
+	public void addOntology(OntologyInputSource ontologySource)
+			throws UnmodifiableOntologySpaceException;
+
+	public void addOntologySpaceListener(OntologySpaceListener listener);
+
+	public void clearOntologySpaceListeners();
+
+	/**
+	 * 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.
+	 * 
+	 * @return the URI that identifies this ontology space
+	 */
+	public IRI getID();
+
+	/**
+	 * Returns all the ontologies encompassed by this ontology space.
+	 * 
+	 * @return the set of ontologies in the ontology space
+	 */
+	public Set<OWLOntology> getOntologies();
+
+	/**
+	 * Returns the ontology identified by the supplied <i>logical</i> IRI, if
+	 * such an ontology has been loaded in this space.<br>
+	 * <br>
+	 * Note that ontologies are not identified by physical IRI here. There's no
+	 * need to ask KReS for ontologies by physical IRI, use a browser or some
+	 * other program instead!
+	 * 
+	 * @param ontologyIri
+	 *            the <i>logical</i> identifier of the ontology to query for.
+	 * 
+	 * @return the requested ontology, or null if no ontology with this ID has
+	 *         been loaded.
+	 */
+	public OWLOntology getOntology(IRI ontologyIri);
+	
+	public boolean containsOntology(IRI ontologyIri);
+
+	public Collection<OntologySpaceListener> getOntologyScopeListeners();
+
+	/**
+	 * Returns the ontology that serves as a root module for this ontology
+	 * space.
+	 * 
+	 * @return the root module of the ontology space
+	 */
+	public OWLOntology getTopOntology();
+
+	/**
+	 * Determines if the ontology identified by the supplied <i>logical</i> IRI
+	 * has been loaded in this space.<br>
+	 * <br>
+	 * Note that ontologies are not identified by physical IRI here. There's no
+	 * need to ask KReS for ontologies by physical IRI, use a browser or some
+	 * other program instead!
+	 * 
+	 * @param ontologyIri
+	 *            the <i>logical</i> identifier of the ontology to query for.
+	 * 
+	 * @return true if an ontology with this ID has been loaded in this space.
+	 */
+	public boolean hasOntology(IRI ontologyIri);
+
+	/**
+	 * Determines if it is no longer possible to modify this space until it is
+	 * torn down.
+	 * 
+	 * @return true if this space is write-locked, false otherwise.
+	 */
+	public boolean isLocked();
+
+	public boolean isSilentMissingOntologyHandling();
+
+	/**
+	 * Removes the given ontology from the ontology space, if the ontology is a
+	 * direct child of the top ontology. This means that the ontology must
+	 * neither be the top ontology for this space, nor a subtree of an imported
+	 * ontology. This is a conservative measure to avoid using undefined
+	 * entities in the space.
+	 * 
+	 * @param ontology
+	 *            the ontology to be removed
+	 * @throws UnmodifiableOntologySpaceException
+	 *             if the ontology space is read-only
+	 */
+	public void removeOntology(OntologyInputSource src)
+			throws OntologySpaceModificationException;
+
+	public void removeOntologySpaceListener(OntologySpaceListener listener);
+	
+	public 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.
+	 */
+	public 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.
+	 */
+	public 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.
+	 */
+	public void setUp();
+
+	/**
+	 * Performs all required operations for disposing of an ontology space and
+	 * releasing its resources (e.g. removing the writelock).
+	 */
+	public void tearDown();
+
+}

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpaceEvent.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpaceEvent.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpaceEvent.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpaceEvent.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,11 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.ontology;
+
+/**
+ * Placeholder for a wrapper of events that affect ontology spaces.
+ * 
+ * @author alessandro
+ * 
+ */
+public class OntologySpaceEvent {
+
+}

Added: 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=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpaceFactory.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpaceFactory.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,58 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.ontology;
+
+import org.apache.stanbol.ontologymanager.ontonet.api.io.OntologyInputSource;
+import org.semanticweb.owlapi.model.IRI;
+
+
+/**
+ * An ontology space factory is responsible for the creation of new, readily
+ * specialized ontology spaces from supplied ontology input sources.
+ * 
+ * Implementations should not call the setup method of the ontology space once
+ * it is created, so that it is not locked from editing since creation time.
+ * 
+ * @author alessandro
+ * 
+ */
+public interface OntologySpaceFactory {
+
+	/**
+	 * Creates and sets up a default core ontology space.
+	 * 
+	 * @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.
+	 */
+	public CoreOntologySpace createCoreOntologySpace(IRI scopeID,
+			OntologyInputSource coreSource);
+
+	/**
+	 * Creates and sets up a default custom ontology space.
+	 * 
+	 * @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.
+	 */
+	public CustomOntologySpace createCustomOntologySpace(IRI scopeID,
+			OntologyInputSource customSource);
+
+	/**
+	 * Creates and sets up a default session ontology space.
+	 * 
+	 * @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.
+	 */
+	public SessionOntologySpace createSessionOntologySpace(IRI scopeID);
+
+}

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpaceListener.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpaceListener.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpaceListener.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpaceListener.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,11 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.ontology;
+
+import org.semanticweb.owlapi.model.IRI;
+
+public interface OntologySpaceListener {
+
+	public void onOntologyAdded(IRI spaceId, IRI addedOntology);
+
+	public void onOntologyRemoved(IRI spaceId, IRI removedOntology);
+
+}

Added: 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=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpaceModificationException.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/OntologySpaceModificationException.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,39 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.ontology;
+
+/**
+ * Thrown whenever an illegal operation that modifies an ontology space is
+ * detected and denied.
+ * 
+ * @author alessandro
+ * 
+ */
+public class OntologySpaceModificationException extends Exception {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = -5147080356192253724L;
+
+	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;
+	}
+
+}

Added: 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=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/ScopeEventListenable.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/ScopeEventListenable.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,22 @@
+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
+ * 
+ */
+public interface ScopeEventListenable {
+
+	public void addScopeEventListener(ScopeEventListener listener);
+
+	public void clearScopeEventListeners();
+
+	public Collection<ScopeEventListener> getScopeEventListeners();
+
+	public void removeScopeEventListener(ScopeEventListener listener);
+
+}

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/ScopeEventListener.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/ScopeEventListener.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/ScopeEventListener.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/ScopeEventListener.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,55 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.ontology;
+
+/**
+ * Objects that want to listen to the registration of ontology scopes should
+ * implement this interface and add themselves as listener to a scope registry.
+ * 
+ * @author alessandro
+ * 
+ */
+public interface ScopeEventListener {
+
+	/**
+	 * Called <i>after</i> an ontology scope, assuming it is already registered
+	 * somewhere, is activated.
+	 * 
+	 * @param scope
+	 *            the activated ontology scope
+	 */
+	public void scopeActivated(OntologyScope scope);
+
+	/**
+	 * Called <i>after</i> a new ontology scope has been created.
+	 * 
+	 * @param scope
+	 *            the created ontology scope
+	 */
+	public void scopeCreated(OntologyScope scope);
+
+	/**
+	 * Called <i>after</i> an ontology scope, assuming it is already registered
+	 * somewhere, is deactivated. If the deactivation of a scope implies
+	 * deregistering of it, a separate event should be fired for deregistration.
+	 * 
+	 * @param scope
+	 *            the deactivated ontology scope
+	 */
+	public void scopeDeactivated(OntologyScope scope);
+
+	/**
+	 * Called <i>after</i> an ontology scope is removed from the scope registry.
+	 * 
+	 * @param scope
+	 *            the deregistered ontology scope
+	 */
+	public void scopeDeregistered(OntologyScope scope);
+
+	/**
+	 * Called <i>after</i> an ontology scope is added to the scope registry.
+	 * 
+	 * @param scope
+	 *            the registered ontology scope
+	 */
+	public void scopeRegistered(OntologyScope scope);
+
+}

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/ScopeOntologyListenable.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/ScopeOntologyListenable.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/ScopeOntologyListenable.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/ScopeOntologyListenable.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,22 @@
+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 ontologies within an ontology scope.
+ * 
+ * @author alessandro
+ * 
+ */
+public interface ScopeOntologyListenable {
+
+	public void addOntologyScopeListener(ScopeOntologyListener listener);
+
+	public void clearOntologyScopeListeners();
+
+	public Collection<ScopeOntologyListener> getOntologyScopeListeners();
+
+	public void removeOntologyScopeListener(ScopeOntologyListener listener);
+
+}

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/ScopeOntologyListener.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/ScopeOntologyListener.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/ScopeOntologyListener.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/ScopeOntologyListener.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,11 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.ontology;
+
+import org.semanticweb.owlapi.model.IRI;
+
+public interface ScopeOntologyListener {
+
+	public void onOntologyAdded(IRI scopeId, IRI addedOntology);
+
+	public void onOntologyRemoved(IRI scopeId, IRI removedOntology);
+	
+}

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/ScopeRegistry.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/ScopeRegistry.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/ScopeRegistry.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/ScopeRegistry.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,108 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.ontology;
+
+import java.util.Set;
+
+import org.semanticweb.owlapi.model.IRI;
+
+/**
+ * A registry that keeps track of the active ontology scopes in a running KReS
+ * instance.
+ * 
+ * @author alessandro
+ * 
+ */
+public interface ScopeRegistry {
+
+	/**
+	 * Adds a scope registration listener to this registry. If the listener was
+	 * already added, this should result in no effect.
+	 * 
+	 * @param listener
+	 *            the listener to be added
+	 */
+	public void addScopeRegistrationListener(ScopeEventListener listener);
+
+	/**
+	 * Removes all registered scope registration listeners.
+	 */
+	public void clearScopeRegistrationListeners();
+
+	/**
+	 * 
+	 * @param scopeID
+	 * @return true iff an ontology scope with ID <code>scopeID</code> is
+	 *         registered.
+	 */
+	public boolean containsScope(IRI scopeID);
+
+	/**
+	 * Removes an ontology scope from this registry, thus deactivating the scope
+	 * and all of its associated spaces. All attached listeners should hear this
+	 * deregistration on their <code>scopeDeregistered()</code> method.
+	 * 
+	 * @param scope
+	 *            the ontology scope to be removed
+	 */
+	public void deregisterScope(OntologyScope scope);
+
+	/**
+	 * Returns the set of registered ontology scopes.
+	 * 
+	 * @return the set of ontology scopes
+	 */
+	public Set<OntologyScope> getRegisteredScopes();
+
+	/**
+	 * Returns the unique ontology scope identified by the given ID.
+	 * 
+	 * @param scopeID
+	 *            the scope identifier
+	 * @return the ontology scope with that ID, or null if no scope with such ID
+	 *         is registered
+	 */
+	public OntologyScope getScope(IRI scopeID);
+
+	public void setScopeActive(IRI scopeID, boolean active);
+
+	public boolean isScopeActive(IRI scopeID);
+
+	public Set<OntologyScope> getActiveScopes();
+
+	/**
+	 * Returns the set of registered scope registration listeners, in no
+	 * particular order.
+	 * 
+	 * @return the set of scope registration listeners
+	 */
+	public Set<ScopeEventListener> getScopeRegistrationListeners();
+
+	/**
+	 * Equivalent to <code>registerScope(scope, false)</code>.
+	 * 
+	 * @param scope
+	 *            the ontology scope to be added
+	 */
+	public void registerScope(OntologyScope scope);
+
+	/**
+	 * Adds an ontology scope to this registry, thus activating the scope if
+	 * <code>activate</code> is set and (at a bare minumum) its core space. All
+	 * attached listeners should hear this registration on their
+	 * <code>scopeRegistered()</code> method.
+	 * 
+	 * @param scope
+	 *            the ontology scope to be added
+	 */
+	public void registerScope(OntologyScope scope, boolean activate);
+
+	/**
+	 * Removes a scope registration listener from this registry. If the listener
+	 * was not previously added, this should result in no effect.
+	 * 
+	 * @param listener
+	 *            the listener to be removed
+	 */
+	public void removeScopeRegistrationListener(
+			ScopeEventListener listener);
+
+}

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/SessionOntologySpace.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/SessionOntologySpace.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/SessionOntologySpace.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/SessionOntologySpace.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,24 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.ontology;
+
+import org.semanticweb.owlapi.model.OWLOntologyManager;
+
+/**
+ * An ontology scope for application use. There exists exactly one scope for
+ * each live (active or halted) KReS session. <br>
+ * <br>
+ * This is the only type of ontology scope that allows public access to its OWL
+ * ontology manager.
+ * 
+ * @author alessandro
+ * 
+ */
+public interface SessionOntologySpace extends OntologySpace {
+
+	/**
+	 * Returns the OWL ontology manager associated to this scope.
+	 * 
+	 * @return the associated ontology manager
+	 */
+	public OWLOntologyManager getOntologyManager();
+
+}

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/SpaceType.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/SpaceType.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/SpaceType.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/SpaceType.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,17 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.ontology;
+
+public enum SpaceType {
+
+	CORE("core"), CUSTOM("custom"), SESSION("session");
+
+	private SpaceType(String suffix) {
+		this.suffix = suffix;
+	}
+
+	private String suffix;
+
+	public String getIRISuffix() {
+		return suffix;
+	}
+
+}

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/UnmodifiableOntologySpaceException.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/UnmodifiableOntologySpaceException.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/UnmodifiableOntologySpaceException.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/ontology/UnmodifiableOntologySpaceException.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,29 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.ontology;
+
+/**
+ * Thrown whenever an attempt to modify the ontology network within a read-only
+ * ontology space (e.g. a core or custom space in a bootstrapped system) is
+ * detected and denied.
+ * 
+ * @author alessandro
+ * 
+ */
+public class UnmodifiableOntologySpaceException extends
+		OntologySpaceModificationException {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 6747720213098173405L;
+
+	/**
+	 * Creates a new instance of UnmodifiableOntologySpaceException.
+	 * 
+	 * @param space
+	 *            the ontology space whose modification was attempted.
+	 */
+	public UnmodifiableOntologySpaceException(OntologySpace space) {
+		super(space);
+	}
+
+}

Propchange: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr  1 12:08:25 2011
@@ -0,0 +1 @@
+target

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryLoader.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryLoader.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryLoader.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/RegistryLoader.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,44 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.registry;
+
+import java.util.Set;
+
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.Registry;
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryContentException;
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryItem;
+import org.apache.stanbol.ontologymanager.ontonet.api.registry.models.RegistryLibrary;
+import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLOntology;
+import org.semanticweb.owlapi.model.OWLOntologyCreationException;
+import org.semanticweb.owlapi.model.OWLOntologyManager;
+
+public interface RegistryLoader {
+
+	
+	public Set<OWLOntology> gatherOntologies(RegistryItem registryItem,
+			OWLOntologyManager manager, boolean recurseRegistries)
+			throws OWLOntologyCreationException;
+			
+	public RegistryLibrary getLibrary(Registry reg, IRI libraryID);
+	
+	public Object getParent(Object child);
+
+	public boolean hasChildren(Object parent);
+
+	public boolean hasLibrary(Registry reg, IRI libraryID);
+
+//	public boolean isPrintingLoadedOntologies();
+
+	public void loadLocations() throws RegistryContentException;
+	
+	
+	/**
+	 * The ontology at <code>physicalIRI</code> may in turn include more than
+	 * one registry.
+	 * 
+	 * @param physicalIRI
+	 * @return
+	 */
+	public Set<Registry> loadRegistriesEager(IRI physicalIRI);
+
+//	public void setPrintLoadedOntologies(boolean doPrint);
+}

Propchange: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr  1 12:08:25 2011
@@ -0,0 +1 @@
+target

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/IRIRegistrySource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/IRIRegistrySource.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/IRIRegistrySource.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/IRIRegistrySource.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,60 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.registry.io;
+
+import java.io.InputStream;
+import java.io.Reader;
+
+import org.semanticweb.owlapi.model.IRI;
+
+public class IRIRegistrySource implements XDRegistrySource {
+
+	protected IRI iri;
+
+	public IRIRegistrySource(IRI physicalIRI) {
+		if (physicalIRI == null)
+			throw new RuntimeException(
+					"Cannot instantiate IRI registry source on null IRI.");
+		this.iri = physicalIRI;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.stlab.xd.registry.io.XDRegistrySource#getInputStream()
+	 */
+	@Override
+	public InputStream getInputStream() {
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.stlab.xd.registry.io.XDRegistrySource#getPhysicalIRI()
+	 */
+	@Override
+	public IRI getPhysicalIRI() {
+		return iri;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.stlab.xd.registry.io.XDRegistrySource#getReader()
+	 */
+	@Override
+	public Reader getReader() {
+		return null;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.stlab.xd.registry.io.XDRegistrySource#isInputStreamAvailable()
+	 */
+	@Override
+	public boolean isInputStreamAvailable() {
+		return false;
+	}
+
+	@Override
+	public boolean isReaderAvailable() {
+		return false;
+	}
+
+}

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/XDRegistrySource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/XDRegistrySource.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/XDRegistrySource.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/io/XDRegistrySource.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,29 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.registry.io;
+
+import java.io.InputStream;
+import java.io.Reader;
+
+import org.semanticweb.owlapi.model.IRI;
+
+public interface XDRegistrySource {
+	/**
+	 * Each invocation will return a new InputStream.
+	 * 
+	 * @return
+	 */
+	public InputStream getInputStream();
+
+	public IRI getPhysicalIRI();
+
+	/**
+	 * Each invocation will return a new Reader.
+	 * 
+	 * @return
+	 */
+	public Reader getReader();
+
+	public boolean isInputStreamAvailable();
+
+	public boolean isReaderAvailable();
+
+}

Propchange: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr  1 12:08:25 2011
@@ -0,0 +1 @@
+target

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/AbstractRegistryItem.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/AbstractRegistryItem.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/AbstractRegistryItem.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/AbstractRegistryItem.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,81 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.registry.models;
+
+import java.net.URL;
+
+
+
+public abstract class AbstractRegistryItem implements RegistryItem {
+	private URL url;
+	private String name;
+	private RegistryLibrary parent;
+
+	public AbstractRegistryItem(String name) {
+		setName(name);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.stlab.xd.registry.models.RegistryItem#setURL(java.net.URL)
+	 */
+	public void setURL(URL url) {
+		this.url = url;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.stlab.xd.registry.models.RegistryItem#getName()
+	 */
+	public String getName() {
+		return this.name;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.stlab.xd.registry.models.RegistryItem#getURL()
+	 */
+	public URL getURL() {
+		return this.url;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.stlab.xd.registry.models.RegistryItem#setParent(org.stlab.xd.registry
+	 * .models.RegistryLibrary)
+	 */
+	public void setParent(RegistryLibrary parent) {
+		this.parent = parent;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.stlab.xd.registry.models.RegistryItem#getParent()
+	 */
+	public RegistryLibrary getParent() {
+		return parent;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.stlab.xd.registry.models.RegistryItem#toString()
+	 */
+	@Override
+	public String toString() {
+		return getName();
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.stlab.xd.registry.models.RegistryItem#setName(java.lang.String)
+	 */
+	public void setName(String string) {
+		this.name = string;
+	}
+}

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/Registry.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/Registry.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/Registry.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/Registry.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,31 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.registry.models;
+
+
+public class Registry extends RegistryLibrary {
+
+	private String message = "";
+
+	public Registry(String name) {
+		super(name);
+	}
+
+	public void setError(String message) {
+		this.message = message;
+	}
+
+	public String getName() {
+		return super.getName() + getError();
+	}
+
+	public String getError() {
+		return this.message;
+	}
+
+	public boolean isOK() {
+		return this.getError().equals("");
+	}
+
+	public boolean isError() {
+		return !isOK();
+	}
+}

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryContentException.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryContentException.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryContentException.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryContentException.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,13 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.registry.models;
+
+public class RegistryContentException extends Exception {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+	public RegistryContentException(Throwable cause) {
+		initCause(cause);
+	}
+
+}

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryItem.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryItem.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryItem.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryItem.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,25 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.registry.models;
+
+import java.net.URL;
+
+public interface RegistryItem {
+
+	public abstract String getName();
+
+	public abstract RegistryLibrary getParent();
+
+	public abstract URL getURL();
+
+	public abstract boolean isLibrary();
+
+	public abstract boolean isOntology();
+
+	public abstract void setName(String string);
+
+	public abstract void setParent(RegistryLibrary parent);
+
+	public abstract void setURL(URL url);
+
+	public abstract String toString();
+
+}
\ No newline at end of file

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryLibrary.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryLibrary.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryLibrary.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryLibrary.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,48 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.registry.models;
+
+
+import java.util.ArrayList;
+
+
+public class RegistryLibrary extends AbstractRegistryItem {
+	
+	private ArrayList<AbstractRegistryItem> children;
+
+	public RegistryLibrary(String name) {
+		super(name);
+		children = new ArrayList<AbstractRegistryItem>();
+	}
+
+	public void addChild(AbstractRegistryItem child) {
+		children.add(child);
+		child.setParent(this);
+	}
+
+	public void removeChild(RegistryItem child) {
+		children.remove(child);
+		child.setParent(null);
+	}
+
+	public void removeChildren(){
+		children = new ArrayList<AbstractRegistryItem>();
+	}
+	public RegistryItem[] getChildren() {
+		return children
+				.toArray(new AbstractRegistryItem[children.size()]);
+	}
+
+	public boolean hasChildren() {
+		return children.size() > 0;
+	}
+
+	@Override
+	public boolean isLibrary() {
+		return true;
+	}
+
+	@Override
+	public boolean isOntology() {
+		return false;
+	}
+
+}

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryOntology.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryOntology.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryOntology.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/registry/models/RegistryOntology.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,20 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.registry.models;
+
+
+
+public class RegistryOntology extends AbstractRegistryItem {
+
+	public RegistryOntology(String name) {
+		super(name);
+	}
+
+	@Override
+	public boolean isLibrary() {
+		return false;
+	}
+
+	@Override
+	public boolean isOntology() {
+		return true;
+	}
+}

Propchange: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr  1 12:08:25 2011
@@ -0,0 +1 @@
+target

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/DuplicateSessionIDException.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/DuplicateSessionIDException.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/DuplicateSessionIDException.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/DuplicateSessionIDException.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,34 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.session;
+
+import org.apache.stanbol.ontologymanager.ontonet.api.DuplicateIDException;
+import org.semanticweb.owlapi.model.IRI;
+
+
+/**
+ * Thrown when attempting to create a KReSSession by forcing a session ID that
+ * is already registered, even if it used to be associated to a session that has
+ * been destroyed.
+ * 
+ * @author alessandro
+ * 
+ */
+public class DuplicateSessionIDException extends DuplicateIDException {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 3548783975623103351L;
+
+	public DuplicateSessionIDException(IRI dupe) {
+		super(dupe);
+	}
+
+	public DuplicateSessionIDException(IRI dupe, String message) {
+		super(dupe, message);
+	}
+
+	public DuplicateSessionIDException(IRI dupe, Throwable cause) {
+		super(dupe, cause);
+	}
+
+}

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/NonReferenceableSessionException.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/NonReferenceableSessionException.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/NonReferenceableSessionException.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/NonReferenceableSessionException.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,29 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.session;
+
+/**
+ * Thrown whenever an attempt to access a KReS session that is bound for removal
+ * is detected.
+ * 
+ * @author alessandro
+ * 
+ */
+public class NonReferenceableSessionException extends Exception {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1642512088759774124L;
+
+	public NonReferenceableSessionException() {
+
+	}
+
+	public NonReferenceableSessionException(String message) {
+		super(message);
+	}
+
+	public NonReferenceableSessionException(Throwable cause) {
+		initCause(cause);
+	}
+
+}

Added: 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=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/Session.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/Session.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,84 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.session;
+
+import org.semanticweb.owlapi.model.IRI;
+
+/**
+ * Note that KReS sessions are possibly disjoint with HTTP sessions or the like.
+ * 
+ * @author alessandro
+ * 
+ */
+public interface Session extends SessionListenable {
+
+	/**
+	 * The states a KReS session can be in: ACTIVE (for running sessions),
+	 * HALTED (for inactive sessions that may later be activated, e.g. when a
+	 * user logs in), ZOMBIE (inactive and bound for destruction, no longer
+	 * referenceable).
+	 * 
+	 * @author alessandro
+	 * 
+	 */
+	public enum State {
+		/**
+		 * Running session
+		 */
+		ACTIVE,
+		/**
+		 * inactive sessions that may later be activated
+		 */
+		HALTED,
+		/**
+		 * Inactive and bound for destruction, no longer referenceable
+		 */
+		ZOMBIE
+	}
+
+	/**
+	 * Closes this KReS Session irreversibly. Most likely includes setting the
+	 * state to ZOMBIE.
+	 */
+	public void close() throws NonReferenceableSessionException;
+
+	/**
+	 * Returns the unique Internationalized Resource Identifier (IRI) that
+	 * identifies this KReS session.<br>
+	 * <br>
+	 * NOTE: There is no set method for the session ID as it is assumed to be
+	 * set in its constructor once and for all.
+	 * 
+	 * @return the IRI that identifies this session
+	 */
+	public IRI getID();
+
+	/**
+	 * Returns the current state of this KReS session.
+	 * 
+	 * @return the state of this session
+	 */
+	public State getSessionState();
+
+	/**
+	 * Equivalent to <code>getState() == State.ACTIVE</code>.
+	 * 
+	 * @return true iff this session is in the ACTIVE state
+	 */
+	public boolean isActive();
+	
+	public void open() throws NonReferenceableSessionException;
+
+	/**
+	 * Sets the KReS session as ACTIVE if <code>active</code> is true, INACTIVE
+	 * otherwise. The state set is returned, which should match the input state
+	 * unless an error occurs.<br>
+	 * <br>
+	 * Should throw an exception if this session is in a ZOMBIE state.
+	 * 
+	 * @param active
+	 *            the desired activity state for this session
+	 * @return the resulting state of this KReS session
+	 */
+	public State setActive(boolean active)
+			throws NonReferenceableSessionException;
+
+}

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionEvent.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionEvent.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionEvent.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionEvent.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,53 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.session;
+
+/**
+ * An event that encompasses a change in the state of a KReS session.
+ * 
+ * @author alessandro
+ * 
+ */
+public class SessionEvent {
+
+	public static enum OperationType {
+		ACTIVATE, CLOSE, CREATE, DEACTIVATE, KILL, STORE;
+	};
+
+	/**
+	 * The KReS session affected by this event.
+	 */
+	private Session affectedSession;
+
+	private OperationType operationType;
+
+	public OperationType getOperationType() {
+		return operationType;
+	}
+
+	/**
+	 * Creates a new instance of SessionEvent.
+	 * 
+	 * @param session
+	 *            the KReS session affected by this event
+	 */
+	public SessionEvent(Session session, OperationType operationType)
+			throws Exception {
+		if (operationType == null)
+			throw new Exception(
+					"No operation type specified for this session event.");
+		if (session == null)
+			throw new Exception(
+					"No KReS session specified for this session event.");
+		this.operationType = operationType;
+		this.affectedSession = session;
+	}
+
+	/**
+	 * Returns the KReS session affected by this event.
+	 * 
+	 * @return the affected KReS session
+	 */
+	public Session getSession() {
+		return affectedSession;
+	}
+
+}

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionIDGenerator.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionIDGenerator.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionIDGenerator.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionIDGenerator.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,56 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.session;
+
+import java.util.Set;
+
+import org.semanticweb.owlapi.model.IRI;
+
+/**
+ * Implementations of this interface provide algorithms for generating valid
+ * identifiers for KReS sessions. These algorithms should take into account the
+ * need for excluding existing session IDs.
+ * 
+ * @author alessandro
+ * 
+ */
+public interface SessionIDGenerator {
+
+	/**
+	 * Generates a new context-free session ID. Whether this causes duplicate
+	 * IDs, it should be care of the object that invoked this method to check
+	 * it.
+	 * 
+	 * @return the newly generated session ID.
+	 */
+	public IRI createSessionID();
+
+	/**
+	 * Generates a new session ID that is different from any IRI in the
+	 * <code>exclude</code> set. Whether this causes duplicate IDs (supposing
+	 * the <code>exclude</code> set does not include all of them), it should be
+	 * care of the object that invoked this method to check it.
+	 * 
+	 * @param exclude
+	 *            the set of IRIs none of which the generate ID must be equal
+	 *            to.
+	 * @return the newly generated session ID.
+	 */
+	public IRI createSessionID(Set<IRI> exclude);
+
+	/**
+	 * Returns the base IRI for all generated IDs to start with. It should be
+	 * used by all <code>createSessionID()</code> methods, or ignore if null.
+	 * 
+	 * @param baseIRI
+	 *            the base IRI.
+	 */
+	public IRI getBaseIRI();
+
+	/**
+	 * Sets the base IRI for all generated IDs to start with. It should be used
+	 * by all <code>createSessionID()</code> methods, or ignore if null.
+	 * 
+	 * @param baseIRI
+	 *            the base IRI.
+	 */
+	public void setBaseIRI(IRI baseIRI);
+}

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionListenable.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionListenable.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionListenable.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionListenable.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,38 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.session;
+
+import java.util.Collection;
+
+public interface SessionListenable {
+
+	/**
+	 * Adds the given SessionListener to the pool of registered listeners.
+	 * 
+	 * @param listener
+	 *            the session listener to be added
+	 */
+	public void addSessionListener(SessionListener listener);
+
+	/**
+	 * Clears the pool of registered session listeners.
+	 */
+	public void clearSessionListeners();
+
+	/**
+	 * Returns all the registered session listeners. It is up to developers to
+	 * decide whether implementations should return sets (unordered but without
+	 * redundancy), lists (e.g. in the order they wer registered but potentially
+	 * redundant) or other data structures that implement {@link Collection}.
+	 * 
+	 * @return a collection of registered session listeners.
+	 */
+	public Collection<SessionListener> getSessionListeners();
+
+	/**
+	 * Removes the given SessionListener from the pool of active listeners.
+	 * 
+	 * @param listener
+	 *            the session listener to be removed
+	 */
+	public void removeSessionListener(SessionListener listener);
+
+}

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionListener.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionListener.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionListener.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionListener.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,20 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.session;
+
+/**
+ * Objects that want to listen to events affecting KReS sessions should
+ * implement this interface and add themselves as listener to a manager.
+ * 
+ * @author alessandro
+ * 
+ */
+public interface SessionListener {
+
+	/**
+	 * Called whenever an event affecting a KReS session is fired.
+	 * 
+	 * @param event
+	 *            the session event.
+	 */
+	public void sessionChanged(SessionEvent event);
+
+}

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionManager.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionManager.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionManager.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/api/session/SessionManager.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,88 @@
+package org.apache.stanbol.ontologymanager.ontonet.api.session;
+
+import java.io.OutputStream;
+import java.util.Set;
+
+import org.apache.stanbol.ontologymanager.ontonet.api.ontology.SessionOntologySpace;
+import org.semanticweb.owlapi.model.IRI;
+
+
+/**
+ * Manages KReS session objects via CRUD-like operations. A
+ * <code>SessionManager</code> maintains in-memory storage of KReS sessions,
+ * creates new ones and either destroys or stores existing ones persistently.
+ * All KReS sessions are managed via unique identifiers of the
+ * <code>org.semanticweb.owlapi.model.IRI</code> type.<br>
+ * <br>
+ * NOTE: implementations should be synchronized, or document whenever they are
+ * not.
+ * 
+ * @author alessandro
+ * 
+ */
+public interface SessionManager extends SessionListenable {
+
+	public Set<IRI> getRegisteredSessionIDs();
+
+	/**
+	 * Generates AND REGISTERS a new KReS session and assigns a unique session
+	 * ID generated internally.
+	 * 
+	 * @return the generated KReS session
+	 */
+	public Session createSession();
+
+	/**
+	 * Generates AND REGISTERS a new KReS session and tries to assign it the
+	 * supplied session ID. If a session with that ID is already registered, the
+	 * new session is <i>not</i> created and a
+	 * <code>DuplicateSessionIDException</code> is thrown.
+	 * 
+	 * @param sessionID
+	 *            the IRI that uniquely identifies the session
+	 * @return the generated KReS session
+	 * @throws DuplicateSessionIDException
+	 *             if a KReS session with that sessionID is already registered
+	 */
+	public Session createSession(IRI sessionID)
+			throws DuplicateSessionIDException;
+
+	/**
+	 * Deletes the KReS session identified by the supplied sessionID and
+	 * releases its resources.
+	 * 
+	 * @param sessionID
+	 *            the IRI that uniquely identifies the session
+	 */
+	public void destroySession(IRI sessionID);
+
+	/**
+	 * Retrieves the unique KReS session identified by <code>sessionID</code>.
+	 * 
+	 * @param sessionID
+	 *            the IRI that uniquely identifies the session
+	 * @return the unique KReS session identified by <code>sessionID</code>
+	 */
+	public Session getSession(IRI sessionID);
+
+	/**
+	 * Returns the ontology space associated with this session.
+	 * 
+	 * @return the session space
+	 */
+	public Set<SessionOntologySpace> getSessionSpaces(IRI sessionID)
+			throws NonReferenceableSessionException;
+
+	/**
+	 * Stores the KReS session identified by <code>sessionID</code> using the
+	 * output stream <code>out</code>.
+	 * 
+	 * @param sessionID
+	 *            the IRI that uniquely identifies the session
+	 * @param out
+	 *            the output stream to store the session
+	 */
+	public void storeSession(IRI sessionID, OutputStream out)
+			throws NonReferenceableSessionException;
+
+}

Propchange: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Apr  1 12:08:25 2011
@@ -0,0 +1 @@
+target

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/Activator.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/Activator.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/Activator.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/Activator.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,61 @@
+package org.apache.stanbol.ontologymanager.ontonet.impl;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Called upon OSGi bundle startup and shutdown, it constructs and releases the
+ * resources required by the KReS Ontology Network Manager during its activity.
+ * 
+ * @author alessandro
+ * 
+ */
+public class Activator implements BundleActivator {
+
+	@Override
+	public void start(BundleContext context) throws Exception {
+
+		// context.addBundleListener(new BundleListener() {
+		//			
+		// @Override
+		// public void bundleChanged(BundleEvent event) {
+		// System.err.println("BundleEvent has fired");
+		//				
+		// }
+		// });
+		// context.addFrameworkListener(new FrameworkListener() {
+		//			
+		// @Override
+		// public void frameworkEvent(FrameworkEvent event) {
+		// System.err.println("FrameworkEvent has fired");
+		//				
+		// }
+		// });
+		// context.addServiceListener(new ServiceListener() {
+		//			
+		// @Override
+		// public void serviceChanged(ServiceEvent event) {
+		// System.err.println("ServiceEvent has fired");
+		//				
+		// }
+		// });
+		// context.getBundle().getLocation();
+		// Instantiate the static context for the KReS ONM
+
+		Logger log = LoggerFactory.getLogger(this.getClass());
+		log.debug("KReS :: Instantiating ONM static context...");
+//		if (ONManager.get() != null) {
+//			log.debug("KReS :: ONM static context instantiated.");
+			log.info("KReS :: Ontology Network Manager set up.");
+//		}
+	}
+
+	@Override
+	public void stop(BundleContext context) throws Exception {
+		LoggerFactory.getLogger(this.getClass()).info(
+				"KReS :: Ontology Network Manager brought down.");
+	}
+
+}

Added: incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ConfigurationManagement.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ConfigurationManagement.java?rev=1087671&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ConfigurationManagement.java (added)
+++ incubator/stanbol/trunk/ontologymanager/ontonet/src/main/java/org/apache/stanbol/ontologymanager/ontonet/impl/ConfigurationManagement.java Fri Apr  1 12:08:25 2011
@@ -0,0 +1,273 @@
+package org.apache.stanbol.ontologymanager.ontonet.impl;
+
+import static org.apache.stanbol.ontologymanager.ontonet.impl.util.OntologyConstants.*;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.semanticweb.owlapi.apibinding.OWLManager;
+import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLClass;
+import org.semanticweb.owlapi.model.OWLClassExpression;
+import org.semanticweb.owlapi.model.OWLDataFactory;
+import org.semanticweb.owlapi.model.OWLDataProperty;
+import org.semanticweb.owlapi.model.OWLIndividual;
+import org.semanticweb.owlapi.model.OWLLiteral;
+import org.semanticweb.owlapi.model.OWLNamedIndividual;
+import org.semanticweb.owlapi.model.OWLObjectProperty;
+import org.semanticweb.owlapi.model.OWLOntology;
+
+/**
+ * <p>
+ * This is the helper class for parsing the ONM configuration ontology. The
+ * configuration ontology should import the following:
+ * </p>
+ * <ul>
+ * <li>http://ontologydesignpatterns.org/ont/iks/kres/onm.owl</li>
+ * </ul>
+ * 
+ * <p>
+ * and must use the following vocabs:
+ * </p>
+ * <ul>
+ * <li>http://kres.iks-project.eu/ontology/meta/onm.owl#Scope : defines a scope</li>
+ * <li>http://kres.iks-project.eu/ontology/meta/onm.owl#activateOnStart :
+ * activate the scope on startup</li>
+ * <li>http://kres.iks-project.eu/ontology/meta/onm.owl#usesCoreOntology :
+ * relates a scope to an ontology to be added in the core space</li>
+ * <li>http://kres.iks-project.eu/ontology/meta/onm.owl#usesCoreLibrary :
+ * relates a scope to a library of ontologies to be added in the core space</li>
+ * <li>http://kres.iks-project.eu/ontology/meta/onm.owl#usesCustomOntology :
+ * relates a scope to an ontology to be added in the custom space</li>
+ * <li>http://kres.iks-project.eu/ontology/meta/onm.owl#usesCustomLibrary :
+ * relates scope to a library of ontologies to be added in the custom space</li>
+ * <li>
+ * http://www.ontologydesignpatterns.org/cpont/codo/coddata.owl#OntologyLibrary
+ * : the class of a library</li>
+ * <li>http://www.ontologydesignpatterns.org/schemas/meta.owl#hasOntology : to
+ * relate a library to an ontology</li>
+ * </ul>
+ * 
+ * @author alessandro
+ * @author enridaga
+ */
+public class ConfigurationManagement {
+
+	private static OWLDataFactory _df = OWLManager.getOWLDataFactory();
+
+	private static final String[] EMPTY_IRI_ARRAY = new String[0];
+
+	private static final OWLClass cScope = _df.getOWLClass(IRI.create(NS_ONM
+			+ "Scope"));
+
+	private static final OWLClass cLibrary = _df
+			.getOWLClass(IRI
+					.create("http://www.ontologydesignpatterns.org/cpont/codo/coddata.owl#OntologyLibrary"));
+
+	private static final OWLDataProperty activateOnStart = _df
+			.getOWLDataProperty(IRI.create(NS_ONM + "activateOnStart"));
+
+	private static final OWLObjectProperty usesCoreOntology = _df
+			.getOWLObjectProperty(IRI.create(NS_ONM + "usesCoreOntology"));
+
+	private static final OWLObjectProperty usesCoreLibrary = _df
+			.getOWLObjectProperty(IRI.create(NS_ONM + "usesCoreLibrary"));
+
+	private static final OWLObjectProperty usesCustomOntology = _df
+			.getOWLObjectProperty(IRI.create(NS_ONM + "usesCustomOntology"));
+
+	private static final OWLObjectProperty usesCustomLibrary = _df
+			.getOWLObjectProperty(IRI.create(NS_ONM + "usesCustomLibrary"));
+
+	private static final OWLObjectProperty libraryHasOntology = _df
+			.getOWLObjectProperty(IRI.create(NS_ONM + "hasOntology"));
+
+	/**
+	 * Get the list of scopes to activate on startup
+	 * 
+	 * @param config
+	 * @return
+	 */
+	public static String[] getScopesToActivate(OWLOntology config) {
+
+		Set<OWLIndividual> scopes = cScope.getIndividuals(config);
+		List<String> result = new ArrayList<String>();
+		boolean doActivate = false;
+		for (OWLIndividual iScope : scopes) {
+			Set<OWLLiteral> activate = iScope.getDataPropertyValues(
+					activateOnStart, config);
+
+			Iterator<OWLLiteral> it = activate.iterator();
+			while (it.hasNext() && !doActivate) {
+				OWLLiteral l = it.next();
+				if (l.isOWLTypedLiteral())
+					doActivate |= Boolean.parseBoolean(l.asOWLTypedLiteral()
+							.getLiteral());
+			}
+
+			if (iScope.isNamed() && doActivate)
+				result.add(((OWLNamedIndividual) iScope).getIRI().toString());
+		}
+
+		return result.toArray(EMPTY_IRI_ARRAY);
+	}
+
+	/**
+	 * To get all the instances of Scope in this configuration
+	 * 
+	 * @param config
+	 * @return
+	 */
+	public static String[] getScopes(OWLOntology config) {
+		Set<OWLIndividual> scopes = cScope.getIndividuals(config);
+		List<String> result = new ArrayList<String>();
+		for (OWLIndividual iScope : scopes) {
+			for (OWLClassExpression sce : iScope.getTypes(config)) {
+				if (sce.containsConjunct(cScope)) {
+					if (iScope.isNamed()) {
+						result.add(((OWLNamedIndividual) iScope).getIRI()
+								.toString());
+					}
+				}
+			}
+		}
+		return result.toArray(EMPTY_IRI_ARRAY);
+	}
+
+	/**
+	 * Utility method to get all the values of an object property of a Scope
+	 * 
+	 * @param ontology
+	 * @param individualIRI
+	 * @param op
+	 * @return
+	 */
+	private static String[] getScopeObjectPropertyValues(OWLOntology ontology,
+			String individualIRI, OWLObjectProperty op) {
+		Set<OWLIndividual> scopes = cScope.getIndividuals(ontology);
+		List<String> result = new ArrayList<String>();
+
+		OWLIndividual iiScope = null;
+
+		// Optimised loop.
+		for (OWLIndividual ind : scopes) {
+			if (ind.isAnonymous())
+				continue;
+			if (((OWLNamedIndividual) ind).getIRI().toString().equals(
+					individualIRI)) {
+				iiScope = ind;
+				break;
+			}
+		}
+
+		if (iiScope != null) {
+
+		}
+
+		for (OWLIndividual iScope : scopes) {
+			if (iScope.isNamed()) {
+				if (((OWLNamedIndividual) iScope).getIRI().toString().equals(
+						individualIRI)) {
+					Set<OWLIndividual> values = iScope.getObjectPropertyValues(
+							op, ontology);
+
+					Iterator<OWLIndividual> it = values.iterator();
+					while (it.hasNext()) {
+						OWLIndividual i = it.next();
+						if (i.isNamed())
+							result.add(((OWLNamedIndividual) i).getIRI()
+									.toString());
+					}
+				}
+			}
+		}
+
+		return result.toArray(EMPTY_IRI_ARRAY);
+	}
+
+	/**
+	 * Utility method to get all the values of a property from a Library subject
+	 * 
+	 * @param ontology
+	 * @param individualIRI
+	 * @param op
+	 * @return
+	 */
+	private static String[] getLibraryObjectPropertyValues(
+			OWLOntology ontology, String individualIRI, OWLObjectProperty op) {
+		Set<OWLIndividual> scopes = cLibrary.getIndividuals(ontology);
+		List<String> result = new ArrayList<String>();
+
+		for (OWLIndividual iLibrary : scopes) {
+			if (iLibrary.isNamed()) {
+				if (((OWLNamedIndividual) iLibrary).getIRI().toString().equals(
+						individualIRI)) {
+					Set<OWLIndividual> values = iLibrary
+							.getObjectPropertyValues(op, ontology);
+
+					Iterator<OWLIndividual> it = values.iterator();
+					while (it.hasNext()) {
+						OWLIndividual i = it.next();
+						if (i.isNamed())
+							result.add(((OWLNamedIndividual) iLibrary).getIRI()
+									.toString());
+					}
+				}
+			}
+		}
+
+		return result.toArray(EMPTY_IRI_ARRAY);
+	}
+
+	/**
+	 * Returns all the IRIs to be loaded in the core space of the scope
+	 * 
+	 * @param config
+	 * @param scopeIRI
+	 * @return
+	 */
+	public static String[] getCoreOntologies(OWLOntology config, String scopeIRI) {
+		List<String> ontologies = new ArrayList<String>();
+		ontologies.addAll(Arrays.asList(getScopeObjectPropertyValues(config,
+				scopeIRI, usesCoreOntology)));
+
+		for (String libraryID : getCoreLibraries(config, scopeIRI)) {
+			ontologies.addAll(Arrays.asList(getLibraryObjectPropertyValues(
+					config, libraryID, libraryHasOntology)));
+		}
+		return ontologies.toArray(new String[ontologies.size()]);
+	}
+
+	/**
+	 * Returns all the resources to be part of the Custom space
+	 * 
+	 * @param config
+	 * @param scopeIRI
+	 * @return
+	 */
+	public static String[] getCustomOntologies(OWLOntology config,
+			String scopeIRI) {
+		List<String> ontologies = new ArrayList<String>();
+		ontologies.addAll(Arrays.asList(getScopeObjectPropertyValues(config,
+				scopeIRI, usesCustomOntology)));
+
+		for (String libraryID : getCustomLibraries(config, scopeIRI)) {
+			ontologies.addAll(Arrays.asList(getLibraryObjectPropertyValues(
+					config, libraryID, libraryHasOntology)));
+		}
+		return ontologies.toArray(new String[ontologies.size()]);
+	}
+
+	private static String[] getCoreLibraries(OWLOntology config, String scopeIRI) {
+		return getScopeObjectPropertyValues(config, scopeIRI, usesCoreLibrary);
+	}
+
+	private static String[] getCustomLibraries(OWLOntology config,
+			String scopeIRI) {
+		return getScopeObjectPropertyValues(config, scopeIRI, usesCustomLibrary);
+	}
+
+}