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

svn commit: r1148497 [1/6] - in /incubator/stanbol/trunk/ontologymanager/store: launchers/fise/src/main/bundles/ web/ web/src/ web/src/main/ web/src/main/java/ web/src/main/java/org/ web/src/main/java/org/apache/ web/src/main/java/org/apache/stanbol/ w...

Author: suat
Date: Tue Jul 19 19:37:37 2011
New Revision: 1148497

URL: http://svn.apache.org/viewvc?rev=1148497&view=rev
Log:
STANBOL 295:
-Moved web bundle under Ontology Manager Store
-Updated related dependency in launcher

Added:
    incubator/stanbol/trunk/ontologymanager/store/web/   (with props)
    incubator/stanbol/trunk/ontologymanager/store/web/pom.xml
    incubator/stanbol/trunk/ontologymanager/store/web/src/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/JAXBProvider.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/LockManagerImp.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/ResourceManagerImp.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/StoreWebFragment.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/Ontologies.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/OntologyClasses.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/OntologyDatatypeProperties.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/OntologyImports.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/OntologyIndividuals.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/OntologyObjectProperties.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/ParticularClass.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/ParticularClassDisjointClasses.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/ParticularClassEquivalentClasses.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/ParticularClassSuperClasses.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/ParticularDatatypeProperty.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/ParticularDatatypePropertyDomains.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/ParticularDatatypePropertyRanges.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/ParticularDatatypePropertySuperProperties.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/ParticularIndividual.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/ParticularIndividualPropertyAssertions.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/ParticularIndividualTypes.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/ParticularObjectProperty.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/ParticularObjectPropertyDomains.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/ParticularObjectPropertyRanges.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/ParticularObjectPropertySuperProperties.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/ParticularOntology.java
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/static/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/static/images/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/static/images/add_icon_16.png   (with props)
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/static/images/delete_icon_16.png   (with props)
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/static/images/ont_class_16.png   (with props)
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/static/images/ont_data_prop.png   (with props)
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/static/images/ont_ind.png   (with props)
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/static/images/ont_obj_prop.png   (with props)
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/static/scripts/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/static/scripts/individualUpdater.js
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/static/scripts/jquery-1.4.2.js
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/static/scripts/paging.js
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/static/scripts/propertyUpdater.js
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/static/scripts/requestResponse.js
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/static/style/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/static/style/store.css
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/templates/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/templates/imports/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/templates/imports/classConstraint.ftl
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/templates/imports/prevNextButtons.ftl
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/templates/imports/propertySerializer.ftl
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/templates/imports/storeDescription.ftl
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/templates/org/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/templates/org/apache/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/templates/org/apache/stanbol/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/templates/org/apache/stanbol/ontologymanager/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/templates/org/apache/stanbol/ontologymanager/store/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/templates/org/apache/stanbol/ontologymanager/store/rest/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/templates/org/apache/stanbol/ontologymanager/store/rest/resources/
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/templates/org/apache/stanbol/ontologymanager/store/rest/resources/ontologies.ftl
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/templates/org/apache/stanbol/ontologymanager/store/rest/resources/ontologyClasses.ftl
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/templates/org/apache/stanbol/ontologymanager/store/rest/resources/ontologyDatatypeProperties.ftl
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/templates/org/apache/stanbol/ontologymanager/store/rest/resources/ontologyImports.ftl
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/templates/org/apache/stanbol/ontologymanager/store/rest/resources/ontologyIndividuals.ftl
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/templates/org/apache/stanbol/ontologymanager/store/rest/resources/ontologyObjectProperties.ftl
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/templates/org/apache/stanbol/ontologymanager/store/rest/resources/particularClass.ftl
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/templates/org/apache/stanbol/ontologymanager/store/rest/resources/particularDatatypeProperty.ftl
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/templates/org/apache/stanbol/ontologymanager/store/rest/resources/particularIndividual.ftl
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/templates/org/apache/stanbol/ontologymanager/store/rest/resources/particularObjectProperty.ftl
    incubator/stanbol/trunk/ontologymanager/store/web/src/main/resources/org/apache/stanbol/commons/web/ontologymanager/store/templates/org/apache/stanbol/ontologymanager/store/rest/resources/particularOntology.ftl
Modified:
    incubator/stanbol/trunk/ontologymanager/store/launchers/fise/src/main/bundles/list.xml

Modified: incubator/stanbol/trunk/ontologymanager/store/launchers/fise/src/main/bundles/list.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/store/launchers/fise/src/main/bundles/list.xml?rev=1148497&r1=1148496&r2=1148497&view=diff
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/store/launchers/fise/src/main/bundles/list.xml (original)
+++ incubator/stanbol/trunk/ontologymanager/store/launchers/fise/src/main/bundles/list.xml Tue Jul 19 19:37:37 2011
@@ -403,7 +403,7 @@
 		</bundle>
 		<bundle>
 			<groupId>org.apache.stanbol</groupId>
-			<artifactId>org.apache.stanbol.commons.web.ontology</artifactId>
+			<artifactId>org.apache.stanbol.ontologymanager.store.web</artifactId>
 			<version>0.9.0-incubating-SNAPSHOT</version>
 		</bundle>
 	</startLevel>

Propchange: incubator/stanbol/trunk/ontologymanager/store/web/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Jul 19 19:37:37 2011
@@ -0,0 +1,4 @@
+.settings
+target
+.classpath
+.project

Added: incubator/stanbol/trunk/ontologymanager/store/web/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/store/web/pom.xml?rev=1148497&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/store/web/pom.xml (added)
+++ incubator/stanbol/trunk/ontologymanager/store/web/pom.xml Tue Jul 19 19:37:37 2011
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+	<modelVersion>4.0.0</modelVersion>
+
+	<parent>
+		<groupId>org.apache.stanbol</groupId>
+		<artifactId>org.apache.stanbol.ontologymanager.store.parent</artifactId>
+		<version>0.9.0-incubating-SNAPSHOT</version>
+		<relativePath>../parent</relativePath>
+	</parent>
+
+	<groupId>org.apache.stanbol</groupId>
+	<artifactId>org.apache.stanbol.ontologymanager.store.web</artifactId>
+	<packaging>bundle</packaging>
+
+	<name>Apache Stanbol Ontology Manager Store - Web</name>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.felix</groupId>
+				<artifactId>maven-bundle-plugin</artifactId>
+				<extensions>true</extensions>
+				<configuration>
+					<instructions>
+						<Service-Component>OSGI-INF/serviceComponents.xml</Service-Component>
+						<Import-Package>
+							<!-- apache derby -->
+							org.apache.derby.jdbc,
+							*
+						</Import-Package>
+					</instructions>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.felix</groupId>
+				<artifactId>maven-scr-plugin</artifactId>
+			</plugin>
+		</plugins>
+	</build>
+
+	<dependencies>
+		<!-- Version will be removed once dependencies are added to stanbol-parent -->
+		<dependency>
+			<groupId>org.apache.stanbol</groupId>
+			<artifactId>org.apache.stanbol.ontologymanager.store.api</artifactId>
+			<version>0.9.0-incubating-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.stanbol</groupId>
+			<artifactId>org.apache.stanbol.commons.web.base</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.apache.felix.scr</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.apache.felix.scr.annotations</artifactId>
+		</dependency>
+
+		<!-- is now included and exported by jersey-core <dependency> <groupId>javax.ws.rs</groupId> 
+			<artifactId>jsr311-api</artifactId> </dependency> -->
+
+		<dependency>
+			<groupId>org.osgi</groupId>
+			<artifactId>org.osgi.compendium</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.osgi</groupId>
+			<artifactId>org.osgi.core</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>com.sun.jersey</groupId>
+			<artifactId>jersey-server</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>com.sun.jersey</groupId>
+			<artifactId>jersey-core</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>com.sun.jersey</groupId>
+			<artifactId>jersey-json</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>javax.servlet</groupId>
+			<artifactId>servlet-api</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.slf4j</groupId>
+			<artifactId>slf4j-api</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.freemarker</groupId>
+			<artifactId>freemarker</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>com.hp.hpl.jena</groupId>
+			<artifactId>jena</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>commons-logging</groupId>
+			<artifactId>commons-logging</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>org.mortbay.jetty</groupId>
+			<artifactId>jetty</artifactId>
+			<scope>test</scope>
+		</dependency>
+		<!-- Version will be removed once dependencies are added to stanbol-parent -->
+		<dependency>
+			<groupId>org.apache.derby</groupId>
+			<artifactId>derby</artifactId>
+			<version>10.7.1.1</version>
+			<scope>provided</scope>
+		</dependency>
+	</dependencies>
+
+</project>

Added: incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/JAXBProvider.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/JAXBProvider.java?rev=1148497&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/JAXBProvider.java (added)
+++ incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/JAXBProvider.java Tue Jul 19 19:37:37 2011
@@ -0,0 +1,187 @@
+/*
+ * 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.store.rest;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.List;
+import java.util.Vector;
+
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+import javax.xml.XMLConstants;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+
+import org.apache.stanbol.ontologymanager.store.model.AdministeredOntologies;
+import org.apache.stanbol.ontologymanager.store.model.BuiltInResource;
+import org.apache.stanbol.ontologymanager.store.model.ClassConstraint;
+import org.apache.stanbol.ontologymanager.store.model.ClassContext;
+import org.apache.stanbol.ontologymanager.store.model.ClassMetaInformation;
+import org.apache.stanbol.ontologymanager.store.model.ClassesForOntology;
+import org.apache.stanbol.ontologymanager.store.model.ConstraintType;
+import org.apache.stanbol.ontologymanager.store.model.ContainerClasses;
+import org.apache.stanbol.ontologymanager.store.model.DatatypePropertiesForOntology;
+import org.apache.stanbol.ontologymanager.store.model.DatatypePropertyContext;
+import org.apache.stanbol.ontologymanager.store.model.DisjointClasses;
+import org.apache.stanbol.ontologymanager.store.model.Domain;
+import org.apache.stanbol.ontologymanager.store.model.EquivalentClasses;
+import org.apache.stanbol.ontologymanager.store.model.EquivalentProperties;
+import org.apache.stanbol.ontologymanager.store.model.ImportsForOntology;
+import org.apache.stanbol.ontologymanager.store.model.IndividualContext;
+import org.apache.stanbol.ontologymanager.store.model.IndividualMetaInformation;
+import org.apache.stanbol.ontologymanager.store.model.IndividualsForOntology;
+import org.apache.stanbol.ontologymanager.store.model.ObjectFactory;
+import org.apache.stanbol.ontologymanager.store.model.ObjectPropertiesForOntology;
+import org.apache.stanbol.ontologymanager.store.model.ObjectPropertyContext;
+import org.apache.stanbol.ontologymanager.store.model.OntologyImport;
+import org.apache.stanbol.ontologymanager.store.model.OntologyMetaInformation;
+import org.apache.stanbol.ontologymanager.store.model.PropertyAssertions;
+import org.apache.stanbol.ontologymanager.store.model.PropertyMetaInformation;
+import org.apache.stanbol.ontologymanager.store.model.Range;
+import org.apache.stanbol.ontologymanager.store.model.ResourceMetaInformationType;
+import org.apache.stanbol.ontologymanager.store.model.SuperProperties;
+import org.apache.stanbol.ontologymanager.store.model.Superclasses;
+import org.xml.sax.SAXException;
+
+import com.sun.jersey.spi.resource.Singleton;
+
+@Singleton
+@Provider
+@Produces(MediaType.APPLICATION_XML)
+public class JAXBProvider implements MessageBodyReader, MessageBodyWriter {
+
+    private Marshaller marshaller;
+
+    private Unmarshaller unmarshaller;
+
+    public JAXBProvider() throws JAXBException, SAXException {
+        ClassLoader cl = ObjectFactory.class.getClassLoader();
+        JAXBContext jc = JAXBContext.newInstance("org.apache.stanbol.ontologymanager.store.model", cl);
+        marshaller = jc.createMarshaller();
+        unmarshaller = jc.createUnmarshaller();
+        String schemaLocations[] = {"model/xlinks.xsd", "model/PersistenceStoreRESTfulInterface.xsd",
+                                    "model/SearchRESTfulInterface.xsd"};
+        SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI,
+            "com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory",
+            JAXBProvider.class.getClassLoader());
+
+        List<StreamSource> streamSourceList = new Vector<StreamSource>();
+        for (String schemaLocation : schemaLocations) {
+            InputStream is = cl.getResourceAsStream(schemaLocation);
+            StreamSource streamSource = new StreamSource(is);
+            streamSourceList.add(streamSource);
+        }
+        StreamSource sources[] = new StreamSource[streamSourceList.size()];
+        Schema schema = schemaFactory.newSchema(streamSourceList.toArray(sources));
+        marshaller.setSchema(schema);
+        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
+        unmarshaller.setSchema(schema);
+    }
+
+    @Override
+    public long getSize(Object t, Class type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+        return -1;
+    }
+
+    @Override
+    public boolean isWriteable(Class type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+        if (type.equals(AdministeredOntologies.class) || type.equals(BuiltInResource.class)
+            || type.equals(ClassConstraint.class) || type.equals(ClassContext.class)
+            || type.equals(ClassesForOntology.class) || type.equals(ClassMetaInformation.class)
+            || type.equals(ConstraintType.class) || type.equals(ContainerClasses.class)
+            || type.equals(DatatypePropertiesForOntology.class) || type.equals(DatatypePropertyContext.class)
+            || type.equals(DisjointClasses.class) || type.equals(Domain.class)
+            || type.equals(EquivalentClasses.class) || type.equals(EquivalentProperties.class)
+            || type.equals(IndividualContext.class) || type.equals(IndividualMetaInformation.class)
+            || type.equals(IndividualsForOntology.class) || type.equals(ObjectPropertiesForOntology.class)
+            || type.equals(ObjectPropertyContext.class) || type.equals(OntologyMetaInformation.class)
+            || type.equals(PropertyAssertions.class) || type.equals(PropertyMetaInformation.class)
+            || type.equals(Range.class) || type.equals(ResourceMetaInformationType.class)
+            || type.equals(Superclasses.class) || type.equals(SuperProperties.class)
+            || type.equals(OntologyImport.class) || type.equals(ImportsForOntology.class)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    @Override
+    public void writeTo(Object t,
+                        Class type,
+                        Type genericType,
+                        Annotation[] annotations,
+                        MediaType mediaType,
+                        MultivaluedMap httpHeaders,
+                        OutputStream entityStream) throws IOException, WebApplicationException {
+        try {
+            marshaller.marshal(t, entityStream);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+    @Override
+    public boolean isReadable(Class type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+        if (type.equals(AdministeredOntologies.class) || type.equals(BuiltInResource.class)
+            || type.equals(ClassConstraint.class) || type.equals(ClassContext.class)
+            || type.equals(ClassesForOntology.class) || type.equals(ClassMetaInformation.class)
+            || type.equals(ConstraintType.class) || type.equals(ContainerClasses.class)
+            || type.equals(DatatypePropertiesForOntology.class) || type.equals(DatatypePropertyContext.class)
+            || type.equals(DisjointClasses.class) || type.equals(Domain.class)
+            || type.equals(EquivalentClasses.class) || type.equals(EquivalentProperties.class)
+            || type.equals(IndividualContext.class) || type.equals(IndividualMetaInformation.class)
+            || type.equals(IndividualsForOntology.class) || type.equals(ObjectPropertiesForOntology.class)
+            || type.equals(ObjectPropertyContext.class) || type.equals(OntologyMetaInformation.class)
+            || type.equals(PropertyAssertions.class) || type.equals(PropertyMetaInformation.class)
+            || type.equals(Range.class) || type.equals(ResourceMetaInformationType.class)
+            || type.equals(Superclasses.class) || type.equals(SuperProperties.class)
+            || type.equals(OntologyImport.class) || type.equals(ImportsForOntology.class)) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+
+    @Override
+    public Object readFrom(Class type,
+                           Type genericType,
+                           Annotation[] annotations,
+                           MediaType mediaType,
+                           MultivaluedMap httpHeaders,
+                           InputStream entityStream) throws IOException, WebApplicationException {
+        try {
+            return unmarshaller.unmarshal(entityStream);
+        } catch (JAXBException e) {
+            throw new RuntimeException(e);
+        }
+    }
+
+}

Added: incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/LockManagerImp.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/LockManagerImp.java?rev=1148497&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/LockManagerImp.java (added)
+++ incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/LockManagerImp.java Tue Jul 19 19:37:37 2011
@@ -0,0 +1,136 @@
+/*
+ * 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.store.rest;
+
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Vector;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.stanbol.ontologymanager.store.api.LockManager;
+
+@Component
+@Service
+public class LockManagerImp implements LockManager {
+
+    private Lock internalLock = null;
+    private ReentrantReadWriteLock globalSpaceLock = null;
+    private List<ReentrantReadWriteLock> rwlockList = null;
+    private Hashtable<String,ReentrantReadWriteLock> index = null;
+
+    public LockManagerImp() {
+        rwlockList = new Vector<ReentrantReadWriteLock>();
+        index = new Hashtable<String,ReentrantReadWriteLock>();
+        internalLock = new ReentrantLock();
+        globalSpaceLock = new ReentrantReadWriteLock();
+    }
+
+    private static LockManager instance = null;
+
+    public static LockManager getInstance() {
+        if (instance == null) {
+            instance = new LockManagerImp();
+        }
+        return instance;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.stanbol.ontologymanager.store.rest.ILockManager#obtainReadLockFor(java.lang.String)
+     */
+    public void obtainReadLockFor(String ontologyPath) {
+        if (ontologyPath.equalsIgnoreCase(GLOBAL_SPACE)) {
+            globalSpaceLock.readLock().lock();
+        } else {
+            String closureID = getClosureIDFor(ontologyPath);
+            internalLock.lock();
+            if (!index.containsKey(closureID)) {
+                ReentrantReadWriteLock rrwl = new ReentrantReadWriteLock();
+                rwlockList.add(rrwl);
+                index.put(closureID, rrwl);
+            }
+            internalLock.unlock();
+            ReentrantReadWriteLock rrwl = index.get(closureID);
+            globalSpaceLock.readLock().lock();
+            rrwl.readLock().lock();
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.stanbol.ontologymanager.store.rest.ILockManager#releaseReadLockFor(java.lang.String)
+     */
+    public void releaseReadLockFor(String ontologyPath) {
+        if (ontologyPath.equalsIgnoreCase(GLOBAL_SPACE)) {
+            globalSpaceLock.readLock().unlock();
+        } else {
+            String closureID = getClosureIDFor(ontologyPath);
+            ReentrantReadWriteLock rrwl = index.get(closureID);
+            rrwl.readLock().unlock();
+            globalSpaceLock.readLock().unlock();
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.stanbol.ontologymanager.store.rest.ILockManager#obtainWriteLockFor(java.lang.String)
+     */
+    public void obtainWriteLockFor(String ontologyPath) {
+        if (ontologyPath.equalsIgnoreCase(GLOBAL_SPACE)) {
+            globalSpaceLock.writeLock().lock();
+        } else {
+            String closureID = getClosureIDFor(ontologyPath);
+            internalLock.lock();
+            if (!index.containsKey(closureID)) {
+                ReentrantReadWriteLock rrwl = new ReentrantReadWriteLock();
+                rwlockList.add(rrwl);
+                index.put(closureID, rrwl);
+            }
+            internalLock.unlock();
+            ReentrantReadWriteLock rrwl = index.get(closureID);
+            globalSpaceLock.readLock().lock();
+            rrwl.writeLock().lock();
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see org.apache.stanbol.ontologymanager.store.rest.ILockManager#releaseWriteLockFor(java.lang.String)
+     */
+    public void releaseWriteLockFor(String ontologyPath) {
+        if (ontologyPath.equalsIgnoreCase(GLOBAL_SPACE)) {
+            globalSpaceLock.writeLock().unlock();
+        } else {
+            String closureID = getClosureIDFor(ontologyPath);
+            ReentrantReadWriteLock rrwl = index.get(closureID);
+            rrwl.writeLock().unlock();
+            globalSpaceLock.readLock().unlock();
+        }
+    }
+
+    private String getClosureIDFor(String ontologyPath) {
+        return ontologyPath;
+    }
+}

Added: incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/ResourceManagerImp.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/ResourceManagerImp.java?rev=1148497&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/ResourceManagerImp.java (added)
+++ incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/ResourceManagerImp.java Tue Jul 19 19:37:37 2011
@@ -0,0 +1,678 @@
+/*
+ * 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.store.rest;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.Vector;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.stanbol.ontologymanager.store.api.ResourceManager;
+import org.osgi.service.component.ComponentContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Class that relates URL(Path)s used by the RESTful interface with the URIs used by the underlying triple
+ * store
+ * 
+ * @author gunes
+ */
+
+@Component(enabled = true)
+@Service
+public class ResourceManagerImp implements ResourceManager {
+
+    private static final String DELIMITER = "|";
+    
+    private static final String DB_URL = "jdbc:derby:ps_db;create=true";
+
+    private static String ontologyPathPrefix = "/ontology/";
+
+    private static String classPathPrefix = "classes/";
+
+    private static String dataPropertyPathPrefix = "datatypeProperties/";
+
+    private static String objectPropertyPathPrefix = "objectProperties/";
+
+    private static String individualPathPrefix = "individuals/";
+
+    private static String ontologiesTable = "resource_manager_ontologies";
+
+    private static String resourcesTable = "resource_manager_resources";
+
+    public static String CLASS_RESOURCE = "CLASS";
+
+    public static String DATA_PROPERTY_RESOURCE = "DATA_PROPERTY";
+
+    public static String OBJECT_PROPERTY_RESOURCE = "OBJECT_PROPERTY";
+
+    public static String INDIVIDUAL_RESOURCE = "INDIVIDUAL";
+
+    Dictionary<String,String> properties = null;
+
+    /** Logger instance **/
+    private static Logger logger = LoggerFactory.getLogger(ResourceManagerImp.class);
+
+    /* private variables to store ontology-path (URI-URL) relations */
+    /* ontologyURI --> ontologyPath */
+    private Hashtable<String,String> ontologies = null;
+
+    /* ontologyPath --> ontologyURI */
+    private Hashtable<String,String> ontologiesInverted = null;
+
+    /*
+     * private varibles to store resource(class/property/individual)-path (resource URI - resource URL)
+     * relations
+     */
+    /* resourceURI --> resourcePath */
+    private Hashtable<String,String> resources = null;
+
+    /* resourcePath --> resourceURI */
+    private Hashtable<String,String> resourcesInverted = null;
+
+    /*
+     * the type of the resource could be values attributed by the static variables: CLASS_RESOURCE,
+     * DATA_PROPERTY_RESOURCE, OBJECT_PROPERTY_RESOURCE and INDIVIDUAL_RESOURCE
+     */
+    /* resourceURI --> resourceType */
+    private Hashtable<String,String> resourcesTypes = null;
+
+    /*
+     * private variable to store the mapping between resource URI - ontology URI, where the resource belongs
+     * to that ontology
+     */
+    /* resourceURI --> ontologyURI */
+    private Hashtable<String,String> resourceToOntologyURIs = null;
+
+    private static ResourceManagerImp INSTANCE = null;
+
+    private void restore() throws IOException {
+        try {
+            Connection con = obtainConnection();
+            Statement statement = con.createStatement();
+
+            boolean ontologiesTableExist = checkTableExists(con, ontologiesTable);
+            boolean resourceTableExist = checkTableExists(con, resourcesTable);
+
+            if (!ontologiesTableExist) {
+                Statement stmt = con.createStatement();
+                String sql = "CREATE TABLE resource_manager_ontologies ("
+                             + "id INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),"
+                             + "ontologyURI varchar(255) DEFAULT NULL,"
+                             + "ontologyPath varchar(255) DEFAULT NULL," + "PRIMARY KEY (id)" + ")";
+                stmt.executeUpdate(sql);
+            }
+
+            if (!resourceTableExist) {
+                // the table does not exist
+                Statement stmt = con.createStatement();
+                String sql = "CREATE TABLE resource_manager_resources (" + "id INTEGER DEFAULT NULL,"
+                             + "resourceURI varchar(255) DEFAULT NULL,"
+                             + "resourcePath varchar(255) DEFAULT NULL,"
+                             + "resourceType varchar(255) DEFAULT NULL" + ") ";
+                stmt.executeUpdate(sql);
+            }
+
+            ResultSet rSet = statement.executeQuery("SELECT * FROM " + ontologiesTable);
+            while (rSet.next()) {
+                String ontologyURI = rSet.getString("ontologyURI");
+                String ontologyPath = rSet.getString("ontologyPath");
+                ontologies.put(ontologyURI, ontologyPath);
+                ontologiesInverted.put(ontologyPath, ontologyURI);
+            }
+            Statement statement2 = con.createStatement();
+            ResultSet rSet2 = statement2.executeQuery("SELECT * from " + resourcesTable);
+            while (rSet2.next()) {
+                String resourceURI = rSet2.getString("resourceURI");
+                String resourcePath = rSet2.getString("resourcePath");
+                String resourceType = rSet2.getString("resourceType");
+                String ontologyTableRowRef = rSet2.getString("id");
+                Statement statement3 = con.createStatement();
+                ResultSet rSet3 = statement3.executeQuery("SELECT * from " + ontologiesTable + " WHERE id="
+                                                          + ontologyTableRowRef);
+                if (rSet3.next()) {
+                    String ontologyURIForResource = rSet3.getString("ontologyURI");
+                    String ontologyPathForResource = rSet3.getString("ontologyPath");
+                    resources.put(ontologyURIForResource + DELIMITER + resourceURI, resourcePath);
+                    resourcesInverted.put(ontologyPathForResource + DELIMITER + resourcePath, resourceURI);
+                    resourceToOntologyURIs.put(resourceURI, ontologyURIForResource);
+                    resourcesTypes.put(ontologyURIForResource + DELIMITER + resourceURI, resourceType);
+                }
+            }
+            con.close();
+        } catch (Exception e) {
+            throw new RuntimeException("Resource manager can not restore ", e);
+        }
+    }
+
+    private boolean checkTableExists(Connection con, String tableName) throws SQLException {
+        // FIXME This should be done by jdbc's table functionality but it does
+        // not seem to work with Apache Derby
+        Statement stmt = con.createStatement();
+        String stmtString = "SELECT COUNT(*) FROM " + tableName;
+        boolean exists = true;
+        try {
+            stmt.execute(stmtString);
+        } catch (SQLException e) {
+            String state = (e).getSQLState();
+            if ("42X05".equals(state)) exists = false;
+        } finally {
+            stmt.close();
+        }
+        return exists;
+    }
+
+    @Activate
+    public void activate(ComponentContext cc) {
+        try {
+            this.restore();
+        } catch (IOException e) {
+            throw new RuntimeException("Can not restore stored information", e);
+        }
+        logger.info("Resource Manager properties are set");
+    }
+
+    public ResourceManagerImp() {
+        INSTANCE = this;
+        ontologies = new Hashtable<String,String>();
+        ontologiesInverted = new Hashtable<String,String>();
+        resources = new Hashtable<String,String>();
+        resourcesInverted = new Hashtable<String,String>();
+        resourceToOntologyURIs = new Hashtable<String,String>();
+        resourcesTypes = new Hashtable<String,String>();
+    }
+
+    public static ResourceManagerImp getInstance() {
+        if (INSTANCE == null) {
+            INSTANCE = new ResourceManagerImp();
+        }
+
+        return INSTANCE;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @seeeu.iksproject.fise.stores.persistencestore.rest.IResourceManager#
+     * registerOntology(java.lang.String)
+     */
+    public void registerOntology(String ontologyURI) {
+        try {
+            if (!ontologies.containsKey(ontologyURI)) {
+                String ontologyPath = normalizeURI(ontologyURI);
+                ontologies.put(ontologyURI, ontologyPath);
+                ontologiesInverted.put(ontologyPath, ontologyURI);
+
+                Connection con = obtainConnection();
+                Statement statement = con.createStatement();
+                statement.executeUpdate("INSERT INTO " + ontologiesTable
+                                        + " (ontologyURI, ontologyPath) VALUES ('" + ontologyURI + "', '"
+                                        + ontologyPath + "')");
+                con.close();
+            }
+        } catch (Exception e) {
+            logger.error("Error ", e);
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @seeeu.iksproject.fise.stores.persistencestore.rest.IResourceManager# registerClass(java.lang.String,
+     * java.lang.String)
+     */
+    public void registerClass(String ontologyURI, String classURI) {
+        try {
+            if (!resources.containsKey(ontologyURI + DELIMITER + classURI)) {
+                String classPath = normalizeURI(classURI);
+                resources.put(ontologyURI + DELIMITER + classURI, classPath);
+                resourcesInverted.put(ontologies.get(ontologyURI) + DELIMITER + classPath, classURI);
+                resourceToOntologyURIs.put(classURI, ontologyURI);
+                resourcesTypes.put(ontologyURI + DELIMITER + classURI, CLASS_RESOURCE);
+                Connection con = obtainConnection();
+                Statement statement = con.createStatement();
+                ResultSet rSet = statement.executeQuery("SELECT id from " + ontologiesTable
+                                                        + " WHERE ontologyURI='" + ontologyURI + "'");
+                if (rSet.next()) {
+                    String ontologyRowID = rSet.getString("id");
+                    statement.executeUpdate("INSERT INTO " + resourcesTable
+                                            + " (id, resourceURI, resourcePath, resourceType) VALUES ("
+                                            + ontologyRowID + ", '" + classURI + "', '" + classPath + "', '"
+                                            + CLASS_RESOURCE + "')");
+                }
+                con.close();
+            }
+        } catch (Exception e) {
+            logger.error("Error ", e);
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @seeeu.iksproject.fise.stores.persistencestore.rest.IResourceManager#
+     * registerDatatypeProperty(java.lang.String, java.lang.String)
+     */
+    public void registerDatatypeProperty(String ontologyURI, String dataPropertyURI) {
+        try {
+            if (!resources.containsKey(ontologyURI + DELIMITER + dataPropertyURI)) {
+                String dataPropertyPath = normalizeURI(dataPropertyURI);
+                resources.put(ontologyURI + DELIMITER + dataPropertyURI, dataPropertyPath);
+                resourcesInverted.put(ontologies.get(ontologyURI) + DELIMITER + dataPropertyPath, dataPropertyURI);
+                resourceToOntologyURIs.put(dataPropertyURI, ontologyURI);
+                resourcesTypes.put(ontologyURI + DELIMITER + dataPropertyURI, DATA_PROPERTY_RESOURCE);
+                Connection con = obtainConnection();
+                Statement statement = con.createStatement();
+                ResultSet rSet = statement.executeQuery("SELECT id from " + ontologiesTable
+                                                        + " WHERE ontologyURI='" + ontologyURI + "'");
+                if (rSet.next()) {
+                    String ontologyRowID = rSet.getString("id");
+                    statement.executeUpdate("INSERT INTO " + resourcesTable
+                                            + " (id, resourceURI, resourcePath, resourceType) VALUES ("
+                                            + ontologyRowID + ", '" + dataPropertyURI + "', '"
+                                            + dataPropertyPath + "', '" + DATA_PROPERTY_RESOURCE + "')");
+                }
+                con.close();
+            }
+        } catch (Exception e) {
+            logger.error("Error ", e);
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @seeeu.iksproject.fise.stores.persistencestore.rest.IResourceManager#
+     * registerObjectProperty(java.lang.String, java.lang.String)
+     */
+    public void registerObjectProperty(String ontologyURI, String objectPropertyURI) {
+        try {
+            if (!resources.containsKey(ontologyURI + DELIMITER + objectPropertyURI)) {
+                String objectPropertyPath = normalizeURI(objectPropertyURI);
+                resources.put(ontologyURI + DELIMITER + objectPropertyURI, objectPropertyPath);
+                resourcesInverted.put(ontologies.get(ontologyURI) + DELIMITER + objectPropertyPath,
+                    objectPropertyURI);
+                resourceToOntologyURIs.put(objectPropertyURI, ontologyURI);
+                resourcesTypes.put(ontologyURI + DELIMITER + objectPropertyURI, OBJECT_PROPERTY_RESOURCE);
+                Connection con = obtainConnection();
+                Statement statement = con.createStatement();
+                ResultSet rSet = statement.executeQuery("SELECT id from " + ontologiesTable
+                                                        + " WHERE ontologyURI='" + ontologyURI + "'");
+                if (rSet.next()) {
+                    String ontologyRowID = rSet.getString("id");
+                    statement.executeUpdate("INSERT INTO " + resourcesTable
+                                            + " (id, resourceURI, resourcePath, resourceType) VALUES ("
+                                            + ontologyRowID + ", '" + objectPropertyURI + "', '"
+                                            + objectPropertyPath + "', '" + OBJECT_PROPERTY_RESOURCE + "')");
+                }
+                con.close();
+            }
+        } catch (Exception e) {
+            logger.error("Error ", e);
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @seeeu.iksproject.fise.stores.persistencestore.rest.IResourceManager#
+     * registerIndividual(java.lang.String, java.lang.String)
+     */
+    public void registerIndividual(String ontologyURI, String individualURI) {
+        try {
+            if (!resources.containsKey(ontologyURI + DELIMITER + individualURI)) {
+                String individualPath = normalizeURI(individualURI);
+                resources.put(ontologyURI + DELIMITER + individualURI, individualPath);
+                resourcesInverted.put(ontologies.get(ontologyURI) + DELIMITER + individualPath, individualURI);
+                resourceToOntologyURIs.put(individualURI, ontologyURI);
+                resourcesTypes.put(ontologyURI + DELIMITER + individualURI, INDIVIDUAL_RESOURCE);
+                Connection con = obtainConnection();
+                Statement statement = con.createStatement();
+                ResultSet rSet = statement.executeQuery("SELECT id from " + ontologiesTable
+                                                        + " WHERE ontologyURI='" + ontologyURI + "'");
+                if (rSet.next()) {
+                    String ontologyRowID = rSet.getString("id");
+                    String statementstr = "INSERT INTO " + resourcesTable
+                                          + " (id, resourceURI, resourcePath, resourceType) VALUES ("
+                                          + ontologyRowID + ", '" + individualURI + "', '" + individualPath
+                                          + "', '" + INDIVIDUAL_RESOURCE + "')";
+                    statement.executeUpdate(statementstr);
+                }
+                con.close();
+            }
+        } catch (Exception e) {
+            logger.error("Error ", e);
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @see
+     * 
+     * org.apache.stanbol.persistencestore.rest.IResourceManager#hasOntology (java.lang.String)
+     */
+    public boolean hasOntology(String ontologyURI) {
+        boolean result = ontologies.containsKey(ontologyURI);
+        return result;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @seeeu.iksproject.fise.stores.persistencestore.rest.IResourceManager# getOntologyPath(java.lang.String)
+     */
+    public String getOntologyPath(String ontologyURI) {
+        String result = null;
+        if (ontologies.containsKey(ontologyURI)) {
+            result = ontologies.get(ontologyURI);
+        }
+        return result;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @seeeu.iksproject.fise.stores.persistencestore.rest.IResourceManager#
+     * getOntologyFullPath(java.lang.String)
+     */
+    public String getOntologyFullPath(String ontologyURI) {
+        String result = null;
+        if (ontologies.containsKey(ontologyURI)) {
+            result = ontologyPathPrefix + ontologies.get(ontologyURI);
+        }
+        return result;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @seeeu.iksproject.fise.stores.persistencestore.rest.IResourceManager#
+     * getResourceFullPath(java.lang.String)
+     */
+    public String getResourceFullPath(String resourceURI) {
+        String result = null;
+        String ontologyURI = resourceToOntologyURIs.get(resourceURI);
+        if (ontologies.containsKey(ontologyURI) && resources.containsKey(ontologyURI + DELIMITER + resourceURI)) {
+            String resourceType = resourcesTypes.get(ontologyURI + DELIMITER + resourceURI);
+            String pathPrefix = null;
+            if (resourceType.equalsIgnoreCase(CLASS_RESOURCE)) {
+                pathPrefix = classPathPrefix;
+            } else if (resourceType.equalsIgnoreCase(OBJECT_PROPERTY_RESOURCE)) {
+                pathPrefix = objectPropertyPathPrefix;
+            } else if (resourceType.equalsIgnoreCase(DATA_PROPERTY_RESOURCE)) {
+                pathPrefix = dataPropertyPathPrefix;
+            } else if (resourceType.equalsIgnoreCase(INDIVIDUAL_RESOURCE)) {
+                pathPrefix = individualPathPrefix;
+            }
+            result = ontologyPathPrefix + ontologies.get(ontologyURI) + "/" + pathPrefix
+                     + resources.get(ontologyURI + DELIMITER + resourceURI);
+        }
+        return result;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @seeeu.iksproject.fise.stores.persistencestore.rest.IResourceManager#
+     * getOntologyURIForPath(java.lang.String)
+     */
+    public String getOntologyURIForPath(String ontologyPath) {
+        String result = null;
+        if (ontologiesInverted.containsKey(ontologyPath)) {
+            result = ontologiesInverted.get(ontologyPath);
+        }
+        return result;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @seeeu.iksproject.fise.stores.persistencestore.rest.IResourceManager#
+     * getResourceURIForPath(java.lang.String, java.lang.String)
+     */
+    public String getResourceURIForPath(String ontologyPath, String resourcePath) {
+        String result = null;
+        if (resourcesInverted.containsKey(ontologyPath + DELIMITER + resourcePath)) {
+            result = resourcesInverted.get(ontologyPath + DELIMITER + resourcePath);
+        }
+        return result;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @seeeu.iksproject.fise.stores.persistencestore.rest.IResourceManager# getResourceType(java.lang.String)
+     */
+    public String getResourceType(String resourceURI) {
+        String result = resourcesTypes.get(resourceURI);
+        return result;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @seeeu.iksproject.fise.stores.persistencestore.rest.IResourceManager# removeOntology(java.lang.String)
+     */
+    public void removeOntology(String ontologyURI) {
+        try {
+            // first clear hashtables
+            String ontologyPath = ontologies.get(ontologyURI);
+            if (ontologyPath == null) {
+                logger.warn("Ontology {} already deleted ", ontologyURI);
+                return;
+            }
+            ontologies.remove(ontologyURI);
+            ontologiesInverted.remove(ontologyPath);
+
+            List<String> keysToRemove = new Vector<String>();
+            Set<String> resources_keys = resources.keySet();
+            Iterator<String> resources_keys_itr = resources_keys.iterator();
+            while (resources_keys_itr.hasNext()) {
+                String key = resources_keys_itr.next();
+                //FIXME were startswith
+                if (key.split("\\"+DELIMITER)[0].contentEquals(ontologyURI)) {
+                    keysToRemove.add(key);
+                }
+            }
+            Iterator<String> keysToRemoveItr = keysToRemove.iterator();
+            while (keysToRemoveItr.hasNext()) {
+                resources.remove(keysToRemoveItr.next());
+            }
+
+            keysToRemove = new Vector<String>();
+            Set<String> resourcesInverted_keys = resourcesInverted.keySet();
+            Iterator<String> resourcesInverted_keys_itr = resourcesInverted_keys.iterator();
+            while (resourcesInverted_keys_itr.hasNext()) {
+                String key = resourcesInverted_keys_itr.next();
+                //FIXME were startswith
+                if (key.split("\\"+DELIMITER)[0].contentEquals(ontologyURI)) {
+                    keysToRemove.add(key);
+                }
+            }
+            keysToRemoveItr = keysToRemove.iterator();
+            while (keysToRemoveItr.hasNext()) {
+                resourcesInverted.remove(keysToRemoveItr.next());
+            }
+
+            keysToRemove = new Vector<String>();
+            Set<String> resourcesTypes_keys = resourcesTypes.keySet();
+            Iterator<String> resourcesTypes_keys_itr = resourcesTypes_keys.iterator();
+            while (resourcesTypes_keys_itr.hasNext()) {
+                String key = resourcesTypes_keys_itr.next();
+                //FIXME were startswith
+                if (key.split("\\"+DELIMITER)[0].contentEquals(ontologyURI)) {
+                    keysToRemove.add(key);
+                }
+            }
+            keysToRemoveItr = keysToRemove.iterator();
+            while (keysToRemoveItr.hasNext()) {
+                resourcesTypes.remove(keysToRemoveItr.next());
+            }
+
+            keysToRemove = new Vector<String>();
+            Set<String> resourceToOntologyURIs_keys = resourceToOntologyURIs.keySet();
+            Iterator<String> resourceToOntologyURIs_keys_itr = resourceToOntologyURIs_keys.iterator();
+            while (resourceToOntologyURIs_keys_itr.hasNext()) {
+                String key = resourceToOntologyURIs_keys_itr.next();
+                String value = resourceToOntologyURIs.get(key);
+                if (value.equalsIgnoreCase(ontologyURI)) {
+                    keysToRemove.add(key);
+                }
+            }
+            keysToRemoveItr = keysToRemove.iterator();
+            while (keysToRemoveItr.hasNext()) {
+                resourceToOntologyURIs.remove(keysToRemoveItr.next());
+            }
+
+            // then clear database
+            Connection con = obtainConnection();
+            Statement statement = con.createStatement();
+            String sql = "SELECT id from " + ontologiesTable + " WHERE ontologyURI='" + ontologyURI + "'";
+            ResultSet rSet = statement.executeQuery(sql);
+            String id = null;
+            if (rSet.next()) {
+                id = rSet.getString("id");
+            }
+
+            statement = con.createStatement();
+            sql = "DELETE from " + ontologiesTable + " WHERE id=" + id;
+            statement.executeUpdate(sql);
+
+            statement = con.createStatement();
+            sql = "DELETE from " + resourcesTable + " WHERE id=" + id;
+            statement.executeUpdate(sql);
+
+            con.close();
+
+        } catch (Exception e) {
+            logger.error("Error ", e);
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @seeeu.iksproject.fise.stores.persistencestore.rest.IResourceManager# removeResource(java.lang.String)
+     */
+    public void removeResource(String resourceURI) {
+        try {
+            // first clear hashtables
+            String classPath = resources.get(resourceURI);
+            if (classPath == null) {
+                logger.warn("Resource {} not found", resourceURI);
+                return;
+            }
+
+            String ontologyURI = resourceToOntologyURIs.get(resourceURI);
+            String ontologyPath = ontologies.get(ontologyURI);
+            resources.remove(ontologyURI + DELIMITER + resourceURI);
+            resourcesInverted.remove(ontologyPath + DELIMITER + classPath);
+            resourcesTypes.remove(ontologyURI + DELIMITER + resourceURI);
+            resourceToOntologyURIs.remove(resourceURI);
+
+            // then clear database
+            Connection con = obtainConnection();
+            Statement statement = con.createStatement();
+            String sql = "DELETE from " + resourcesTable + " WHERE resourceURI='" + resourceURI + "'";
+            statement.executeUpdate(sql);
+            con.close();
+        } catch (Exception e) {
+            logger.error("Error ", e);
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @seeeu.iksproject.fise.stores.persistencestore.rest.IResourceManager#
+     * resolveOntologyURIFromResourceURI(java.lang.String)
+     */
+    public String resolveOntologyURIFromResourceURI(String resourceURI) {
+        String result = null;
+        if (resourceToOntologyURIs.containsKey(resourceURI)) {
+            result = resourceToOntologyURIs.get(resourceURI);
+        }
+        return result;
+    }
+
+    /*
+     * (non-Javadoc)
+     * 
+     * @seeeu.iksproject.fise.stores.persistencestore.rest.IResourceManager# clearResourceManager()
+     */
+    public void clearResourceManager() {
+        try {
+            // first clear hashtables
+            ontologies.clear();
+            ontologiesInverted.clear();
+            resources.clear();
+            resourcesInverted.clear();
+            resourcesTypes.clear();
+            resourceToOntologyURIs.clear();
+
+            // then clear database
+            Connection con = obtainConnection();
+            boolean ontologiesTableExists = checkTableExists(con, ontologiesTable);
+            boolean resourceTableExists = checkTableExists(con, resourcesTable);
+            Statement statement = con.createStatement();
+            if (ontologiesTableExists) {
+                String sql1 = "DELETE  FROM " + ontologiesTable;
+                statement.executeUpdate(sql1);
+            }
+            if (resourceTableExists) {
+                statement = con.createStatement();
+                String sql2 = "DELETE FROM " + resourcesTable;
+                statement.execute(sql2);
+            }
+            con.close();
+            logger.info("Connection Closed");
+        } catch (Exception e) {
+            logger.error("Error ", e);
+        }
+    }
+
+    public Connection obtainConnection() throws InstantiationException,
+                                        IllegalAccessException,
+                                        ClassNotFoundException,
+                                        SQLException {
+        return DriverManager.getConnection(DB_URL);
+    }
+
+    private String normalizeURI(String uri) {
+        // FIXME Find a solution to # problem
+        return uri.replace("#", "/");
+    }
+
+    @Override
+    public String convertEntityRelativePathToURI(String entityPath) {
+        return entityPath.substring(0, entityPath.lastIndexOf("/")) + "#"
+               + entityPath.substring(entityPath.lastIndexOf("/") + 1);
+    }
+}

Added: incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/StoreWebFragment.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/StoreWebFragment.java?rev=1148497&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/StoreWebFragment.java (added)
+++ incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/StoreWebFragment.java Tue Jul 19 19:37:37 2011
@@ -0,0 +1,161 @@
+/*
+ * 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.store.rest;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.stanbol.commons.web.base.LinkResource;
+import org.apache.stanbol.commons.web.base.NavigationLink;
+import org.apache.stanbol.commons.web.base.ScriptResource;
+import org.apache.stanbol.commons.web.base.WebFragment;
+import org.apache.stanbol.ontologymanager.store.rest.resources.Ontologies;
+import org.apache.stanbol.ontologymanager.store.rest.resources.OntologyClasses;
+import org.apache.stanbol.ontologymanager.store.rest.resources.OntologyDatatypeProperties;
+import org.apache.stanbol.ontologymanager.store.rest.resources.OntologyImports;
+import org.apache.stanbol.ontologymanager.store.rest.resources.OntologyIndividuals;
+import org.apache.stanbol.ontologymanager.store.rest.resources.OntologyObjectProperties;
+import org.apache.stanbol.ontologymanager.store.rest.resources.ParticularClass;
+import org.apache.stanbol.ontologymanager.store.rest.resources.ParticularClassDisjointClasses;
+import org.apache.stanbol.ontologymanager.store.rest.resources.ParticularClassEquivalentClasses;
+import org.apache.stanbol.ontologymanager.store.rest.resources.ParticularClassSuperClasses;
+import org.apache.stanbol.ontologymanager.store.rest.resources.ParticularDatatypeProperty;
+import org.apache.stanbol.ontologymanager.store.rest.resources.ParticularDatatypePropertyDomains;
+import org.apache.stanbol.ontologymanager.store.rest.resources.ParticularDatatypePropertyRanges;
+import org.apache.stanbol.ontologymanager.store.rest.resources.ParticularDatatypePropertySuperProperties;
+import org.apache.stanbol.ontologymanager.store.rest.resources.ParticularIndividual;
+import org.apache.stanbol.ontologymanager.store.rest.resources.ParticularIndividualPropertyAssertions;
+import org.apache.stanbol.ontologymanager.store.rest.resources.ParticularIndividualTypes;
+import org.apache.stanbol.ontologymanager.store.rest.resources.ParticularObjectProperty;
+import org.apache.stanbol.ontologymanager.store.rest.resources.ParticularObjectPropertyDomains;
+import org.apache.stanbol.ontologymanager.store.rest.resources.ParticularObjectPropertyRanges;
+import org.apache.stanbol.ontologymanager.store.rest.resources.ParticularObjectPropertySuperProperties;
+import org.apache.stanbol.ontologymanager.store.rest.resources.ParticularOntology;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.component.ComponentContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import freemarker.cache.ClassTemplateLoader;
+import freemarker.cache.TemplateLoader;
+
+@Component(immediate = true, metatype = true)
+@Service
+public class StoreWebFragment implements WebFragment {
+    private static final Logger log = LoggerFactory.getLogger(StoreWebFragment.class);
+    private static final String NAME = "ontology";
+
+    private static final String TEMPLATE_PATH = "/org/apache/stanbol/commons/web/ontologymanager/store/templates";
+    private static final String STATIC_RESOURCE_PATH = "/org/apache/stanbol/commons/web/ontologymanager/store/static";
+
+    private BundleContext bundleContext;
+
+    @Override
+    public String getName() {
+        return NAME;
+    }
+
+    @Activate
+    protected void activate(ComponentContext ctx) {
+        this.bundleContext = ctx.getBundleContext();
+    }
+
+    @Override
+    public Set<Class<?>> getJaxrsResourceClasses() {
+        Set<Class<?>> classes = new HashSet<Class<?>>();
+        classes.add(Ontologies.class);
+        classes.add(OntologyClasses.class);
+        classes.add(OntologyDatatypeProperties.class);
+        classes.add(OntologyObjectProperties.class);
+        classes.add(OntologyIndividuals.class);
+        classes.add(OntologyImports.class);
+        classes.add(ParticularClass.class);
+        classes.add(ParticularDatatypeProperty.class);
+        classes.add(ParticularOntology.class);
+        classes.add(ParticularObjectProperty.class);
+        classes.add(ParticularIndividual.class);
+        classes.add(ParticularClassSuperClasses.class);
+        classes.add(ParticularClassDisjointClasses.class);
+        classes.add(ParticularClassEquivalentClasses.class);
+        classes.add(ParticularObjectPropertyRanges.class);
+        classes.add(ParticularObjectPropertyDomains.class);
+        classes.add(ParticularObjectPropertySuperProperties.class);
+        classes.add(ParticularDatatypePropertyDomains.class);
+        classes.add(ParticularDatatypePropertyRanges.class);
+        classes.add(ParticularDatatypePropertySuperProperties.class);
+        classes.add(ParticularIndividualTypes.class);
+        classes.add(ParticularIndividualPropertyAssertions.class);
+
+        return classes;
+    }
+
+    @Override
+    public Set<Object> getJaxrsResourceSingletons() {
+        Set<Object> singletons = new HashSet<Object>();
+        try {
+            singletons.add(new JAXBProvider());
+        } catch (Exception e) {
+            log.warn("Error in creating JAXB provider, ", e);
+        }
+        return singletons;
+    }
+
+    @Override
+    public String getStaticResourceClassPath() {
+        return STATIC_RESOURCE_PATH;
+    }
+
+    @Override
+    public TemplateLoader getTemplateLoader() {
+        return new ClassTemplateLoader(getClass(), TEMPLATE_PATH);
+    }
+
+    @Override
+    public List<LinkResource> getLinkResources() {
+        List<LinkResource> resources = new ArrayList<LinkResource>();
+        resources.add(new LinkResource("stylesheet", "style/store.css", this, 0));
+        return resources;
+    }
+
+    @Override
+    public List<ScriptResource> getScriptResources() {
+        List<ScriptResource> resources = new ArrayList<ScriptResource>();
+        resources.add(new ScriptResource("text/javascript", "scripts/paging.js", this, 0));
+        resources.add(new ScriptResource("text/javascript", "scripts/propertyUpdater.js", this, 1));
+        resources.add(new ScriptResource("text/javascript", "scripts/requestResponse.js", this, 2));
+        resources.add(new ScriptResource("text/javascript", "scripts/individualUpdater.js", this, 3));
+        return resources;
+    }
+
+    @Override
+    public List<NavigationLink> getNavigationLinks() {
+        List<NavigationLink> links = new ArrayList<NavigationLink>();
+        links.add(new NavigationLink("ontology", "/ontology", "/imports/storeDescription.ftl", 70));
+        return links;
+    }
+
+    @Override
+    public BundleContext getBundleContext() {
+        return bundleContext;
+    }
+
+}

Added: incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/Ontologies.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/Ontologies.java?rev=1148497&view=auto
==============================================================================
--- incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/Ontologies.java (added)
+++ incubator/stanbol/trunk/ontologymanager/store/web/src/main/java/org/apache/stanbol/ontologymanager/store/rest/resources/Ontologies.java Tue Jul 19 19:37:37 2011
@@ -0,0 +1,178 @@
+/*
+ * 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.store.rest.resources;
+
+import static javax.ws.rs.core.MediaType.TEXT_HTML;
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.stanbol.commons.web.base.ContextHelper;
+import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
+import org.apache.stanbol.ontologymanager.store.api.LockManager;
+import org.apache.stanbol.ontologymanager.store.api.PersistenceStore;
+import org.apache.stanbol.ontologymanager.store.api.ResourceManager;
+import org.apache.stanbol.ontologymanager.store.model.AdministeredOntologies;
+import org.apache.stanbol.ontologymanager.store.model.OntologyMetaInformation;
+import org.apache.stanbol.ontologymanager.store.rest.LockManagerImp;
+import org.apache.stanbol.ontologymanager.store.rest.ResourceManagerImp;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.sun.jersey.api.view.Viewable;
+
+@Path("/ontology")
+public class Ontologies extends BaseStanbolResource {
+    private static final Logger logger = LoggerFactory.getLogger(Ontologies.class);
+
+    private static final String VIEWABLE_PATH = "/org/apache/stanbol/ontologymanager/store/rest/resources/ontologies";
+
+    private PersistenceStore persistenceStore;
+
+    public Ontologies(@Context ServletContext context) {
+        this.persistenceStore = ContextHelper.getServiceFromContext(PersistenceStore.class, context);
+    }
+
+    @GET
+    @Produces({MediaType.APPLICATION_XML})
+    public Object getClichedMessage() {
+
+        LockManager lockManager = LockManagerImp.getInstance();
+        lockManager.obtainReadLockFor(LockManagerImp.GLOBAL_SPACE);
+        Response response = null;
+        try {
+            AdministeredOntologies administeredOntologies = persistenceStore.retrieveAdministeredOntologies();
+            response = Response.ok(administeredOntologies, MediaType.APPLICATION_XML_TYPE).build();
+        } catch (Exception e) {
+            throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
+        } finally {
+            lockManager.releaseReadLockFor(LockManagerImp.GLOBAL_SPACE);
+        }
+        return response;
+
+    }
+
+    @POST
+    @Consumes("application/x-www-form-urlencoded")
+    @Produces(MediaType.APPLICATION_XML)
+    public Response saveOntology(@FormParam("ontologyURI") String ontologyURI,
+                                 @FormParam("ontologyContent") String ontologyContent) {
+        Response response = null;
+        LockManager lockManager = LockManagerImp.getInstance();
+        lockManager.obtainReadLockFor(LockManagerImp.GLOBAL_SPACE);
+        lockManager.obtainWriteLockFor(ontologyURI);
+        try {
+            OntologyMetaInformation ontologyMetaInformation = null;
+            if (ontologyContent != null && !ontologyContent.isEmpty()) {
+                ontologyMetaInformation = persistenceStore
+                        .saveOntology(ontologyContent, ontologyURI, "UTF-8");
+            } else if (ontologyURI != null && !ontologyURI.isEmpty()) {
+                try{
+                ontologyMetaInformation = persistenceStore.saveOntology(new URL(ontologyURI), ontologyURI,
+                    "UTF-8");
+                }catch (MalformedURLException e) {
+                    throw new WebApplicationException(e, Status.BAD_REQUEST);
+                }
+            }else{
+                throw new WebApplicationException(new IllegalArgumentException("Ontology Content or URI can not be both null"),Status.BAD_REQUEST);
+            }
+            response = Response.ok(ontologyMetaInformation, MediaType.APPLICATION_XML_TYPE).build();
+        } catch (Exception e) {
+            logger.error("Error ", e);
+            throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
+        } finally {
+            lockManager.releaseReadLockFor(LockManagerImp.GLOBAL_SPACE);
+            lockManager.releaseWriteLockFor(ontologyURI);
+        }
+        return response;
+    }
+
+    // The Java method will process HTTP DELETE requests
+    @DELETE
+    public void delete() {
+        LockManager lockManager = LockManagerImp.getInstance();
+        lockManager.obtainWriteLockFor(LockManagerImp.GLOBAL_SPACE);
+        try {
+
+            persistenceStore.clearPersistenceStore();
+            ResourceManager resourceManager = ResourceManagerImp.getInstance();
+            resourceManager.clearResourceManager();
+        } catch (Exception e) {
+            logger.error("Error ", e);
+            throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
+        } finally {
+            lockManager.releaseWriteLockFor(LockManagerImp.GLOBAL_SPACE);
+        }
+    }
+
+    // Methods for HTML View
+    @GET
+    @Produces(TEXT_HTML + ";qs=2")
+    public Viewable getViewable(@Context UriInfo uriInfo) {
+        return new Viewable(VIEWABLE_PATH, this);
+    }
+
+    @POST
+    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
+    @Produces(MediaType.TEXT_HTML + ";qs=2")
+    public Response createAndRedirect(@FormParam("ontologyURI") String ontologyURI,
+                                      @FormParam("ontologyContent") String ontologyContent) {
+        Response response = this.saveOntology(ontologyURI, ontologyContent);
+        OntologyMetaInformation ont = ((OntologyMetaInformation) response.getEntity());
+        try {
+            return Response.seeOther(URI.create(ont.getHref())).type(MediaType.TEXT_HTML)
+                    .header("Accept", MediaType.TEXT_HTML).build();
+        } catch (Exception e) {
+            logger.error("Error ", e);
+            throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR);
+        }
+
+    }
+
+    public List<OntologyMetaInformation> getOntologies() {
+        LockManager lockManager = LockManagerImp.getInstance();
+        lockManager.obtainReadLockFor(LockManagerImp.GLOBAL_SPACE);
+        List<OntologyMetaInformation> onts = new ArrayList<OntologyMetaInformation>();
+        try {
+            onts = persistenceStore.retrieveAdministeredOntologies().getOntologyMetaInformation();
+        } catch (Exception e) {
+            logger.error("Error ", e);
+            throw new RuntimeException(e);
+        } finally {
+            lockManager.releaseReadLockFor(LockManagerImp.GLOBAL_SPACE);
+        }
+        return onts;
+    }
+}