You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by co...@apache.org on 2011/03/20 18:01:36 UTC
svn commit: r1083505 [1/9] - in /incubator/stanbol/trunk/kres/jersey: ./
src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/stanbol/ src/main/java/org/apache/stanbol/kres/
src/main/java/org/apache/stanbo...
Author: concelvio
Date: Sun Mar 20 17:01:32 2011
New Revision: 1083505
URL: http://svn.apache.org/viewvc?rev=1083505&view=rev
Log:
STANBOL-39:
1) Created the module kres/jersey and added required pom.xml and src directory
2) Moved all the remain classes of eu.iksproject.kres.jersey after deleting classes of rest services (shifted in rules/web, reasoners/web, reengineer/web and ontologymanager/web) to org.apache.stanbol.kres.jersey (module kres/jersey)
Added:
incubator/stanbol/trunk/kres/jersey/ (with props)
incubator/stanbol/trunk/kres/jersey/pom.xml
incubator/stanbol/trunk/kres/jersey/src/
incubator/stanbol/trunk/kres/jersey/src/main/
incubator/stanbol/trunk/kres/jersey/src/main/java/
incubator/stanbol/trunk/kres/jersey/src/main/java/org/
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/JerseyEndpoint.java
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/JerseyEndpointApplication.java
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/JettyServer.java
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/format/
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/format/KReSFormat.java
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/processors/
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/processors/KReSViewProcessor.java
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/DocumentationResource.java
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/GraphsResource.java
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/KReSResource.java
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/KReSSessionIDResource.java
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/KReSSessionResource.java
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/NavigationMixin.java
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/RESTfulResource.java
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/util/
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/util/OntologyRenderUtils.java
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/writers/
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/writers/GraphWriter.java
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/writers/JSONJenaWriter.java
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/writers/JenaModelTransformer.java
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/writers/JenaModelWriter.java
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/writers/OWLOntologyWriter.java
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/writers/OwlModelWriter.java
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/writers/ResultSetToXml.java
incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/writers/ResultSetWriter.java
incubator/stanbol/trunk/kres/jersey/src/main/resources/
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/add.gif (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/addRule.gif (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/ajax-loader.gif (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/anonymous_48.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/black_gear_128.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/black_gear_16.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/caos_puzzle.jpg (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/compass_48.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/compass_map_48.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/configure.gif (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/delete.gif (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/download.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/download_rdf.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/external.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/favicon-black.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/favicon-sw.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/favicon.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/fise_logo_cropped.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/fise_logo_white.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/fise_logo_white_small.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/foldable_folded.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/foldable_unfolded.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/header_bg.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/iks_project_logo.jpg (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/kresLogo.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/kresLogoExtended.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/loading.gif (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/next.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/organization_48.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/previous.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/rdf.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/rdf_flyer.64.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/rdf_flyer_16.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/rdf_flyer_24.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/rules.gif (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/stlabLogo.jpg (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/stlabLogo.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/sw-cube.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/user_48.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/user_group_48.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/images/wikipedia_w_16.png (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/scripts/
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/scripts/jit-yc.js
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/scripts/jit.js
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/scripts/jquery-1.4.2.js
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/scripts/jquery.rdfquery.core-1.0.js
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/scripts/json2.js
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/scripts/jsonToTurtle.js
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/scripts/kres.js
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/scripts/prettify/
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/scripts/prettify/kres.css
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/scripts/prettify/prettify.css
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/scripts/prettify/prettify.js
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/scripts/scout.js
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/scripts/tinybox.js
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/style/
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/style/fise.css
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/style/images/
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/style/images/date-bottom.gif (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/style/images/date-top.gif (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/style/images/footer.jpg (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/style/images/frontphoto.jpg (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/style/images/header.jpg (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/style/images/wrapbg.gif (with props)
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/style/kres.css
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/static/style/kress.css
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/ajax/
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/ajax/contentitem.ftl
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/imports/
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/imports/common.ftl
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/imports/contentitem.ftl
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/imports/entities.ftl
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/imports/kres.ftl
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/imports/sparql.ftl
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/org/
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/org/apache/
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/org/apache/stanbol/
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/org/apache/stanbol/kres/
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/org/apache/stanbol/kres/jersey/
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/org/apache/stanbol/kres/jersey/manager/
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/org/apache/stanbol/kres/jersey/manager/Recipe/
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/org/apache/stanbol/kres/jersey/manager/Recipe/index.ftl
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/org/apache/stanbol/kres/jersey/resource/
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/org/apache/stanbol/kres/jersey/resource/DocumentationResource/
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/org/apache/stanbol/kres/jersey/resource/DocumentationResource/index.ftl
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/org/apache/stanbol/kres/jersey/resource/KReSResource/
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/org/apache/stanbol/kres/jersey/resource/KReSResource/index.ftl
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/org/apache/stanbol/kres/jersey/resource/RESTfulResource/
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/org/apache/stanbol/kres/jersey/resource/RESTfulResource/index.ftl
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/org/apache/stanbol/kres/jersey/resource/SemionReengineerResource/
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/org/apache/stanbol/kres/jersey/resource/SemionReengineerResource/index.ftl
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/org/apache/stanbol/kres/jersey/resource/SemionRefactorerResource/
incubator/stanbol/trunk/kres/jersey/src/main/resources/META-INF/templates/org/apache/stanbol/kres/jersey/resource/SemionRefactorerResource/index.ftl
incubator/stanbol/trunk/kres/jersey/src/test/
incubator/stanbol/trunk/kres/jersey/src/test/java/
incubator/stanbol/trunk/kres/jersey/src/test/java/org/
incubator/stanbol/trunk/kres/jersey/src/test/java/org/apache/
incubator/stanbol/trunk/kres/jersey/src/test/java/org/apache/stanbol/
incubator/stanbol/trunk/kres/jersey/src/test/java/org/apache/stanbol/kres/
incubator/stanbol/trunk/kres/jersey/src/test/java/org/apache/stanbol/kres/jersey/
incubator/stanbol/trunk/kres/jersey/src/test/java/org/apache/stanbol/kres/jersey/readers/
incubator/stanbol/trunk/kres/jersey/src/test/java/org/apache/stanbol/kres/jersey/readers/OWLOntologyReader.java
Propchange: incubator/stanbol/trunk/kres/jersey/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sun Mar 20 17:01:32 2011
@@ -0,0 +1 @@
+target
Added: incubator/stanbol/trunk/kres/jersey/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/jersey/pom.xml?rev=1083505&view=auto
==============================================================================
--- incubator/stanbol/trunk/kres/jersey/pom.xml (added)
+++ incubator/stanbol/trunk/kres/jersey/pom.xml Sun Mar 20 17:01:32 2011
@@ -0,0 +1,353 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>stanbol-parent</artifactId>
+ <version>0.9-SNAPSHOT</version>
+ <relativePath>../../parent</relativePath>
+ </parent>
+ <artifactId>org.apache.stanbol.kres.jersey</artifactId>
+ <version>${stanbol-version}</version>
+ <packaging>bundle</packaging>
+
+ <name>Apache Stanbol KReS Jersey JAX-RS API and front-end</name>
+ <description>Set of common classes used to create rest service, kres site and fron-end</description>
+
+ <properties>
+ <kres-version>0.7</kres-version>
+ </properties>
+
+ <dependencies>
+
+ <!-- dependencies on other IKS modules -->
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>org.apache.clerezza.rdf.core</artifactId>
+ <version>0.12-incubating-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>org.apache.clerezza.rdf.rdfjson</artifactId>
+ <version>0.3-incubating-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>org.apache.clerezza.jaxrs.rdf.providers</artifactId>
+ <version>0.13-incubating-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>org.apache.clerezza.rdf.jena.serializer</artifactId>
+ <version>0.9-incubating-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>org.apache.clerezza.rdf.rdfjson</artifactId>
+ <version>0.3-incubating-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- specific deps for this project -->
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-server</artifactId>
+ <version>${jersey-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-core</artifactId>
+ <version>${jersey-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-json</artifactId>
+ <version>${jersey-version}</version>
+ <exclusions>
+ <!-- jaxb is now part of java 6 -->
+ <exclusion>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>com.sun.xml.bind</groupId>
+ <artifactId>jaxb-impl</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <!--
+ <dependency> <groupId>com.sun.jersey.contribs</groupId>
+ <artifactId>jersey-multipart</artifactId> <version>1.4</version>
+ </dependency>
+ -->
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>freemarker</groupId>
+ <artifactId>freemarker</artifactId>
+ <version>2.3.9</version>
+ </dependency>
+ <!-- indirect dependency for freemarker -->
+ <dependency>
+ <groupId>org.codehaus.jettison</groupId>
+ <artifactId>jettison</artifactId>
+ <version>1.2</version>
+ </dependency>
+
+ <!-- servlet container, most useful for the tests -->
+ <dependency>
+ <groupId>org.mortbay.jetty</groupId>
+ <artifactId>jetty</artifactId>
+ <version>6.1.22</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- generic tax -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.5.2</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>1.4</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- OSGi tax -->
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>4.1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ <version>4.1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ <version>1.2.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- for tests -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.7</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.6</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-client</artifactId>
+ <version>${jersey-version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam</artifactId>
+ <version>${pax-exam-version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-junit</artifactId>
+ <version>${pax-exam-version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-container-default</artifactId>
+ <version>${pax-exam-version}</version>
+ <scope>test</scope>
+ </dependency>
+
+
+ <!-- KReS -->
+ <!--
+ <dependency> <groupId>eu.iksproject</groupId>
+ <artifactId>eu.iksproject.kres.api</artifactId>
+ <version>${kres-version}</version> <scope>provided</scope>
+ </dependency>
+ -->
+ <dependency>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.ontologymanager.ontonet</artifactId>
+ <version>${stanbol-version}</version>
+ </dependency>
+ <!--
+ <dependency>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.ontologymanager.store</artifactId>
+ <version>${stanbol-version}</version>
+ </dependency>
+ -->
+ <dependency>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.reasoners.base</artifactId>
+ <version>${stanbol-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.reengineer.base</artifactId>
+ <version>${stanbol-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.rules.manager</artifactId>
+ <version>${stanbol-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.rules.refactor</artifactId>
+ <version>${stanbol-version}</version>
+ </dependency>
+
+ <!--
+ <dependency> <groupId>eu.iksproject</groupId>
+ <artifactId>eu.iksproject.kres.manager</artifactId>
+ <version>${kres-version}</version> <scope>provided</scope>
+ </dependency> <dependency> <groupId>eu.iksproject</groupId>
+ <artifactId>eu.iksproject.kres.rules</artifactId>
+ <version>${kres-version}</version> <scope>provided</scope>
+ </dependency> <dependency> <groupId>eu.iksproject</groupId>
+ <artifactId>eu.iksproject.kres.semion.manager</artifactId>
+ <version>${kres-version}</version> <scope>provided</scope>
+ </dependency> <dependency> <groupId>eu.iksproject</groupId>
+ <artifactId>eu.iksproject.kres.semion.refactorer</artifactId>
+ <version>${kres-version}</version> <scope>provided</scope>
+ </dependency>
+ -->
+ <dependency>
+ <groupId>eu.iksproject</groupId>
+ <artifactId>eu.iksproject.kres.shared.dependency.owlapi</artifactId>
+ <version>${kres-version}</version>
+ <scope>provided</scope>
+ </dependency>
+ <!--
+ <dependency> <groupId>eu.iksproject</groupId>
+ <artifactId>eu.iksproject.kres.reasoners</artifactId>
+ <version>${kres-version}</version> <scope>provided</scope>
+ </dependency> <dependency> <groupId>eu.iksproject</groupId>
+ <artifactId>eu.iksproject.kres.storage.provider</artifactId>
+ <version>${kres-version}</version> <scope>provided</scope>
+ </dependency>
+ -->
+ <dependency>
+ <groupId>com.hp.hpl.jena</groupId>
+ <artifactId>jena</artifactId>
+ <version>2.6.2</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+
+
+
+
+ <repositories>
+ <!-- needed for jersey -->
+ <repository>
+ <id>maven2-repository.dev.java.net</id>
+ <name>Java.net Repository for Maven</name>
+ <url>http://download.java.net/maven/2/</url>
+ </repository>
+ <repository>
+ <id>repository-codehaus</id>
+ <name>Codehaus maven repository</name>
+ <url>http://repository.codehaus.org</url>
+ </repository>
+
+ <!-- needed for clerezza SNAPSHOT only -->
+ <repository>
+ <id>apache repository - snapshot repo</id>
+ <name>apache repository</name>
+ <url>https://repository.apache.org/content/repositories/snapshots</url>
+ </repository>
+ </repositories>
+
+ <build>
+ <!-- make it an OSGi bundle -->
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ org.apache.stanbol.kres.jersey.*;version=${stanbol-version}
+ </Export-Package>
+ <Embed-Dependency>*;scope=compile|runtime;inline=false;artifactId=jersey-json|jettison|jackson-core-asl</Embed-Dependency>
+ <Embed-Transitive>true</Embed-Transitive>
+ <Import-Package>
+ org.semanticweb.owlapi.*,
+ !javax.servlet.jsp.*,
+ !org.apache.tools.*,
+ !org.mortbay.*,
+ !org.apache.xpath.*,
+ !org.jdom.*,
+ !org.jaxen.*,
+ !org.apache.xml.*,
+ !org.mozilla.javascript.*,
+ !org.python.*,
+ !org.dom4j.*,
+ !org.apache.log.*,
+ *
+ </Import-Package>
+ <Embed-Dependency>freemarker</Embed-Dependency>
+ <_nouses>true</_nouses>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Added: incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/JerseyEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/JerseyEndpoint.java?rev=1083505&view=auto
==============================================================================
--- incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/JerseyEndpoint.java (added)
+++ incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/JerseyEndpoint.java Sun Mar 20 17:01:32 2011
@@ -0,0 +1,139 @@
+package org.apache.stanbol.kres.jersey;
+
+import java.io.IOException;
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+import org.apache.clerezza.rdf.core.access.TcManager;
+import org.apache.clerezza.rdf.core.serializedform.Serializer;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.stanbol.ontologymanager.ontonet.api.KReSONManager;
+import org.apache.stanbol.reengineer.base.api.SemionManager;
+import org.apache.stanbol.reengineer.base.api.SemionReengineer;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.component.ComponentContext;
+import org.osgi.service.http.HttpService;
+import org.osgi.service.http.NamespaceException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.sun.jersey.spi.container.servlet.ServletContainer;
+
+import org.apache.stanbol.kres.jersey.processors.KReSViewProcessor;
+
+/**
+ * Jersey-based RESTful endpoint for KReS.
+ *
+ * This OSGi component serves as a bridge between the OSGi context and the
+ * Servlet context available to JAX-RS resources.
+ *
+ * @author andrea.nuzzolese
+ */
+
+@Component(immediate = true, metatype = true)
+public class JerseyEndpoint {
+
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ @Property(value = "/kres")
+ public static final String ALIAS_PROPERTY = "org.apache.stanbol.kres.jersey.alias";
+
+ @Property(value = "/kres/static")
+ public static final String STATIC_RESOURCES_URL_ROOT_PROPERTY = "org.apache.stanbol.kres.jersey.static.url";
+
+ @Property(value = "/META-INF/static")
+ public static final String STATIC_RESOURCES_CLASSPATH_PROPERTY = "eu.iksproject.kres.jersey.static.classpath";
+
+ @Property(value = "/META-INF/templates")
+ public static final String FREEMARKER_TEMPLATE_CLASSPATH_PROPERTY = "eu.iksproject.kres.jersey.templates.classpath";
+
+ @Reference
+ TcManager tcManager;
+
+ @Reference
+ HttpService httpService;
+
+ @Reference
+ Serializer serializer;
+
+ protected ServletContext servletContext;
+
+ public Dictionary<String, String> getInitParams() {
+ // pass configuration for Jersey resource
+ // TODO: make the list of enabled JAX-RS resources and providers
+ // configurable using an OSGi service
+ Dictionary<String, String> initParams = new Hashtable<String, String>();
+ initParams.put("javax.ws.rs.Application",
+ JerseyEndpointApplication.class.getName());
+
+ // make jersey automatically turn resources into Viewable models and
+ // hence lookup matching freemarker templates
+ initParams.put("com.sun.jersey.config.feature.ImplicitViewables",
+ "true");
+ return initParams;
+ }
+
+ protected void activate(ComponentContext ctx) throws IOException,
+ ServletException, NamespaceException {
+
+ // register the JAX-RS resources as a servlet under configurable alias
+ ServletContainer container = new ServletContainer();
+ String alias = (String) ctx.getProperties().get(ALIAS_PROPERTY);
+ String staticUrlRoot = (String) ctx.getProperties().get(
+ STATIC_RESOURCES_URL_ROOT_PROPERTY);
+ String staticClasspath = (String) ctx.getProperties().get(
+ STATIC_RESOURCES_CLASSPATH_PROPERTY);
+ String freemakerTemplates = (String) ctx.getProperties().get(
+ FREEMARKER_TEMPLATE_CLASSPATH_PROPERTY);
+
+ log.info("Registering servlets with HTTP service "
+ + httpService.toString());
+ ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
+ Thread.currentThread().setContextClassLoader(
+ getClass().getClassLoader());
+ try {
+ httpService.registerServlet(alias, container, getInitParams(), null);
+ httpService.registerResources(staticUrlRoot, staticClasspath, null);
+ } finally {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ }
+
+ // forward the main KReS OSGi components to the servlet context so that
+ // they can be looked up by the JAX-RS resources
+ servletContext = container.getServletContext();
+ servletContext.setAttribute(BundleContext.class.getName(),
+ ctx.getBundleContext());
+ servletContext.setAttribute(Serializer.class.getName(), serializer);
+ servletContext.setAttribute(TcManager.class.getName(), tcManager);
+
+ servletContext.setAttribute(STATIC_RESOURCES_URL_ROOT_PROPERTY,
+ staticUrlRoot);
+ servletContext.setAttribute(
+ KReSViewProcessor.FREEMARKER_TEMPLATE_PATH_INIT_PARAM,
+ freemakerTemplates);
+
+ log.info("Jersey servlet registered at {}", alias);
+ }
+
+ protected void deactivate(ComponentContext ctx) {
+ log.info("Deactivating jersey bundle");
+ String alias = (String) ctx.getProperties().get(ALIAS_PROPERTY);
+ httpService.unregister(alias);
+ servletContext = null;
+ }
+
+
+ protected void bindHttpService(HttpService httpService) {
+ this.httpService = httpService;
+ }
+
+ protected void unbindHttpService(HttpService httpService) {
+ this.httpService = null;
+ }
+
+}
Added: incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/JerseyEndpointApplication.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/JerseyEndpointApplication.java?rev=1083505&view=auto
==============================================================================
--- incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/JerseyEndpointApplication.java (added)
+++ incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/JerseyEndpointApplication.java Sun Mar 20 17:01:32 2011
@@ -0,0 +1,63 @@
+package org.apache.stanbol.kres.jersey;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.core.Application;
+
+import org.apache.stanbol.kres.jersey.processors.KReSViewProcessor;
+import org.apache.stanbol.kres.jersey.resource.DocumentationResource;
+import org.apache.stanbol.kres.jersey.resource.GraphsResource;
+import org.apache.stanbol.kres.jersey.resource.KReSResource;
+import org.apache.stanbol.kres.jersey.resource.KReSSessionIDResource;
+import org.apache.stanbol.kres.jersey.resource.KReSSessionResource;
+import org.apache.stanbol.kres.jersey.resource.RESTfulResource;
+import org.apache.stanbol.kres.jersey.writers.GraphWriter;
+import org.apache.stanbol.kres.jersey.writers.OWLOntologyWriter;
+import org.apache.stanbol.kres.jersey.writers.ResultSetWriter;
+
+/**
+ * Statically define the list of available resources and providers to be used by the KReS JAX-RS Endpoint.
+ *
+ * The jersey auto-scan mechanism does not seem to work when deployed through OSGi's HttpService
+ * initialization.
+ *
+ * In the future this class might get refactored as an OSGi service to allow for dynamic configuration and
+ * deployment of additional JAX-RS resources and providers.
+ *
+ * @author andrea.nuzzolese
+ */
+
+public class JerseyEndpointApplication extends Application {
+
+ @Override
+ public Set<Class<?>> getClasses() {
+ Set<Class<?>> classes = new HashSet<Class<?>>();
+
+ // resources
+ classes.add(KReSResource.class);
+ classes.add(KReSSessionResource.class);
+ classes.add(KReSSessionIDResource.class);
+ classes.add(GraphsResource.class);
+ classes.add(DocumentationResource.class);
+
+ /* REST services */
+ classes.add(RESTfulResource.class);
+ /* end rest services */
+ // message body writers
+ classes.add(GraphWriter.class);
+ classes.add(ResultSetWriter.class);
+ // classes.add(OwlModelWriter.class);
+ classes.add(OWLOntologyWriter.class);
+ return classes;
+ }
+
+ @Override
+ public Set<Object> getSingletons() {
+ Set<Object> singletons = new HashSet<Object>();
+ // view processors
+ singletons.add(new KReSViewProcessor());
+ return singletons;
+ }
+
+}
Added: incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/JettyServer.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/JettyServer.java?rev=1083505&view=auto
==============================================================================
--- incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/JettyServer.java (added)
+++ incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/JettyServer.java Sun Mar 20 17:01:32 2011
@@ -0,0 +1,96 @@
+package org.apache.stanbol.kres.jersey;
+
+import java.net.URI;
+import java.util.Dictionary;
+import java.util.Enumeration;
+
+import org.mortbay.jetty.Server;
+import org.mortbay.jetty.servlet.Context;
+import org.mortbay.jetty.servlet.ServletHolder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.sun.jersey.spi.container.servlet.ServletContainer;
+
+/**
+ * Standalone (OSGi independent) Jetty-based server with the KReS Jersey
+ * endpoint. The OSGi component need be injected manually to the ServletContext
+ * to make them available to the resources.
+ *
+ * This class is mainly useful for testing the JAX-RS resources without faking a
+ * complete OSGI runtime.
+ *
+ * For seamless OSGi deployments the JerseyEndpoint component should be
+ * automatically registered in the container and registers the JAXRS resources
+ * automatically.
+ *
+ * @author andrea.nuzzolese
+ */
+public class JettyServer {
+
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ public static String DEFAUL_BASE_URI = "http://localhost:9998/";
+
+ protected Server server = new Server();
+
+ private Context context;
+
+ public void start(String baseUri) throws Exception {
+ log.info("starting the Jetty / Jersey endpoint");
+ ServletHolder servletHolder = new ServletHolder(ServletContainer.class);
+ Dictionary<String, String> initParams = new JerseyEndpoint().getInitParams();
+ Enumeration<String> keys = initParams.keys();
+ while (keys.hasMoreElements()) {
+ String key = keys.nextElement();
+ servletHolder.setInitParameter(key, initParams.get(key));
+ }
+
+ URI uri = new URI(baseUri);
+ // restart any previous server instance while keeping the previous
+ // attribute settings
+ if (server.isRunning()) {
+ server.stop();
+ }
+ server = new Server(uri.getPort());
+ context = new Context(server, "/", Context.SESSIONS);
+ context.addServlet(servletHolder, "/*");
+ server.start();
+ }
+
+ public void stop() throws Exception {
+ log.info("stopping the Jetty / Jersey endpoint");
+ server.stop();
+ }
+
+ public void setAttribute(String name, Object value) {
+ if (context != null) {
+ context.getServletContext().setAttribute(name, value);
+ }
+ }
+
+ public Object getAttribute(String name) {
+ if (context != null) {
+ return context.getServletContext().getAttribute(name);
+ }
+ return null;
+ }
+
+ public void removeAttribute(String name) {
+ if (context != null) {
+ context.getServletContext().removeAttribute(name);
+ }
+ }
+
+ /**
+ * For starting manually.
+ */
+ public static void main(String[] args) throws Exception {
+ JettyServer server = new JettyServer();
+ server.start(DEFAUL_BASE_URI);
+ System.out.println("Hit enter to stop it...");
+ System.in.read();
+ server.stop();
+ }
+
+}
\ No newline at end of file
Added: incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/format/KReSFormat.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/format/KReSFormat.java?rev=1083505&view=auto
==============================================================================
--- incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/format/KReSFormat.java (added)
+++ incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/format/KReSFormat.java Sun Mar 20 17:01:32 2011
@@ -0,0 +1,34 @@
+package org.apache.stanbol.kres.jersey.format;
+
+import javax.ws.rs.core.MediaType;
+
+public class KReSFormat extends MediaType {
+
+
+
+ public static final String RDF_XML = "application/rdf+xml";
+
+ public static final MediaType RDF_XML_TYPE = new MediaType("application", "rdf+xml");
+
+ public static final String OWL_XML = "application/owl+xml";
+
+ public static final MediaType OWL_XML_TYPE = new MediaType("application", "owl+xml");
+
+ public static final String MANCHESTER_OWL = "application/manchester+owl";
+
+ public static final MediaType MANCHESTER_OWL_TYPE = new MediaType("application", "manchester+xml");
+
+ public static final String FUNCTIONAL_OWL = "application/functional+owl";
+
+ public static final MediaType FUNCTIONAL_OWL_TYPE = new MediaType("application", "functional+xml");
+
+ public static final String TURTLE = "application/turtle";
+
+ public static final MediaType TURTLE_TYPE = new MediaType("application", "turtle");
+
+ public static final String RDF_JSON = "application/rdf+json";
+
+ public static final MediaType RDF_JSON_TYPE = new MediaType("application", "rdf+json");
+
+
+}
Added: incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/processors/KReSViewProcessor.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/processors/KReSViewProcessor.java?rev=1083505&view=auto
==============================================================================
--- incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/processors/KReSViewProcessor.java (added)
+++ incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/processors/KReSViewProcessor.java Sun Mar 20 17:01:32 2011
@@ -0,0 +1,220 @@
+package org.apache.stanbol.kres.jersey.processors;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintStream;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.ext.Provider;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.sun.jersey.api.view.Viewable;
+import com.sun.jersey.spi.resource.Singleton;
+import com.sun.jersey.spi.template.ViewProcessor;
+
+import freemarker.cache.ClassTemplateLoader;
+import freemarker.template.Configuration;
+import freemarker.template.Template;
+
+/**
+ * Match a Viewable-named view with a Freemarker template.
+ *
+ * This class is based on the following original implementation:
+ * http://github.com/cwinters/jersey-freemarker/
+ *
+ * <p>
+ * You can configure the location of your templates with the context param
+ * 'freemarker.template.path'. If not assigned we'll use a default of
+ * <tt>WEB-INF/templates</tt>. Note that this uses Freemarker's
+ * {@link freemarker.cache.WebappTemplateLoader} to load/cache the templates, so
+ * check its docs (or crank up the logging under the 'freemarker.cache' package)
+ * if your templates aren't getting loaded.
+ * </p>
+ *
+ * <p>
+ * This will put your Viewable's model object in the template variable "it",
+ * unless the model is a Map. If so, the values will be assigned to the template
+ * assuming the map is of type <tt>Map<String,Object></tt>.
+ * </p>
+ *
+ * <p>
+ * There are a number of methods you can override to change the behavior, such
+ * as handling processing exceptions, changing the default template extension,
+ * or adding variables to be assigned to every template context.
+ * </p>
+ *
+ * @author Chris Winters <ch...@cwinters.com> // original code
+ * @author Olivier Grisel <og...@nuxeo.com> // ViewProcessor refactoring
+ */
+@Singleton
+@Provider
+public class KReSViewProcessor implements ViewProcessor<Template> {
+
+ public static final String FREEMARKER_TEMPLATE_PATH_INIT_PARAM = "kres.freemarker.template.path";
+
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ protected Configuration freemarkerConfig;
+
+ protected String rootPath;
+
+ @Context
+ protected ServletContext context;
+
+ public KReSViewProcessor() {
+ }
+
+ /**
+ * @return extension for templates, ".ftl" by default; if we don't see this
+ * at the end of your view we'll append it so we can find the
+ * template resource
+ */
+ protected String getDefaultExtension() {
+ return ".ftl";
+ }
+
+ /**
+ * Define additional variables to make available to the template.
+ *
+ * @param viewableVariables variables provided by whomever generated the
+ * viewable object; these are provided for reference only, there
+ * will be no effect if you modify this map
+ * @return new variables for the template context, which will override any
+ * defaults provided
+ */
+ protected Map<String, Object> getVariablesForTemplate(
+ final Map<String, Object> viewableVariables) {
+ return Collections.emptyMap();
+ }
+
+ /**
+ * Catch any exception generated during template processing.
+ *
+ * @param t throwable caught
+ * @param templatePath path of template we're executing
+ * @param templateContext context use when evaluating this template
+ * @param out output stream from servlet container
+ * @throws IOException on any write errors, or if you want to rethrow
+ */
+ protected void onProcessException(final Throwable t,
+ final Template template, final Map<String, Object> templateContext,
+ final OutputStream out) throws IOException {
+ log.error("Error processing freemarker template @ "
+ + template.getName() + ": " + t.getMessage(), t);
+ out.write("<pre>".getBytes());
+ t.printStackTrace(new PrintStream(out));
+ out.write("</pre>".getBytes());
+ }
+
+ /**
+ * Modify freemarker configuration after we've created it and applied any
+ * settings from 'freemarker.properties' on the classpath.
+ *
+ * @param config configuration we've created so far
+ * @param context servlet context used to create the configuration
+ */
+ protected void assignFreemarkerConfig(final Configuration config,
+ final ServletContext context) {
+ // TODO read those parameters from context instead of hardcoding them
+
+ // don't always put a ',' in numbers (e.g., id=2000 vs id=2,000)
+ config.setNumberFormat("0");
+
+ // don't look for list.en.ftl when list.ftl requested
+ config.setLocalizedLookup(false);
+
+ // don't cache for more that 2s
+ config.setTemplateUpdateDelay(2);
+ log.info("Assigned default freemarker configuration");
+ }
+
+ protected Configuration getConfig() {
+ if (freemarkerConfig == null) {
+ // deferred initialization of the freemarker config to ensure that
+ // the injected ServletContext is fully functional and for some
+ // reason the #getInitParam access does not work hence using the
+ // #getAttribute access after servlet init.
+ Configuration config = new Configuration();
+ if (context != null) {
+ rootPath = (String) context.getAttribute(FREEMARKER_TEMPLATE_PATH_INIT_PARAM);
+ }
+ if (rootPath == null || rootPath.trim().length() == 0) {
+ log.info("No 'freemarker.template.path' context-param, "
+ + "defaulting to '/WEB-INF/templates'");
+ rootPath = "/WEB-INF/templates";
+ }
+ rootPath = rootPath.replaceAll("/$", "");
+ config.setTemplateLoader(new ClassTemplateLoader(getClass(), rootPath));
+
+ // TODO: make the usage of a freemaker properties file an explicit
+ // parameter declared in the servlet context instead of magic
+ // classloading auto-detect. That way the application could
+ // explicitly override the defaults
+ final InputStream fmProps = context.getResourceAsStream("freemarker.properties");
+ boolean loadDefaults = true;
+ if (fmProps != null) {
+ try {
+ config.setSettings(fmProps);
+ log.info("Assigned freemarker configuration from 'freemarker.properties'");
+ loadDefaults = false;
+ } catch (Throwable t) {
+ log.warn(
+ "Failed to load/assign freemarker.properties, will"
+ + " use default settings instead: "
+ + t.getMessage(), t);
+ }
+ }
+ if (loadDefaults) {
+ assignFreemarkerConfig(config, context);
+ }
+ freemarkerConfig = config;
+ }
+ return freemarkerConfig;
+ }
+
+ public Template resolve(final String path) {
+ // accept both '/path/to/template' and '/path/to/template.ftl'
+ final String defaultExtension = getDefaultExtension();
+ final String filePath = path.endsWith(defaultExtension) ? path : path
+ + defaultExtension;
+ try {
+ return getConfig().getTemplate(filePath);
+ } catch (IOException e) {
+ log.error("Failed to load freemaker template: " + rootPath
+ + filePath);
+ return null;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void writeTo(Template template, Viewable viewable, OutputStream out)
+ throws IOException {
+ out.flush(); // send status + headers
+
+ Object model = viewable.getModel();
+ final Map<String, Object> vars = new HashMap<String, Object>();
+ if (model instanceof Map<?, ?>) {
+ vars.putAll((Map<String, Object>) model);
+ } else {
+ vars.put("it", model);
+ }
+ // override custom variables if any
+ vars.putAll(getVariablesForTemplate(vars));
+
+ final OutputStreamWriter writer = new OutputStreamWriter(out);
+ try {
+ template.process(vars, writer);
+ } catch (Throwable t) {
+ onProcessException(t, template, vars, out);
+ }
+ }
+
+}
\ No newline at end of file
Added: incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/DocumentationResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/DocumentationResource.java?rev=1083505&view=auto
==============================================================================
--- incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/DocumentationResource.java (added)
+++ incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/DocumentationResource.java Sun Mar 20 17:01:32 2011
@@ -0,0 +1,33 @@
+package org.apache.stanbol.kres.jersey.resource;
+
+import javax.ws.rs.Path;
+import javax.ws.rs.core.MediaType;
+
+import com.sun.jersey.api.view.ImplicitProduces;
+
+@Path("/documentation")
+@ImplicitProduces(MediaType.TEXT_HTML + ";qs=2")
+public class DocumentationResource extends NavigationMixin {
+
+ private final String JAVADOC = "http://stlab.istc.cnr.it/documents/iks/kres/";
+ private final String ALPHA_RELEASE_DOCUMENTATION = "http://stlab.istc.cnr.it/documents/iks/IKS-D5.2-1.0-final.pdf";
+ private final String REQUIREMENTS_RELEASE_DOCUMENTATION = "http://www.interactive-knowledge.org/sites/www.interactive-knowledge.org/files/IKS_D3.2-1.1.1.pdf";
+ private final String ALPHA_RELEASE_CODE = "http://iks-project.googlecode.com/svn/sandbox/kres/trunk";
+
+
+ public String getJavadoc(){
+ return JAVADOC;
+ }
+
+ public String getAlphaReleaseDocumentation(){
+ return ALPHA_RELEASE_DOCUMENTATION;
+ }
+
+ public String getRequirementsReleaseDocumentation(){
+ return REQUIREMENTS_RELEASE_DOCUMENTATION;
+ }
+
+ public String getAlphaReleaseCode(){
+ return ALPHA_RELEASE_CODE;
+ }
+}
Added: incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/GraphsResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/GraphsResource.java?rev=1083505&view=auto
==============================================================================
--- incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/GraphsResource.java (added)
+++ incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/GraphsResource.java Sun Mar 20 17:01:32 2011
@@ -0,0 +1,146 @@
+package org.apache.stanbol.kres.jersey.resource;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.clerezza.rdf.core.access.TcManager;
+import org.apache.stanbol.ontologymanager.ontonet.api.KReSONManager;
+import org.apache.stanbol.ontologymanager.ontonet.impl.ontology.NoSuchStoreException;
+import org.apache.stanbol.ontologymanager.ontonet.impl.ontology.OntologyStorage;
+import org.semanticweb.owlapi.apibinding.OWLManager;
+import org.semanticweb.owlapi.model.AddAxiom;
+import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLDataFactory;
+import org.semanticweb.owlapi.model.OWLNamedIndividual;
+import org.semanticweb.owlapi.model.OWLObjectProperty;
+import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom;
+import org.semanticweb.owlapi.model.OWLOntology;
+import org.semanticweb.owlapi.model.OWLOntologyCreationException;
+import org.semanticweb.owlapi.model.OWLOntologyManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.sun.jersey.api.view.ImplicitProduces;
+
+import org.apache.stanbol.kres.jersey.format.KReSFormat;
+
+@Path("/graphs")
+@ImplicitProduces(MediaType.TEXT_HTML + ";qs=2")
+public class GraphsResource extends NavigationMixin {
+
+ protected TcManager tcManager;
+ protected KReSONManager onManager;
+ protected OntologyStorage storage;
+
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ public GraphsResource(@Context ServletContext servletContext) {
+ storage = (OntologyStorage) (servletContext.getAttribute(OntologyStorage.class.getName()));
+ tcManager = (TcManager) servletContext.getAttribute(TcManager.class.getName());
+ onManager = (KReSONManager) (servletContext.getAttribute(KReSONManager.class.getName()));
+ if (onManager == null) {
+ throw new IllegalStateException("OntologyStorage missing in ServletContext");
+ } else {
+ storage = onManager.getOntologyStore();
+ }
+ }
+
+ @GET
+ @Path("/resume")
+ @Produces( {KReSFormat.FUNCTIONAL_OWL, KReSFormat.MANCHESTER_OWL, KReSFormat.OWL_XML, KReSFormat.RDF_XML,
+ KReSFormat.TURTLE, KReSFormat.RDF_JSON})
+ public Response graphs(@Context HttpHeaders headers, @Context ServletContext servletContext) {
+ Set<IRI> iris = storage.listGraphs();
+ if (iris != null) {
+
+ OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
+ OWLDataFactory factory = OWLManager.getOWLDataFactory();
+
+ OWLOntology ontology;
+ try {
+ ontology = manager.createOntology();
+
+ String ns = onManager.getKReSNamespace();
+
+ OWLNamedIndividual storage = factory.getOWLNamedIndividual(IRI.create(ns + "Storage"));
+
+ OWLObjectProperty p = factory.getOWLObjectProperty(IRI.create(ns + "hasGraph"));
+
+ for (IRI iri : iris) {
+ iri = IRI.create(iri.toString().replace("<", "").replace(">", ""));
+ OWLNamedIndividual graph = factory.getOWLNamedIndividual(iri);
+ OWLObjectPropertyAssertionAxiom axiom = factory.getOWLObjectPropertyAssertionAxiom(p,
+ storage, graph);
+ manager.applyChange(new AddAxiom(ontology, axiom));
+ }
+
+ return Response.ok(ontology).build();
+ } catch (OWLOntologyCreationException e) {
+ return Response.status(500).build();
+ }
+
+ }
+
+ return Response.status(404).build();
+ }
+
+ @GET
+ @Path("/{graphid:.+}")
+ public Response getGraph(@PathParam("graphid") String graphid,
+ @Context UriInfo uriInfo,
+ @Context HttpHeaders headers) {
+
+ IRI ontologyID = IRI.create(graphid);
+
+ // return Response.ok(tcManager.getMGraph(new UriRef(graphid))).build();
+ try {
+ return Response.ok(storage.getGraph(ontologyID)).build();
+ } catch (NoSuchStoreException e) {
+ return Response.status(204).build();
+ }
+
+ }
+
+ @POST
+ @Consumes(MediaType.MULTIPART_FORM_DATA)
+ public Response storeGraph(@FormParam("graph") InputStream graph, @FormParam("id") String id) {
+ try {
+ OWLOntology ontology = OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(
+ graph);
+ storage.store(ontology, IRI.create(id));
+ return Response.ok().build();
+ } catch (OWLOntologyCreationException e) {
+ return Response.status(500).build();
+ }
+ }
+
+ public String getNamespace() {
+ return onManager.getKReSNamespace();
+ }
+
+ public List<String> getStoredGraphs() {
+ Set<IRI> iris = storage.listGraphs();
+
+ ArrayList<String> graphs = new ArrayList<String>();
+ for (IRI iri : iris) {
+ graphs.add(iri.toString());
+ }
+ return graphs;
+ }
+}
Added: incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/KReSResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/KReSResource.java?rev=1083505&view=auto
==============================================================================
--- incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/KReSResource.java (added)
+++ incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/KReSResource.java Sun Mar 20 17:01:32 2011
@@ -0,0 +1,18 @@
+package org.apache.stanbol.kres.jersey.resource;
+
+import javax.ws.rs.Path;
+
+import com.sun.jersey.api.view.ImplicitProduces;
+
+
+/**
+ *
+ * @author andrea.nuzzolese
+ *
+ */
+
+@Path("/")
+@ImplicitProduces("text/html")
+public class KReSResource extends NavigationMixin {
+
+}
Added: incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/KReSSessionIDResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/KReSSessionIDResource.java?rev=1083505&view=auto
==============================================================================
--- incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/KReSSessionIDResource.java (added)
+++ incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/KReSSessionIDResource.java Sun Mar 20 17:01:32 2011
@@ -0,0 +1,58 @@
+package org.apache.stanbol.kres.jersey.resource;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+import javax.ws.rs.core.Response.Status;
+
+import org.apache.stanbol.ontologymanager.ontonet.api.KReSONManager;
+import org.apache.stanbol.ontologymanager.ontonet.api.session.KReSSession;
+import org.apache.stanbol.ontologymanager.ontonet.api.session.KReSSessionManager;
+import org.apache.stanbol.ontologymanager.ontonet.impl.ONManager;
+import org.apache.stanbol.ontologymanager.ontonet.impl.renderers.SessionRenderer;
+import org.semanticweb.owlapi.model.IRI;
+
+@Path("/session/{id:.+}")
+public class KReSSessionIDResource extends NavigationMixin {
+
+ /*
+ * Placeholder for the KReSONManager to be fetched from the servlet context.
+ */
+ protected KReSONManager onm;
+
+ protected ServletContext servletContext;
+
+ public KReSSessionIDResource(@Context ServletContext servletContext) {
+ this.servletContext = servletContext;
+ onm = (KReSONManager) this.servletContext
+ .getAttribute(KReSONManager.class.getName());
+ if (onm == null) {
+ System.err
+ .println("[KReS] :: No KReS Ontology Network Manager provided by Servlet Context. Instantiating now...");
+ onm = new ONManager();
+ }
+ }
+
+ @GET
+ @Produces("application/rdf+xml")
+ public Response getSessionMetadataOntology(
+ @PathParam("id") String sessionId, @Context UriInfo uriInfo,
+ @Context HttpHeaders headers) {
+
+ KReSSession ses = null;
+ KReSSessionManager mgr = onm.getSessionManager();
+ ses = mgr.getSession(IRI.create(sessionId));
+ if (ses == null)
+ return Response.status(Status.NO_CONTENT).build();
+
+ return Response.ok(SessionRenderer.getSessionMetadataRDF(ses)).build();
+
+ }
+
+}
Added: incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/KReSSessionResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/KReSSessionResource.java?rev=1083505&view=auto
==============================================================================
--- incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/KReSSessionResource.java (added)
+++ incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/KReSSessionResource.java Sun Mar 20 17:01:32 2011
@@ -0,0 +1,206 @@
+package org.apache.stanbol.kres.jersey.resource;
+
+import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
+import static javax.ws.rs.core.Response.Status.NOT_FOUND;
+
+import java.io.InputStream;
+
+import javax.servlet.ServletContext;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.stanbol.ontologymanager.ontonet.api.KReSONManager;
+import org.apache.stanbol.ontologymanager.ontonet.api.io.RootOntologyIRISource;
+import org.apache.stanbol.ontologymanager.ontonet.api.io.RootOntologySource;
+import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologyScope;
+import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologySpaceFactory;
+import org.apache.stanbol.ontologymanager.ontonet.api.ontology.OntologySpaceModificationException;
+import org.apache.stanbol.ontologymanager.ontonet.api.ontology.ScopeRegistry;
+import org.apache.stanbol.ontologymanager.ontonet.api.ontology.SessionOntologySpace;
+import org.apache.stanbol.ontologymanager.ontonet.api.ontology.UnmodifiableOntologySpaceException;
+import org.apache.stanbol.ontologymanager.ontonet.api.session.KReSSession;
+import org.apache.stanbol.ontologymanager.ontonet.api.session.KReSSessionManager;
+import org.apache.stanbol.ontologymanager.ontonet.impl.ONManager;
+import org.apache.stanbol.ontologymanager.ontonet.impl.renderers.SessionRenderer;
+import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLOntology;
+import org.semanticweb.owlapi.model.OWLOntologyCreationException;
+
+import org.apache.stanbol.kres.jersey.format.KReSFormat;
+
+@Path("/session")
+public class KReSSessionResource extends NavigationMixin {
+
+ /*
+ * Placeholder for the KReSONManager to be fetched from the servlet context.
+ */
+ protected KReSONManager onm;
+
+ protected ServletContext servletContext;
+
+ public KReSSessionResource(@Context ServletContext servletContext) {
+ this.servletContext = servletContext;
+ onm = (KReSONManager) this.servletContext.getAttribute(KReSONManager.class.getName());
+ if (onm == null) {
+ System.err
+ .println("[KReS] :: No KReS Ontology Network Manager provided by Servlet Context. Instantiating now...");
+ onm = new ONManager();
+ }
+ }
+
+ @PUT
+ @Consumes(MediaType.MULTIPART_FORM_DATA)
+ public Response addOntology(@QueryParam("scope") String scope,
+ @QueryParam("import") InputStream importOntology,
+ @QueryParam("session") String session,
+ @Context UriInfo uriInfo,
+ @Context HttpHeaders headers,
+ @Context ServletContext servletContext) {
+
+ IRI scopeIRI = IRI.create(scope);
+ IRI sessionIRI = IRI.create(session);
+
+ OWLOntology ontology;
+ try {
+ ontology = onm.getOwlCacheManager().loadOntologyFromOntologyDocument(importOntology);
+
+ ScopeRegistry scopeRegistry = onm.getScopeRegistry();
+
+ OntologyScope ontologyScope = scopeRegistry.getScope(scopeIRI);
+ SessionOntologySpace sos = ontologyScope.getSessionSpace(sessionIRI);
+ try {
+ sos.addOntology(new RootOntologySource(ontology));
+ return Response.ok().build();
+ } catch (UnmodifiableOntologySpaceException e) {
+ return Response.status(INTERNAL_SERVER_ERROR).build();
+ }
+ } catch (OWLOntologyCreationException e1) {
+ return Response.status(NOT_FOUND).build();
+ }
+
+ }
+
+ @PUT
+ @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
+ public Response addOntology(@QueryParam("scope") String scope,
+ @QueryParam("session") String session,
+ @QueryParam("location") String location,
+ @Context UriInfo uriInfo,
+ @Context HttpHeaders headers,
+ @Context ServletContext servletContext) {
+
+ IRI scopeIRI = IRI.create(scope);
+ IRI sessionIRI = IRI.create(session);
+ IRI ontologyIRI = IRI.create(location);
+ ScopeRegistry scopeRegistry = onm.getScopeRegistry();
+
+ OntologyScope ontologyScope = scopeRegistry.getScope(scopeIRI);
+ SessionOntologySpace sos = ontologyScope.getSessionSpace(sessionIRI);
+ try {
+ sos.addOntology(new RootOntologyIRISource(ontologyIRI));
+ return Response.ok().build();
+ } catch (UnmodifiableOntologySpaceException e) {
+ return Response.status(INTERNAL_SERVER_ERROR).build();
+ } catch (OWLOntologyCreationException e) {
+ return Response.status(INTERNAL_SERVER_ERROR).build();
+ }
+
+ }
+
+ @POST
+ @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
+ @Produces(value = {KReSFormat.RDF_XML, KReSFormat.OWL_XML, KReSFormat.TURTLE, KReSFormat.FUNCTIONAL_OWL,
+ KReSFormat.MANCHESTER_OWL, KReSFormat.RDF_JSON})
+ public Response createSession(@FormParam("scope") String scope,
+ @Context UriInfo uriInfo,
+ @Context HttpHeaders headers) {
+
+ KReSSession ses = null;
+ KReSSessionManager mgr = onm.getSessionManager();
+
+ /*
+ * Create the KReS session to associate to the scope.
+ */
+ ses = mgr.createSession();
+
+ /*
+ * First get the scope registry.
+ */
+ ScopeRegistry scopeRegistry = onm.getScopeRegistry();
+
+ /*
+ * Then retrieve the ontology scope.
+ */
+ IRI scopeIRI = IRI.create(scope);
+ OntologyScope ontologyScope = scopeRegistry.getScope(scopeIRI);
+
+ /*
+ * Finally associate the KReS session to the scope.
+ */
+ OntologySpaceFactory ontologySpaceFactory = onm.getOntologySpaceFactory();
+ SessionOntologySpace sessionOntologySpace = ontologySpaceFactory.createSessionOntologySpace(scopeIRI);
+ ontologyScope.addSessionSpace(sessionOntologySpace, ses.getID());
+
+ return Response.ok(SessionRenderer.getSessionMetadataRDF(ses)).build();
+
+ }
+
+ /**
+ * FIXME what are these path params anyway?
+ *
+ * @param scope
+ * @param session
+ * @param deleteOntology
+ * @param uriInfo
+ * @param headers
+ * @return
+ */
+ @DELETE
+ public Response deleteSession(@PathParam("scope") String scope,
+ @PathParam("session") String session,
+ @PathParam("delete") String deleteOntology,
+ @Context UriInfo uriInfo,
+ @Context HttpHeaders headers) {
+
+ IRI scopeID = IRI.create(scope);
+ IRI sessionID = IRI.create(session);
+
+ if (deleteOntology != null) {
+ IRI ontologyIRI = IRI.create(deleteOntology);
+
+ ScopeRegistry scopeRegistry = onm.getScopeRegistry();
+
+ OntologyScope ontologyScope = scopeRegistry.getScope(scopeID);
+ SessionOntologySpace sos = ontologyScope.getSessionSpace(sessionID);
+
+ try {
+ /*
+ * TODO : previous implementation reloaded the whole ontology before deleting it, thus
+ * treating this as a physical IRI. See if it still works this way
+ */
+ OWLOntology o = sos.getOntology(ontologyIRI);
+ if (o != null) sos.removeOntology(new RootOntologySource(o));
+ return Response.ok().build();
+ } catch (OntologySpaceModificationException e) {
+ return Response.status(INTERNAL_SERVER_ERROR).build();
+ }
+ } else {
+ onm.getSessionManager().destroySession(sessionID);
+ return Response.ok().build();
+ }
+
+ }
+
+}
Added: incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/NavigationMixin.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/NavigationMixin.java?rev=1083505&view=auto
==============================================================================
--- incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/NavigationMixin.java (added)
+++ incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/NavigationMixin.java Sun Mar 20 17:01:32 2011
@@ -0,0 +1,73 @@
+package org.apache.stanbol.kres.jersey.resource;
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.commons.io.LineIterator;
+import org.apache.commons.lang.ArrayUtils;
+
+public class NavigationMixin {
+
+ @Context
+ protected UriInfo uriInfo;
+
+ public URI getPublicBaseUri() {
+ return uriInfo.getBaseUri();
+ }
+
+ public List<MenuItem> getMainMenuItems() {
+ return Arrays.asList(new MenuItem("Home", "/kres", "homeMenu", uriInfo, null),
+ new MenuItem("Usage", "javascript:expandMenu('usageMenu')", "usageMenu", uriInfo,
+ Arrays.asList(new MenuItem("Documentation", "/kres/documentation", "documentationMenu", uriInfo, null),
+ new MenuItem("RESTful services", "/kres/documentation/restful", "restfulMenu", uriInfo, null))));
+
+
+ }
+
+ public static class MenuItem {
+
+ public MenuItem(String label, String link, String id, UriInfo uriInfo, List<MenuItem> subMenu) {
+ this.label = label;
+ this.link = link;
+ this.id = id;
+ this.subMenu = subMenu;
+ cssClass = uriInfo.getPath().startsWith(link.substring(1)) ? "current" : "unselected";
+ }
+
+ protected final String label;
+
+ protected final String id;
+
+ protected final String link;
+
+ protected final List<MenuItem> subMenu;
+
+ protected final String cssClass;
+
+ public String getLabel() {
+ return label;
+ }
+
+ public String getLink() {
+ return link;
+ }
+
+ public String getCssClass() {
+ return cssClass;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public List<MenuItem> getSubMenu() {
+ return subMenu;
+ }
+
+ }
+
+}
Added: incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/RESTfulResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/RESTfulResource.java?rev=1083505&view=auto
==============================================================================
--- incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/RESTfulResource.java (added)
+++ incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/resource/RESTfulResource.java Sun Mar 20 17:01:32 2011
@@ -0,0 +1,13 @@
+package org.apache.stanbol.kres.jersey.resource;
+
+import javax.ws.rs.Path;
+import javax.ws.rs.core.MediaType;
+
+import com.sun.jersey.api.view.ImplicitProduces;
+
+@Path("/documentation/restful")
+@ImplicitProduces(MediaType.TEXT_HTML + ";qs=2")
+public class RESTfulResource extends NavigationMixin {
+
+}
+
Added: incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/util/OntologyRenderUtils.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/util/OntologyRenderUtils.java?rev=1083505&view=auto
==============================================================================
--- incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/util/OntologyRenderUtils.java (added)
+++ incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/util/OntologyRenderUtils.java Sun Mar 20 17:01:32 2011
@@ -0,0 +1,177 @@
+package org.apache.stanbol.kres.jersey.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.stanbol.ontologymanager.ontonet.api.KReSONManager;
+import org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxOntologyFormat;
+import org.coode.owlapi.turtle.TurtleOntologyFormat;
+import org.semanticweb.owlapi.apibinding.OWLManager;
+import org.semanticweb.owlapi.io.OWLFunctionalSyntaxOntologyFormat;
+import org.semanticweb.owlapi.io.OWLXMLOntologyFormat;
+import org.semanticweb.owlapi.io.RDFXMLOntologyFormat;
+import org.semanticweb.owlapi.io.StringDocumentTarget;
+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.OWLDataFactory;
+import org.semanticweb.owlapi.model.OWLImportsDeclaration;
+import org.semanticweb.owlapi.model.OWLOntology;
+import org.semanticweb.owlapi.model.OWLOntologyChange;
+import org.semanticweb.owlapi.model.OWLOntologyCreationException;
+import org.semanticweb.owlapi.model.OWLOntologyFormat;
+import org.semanticweb.owlapi.model.OWLOntologyManager;
+import org.semanticweb.owlapi.model.OWLOntologyStorageException;
+
+import org.apache.stanbol.kres.jersey.format.KReSFormat;
+
+public class OntologyRenderUtils {
+
+ /**
+ * TODO : make a writer for this.
+ *
+ * @param ont
+ * @param format
+ * @return
+ * @throws OWLOntologyStorageException
+ */
+ public static String renderOntology(OWLOntology ont,
+ OWLOntologyFormat format, String rewritePrefix, KReSONManager onm)
+ throws OWLOntologyStorageException {
+ OWLOntologyManager tmpmgr = OWLManager.createOWLOntologyManager();
+ OWLDataFactory df = tmpmgr.getOWLDataFactory();
+
+ // Now the hack
+ OWLOntology o2 = null;
+ OWLOntology copy = null;
+ OWLOntologyManager origMgr = ont.getOWLOntologyManager();
+ try {
+ List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>();
+ copy = tmpmgr.createOntology(ont.getOntologyID());
+ for (OWLAxiom ax : ont.getAxioms()) {
+ changes.add(new AddAxiom(copy, ax));
+ }
+ for (OWLImportsDeclaration imp : ont.getImportsDeclarations()) {
+ OWLOntology oi = origMgr.getImportedOntology(imp);
+ if (oi == null)
+ oi = onm.getOwlCacheManager().getImportedOntology(imp);
+ String impiri = "";
+ if (rewritePrefix != null)
+ impiri += rewritePrefix + "/";
+ if (oi == null)
+ // Proprio non riesci a ottenerla questa ontologia? Rinuncia
+ continue;
+ if (oi.isAnonymous())
+ impiri = imp.getIRI().toString();
+ else
+ impiri += oi.getOntologyID().getOntologyIRI();
+ OWLImportsDeclaration im = df.getOWLImportsDeclaration(IRI
+ .create(impiri));
+ changes.add(new AddImport(copy, im));
+ }
+ tmpmgr.applyChanges(changes);
+ } catch (OWLOntologyCreationException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ if (copy != null)
+ o2 = copy;
+ else
+ o2 = ont;
+
+ StringDocumentTarget tgt = new StringDocumentTarget();
+ tmpmgr.saveOntology(o2, format, tgt);
+ return tgt.toString();
+ }
+
+ public static String renderOntology(OWLOntology ont, String format,
+ String rewritePrefix, KReSONManager onm)
+ throws OWLOntologyStorageException {
+ OWLOntologyManager tmpmgr = OWLManager.createOWLOntologyManager();
+ OWLDataFactory df = tmpmgr.getOWLDataFactory();
+ StringDocumentTarget tgt = new StringDocumentTarget();
+
+ // Now the hack
+ OWLOntology o2 = null;
+ OWLOntology copy = null;
+ OWLOntologyManager origMgr = ont.getOWLOntologyManager();
+ try {
+ List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>();
+ copy = tmpmgr.createOntology(ont.getOntologyID());
+ for (OWLAxiom ax : ont.getAxioms()) {
+ changes.add(new AddAxiom(copy, ax));
+ }
+ for (OWLImportsDeclaration imp : ont.getImportsDeclarations()) {
+ OWLOntology oi = origMgr.getImportedOntology(imp);
+ if (oi == null)
+ oi = onm.getOwlCacheManager().getImportedOntology(imp);
+ String impiri = "";
+ if (rewritePrefix != null)
+ impiri += rewritePrefix + "/";
+ if (oi == null)
+ // Proprio non riesci a ottenerla questa ontologia? Rinuncia
+ continue;
+ if (oi.isAnonymous())
+ impiri = imp.getIRI().toString();
+ else
+ impiri += oi.getOntologyID().getOntologyIRI();
+ OWLImportsDeclaration im = df.getOWLImportsDeclaration(IRI
+ .create(impiri));
+ changes.add(new AddImport(copy, im));
+ }
+ tmpmgr.applyChanges(changes);
+ } catch (OWLOntologyCreationException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ if (copy != null)
+ o2 = copy;
+ else
+ o2 = ont;
+
+ if (format.equals(KReSFormat.RDF_XML)) {
+ try {
+ tmpmgr.saveOntology(o2, new RDFXMLOntologyFormat(), tgt);
+ } catch (OWLOntologyStorageException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ } else if (format.equals(KReSFormat.OWL_XML)) {
+ try {
+ tmpmgr.saveOntology(o2, new OWLXMLOntologyFormat(), tgt);
+ } catch (OWLOntologyStorageException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ } else if (format.equals(KReSFormat.MANCHESTER_OWL)) {
+ try {
+ tmpmgr.saveOntology(o2,
+ new ManchesterOWLSyntaxOntologyFormat(), tgt);
+ } catch (OWLOntologyStorageException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ } else if (format.equals(KReSFormat.FUNCTIONAL_OWL)) {
+ try {
+ tmpmgr.saveOntology(o2,
+ new OWLFunctionalSyntaxOntologyFormat(), tgt);
+ } catch (OWLOntologyStorageException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ } else if (format.equals(KReSFormat.TURTLE)) {
+ try {
+ tmpmgr.saveOntology(o2, new TurtleOntologyFormat(), tgt);
+ } catch (OWLOntologyStorageException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ return tgt.toString();
+ }
+
+}
Added: incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/writers/GraphWriter.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/writers/GraphWriter.java?rev=1083505&view=auto
==============================================================================
--- incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/writers/GraphWriter.java (added)
+++ incubator/stanbol/trunk/kres/jersey/src/main/java/org/apache/stanbol/kres/jersey/writers/GraphWriter.java Sun Mar 20 17:01:32 2011
@@ -0,0 +1,72 @@
+package org.apache.stanbol.kres.jersey.writers;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Iterator;
+
+import javax.servlet.ServletContext;
+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.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.clerezza.rdf.core.Triple;
+import org.apache.clerezza.rdf.core.TripleCollection;
+import org.apache.clerezza.rdf.core.serializedform.Serializer;
+import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
+
+@Provider
+@Produces( { MediaType.TEXT_PLAIN, SupportedFormat.N3,
+ SupportedFormat.N_TRIPLE, SupportedFormat.RDF_XML,
+ SupportedFormat.TURTLE, SupportedFormat.X_TURTLE,
+ SupportedFormat.RDF_JSON })
+public class GraphWriter implements MessageBodyWriter<TripleCollection> {
+
+ @Context
+ protected ServletContext servletContext;
+
+ protected Serializer getSerializer() {
+ return (Serializer) servletContext.getAttribute(Serializer.class.getName());
+ }
+
+ public boolean isWriteable(Class<?> type, Type genericType,
+ Annotation[] annotations, MediaType mediaType) {
+ return TripleCollection.class.isAssignableFrom(type);
+ }
+
+ public long getSize(TripleCollection t, Class<?> type, Type genericType,
+ Annotation[] annotations, MediaType mediaType) {
+ return -1;
+ }
+
+ public void writeTo(TripleCollection t, Class<?> type, Type genericType,
+ Annotation[] annotations, MediaType mediaType,
+ MultivaluedMap<String, Object> httpHeaders,
+ OutputStream entityStream) throws IOException,
+ WebApplicationException {
+
+ // Fallback to our own "serializer" with text/plain, useful if no
+ // other serializer services are available
+ if (MediaType.TEXT_PLAIN.equals(mediaType.toString())) {
+ dump(entityStream, t);
+ } else {
+ getSerializer().serialize(entityStream, t, mediaType.toString());
+ }
+ }
+
+ private void dump(OutputStream os, TripleCollection t) {
+ final PrintWriter pw = new PrintWriter(new OutputStreamWriter(os));
+ final Iterator<Triple> it = t.iterator();
+ while (it.hasNext()) {
+ pw.println(it.next());
+ }
+ pw.flush();
+ }
+}
\ No newline at end of file