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

svn commit: r1394600 [4/5] - in /stanbol/trunk/ontologymanager/generic: core/ core/src/ core/src/license/ core/src/main/ core/src/main/java/ core/src/main/java/org/ core/src/main/java/org/apache/ core/src/main/java/org/apache/stanbol/ core/src/main/jav...

Added: stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/scope/ScopeEventListenable.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/scope/ScopeEventListenable.java?rev=1394600&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/scope/ScopeEventListenable.java (added)
+++ stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/scope/ScopeEventListenable.java Fri Oct  5 15:42:33 2012
@@ -0,0 +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.
+ */
+package org.apache.stanbol.ontologymanager.servicesapi.scope;
+
+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.<br/>
+ * <br/>
+ * This interface adds support for CRUD operations on scope event listeners.
+ * 
+ */
+public interface ScopeEventListenable {
+
+    /**
+     * 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);
+
+}

Added: stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/scope/ScopeEventListener.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/scope/ScopeEventListener.java?rev=1394600&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/scope/ScopeEventListener.java (added)
+++ stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/scope/ScopeEventListener.java Fri Oct  5 15:42:33 2012
@@ -0,0 +1,71 @@
+/*
+* 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.servicesapi.scope;
+
+/**
+ * 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 alexdma
+ * 
+ */
+public interface ScopeEventListener {
+
+	/**
+	 * Called <i>after</i> an ontology scope, assuming it is already registered
+	 * somewhere, is activated.
+	 * 
+	 * @param scope
+	 *            the activated ontology scope
+	 */
+    void scopeActivated(Scope scope);
+
+	/**
+	 * Called <i>after</i> a new ontology scope has been created.
+	 * 
+	 * @param scope
+	 *            the created ontology scope
+	 */
+    void scopeCreated(Scope 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
+	 */
+    void scopeDeactivated(Scope scope);
+
+	/**
+	 * Called <i>after</i> an ontology scope is removed from the scope registry.
+	 * 
+	 * @param scope
+	 *            the deregistered ontology scope
+	 */
+    void scopeUnregistered(Scope scope);
+
+	/**
+	 * Called <i>after</i> an ontology scope is added to the scope registry.
+	 * 
+	 * @param scope
+	 *            the registered ontology scope
+	 */
+    void scopeRegistered(Scope scope);
+
+}

Added: stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/scope/ScopeFactory.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/scope/ScopeFactory.java?rev=1394600&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/scope/ScopeFactory.java (added)
+++ stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/scope/ScopeFactory.java Fri Oct  5 15:42:33 2012
@@ -0,0 +1,39 @@
+/*
+ * 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.servicesapi.scope;
+
+import org.apache.stanbol.ontologymanager.servicesapi.collector.DuplicateIDException;
+import org.apache.stanbol.ontologymanager.servicesapi.io.OntologyInputSource;
+
+public interface ScopeFactory {
+
+    /**
+     * 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.
+     */
+    Scope createOntologyScope(String scopeID, OntologyInputSource<?>... coreOntologies) throws DuplicateIDException;
+
+}

Added: stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/scope/ScopeManager.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/scope/ScopeManager.java?rev=1394600&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/scope/ScopeManager.java (added)
+++ stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/scope/ScopeManager.java Fri Oct  5 15:42:33 2012
@@ -0,0 +1,109 @@
+/*
+ * 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.servicesapi.scope;
+
+import java.io.File;
+
+import org.apache.stanbol.ontologymanager.servicesapi.OfflineConfiguration;
+import org.apache.stanbol.ontologymanager.servicesapi.io.OntologyInputSource;
+
+/**
+ * An Ontology Network Manager holds all references and tools for creating, modifying and deleting the logical
+ * realms that store Web Ontologies, as well as offer facilities for handling the ontologies contained
+ * therein.<br>
+ * <br>
+ * Note that since this object is both a {@link ScopeRegistry} and an {@link ScopeFactory}, the call to
+ * {@link ScopeRegistry#registerScope(OntologyScope)} or its overloads after
+ * {@link ScopeFactory#createOntologyScope(String, OntologyInputSource...)} is unnecessary, as the ONManager
+ * automatically registers newly created scopes.
+ * 
+ * @author alexdma, anuzzolese
+ * 
+ */
+public interface ScopeManager extends ScopeFactory, ScopeRegistry {
+
+    /**
+     * The key used to configure the path of the ontology network configuration.
+     */
+    String CONFIG_ONTOLOGY_PATH = "org.apache.stanbol.ontologymanager.ontonet.onconfig";
+
+    /**
+     * The key used to configure the connectivity policy.
+     */
+    String CONNECTIVITY_POLICY = "org.apache.stanbol.ontologymanager.ontonet.connectivity";
+
+    /**
+     * The key used to configure the simple identifier of the scope registry (which should also be
+     * concatenated with the base namespace to obtain the registry's HTTP endpoint URI).
+     */
+    String ID_SCOPE_REGISTRY = "org.apache.stanbol.ontologymanager.ontonet.scopeRegistry.id";
+
+    /**
+     * Returns the offline configuration set for this ontology network manager, if any.
+     * 
+     * @return the offline configuration, or null if none was set.
+     */
+    OfflineConfiguration getOfflineConfiguration();
+
+    /**
+     * Implementations should be able to create a {@link File} object from this path.
+     * 
+     * @return the local path of the ontology storing the ontology network configuration.
+     */
+    String getOntologyNetworkConfigurationPath();
+
+    /**
+     * Returns the base namespace to be used for the Stanbol ontology network (e.g. for the creation of new
+     * scopes). For convenience, it is returned as a string so that it can be concatenated to form IRIs.
+     * 
+     * @deprecated please use {@link OfflineConfiguration#getDefaultOntologyNetworkNamespace()} to obtain the
+     *             namespace
+     * 
+     * @return the base namespace of the Stanbol ontology network.
+     */
+    String getOntologyNetworkNamespace();
+
+    /**
+     * Returns the ontology space factory that was created along with the manager context. <br>
+     * <br>
+     * Note: Because this can be backend-dependent, this method is not deprecated yet.
+     * 
+     * @return the default ontology space factory.
+     */
+    PersistentCollectorFactory getPersistentCollectorFactory();
+
+    /**
+     * Returns the unique ontology scope registry for this context.
+     * 
+     * @deprecated This methods now returns the current object, which is also a {@link ScopeRegistry}.
+     * @return the ontology scope registry.
+     */
+    ScopeRegistry getScopeRegistry();
+
+    /**
+     * Sets the IRI that will be the base namespace for all ontology scopes and collectors created by this
+     * object.
+     * 
+     * @deprecated {@link ScopeManager} should set its namespace to be the same as
+     *             {@link OfflineConfiguration#getDefaultOntologyNetworkNamespace()} whenever it changes on
+     *             the object obtained by calling {@link #getOfflineConfiguration()}.
+     * 
+     * @param namespace
+     *            the base namespace.
+     */
+    void setOntologyNetworkNamespace(String namespace);
+}

Added: stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/scope/ScopeRegistry.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/scope/ScopeRegistry.java?rev=1394600&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/scope/ScopeRegistry.java (added)
+++ stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/scope/ScopeRegistry.java Fri Oct  5 15:42:33 2012
@@ -0,0 +1,120 @@
+/*
+ * 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.servicesapi.scope;
+
+import java.util.Set;
+
+import org.apache.stanbol.ontologymanager.servicesapi.collector.DuplicateIDException;
+
+/**
+ * A registry that keeps track of the active ontology scopes in a running KReS instance. <br>
+ * <br>
+ * TODO deprecate scope registration methods and manage registration automcatically.
+ * 
+ * @author alexdma
+ * 
+ */
+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
+     */
+    void addScopeRegistrationListener(ScopeEventListener listener);
+
+    /**
+     * Removes all registered scope registration listeners.
+     */
+    void clearScopeRegistrationListeners();
+
+    /**
+     * 
+     * @param scopeID
+     * @return true iff an ontology scope with ID <code>scopeID</code> is registered.
+     */
+    boolean containsScope(String 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
+     */
+    void deregisterScope(Scope scope);
+
+    Set<Scope> getActiveScopes();
+
+    /**
+     * Returns the set of registered ontology scopes.
+     * 
+     * @return the set of ontology scopes
+     */
+    Set<Scope> 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
+     */
+    Scope getScope(String scopeID);
+
+    /**
+     * Returns the set of registered scope registration listeners, in no particular order.
+     * 
+     * @return the set of scope registration listeners
+     */
+    Set<ScopeEventListener> getScopeRegistrationListeners();
+
+    boolean isScopeActive(String scopeID);
+
+    /**
+     * Equivalent to <code>registerScope(scope, false)</code>.
+     * 
+     * @param scope
+     *            the ontology scope to be added
+     */
+    void registerScope(Scope scope) throws DuplicateIDException;
+
+    /**
+     * 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
+     */
+    void registerScope(Scope scope, boolean activate) throws DuplicateIDException;
+
+    /**
+     * 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
+     */
+    void removeScopeRegistrationListener(ScopeEventListener listener);
+
+    void setScopeActive(String scopeID, boolean active);
+
+}

Added: stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/DuplicateSessionIDException.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/DuplicateSessionIDException.java?rev=1394600&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/DuplicateSessionIDException.java (added)
+++ stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/DuplicateSessionIDException.java Fri Oct  5 15:42:33 2012
@@ -0,0 +1,47 @@
+/*
+ * 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.servicesapi.session;
+
+import org.apache.stanbol.ontologymanager.servicesapi.collector.DuplicateIDException;
+
+/**
+ * Thrown when attempting to create a {@link Session} by forcing a session ID that is already registered, even
+ * if it used to be associated to a session that has been destroyed.
+ * 
+ * @author alexdma
+ * 
+ */
+public class DuplicateSessionIDException extends DuplicateIDException {
+
+    /**
+	 * 
+	 */
+    private static final long serialVersionUID = 3548783975623103351L;
+
+    public DuplicateSessionIDException(String dupe) {
+        super(dupe);
+    }
+
+    public DuplicateSessionIDException(String dupe, String message) {
+        super(dupe, message);
+    }
+
+    public DuplicateSessionIDException(String dupe, Throwable cause) {
+        super(dupe, cause);
+    }
+
+}

Added: stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/NonReferenceableSessionException.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/NonReferenceableSessionException.java?rev=1394600&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/NonReferenceableSessionException.java (added)
+++ stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/NonReferenceableSessionException.java Fri Oct  5 15:42:33 2012
@@ -0,0 +1,42 @@
+/*
+ * 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.servicesapi.session;
+
+/**
+ * Thrown whenever an attempt to access a session that is bound for removal is detected.
+ * 
+ * @author alexdma
+ * 
+ */
+public class NonReferenceableSessionException extends RuntimeException {
+
+    /**
+	 * 
+	 */
+    private static final long serialVersionUID = 1642512088759774124L;
+
+    public NonReferenceableSessionException() {}
+
+    public NonReferenceableSessionException(String message) {
+        super(message);
+    }
+
+    public NonReferenceableSessionException(Throwable cause) {
+        initCause(cause);
+    }
+
+}

Added: stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/Session.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/Session.java?rev=1394600&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/Session.java (added)
+++ stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/Session.java Fri Oct  5 15:42:33 2012
@@ -0,0 +1,126 @@
+/*
+ * 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.servicesapi.session;
+
+import java.util.Set;
+
+import org.apache.stanbol.ontologymanager.servicesapi.collector.Lockable;
+import org.apache.stanbol.ontologymanager.servicesapi.collector.OntologyCollector;
+import org.apache.stanbol.ontologymanager.servicesapi.ontology.OWLExportable;
+
+/**
+ * Note that sessions are possibly disjoint with HTTP sessions or the like.
+ * 
+ * @author alexdma
+ * 
+ */
+public interface Session extends OntologyCollector, OWLExportable, Lockable, SessionListenable {
+
+    static final String shortName = "session";
+
+    /**
+     * The states a 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 alexdma
+     * 
+     */
+    enum State {
+        /**
+         * Running session
+         */
+        ACTIVE,
+        /**
+         * inactive sessions that may later be activated
+         */
+        HALTED,
+        /**
+         * Inactive and bound for destruction, no longer referenceable
+         */
+        ZOMBIE
+    }
+
+    /**
+     * Instructs the session to reference the supplied ontology scope. This way, whenever session data are
+     * processed, scope data will be considered as well.
+     * 
+     * @param scope
+     *            the ontology scope to be referenced.
+     */
+    void attachScope(String scopeId);
+
+    /**
+     * Removes all references to ontology scopes, thus leaving the session data as standalone.
+     */
+    void clearScopes();
+
+    /**
+     * Closes this Session irreversibly. Most likely includes setting the state to ZOMBIE.
+     */
+    void close();
+
+    /**
+     * Instructs the session to no longer reference the supplied ontology scope. If a scope with the supplied
+     * identifier was not attached, this method has no effect.
+     * 
+     * @param scope
+     *            the identifer of the ontology scope to be detached.
+     */
+    void detachScope(String scopeId);
+
+    /**
+     * Gets the identifiers of the scopes currently attached to this session.
+     * 
+     * @return the attached scope identifiers
+     */
+    Set<String> getAttachedScopes();
+
+    /**
+     * Returns the current state of this KReS session.
+     * 
+     * @return the state of this session
+     */
+    State getSessionState();
+
+    /**
+     * Equivalent to <code>getState() == State.ACTIVE</code>.
+     * 
+     * @return true iff this session is in the ACTIVE state
+     */
+    boolean isActive();
+
+    /**
+     * Sets this session as active
+     * 
+     * @throws NonReferenceableSessionException
+     */
+    void open();
+
+    /**
+     * Sets the 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
+     */
+    State setActive(boolean active);
+
+}

Added: stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/SessionEvent.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/SessionEvent.java?rev=1394600&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/SessionEvent.java (added)
+++ stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/SessionEvent.java Fri Oct  5 15:42:33 2012
@@ -0,0 +1,71 @@
+/*
+ * 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.servicesapi.session;
+
+/**
+ * An event that encompasses a change in the state of a KReS session.
+ * 
+ * @author alexdma
+ * 
+ */
+public class SessionEvent {
+
+    public enum OperationType {
+        ACTIVATE,
+        CLOSE,
+        CREATE,
+        DEACTIVATE,
+        KILL,
+        STORE
+    }
+
+    /**
+     * The session affected by this event.
+     */
+    private Session affectedSession;
+
+    private OperationType operationType;
+
+    /**
+     * Creates a new instance of SessionEvent.
+     * 
+     * @param session
+     *            the KReS session affected by this event
+     */
+    public SessionEvent(Session session, OperationType operationType) {
+        if (operationType == null) throw new IllegalArgumentException(
+                "No operation type specified for this session event.");
+        if (session == null) throw new IllegalArgumentException(
+                "No session specified for this session event.");
+        this.operationType = operationType;
+        this.affectedSession = session;
+    }
+
+    public OperationType getOperationType() {
+        return operationType;
+    }
+
+    /**
+     * Returns the KReS session affected by this event.
+     * 
+     * @return the affected KReS session
+     */
+    public Session getSession() {
+        return affectedSession;
+    }
+
+}

Added: stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/SessionIDGenerator.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/SessionIDGenerator.java?rev=1394600&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/SessionIDGenerator.java (added)
+++ stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/SessionIDGenerator.java Fri Oct  5 15:42:33 2012
@@ -0,0 +1,72 @@
+/*
+* 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.servicesapi.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 alexdma
+ * 
+ */
+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.
+	 */
+    String 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.
+	 */
+    String createSessionID(Set<String> 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.
+	 */
+    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.
+	 */
+    void setBaseIRI(IRI baseIRI);
+}

Added: stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/SessionLimitException.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/SessionLimitException.java?rev=1394600&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/SessionLimitException.java (added)
+++ stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/SessionLimitException.java Fri Oct  5 15:42:33 2012
@@ -0,0 +1,52 @@
+/*
+ * 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.servicesapi.session;
+
+/**
+ * Thrown whenever there is an attempt to exceed the maximum allowed number of active sessions.
+ * 
+ * @author alexdma
+ * 
+ */
+public class SessionLimitException extends Exception {
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = -7717192393787765332L;
+
+    private int limit;
+
+    public SessionLimitException(int limit) {
+        this.limit = limit;
+    }
+
+    public SessionLimitException(int limit, String message) {
+        super(message);
+        this.limit = limit;
+    }
+
+    public SessionLimitException(int limit, Throwable cause) {
+        this(limit);
+        initCause(cause);
+    }
+
+    public int getSessionLimit() {
+        return limit;
+    }
+
+}

Added: stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/SessionListenable.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/SessionListenable.java?rev=1394600&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/SessionListenable.java (added)
+++ stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/SessionListenable.java Fri Oct  5 15:42:33 2012
@@ -0,0 +1,54 @@
+/*
+* 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.servicesapi.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
+	 */
+    void addSessionListener(SessionListener listener);
+
+	/**
+	 * Clears the pool of registered session listeners.
+	 */
+    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.
+	 */
+    Collection<SessionListener> getSessionListeners();
+
+	/**
+	 * Removes the given SessionListener from the pool of active listeners.
+	 * 
+	 * @param listener
+	 *            the session listener to be removed
+	 */
+    void removeSessionListener(SessionListener listener);
+
+}

Added: stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/SessionListener.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/SessionListener.java?rev=1394600&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/SessionListener.java (added)
+++ stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/SessionListener.java Fri Oct  5 15:42:33 2012
@@ -0,0 +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.
+ */
+package org.apache.stanbol.ontologymanager.servicesapi.session;
+
+import org.apache.stanbol.ontologymanager.servicesapi.scope.Scope;
+
+/**
+ * Objects that want to listen to events affecting sessions should implement this interface and add themselves
+ * as listener to a manager.
+ * 
+ * @author alexdma
+ * 
+ */
+public interface SessionListener {
+
+    /**
+     * Called whenever a scope is appended to a session.
+     * 
+     * @param session
+     *            the affected session
+     * @param scopeId
+     *            the identifier of the scope that was attached.
+     */
+    void scopeAppended(Session session, String scopeId);
+
+    /**
+     * Called whenever a scope is detached from a session.
+     * 
+     * @param session
+     *            the affected session
+     * @param scopeId
+     *            the identifier of the scope that was attached. Note that the corresponding
+     *            {@link Scope} could be null if detachment occurred as a consequence of a scope
+     *            deletion.
+     * */
+    void scopeDetached(Session session, String scopeId);
+
+    /**
+     * Called whenever an event affecting a session is fired. This method encompasses all and only the event
+     * where it only interesting to know the affected session.
+     * 
+     * @param event
+     *            the session event.
+     */
+    void sessionChanged(SessionEvent event);
+
+}

Added: stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/SessionManager.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/SessionManager.java?rev=1394600&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/SessionManager.java (added)
+++ stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/session/SessionManager.java Fri Oct  5 15:42:33 2012
@@ -0,0 +1,130 @@
+/*
+ * 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.servicesapi.session;
+
+import java.io.OutputStream;
+import java.util.Set;
+
+import org.apache.stanbol.ontologymanager.servicesapi.NamedArtifact;
+import org.semanticweb.owlapi.model.OWLOntologyStorageException;
+
+/**
+ * Manages session objects via CRUD-like operations. A <code>SessionManager</code> maintains in-memory storage
+ * of sessions, creates new ones and either destroys or stores existing ones persistently. All 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 alexdma
+ * 
+ */
+public interface SessionManager extends NamedArtifact, SessionListenable {
+
+    /**
+     * The key used to configure the connectivity policy.
+     */
+    String CONNECTIVITY_POLICY = "org.apache.stanbol.ontologymanager.ontonet.session_connectivity";
+
+    /**
+     * The key used to configure the base namespace of the ontology network.
+     */
+    String ID = "org.apache.stanbol.ontologymanager.ontonet.session_mgr_id";
+
+    /**
+     * The key used to configure the base namespace of the ontology network.
+     */
+    String MAX_ACTIVE_SESSIONS = "org.apache.stanbol.ontologymanager.ontonet.session_limit";
+
+    /**
+     * Generates <b>and registers</b> a new session and assigns a unique session ID generated internally. This
+     * will not cause {@link DuplicateSessionIDException}s to be thrown.
+     * 
+     * @return the generated session
+     */
+    Session createSession() throws SessionLimitException;
+
+    /**
+     * Generates <b>and registers</b> a new 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 session
+     * @throws DuplicateSessionIDException
+     *             if a session with that sessionID is already registered
+     */
+    Session createSession(String sessionID) throws DuplicateSessionIDException, SessionLimitException;
+
+    /**
+     * Deletes the session identified by the supplied sessionID and releases its resources.
+     * 
+     * @param sessionID
+     *            the IRI that uniquely identifies the session
+     */
+    void destroySession(String sessionID);
+
+    /**
+     * Gets the number of sessions that can be simultaneously active and managed by this session manager.
+     * 
+     * @return the session limit.
+     */
+    int getActiveSessionLimit();
+
+    /**
+     * Returns the set of strings that identify registered sessions, whatever their state.
+     * 
+     * @return the IDs of all registered sessions.
+     */
+    Set<String> getRegisteredSessionIDs();
+
+    /**
+     * Retrieves the unique session identified by <code>sessionID</code>.
+     * 
+     * @param sessionID
+     *            the IRI that uniquely identifies the session
+     * @return the unique session identified by <code>sessionID</code>
+     */
+    Session getSession(String sessionID);
+
+    /**
+     * Sets the maximum allowed number of active sessions managed by this manager simultaneously. A negative
+     * value denotes no limit.
+     * 
+     * Note that it is possible to set this value to zero, thus preventing Stanbol from creating session at
+     * all.
+     * 
+     * @param limit
+     */
+    void setActiveSessionLimit(int limit);
+
+    /**
+     * Stores the session identified by <code>sessionID</code> using the output stream <code>out</code>.
+     * 
+     * @deprecated As of now, session contents are always stored. Deprecation will be removed if a new policy
+     *             is implemented.
+     * 
+     * @param sessionID
+     *            the IRI that uniquely identifies the session
+     * @param out
+     *            the output stream to store the session
+     * @throws OWLOntologyStorageException
+     */
+    void storeSession(String sessionID, OutputStream out) throws NonReferenceableSessionException,
+                                                         OWLOntologyStorageException;
+
+}

Added: stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/util/OntologyConstants.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/util/OntologyConstants.java?rev=1394600&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/util/OntologyConstants.java (added)
+++ stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/util/OntologyConstants.java Fri Oct  5 15:42:33 2012
@@ -0,0 +1,27 @@
+/*
+ * 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.servicesapi.util;
+
+@Deprecated
+public class OntologyConstants {
+
+    public static final String NS_STANBOL = "http://stanbol.apache.org/";
+
+    public static final String NS_ODP = "http://www.ontologydesignpatterns.org/";
+
+    public static final String NS_ONM = NS_STANBOL + "ontology/meta/onm.owl#";
+}

Added: stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/util/OntologyNetworkConfigurationUtils.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/util/OntologyNetworkConfigurationUtils.java?rev=1394600&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/util/OntologyNetworkConfigurationUtils.java (added)
+++ stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/util/OntologyNetworkConfigurationUtils.java Fri Oct  5 15:42:33 2012
@@ -0,0 +1,268 @@
+/*
+ * 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.servicesapi.util;
+
+import static org.apache.stanbol.ontologymanager.servicesapi.util.OntologyConstants.NS_ONM;
+
+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 alexdma
+ * @author enridaga
+ */
+public class OntologyNetworkConfigurationUtils {
+
+    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();
+                doActivate |= Boolean.parseBoolean(l.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);
+    }
+
+}

Added: stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/util/OntologyUtils.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/util/OntologyUtils.java?rev=1394600&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/util/OntologyUtils.java (added)
+++ stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/util/OntologyUtils.java Fri Oct  5 15:42:33 2012
@@ -0,0 +1,109 @@
+/*
+ * 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.servicesapi.util;
+
+import static org.apache.stanbol.commons.web.base.format.KRFormat.FUNCTIONAL_OWL;
+import static org.apache.stanbol.commons.web.base.format.KRFormat.MANCHESTER_OWL;
+import static org.apache.stanbol.commons.web.base.format.KRFormat.N3;
+import static org.apache.stanbol.commons.web.base.format.KRFormat.N_TRIPLE;
+import static org.apache.stanbol.commons.web.base.format.KRFormat.OWL_XML;
+import static org.apache.stanbol.commons.web.base.format.KRFormat.RDF_JSON;
+import static org.apache.stanbol.commons.web.base.format.KRFormat.RDF_XML;
+import static org.apache.stanbol.commons.web.base.format.KRFormat.TURTLE;
+import static org.apache.stanbol.commons.web.base.format.KRFormat.X_TURTLE;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.stanbol.commons.owl.util.URIUtils;
+import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLOntologyID;
+
+public class OntologyUtils {
+
+    private static String[] preferredFormats = {RDF_XML, TURTLE, X_TURTLE, RDF_JSON, N3, N_TRIPLE,
+                                                MANCHESTER_OWL, FUNCTIONAL_OWL, OWL_XML};
+
+    /**
+     * Extracts an OWL Ontology ID from its standard string form. The string must be of type
+     * <tt>ontologyIRI[:::versionIRI]</tt>. Any substring <tt>"%3A%3A%3A"</tt> present in <tt>ontologyIRI</tt>
+     * or <tt>versionIRI</tt> will be URL-decoded (i.e. converted to <tt>":::"</tt>).<br/>
+     * <br/>
+     * Also note that both <tt>ontologyIRI</tt> and <tt>versionIRI</tt> are desanitized in the process.
+     * 
+     * @param stringForm
+     *            the string to decode
+     * @return the string form of this ID.
+     * @see URIUtils#desanitize(IRI)
+     */
+    public static OWLOntologyID decode(String stringForm) {
+        if (stringForm == null || stringForm.isEmpty()) throw new IllegalArgumentException(
+                "Supplied string form must be non-null and non-empty.");
+        IRI oiri, viri;
+        String[] split = stringForm.split(":::");
+        if (split.length >= 1) {
+            oiri = URIUtils.desanitize(IRI.create(split[0].replace("%3A%3A%3A", ":::")));
+            viri = (split.length > 1) ? URIUtils.desanitize(IRI.create(split[1].replace("%3A%3A%3A", ":::")))
+                    : null;
+            return (viri != null) ? new OWLOntologyID(oiri, viri) : new OWLOntologyID(oiri);
+        } else return null; // Anonymous but versioned ontologies are not acceptable.
+    }
+
+    /**
+     * Provides a standardized string format for an OWL Ontology ID. The string returned is of type
+     * <tt>ontologyIRI[:::versionIRI]</tt>. Any substring <tt>":::"</tt> present in <tt>ontologyIRI</tt> or
+     * <tt>versionIRI</tt> will be URL-encoded (i.e. converted to <tt>"%3A%3A%3A"</tt>).<br/>
+     * <br/>
+     * Also note that both <tt>ontologyIRI</tt> and <tt>versionIRI</tt> are sanitized in the process. No other
+     * URL encoding occurs.
+     * 
+     * @param id
+     *            the OWL ontology ID to encode
+     * @return the string form of this ID.
+     * @see URIUtils#sanitize(IRI)
+     */
+    public static String encode(OWLOntologyID id) {
+        if (id == null) throw new IllegalArgumentException("Cannot encode a null OWLOntologyID.");
+        if (id.getOntologyIRI() == null) throw new IllegalArgumentException(
+                "Cannot encode an OWLOntologyID that is missing an ontologyIRI.");
+        String s = "";
+        s += URIUtils.sanitize(id.getOntologyIRI()).toString().replace(":::", "%3A%3A%3A");
+        if (id.getVersionIRI() != null) s += (":::")
+                                             + URIUtils.sanitize(id.getVersionIRI()).toString()
+                                                     .replace(":::", "%3A%3A%3A");
+        return s;
+    }
+
+    public static List<String> getPreferredFormats() {
+        List<String> result = new ArrayList<String>();
+        for (String f : preferredFormats)
+            result.add(f);
+        return result;
+    }
+
+    public static List<String> getPreferredSupportedFormats(Collection<String> supported) {
+        List<String> result = new ArrayList<String>();
+        for (String f : preferredFormats)
+            if (supported.contains(f)) result.add(f);
+        // The non-preferred supported formats on the tail in any order
+        for (String f : supported)
+            if (!result.contains(f)) result.add(f);
+        return result;
+    }
+
+}

Added: stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/util/ScopeSetRenderer.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/util/ScopeSetRenderer.java?rev=1394600&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/util/ScopeSetRenderer.java (added)
+++ stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/util/ScopeSetRenderer.java Fri Oct  5 15:42:33 2012
@@ -0,0 +1,82 @@
+/*
+ * 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.servicesapi.util;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.stanbol.ontologymanager.servicesapi.Vocabulary;
+import org.apache.stanbol.ontologymanager.servicesapi.scope.Scope;
+import org.semanticweb.owlapi.apibinding.OWLManager;
+import org.semanticweb.owlapi.model.AddAxiom;
+import org.semanticweb.owlapi.model.AddImport;
+import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLAxiom;
+import org.semanticweb.owlapi.model.OWLClass;
+import org.semanticweb.owlapi.model.OWLDataFactory;
+import org.semanticweb.owlapi.model.OWLNamedIndividual;
+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.LoggerFactory;
+
+/**
+ * Just an attempt. If we like it, make an API out of it.
+ * 
+ * XXX deprecate it in favor of {@link Vocabulary} ?
+ * 
+ * @author alexdma
+ * 
+ */
+public class ScopeSetRenderer {
+
+    private static OWLDataFactory __factory = OWLManager.getOWLDataFactory();
+
+    private static IRI _scopeIri = IRI.create(Vocabulary.SCOPE_URIREF.getUnicodeString());
+
+    private static OWLClass cScope = __factory.getOWLClass(_scopeIri);
+
+    public static OWLOntology getScopes(Set<Scope> scopes) {
+
+        OWLOntologyManager mgr = OWLManager.createOWLOntologyManager();
+        OWLOntology ont = null;
+        try {
+            ont = mgr.createOntology();
+        } catch (OWLOntologyCreationException e) {
+            LoggerFactory.getLogger(ScopeSetRenderer.class).error(
+                "KReS :: could not create empty ontology for rendering scopes.", e);
+            return null;
+        }
+        List<OWLOntologyChange> additions = new LinkedList<OWLOntologyChange>();
+        // The ODP metadata vocabulary is always imported.
+        // TODO : also import the ONM meta when it goes online.
+        additions.add(new AddImport(ont, __factory.getOWLImportsDeclaration(IRI
+                .create("http://www.ontologydesignpatterns.org/schemas/meta.owl"))));
+        for (Scope scope : scopes) {
+            OWLNamedIndividual iScope = __factory.getOWLNamedIndividual(IRI.create(scope
+                    .getDefaultNamespace() + scope.getID()));
+            OWLAxiom ax = __factory.getOWLClassAssertionAxiom(cScope, iScope);
+            additions.add(new AddAxiom(ont, ax));
+        }
+        mgr.applyChanges(additions);
+
+        return ont;
+    }
+
+}

Added: stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/util/StringUtils.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/util/StringUtils.java?rev=1394600&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/util/StringUtils.java (added)
+++ stanbol/trunk/ontologymanager/generic/servicesapi/src/main/java/org/apache/stanbol/ontologymanager/servicesapi/util/StringUtils.java Fri Oct  5 15:42:33 2012
@@ -0,0 +1,41 @@
+/*
+ * 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.servicesapi.util;
+
+import org.semanticweb.owlapi.model.IRI;
+
+public class StringUtils {
+
+    public static IRI stripIRITerminator(IRI iri) {
+        if (iri == null) return null;
+        return IRI.create(stripIRITerminator(iri.toString()));
+    }
+
+    public static String stripIRITerminator(String iri) {
+        if (iri == null) return null;
+        if (iri.endsWith("/") || iri.endsWith("#") || iri.endsWith(":"))
+        // Shorten the string by one
+        return stripIRITerminator(iri.substring(0, iri.length() - 1));
+        else return iri;
+    }
+
+    public static String stripNamespace(String fullIri, String namespace) {
+        if (fullIri.startsWith(namespace)) return fullIri.substring(namespace.length() - 1);
+        else return fullIri;
+    }
+
+}

Added: stanbol/trunk/ontologymanager/generic/servicesapi/src/main/resources/META-INF/conf/onm.owl
URL: http://svn.apache.org/viewvc/stanbol/trunk/ontologymanager/generic/servicesapi/src/main/resources/META-INF/conf/onm.owl?rev=1394600&view=auto
==============================================================================
--- stanbol/trunk/ontologymanager/generic/servicesapi/src/main/resources/META-INF/conf/onm.owl (added)
+++ stanbol/trunk/ontologymanager/generic/servicesapi/src/main/resources/META-INF/conf/onm.owl Fri Oct  5 15:42:33 2012
@@ -0,0 +1,319 @@
+<?xml version="1.0"?>
+<!--
+  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.
+-->
+
+<!DOCTYPE rdf:RDF [
+    <!ENTITY owl "http://www.w3.org/2002/07/owl#" >
+    <!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
+    <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
+    <!ENTITY ontology "http://omv.ontoware.org/2005/05/ontology#" >
+    <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
+    <!ENTITY onm "http://kres.iks-project.eu/ontology/meta/onm.owl#" >
+    <!ENTITY meta "http://www.ontologydesignpatterns.org/schemas/meta.owl#" >
+    <!ENTITY coddata "http://www.ontologydesignpatterns.org/cpont/codo/coddata.owl#" >
+]>
+
+
+<rdf:RDF xmlns="http://kres.iks-project.eu/ontology/meta/onm.owl#"
+     xml:base="http://kres.iks-project.eu/ontology/meta/onm.owl"
+     xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
+     xmlns:owl="http://www.w3.org/2002/07/owl#"
+     xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
+     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+     xmlns:ontology="http://omv.ontoware.org/2005/05/ontology#"
+     xmlns:coddata="http://www.ontologydesignpatterns.org/cpont/codo/coddata.owl#"
+     xmlns:meta="http://www.ontologydesignpatterns.org/schemas/meta.owl#"
+     xmlns:onm="http://kres.iks-project.eu/ontology/meta/onm.owl#">
+    <owl:Ontology rdf:about="http://kres.iks-project.eu/ontology/meta/onm.owl">
+        <owl:versionInfo xml:lang="en">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 &quot;License&quot;); 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 &quot;AS IS&quot; 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.
+</owl:versionInfo>
+        <rdfs:comment xml:lang="en">The IKS Ontology Network Manager metalevel vocabulary.</rdfs:comment>
+        <owl:imports rdf:resource="http://www.ontologydesignpatterns.org/schemas/meta.owl"/>
+    </owl:Ontology>
+    
+
+
+    <!-- 
+    ///////////////////////////////////////////////////////////////////////////////////////
+    //
+    // Annotation properties
+    //
+    ///////////////////////////////////////////////////////////////////////////////////////
+     -->
+
+    <owl:AnnotationProperty rdf:about="&rdfs;label"/>
+    <owl:AnnotationProperty rdf:about="&rdfs;comment"/>
+    
+
+
+    <!-- 
+    ///////////////////////////////////////////////////////////////////////////////////////
+    //
+    // Datatypes
+    //
+    ///////////////////////////////////////////////////////////////////////////////////////
+     -->
+
+    
+
+
+    <!-- 
+    ///////////////////////////////////////////////////////////////////////////////////////
+    //
+    // Object Properties
+    //
+    ///////////////////////////////////////////////////////////////////////////////////////
+     -->
+
+    
+
+
+    <!-- http://kres.iks-project.eu/ontology/meta/onm.owl#isCoreLibraryOf -->
+
+    <owl:ObjectProperty rdf:about="&onm;isCoreLibraryOf">
+        <rdfs:label xml:lang="en">is core library of</rdfs:label>
+        <rdfs:subPropertyOf rdf:resource="&onm;isLibraryUsedBy"/>
+        <owl:inverseOf rdf:resource="&onm;usesCoreLibrary"/>
+    </owl:ObjectProperty>
+    
+
+
+    <!-- http://kres.iks-project.eu/ontology/meta/onm.owl#isCoreOntologyUsedBy -->
+
+    <owl:ObjectProperty rdf:about="&onm;isCoreOntologyUsedBy">
+        <rdfs:subPropertyOf rdf:resource="&onm;isOntologyUsedBy"/>
+        <owl:inverseOf rdf:resource="&onm;usesCoreOntology"/>
+    </owl:ObjectProperty>
+    
+
+
+    <!-- http://kres.iks-project.eu/ontology/meta/onm.owl#isCustomLibraryOf -->
+
+    <owl:ObjectProperty rdf:about="&onm;isCustomLibraryOf">
+        <rdfs:label xml:lang="en">is custom library of</rdfs:label>
+        <rdfs:subPropertyOf rdf:resource="&onm;isLibraryUsedBy"/>
+        <owl:inverseOf rdf:resource="&onm;usesCustomLibrary"/>
+    </owl:ObjectProperty>
+    
+
+
+    <!-- http://kres.iks-project.eu/ontology/meta/onm.owl#isCustomOntologyUsedBy -->
+
+    <owl:ObjectProperty rdf:about="&onm;isCustomOntologyUsedBy">
+        <rdfs:subPropertyOf rdf:resource="&onm;isOntologyUsedBy"/>
+        <owl:inverseOf rdf:resource="&onm;usesCustomOntology"/>
+    </owl:ObjectProperty>
+    
+
+
+    <!-- http://kres.iks-project.eu/ontology/meta/onm.owl#isLibraryUsedBy -->
+
+    <owl:ObjectProperty rdf:about="&onm;isLibraryUsedBy">
+        <rdfs:label xml:lang="en">is library used by</rdfs:label>
+        <rdfs:subPropertyOf rdf:resource="&onm;isOntologyResourceUsedBy"/>
+        <owl:inverseOf rdf:resource="&onm;usesLibrary"/>
+    </owl:ObjectProperty>
+    
+
+
+    <!-- http://kres.iks-project.eu/ontology/meta/onm.owl#isOntologyResourceUsedBy -->
+
+    <owl:ObjectProperty rdf:about="&onm;isOntologyResourceUsedBy">
+        <rdfs:label xml:lang="en">is ontology resource used by</rdfs:label>
+        <owl:inverseOf rdf:resource="&onm;usesOntologyResource"/>
+        <rdfs:subPropertyOf rdf:resource="&owl;topObjectProperty"/>
+    </owl:ObjectProperty>
+    
+
+
+    <!-- http://kres.iks-project.eu/ontology/meta/onm.owl#isOntologyUsedBy -->
+
+    <owl:ObjectProperty rdf:about="&onm;isOntologyUsedBy">
+        <rdfs:subPropertyOf rdf:resource="&onm;isOntologyResourceUsedBy"/>
+        <owl:inverseOf rdf:resource="&onm;usesOntology"/>
+    </owl:ObjectProperty>
+    
+
+
+    <!-- http://kres.iks-project.eu/ontology/meta/onm.owl#usesCoreLibrary -->
+
+    <owl:ObjectProperty rdf:about="&onm;usesCoreLibrary">
+        <rdfs:label xml:lang="en">uses core library</rdfs:label>
+        <rdfs:subPropertyOf rdf:resource="&onm;usesLibrary"/>
+        <rdfs:range rdf:resource="&coddata;OntologyLibrary"/>
+    </owl:ObjectProperty>
+    
+
+
+    <!-- http://kres.iks-project.eu/ontology/meta/onm.owl#usesCoreOntology -->
+
+    <owl:ObjectProperty rdf:about="&onm;usesCoreOntology">
+        <rdfs:subPropertyOf rdf:resource="&onm;usesOntology"/>
+        <rdfs:range rdf:resource="&ontology;Ontology"/>
+    </owl:ObjectProperty>
+    
+
+
+    <!-- http://kres.iks-project.eu/ontology/meta/onm.owl#usesCustomLibrary -->
+
+    <owl:ObjectProperty rdf:about="&onm;usesCustomLibrary">
+        <rdfs:label xml:lang="en">uses custom library</rdfs:label>
+        <rdfs:subPropertyOf rdf:resource="&onm;usesLibrary"/>
+        <rdfs:range rdf:resource="&coddata;OntologyLibrary"/>
+    </owl:ObjectProperty>
+    
+
+
+    <!-- http://kres.iks-project.eu/ontology/meta/onm.owl#usesCustomOntology -->
+
+    <owl:ObjectProperty rdf:about="&onm;usesCustomOntology">
+        <rdfs:subPropertyOf rdf:resource="&onm;usesOntology"/>
+        <rdfs:range rdf:resource="&ontology;Ontology"/>
+    </owl:ObjectProperty>
+    
+
+
+    <!-- http://kres.iks-project.eu/ontology/meta/onm.owl#usesLibrary -->
+
+    <owl:ObjectProperty rdf:about="&onm;usesLibrary">
+        <rdfs:label xml:lang="en">uses library</rdfs:label>
+        <rdfs:comment xml:lang="en">of something that relies upon something else as a data/function vocabulary for performing its own business.</rdfs:comment>
+        <rdfs:subPropertyOf rdf:resource="&onm;usesOntologyResource"/>
+        <rdfs:range rdf:resource="&coddata;OntologyLibrary"/>
+    </owl:ObjectProperty>
+    
+
+
+    <!-- http://kres.iks-project.eu/ontology/meta/onm.owl#usesOntology -->
+
+    <owl:ObjectProperty rdf:about="&onm;usesOntology">
+        <rdfs:label xml:lang="en">uses ontology</rdfs:label>
+        <rdfs:subPropertyOf rdf:resource="&onm;usesOntologyResource"/>
+        <rdfs:range rdf:resource="&ontology;Ontology"/>
+    </owl:ObjectProperty>
+    
+
+
+    <!-- http://kres.iks-project.eu/ontology/meta/onm.owl#usesOntologyResource -->
+
+    <owl:ObjectProperty rdf:about="&onm;usesOntologyResource">
+        <rdfs:label xml:lang="en">uses ontology resource</rdfs:label>
+        <rdfs:subPropertyOf rdf:resource="&owl;topObjectProperty"/>
+    </owl:ObjectProperty>
+    
+
+
+    <!-- http://www.ontologydesignpatterns.org/schemas/meta.owl#hasOntology -->
+
+    <owl:ObjectProperty rdf:about="&meta;hasOntology"/>
+    
+
+
+    <!-- http://www.w3.org/2002/07/owl#topObjectProperty -->
+
+    <owl:ObjectProperty rdf:about="&owl;topObjectProperty">
+        <rdfs:range rdf:resource="&coddata;OntologyLibrary"/>
+    </owl:ObjectProperty>
+    
+
+
+    <!-- 
+    ///////////////////////////////////////////////////////////////////////////////////////
+    //
+    // Data properties
+    //
+    ///////////////////////////////////////////////////////////////////////////////////////
+     -->
+
+    
+
+
+    <!-- http://kres.iks-project.eu/ontology/meta/onm.owl#activateOnStart -->
+
+    <owl:DatatypeProperty rdf:about="&onm;activateOnStart">
+        <rdfs:domain rdf:resource="&onm;Scope"/>
+        <rdfs:range rdf:resource="&xsd;boolean"/>
+        <rdfs:subPropertyOf rdf:resource="&owl;topDataProperty"/>
+    </owl:DatatypeProperty>
+    
+
+
+    <!-- http://www.w3.org/2002/07/owl#topDataProperty -->
+
+    <owl:DatatypeProperty rdf:about="&owl;topDataProperty"/>
+    
+
+
+    <!-- 
+    ///////////////////////////////////////////////////////////////////////////////////////
+    //
+    // Classes
+    //
+    ///////////////////////////////////////////////////////////////////////////////////////
+     -->
+
+    
+
+
+    <!-- http://kres.iks-project.eu/ontology/meta/onm.owl#Scope -->
+
+    <owl:Class rdf:about="&onm;Scope">
+        <rdfs:label xml:lang="en">Scope</rdfs:label>
+        <rdfs:subClassOf>
+            <owl:Restriction>
+                <owl:onProperty rdf:resource="&onm;usesLibrary"/>
+                <owl:allValuesFrom rdf:resource="&coddata;OntologyLibrary"/>
+            </owl:Restriction>
+        </rdfs:subClassOf>
+        <rdfs:subClassOf>
+            <owl:Restriction>
+                <owl:onProperty rdf:resource="&onm;activateOnStart"/>
+                <owl:maxQualifiedCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:maxQualifiedCardinality>
+                <owl:onDataRange rdf:resource="&xsd;boolean"/>
+            </owl:Restriction>
+        </rdfs:subClassOf>
+        <rdfs:comment xml:lang="en">An entity involving a set of (networked) ontologies encompassing a given domain or meta-domain.</rdfs:comment>
+    </owl:Class>
+    
+
+
+    <!-- http://omv.ontoware.org/2005/05/ontology#Ontology -->
+
+    <owl:Class rdf:about="&ontology;Ontology"/>
+    
+
+
+    <!-- http://www.ontologydesignpatterns.org/cpont/codo/coddata.owl#OntologyLibrary -->
+
+    <owl:Class rdf:about="&coddata;OntologyLibrary">
+        <rdfs:subClassOf>
+            <owl:Restriction>
+                <owl:onProperty rdf:resource="&meta;hasOntology"/>
+                <owl:allValuesFrom rdf:resource="&ontology;Ontology"/>
+            </owl:Restriction>
+        </rdfs:subClassOf>
+    </owl:Class>
+</rdf:RDF>
+
+
+
+<!-- Generated by the OWL API (version 3.2.3.22702) http://owlapi.sourceforge.net -->
+