You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by og...@apache.org on 2011/04/04 15:02:56 UTC

svn commit: r1088603 [2/9] - in /incubator/stanbol/trunk: ./ commons/ commons/web/ commons/web/base/ commons/web/base/src/ commons/web/base/src/main/ commons/web/base/src/main/java/ commons/web/base/src/main/java/org/ commons/web/base/src/main/java/org...

Added: incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/JsonLdSerializerProvider.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/JsonLdSerializerProvider.java?rev=1088603&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/JsonLdSerializerProvider.java (added)
+++ incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/JsonLdSerializerProvider.java Mon Apr  4 13:02:49 2011
@@ -0,0 +1,154 @@
+package org.apache.stanbol.commons.web.base.writers;
+
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+
+import java.io.BufferedWriter;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.clerezza.rdf.core.BNode;
+import org.apache.clerezza.rdf.core.NonLiteral;
+import org.apache.clerezza.rdf.core.Triple;
+import org.apache.clerezza.rdf.core.TripleCollection;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.serializedform.SerializingProvider;
+import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
+import org.apache.stanbol.jsonld.JsonLd;
+import org.apache.stanbol.jsonld.JsonLdResource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Implements a <a href="http://json-ld.org/">JSON-LD</a> serialization of a Clerezza
+ * {@link TripleCollection}.<br>
+ * <br>
+ * Note: This implementation is based on <a href="http://json-ld.org/spec/">JSON-LD
+ * specification</a> draft from 25 October 2010.
+ *
+ * @author Fabian Christ
+ *
+ * @scr.component immediate="true"
+ * @scr.service
+ *                 interface="org.apache.clerezza.rdf.core.serializedform.SerializingProvider"
+ */
+@SupportedFormat(JsonLdSerializerProvider.SUPPORTED_FORMAT)
+public class JsonLdSerializerProvider implements SerializingProvider {
+
+    public static final String SUPPORTED_FORMAT = APPLICATION_JSON;
+
+    private static final String RDF_NS_TYPE="http://www.w3.org/1999/02/22-rdf-syntax-ns#type";
+
+    private static final Logger logger = LoggerFactory.getLogger(JsonLdSerializerProvider.class);
+
+    // Map from Namespace -> to Prefix
+    private Map<String, String> namespacePrefixMap = new HashMap<String, String>();
+
+    private int indentation = 2;
+
+    @Override
+    public void serialize(OutputStream serializedGraph, TripleCollection tc, String formatIdentifier) {
+        if (!formatIdentifier.equals(SUPPORTED_FORMAT)) {
+            logger.info("serialize() the format '" + formatIdentifier + "' is not supported by this implementation");
+            return;
+        }
+
+        JsonLd jsonLd = new JsonLd();
+        jsonLd.setNamespacePrefixMap(this.namespacePrefixMap);
+
+        Map<NonLiteral, String> subjects = createSubjectsMap(tc);
+        for (NonLiteral subject : subjects.keySet()) {
+            JsonLdResource resource = new JsonLdResource();
+            resource.setSubject(subject.toString());
+
+            Iterator<Triple> triplesFromSubject = tc.filter(subject, null, null);
+            while (triplesFromSubject.hasNext()) {
+                Triple currentTriple = triplesFromSubject.next();
+                if (currentTriple.getPredicate().getUnicodeString().equals(RDF_NS_TYPE)) {
+                    if (logger.isDebugEnabled()) {
+                        logger.debug("serialize() adding rdf:type: \"a\":" + currentTriple.getObject());
+                    }
+                    resource.addType(currentTriple.getObject().toString());
+                } else {
+                    if (logger.isDebugEnabled()) {
+                        logger.debug("serializer() adding predicate " + currentTriple.getPredicate().toString() + " with object " + currentTriple.getObject().toString());
+                    }
+
+                    String property = currentTriple.getPredicate().getUnicodeString();
+                    String value = currentTriple.getObject().toString();
+                    resource.putProperty(property, value);
+                }
+            }
+
+            jsonLd.put(resource.getSubject(), resource);
+        }
+
+        try {
+            BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(serializedGraph));
+            writer.write(jsonLd.toString(this.indentation));
+            writer.flush();
+        } catch (IOException ioe) {
+            logger.error(ioe.getMessage());
+            throw new RuntimeException(ioe.getMessage());
+        }
+    }
+
+    private Map<NonLiteral, String> createSubjectsMap(TripleCollection tc) {
+        Map<NonLiteral, String> subjects = new HashMap<NonLiteral, String>();
+        int bNodeCounter = 0;
+        for (Triple triple : tc) {
+            NonLiteral subject = triple.getSubject();
+            if (!subjects.containsKey(subject)) {
+                if (subject instanceof UriRef) {
+                    subjects.put(subject, subject.toString());
+                } else if (subject instanceof BNode) {
+                    bNodeCounter++;
+                    subjects.put(subject, "_:bnode" + bNodeCounter);
+                }
+            }
+        }
+        return subjects;
+    }
+
+    /**
+     * Get the known namespace to prefix mapping.
+     *
+     * @return A {@link Map} from namespace String to prefix String.
+     */
+    public Map<String, String> getNamespacePrefixMap() {
+        return namespacePrefixMap;
+    }
+
+    /**
+     * Sets the known namespaces for the serializer.
+     *
+     * @param knownNamespaces A {@link Map} from namespace String to prefix String.
+     */
+    public void setNamespacePrefixMap(Map<String, String> knownNamespaces) {
+        this.namespacePrefixMap = knownNamespaces;
+    }
+
+    /**
+     * Returns the current number of space characters which are used
+     * to indent the serialized output.
+     *
+     * @return Number of space characters used for indentation.
+     */
+    public int getIndentation() {
+        return indentation;
+    }
+
+    /**
+     * Sets the number of characters used per indentation level for the serialized output.<br />
+     * Set this value to zero (0) if you don't want indentation. Default value is 2.
+     *
+     * @param indentation Number of space characters used for indentation.
+     */
+    public void setIndentation(int indentation) {
+        this.indentation = indentation;
+    }
+}

Added: incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/ResultSetToXml.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/ResultSetToXml.java?rev=1088603&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/ResultSetToXml.java (added)
+++ incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/ResultSetToXml.java Mon Apr  4 13:02:49 2011
@@ -0,0 +1,97 @@
+package org.apache.stanbol.commons.web.base.writers;
+
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.clerezza.rdf.core.BNode;
+import org.apache.clerezza.rdf.core.Language;
+import org.apache.clerezza.rdf.core.PlainLiteral;
+import org.apache.clerezza.rdf.core.Resource;
+import org.apache.clerezza.rdf.core.TypedLiteral;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.sparql.ResultSet;
+import org.apache.clerezza.rdf.core.sparql.SolutionMapping;
+import org.apache.clerezza.rdf.core.sparql.query.Variable;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+class ResultSetToXml {
+
+    private final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+
+    Document toDocument(ResultSet rs) throws ParserConfigurationException {
+        final Document doc = dbf.newDocumentBuilder().newDocument();
+
+        // root element
+        Element root = doc.createElement("sparql");
+        root.setAttribute("xmlns", "http://www.w3.org/2005/sparql-results#");
+        doc.appendChild(root);
+        Element head = doc.createElement("head");
+        root.appendChild(head);
+
+        // result set
+        Element results = doc.createElement("results");
+        SolutionMapping solutionMapping = null;
+        while (rs.hasNext()) {
+            solutionMapping = rs.next();
+            createResultElement(solutionMapping, results, doc);
+        }
+        createVariable(solutionMapping, head, doc);
+        root.appendChild(results);
+
+        return doc;
+    }
+
+    private void createResultElement(SolutionMapping solutionMap, Element results, Document doc) {
+        Set<Variable> keys = solutionMap.keySet();
+        Element result = doc.createElement("result");
+        results.appendChild(result);
+        for (Variable key : keys) {
+            Element bindingElement = doc.createElement("binding");
+            bindingElement.setAttribute("name", key.getName());
+            bindingElement.appendChild(createValueElement(
+                    (Resource) solutionMap.get(key), doc));
+            result.appendChild(bindingElement);
+        }
+    }
+
+    private void createVariable(SolutionMapping solutionMap, Element head, Document doc) {
+        if(solutionMap != null) {
+            Set<Variable> keys = solutionMap.keySet();
+            for (Variable key : keys) {
+                Element varElement = doc.createElement("variable");
+                varElement.setAttribute("name", key.getName());
+                head.appendChild(varElement);
+            }
+        }
+    }
+
+    private Element createValueElement(Resource resource, Document doc) {
+        Element value;
+        if (resource instanceof UriRef) {
+            value = doc.createElement("uri");
+            value.appendChild(doc.createTextNode(((UriRef) resource)
+                    .getUnicodeString()));
+        } else if (resource instanceof TypedLiteral) {
+            value = doc.createElement("literal");
+            value.appendChild(doc.createTextNode(((TypedLiteral) resource)
+                    .getLexicalForm()));
+            value.setAttribute("datatype", (((TypedLiteral) resource)
+                    .getDataType().getUnicodeString()));
+        } else if (resource instanceof PlainLiteral) {
+            value = doc.createElement("literal");
+            value.appendChild(doc.createTextNode(((PlainLiteral) resource)
+                    .getLexicalForm()));
+            Language lang = ((PlainLiteral) resource).getLanguage();
+            if (lang != null) {
+                value.setAttribute("xml:lang", (lang.toString()));
+            }
+        } else {
+            value = doc.createElement("bnode");
+            value.appendChild(doc.createTextNode(((BNode) resource).toString()));
+        }
+        return value;
+    }
+}

Added: incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/ResultSetWriter.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/ResultSetWriter.java?rev=1088603&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/ResultSetWriter.java (added)
+++ incubator/stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/writers/ResultSetWriter.java Mon Apr  4 13:02:49 2011
@@ -0,0 +1,70 @@
+package org.apache.stanbol.commons.web.base.writers;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+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.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.clerezza.rdf.core.sparql.ResultSet;
+import org.w3c.dom.Document;
+
+/**
+ * MessageBodyWriter for a ResultSet.
+ * Clerezza does provide such a writer, but it seems to require
+ * quite a lot of Clerezza dependencies that we don't really need.
+ */
+@Provider
+@Produces({"application/sparql-results+xml", "application/xml", "text/xml"})
+public class ResultSetWriter implements MessageBodyWriter<ResultSet> {
+
+    public static final String ENCODING = "UTF-8";
+
+    @Override
+    public long getSize(ResultSet resultSet, Class<?> type, Type genericType,
+            Annotation[] annotations, MediaType mediaType) {
+        return -1;
+    }
+
+    @Override
+    public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
+        return ResultSet.class.isAssignableFrom(type);
+    }
+
+    @Override
+    public void writeTo(ResultSet resultSet, Class<?> type, Type genericType,
+            Annotation[] annotations, MediaType mediaType,
+            MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
+            throws IOException, WebApplicationException {
+
+        try {
+            Document doc = new ResultSetToXml().toDocument(resultSet);
+            DOMSource domSource = new DOMSource(doc);
+            StreamResult streamResult = new StreamResult(entityStream);
+            TransformerFactory tf = TransformerFactory.newInstance();
+            Transformer serializer = tf.newTransformer();
+            serializer.setOutputProperty(OutputKeys.ENCODING,ENCODING);
+            serializer.setOutputProperty(OutputKeys.INDENT,"yes");
+            serializer.transform(domSource, streamResult);
+        } catch(TransformerException te) {
+            throw new IOException("TransformerException in writeTo()", te);
+        } catch(ParserConfigurationException pce) {
+            throw new IOException("Exception in ResultSetToXml.toDocument()", pce);
+        }
+
+        entityStream.flush();
+    }
+}

Added: incubator/stanbol/trunk/commons/web/base/src/test/java/org/apache/stanbol/commons/web/base/writers/JsonLdSerializerProviderTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/base/src/test/java/org/apache/stanbol/commons/web/base/writers/JsonLdSerializerProviderTest.java?rev=1088603&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/web/base/src/test/java/org/apache/stanbol/commons/web/base/writers/JsonLdSerializerProviderTest.java (added)
+++ incubator/stanbol/trunk/commons/web/base/src/test/java/org/apache/stanbol/commons/web/base/writers/JsonLdSerializerProviderTest.java Mon Apr  4 13:02:49 2011
@@ -0,0 +1,189 @@
+package org.apache.stanbol.commons.web.base.writers;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.TimeZone;
+
+import org.apache.clerezza.rdf.core.MGraph;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
+import org.apache.clerezza.rdf.core.impl.util.W3CDateFormat;
+import org.apache.commons.io.IOUtils;
+import org.apache.stanbol.enhancer.servicesapi.ContentItem;
+import org.apache.stanbol.enhancer.servicesapi.TextAnnotation;
+import org.apache.stanbol.enhancer.servicesapi.helper.RdfEntityFactory;
+import org.apache.stanbol.enhancer.servicesapi.rdf.OntologicalClasses;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+
+public class JsonLdSerializerProviderTest {
+
+    private JsonLdSerializerProvider jsonldProvider;
+    private String formatIdentifier = "application/json";
+
+    private String expectedW3CFormattedDate;
+    
+    @Before
+    public void setup() {
+        jsonldProvider = new JsonLdSerializerProvider();
+    }
+
+    @Test
+    public void testWrongFormat() {
+        String context = "Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived "
+            + "in New Zealand and worked at the University of Otago.";
+        ContentItem ci = getContentItem("urn:iks-project:enhancer:test:content-item:person", context);
+
+        OutputStream serializedGraph = new ByteArrayOutputStream();
+        jsonldProvider.serialize(serializedGraph, ci.getMetadata(), "application/format+notsupported");
+    }
+
+    @Test
+    public void testSingleSubjectSerializeNoNs() {
+        String context = "Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived "
+            + "in New Zealand and worked at the University of Otago.";
+
+        ContentItem ci = getContentItem("urn:iks-project:enhancer:test:content-item:person", context);
+        getTextAnnotation(ci, "Person", "Patrick Marshall", context, OntologicalClasses.DBPEDIA_PERSON);
+
+        OutputStream serializedGraph = new ByteArrayOutputStream();
+        jsonldProvider.setIndentation(0);
+        jsonldProvider.serialize(serializedGraph, ci.getMetadata(), formatIdentifier);
+        
+        String expected = "{\"@\":\"<urn:iks-project:enhancer:test:text-annotation:Person>\",\"a\":[\"<http:\\/\\/fise.iks-project.eu\\/ontology\\/Enhancement>\",\"<http:\\/\\/fise.iks-project.eu\\/ontology\\/TextAnnotation>\"],\"http:\\/\\/fise.iks-project.eu\\/ontology\\/end\":\"\\\"20\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#int>\",\"http:\\/\\/fise.iks-project.eu\\/ontology\\/selected-text\":\"\\\"Patrick Marshall\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#string>\",\"http:\\/\\/fise.iks-project.eu\\/ontology\\/selection-context\":\"\\\"Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#string>\",\"http:\\/\\/fise.iks-project.eu\\/ontology\\/start\":\"\\\"4\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#int>\",\"http:\\/\\/purl.org\\/dc\\/terms\\/created\":\"\\\"" + this.expectedW3CFormattedDate + "\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSche
 ma#dateTime>\",\"http:\\/\\/purl.org\\/dc\\/terms\\/creator\":\"<urn:iks-project:enhancer:test:dummyEngine>\",\"http:\\/\\/purl.org\\/dc\\/terms\\/type\":\"<http:\\/\\/dbpedia.org\\/ontology\\/Person>\"}";
+        String result = serializedGraph.toString();
+        Assert.assertEquals(expected, result);
+    }
+
+    @Test
+    public void testSingleSubjectSerializeNoNsWithIndent() {
+        String context = "Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.";
+
+        ContentItem ci = getContentItem("urn:iks-project:enhancer:test:content-item:person", context);
+        getTextAnnotation(ci, "Person", "Patrick Marshall", context, OntologicalClasses.DBPEDIA_PERSON);
+
+        OutputStream serializedGraph = new ByteArrayOutputStream();
+        jsonldProvider.serialize(serializedGraph, ci.getMetadata(), formatIdentifier);
+
+        String expected = "{\n  \"@\": \"<urn:iks-project:enhancer:test:text-annotation:Person>\",\n  \"a\": [\n    \"<http:\\/\\/fise.iks-project.eu\\/ontology\\/Enhancement>\",\n    \"<http:\\/\\/fise.iks-project.eu\\/ontology\\/TextAnnotation>\"\n  ],\n  \"http:\\/\\/fise.iks-project.eu\\/ontology\\/end\": \"\\\"20\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#int>\",\n  \"http:\\/\\/fise.iks-project.eu\\/ontology\\/selected-text\": \"\\\"Patrick Marshall\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#string>\",\n  \"http:\\/\\/fise.iks-project.eu\\/ontology\\/selection-context\": \"\\\"Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#string>\",\n  \"http:\\/\\/fise.iks-project.eu\\/ontology\\/start\": \"\\\"4\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#int>\",\n  \"http:\\/\\/purl.org\\/dc\\/terms\\/created\": \"\\\"" + this.expectedW3CFormattedDa
 te + "\\\"^^<http:\\/\\/www.w3.org\\/2001\\/XMLSchema#dateTime>\",\n  \"http:\\/\\/purl.org\\/dc\\/terms\\/creator\": \"<urn:iks-project:enhancer:test:dummyEngine>\",\n  \"http:\\/\\/purl.org\\/dc\\/terms\\/type\": \"<http:\\/\\/dbpedia.org\\/ontology\\/Person>\"\n}";
+        String result = serializedGraph.toString();
+        Assert.assertEquals(expected, result);
+    }
+
+    @Test
+    public void testSingleSubjectSerializeWithNs() {
+        String context = "Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.";
+
+        ContentItem ci = getContentItem("urn:iks-project:enhancer:test:content-item:person", context);
+        getTextAnnotation(ci, "Person", "Patrick Marshall", context, OntologicalClasses.DBPEDIA_PERSON);
+
+        OutputStream serializedGraph = new ByteArrayOutputStream();
+        Map<String, String> nsMap = new HashMap<String, String>();
+        nsMap.put("http://fise.iks-project.eu/ontology/", "enhancer");
+        nsMap.put("http://www.w3.org/2001/XMLSchema#", "xmlns");
+        nsMap.put("http://dbpedia.org/ontology/", "dbpedia");
+        nsMap.put("http://purl.org/dc/terms", "dcterms");
+        jsonldProvider.setIndentation(0);
+        jsonldProvider.setNamespacePrefixMap(nsMap);
+        jsonldProvider.serialize(serializedGraph, ci.getMetadata(), formatIdentifier);
+
+        String expected = "{\"#\":{\"dbpedia\":\"http:\\/\\/dbpedia.org\\/ontology\\/\",\"dcterms\":\"http:\\/\\/purl.org\\/dc\\/terms\",\"enhancer\":\"http:\\/\\/fise.iks-project.eu\\/ontology\\/\",\"xmlns\":\"http:\\/\\/www.w3.org\\/2001\\/XMLSchema#\"},\"@\":\"<urn:iks-project:enhancer:test:text-annotation:Person>\",\"a\":[\"<enhancer:Enhancement>\",\"<enhancer:TextAnnotation>\"],\"dcterms:\\/created\":\"\\\"" + this.expectedW3CFormattedDate + "\\\"^^<xmlns:dateTime>\",\"dcterms:\\/creator\":\"<urn:iks-project:enhancer:test:dummyEngine>\",\"dcterms:\\/type\":\"<dbpedia:Person>\",\"enhancer:end\":\"\\\"20\\\"^^<xmlns:int>\",\"enhancer:selected-text\":\"\\\"Patrick Marshall\\\"^^<xmlns:string>\",\"enhancer:selection-context\":\"\\\"Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.\\\"^^<xmlns:string>\",\"enhancer:start\":\"\\\"4\\\"^^<xmlns:int>\"}";
+        String result = serializedGraph.toString();
+        Assert.assertEquals(expected, result);
+    }
+
+    @Test
+    public void testSingleSubjectSerializeWithNsWithIndent() {
+        String context = "Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the University of Otago.";
+
+        ContentItem ci = getContentItem("urn:iks-project:enhancer:test:content-item:person", context);
+        getTextAnnotation(ci, "Person", "Patrick Marshall", context, OntologicalClasses.DBPEDIA_PERSON);
+
+        OutputStream serializedGraph = new ByteArrayOutputStream();
+        Map<String, String> nsMap = new HashMap<String, String>();
+        nsMap.put("http://fise.iks-project.eu/ontology/", "enhancer");
+        nsMap.put("http://www.w3.org/2001/XMLSchema#", "xmlns");
+        nsMap.put("http://dbpedia.org/ontology/", "dbpedia");
+        nsMap.put("http://purl.org/dc/terms", "dcterms");
+        jsonldProvider.setIndentation(4);
+        jsonldProvider.setNamespacePrefixMap(nsMap);
+        jsonldProvider.serialize(serializedGraph, ci.getMetadata(), formatIdentifier);
+
+        String expected = "{\n    \"#\": {\n        \"dbpedia\": \"http:\\/\\/dbpedia.org\\/ontology\\/\",\n        \"dcterms\": \"http:\\/\\/purl.org\\/dc\\/terms\",\n        \"enhancer\": \"http:\\/\\/fise.iks-project.eu\\/ontology\\/\",\n        \"xmlns\": \"http:\\/\\/www.w3.org\\/2001\\/XMLSchema#\"\n    },\n    \"@\": \"<urn:iks-project:enhancer:test:text-annotation:Person>\",\n    \"a\": [\n        \"<enhancer:Enhancement>\",\n        \"<enhancer:TextAnnotation>\"\n    ],\n    \"dcterms:\\/created\": \"\\\"" + this.expectedW3CFormattedDate + "\\\"^^<xmlns:dateTime>\",\n    \"dcterms:\\/creator\": \"<urn:iks-project:enhancer:test:dummyEngine>\",\n    \"dcterms:\\/type\": \"<dbpedia:Person>\",\n    \"enhancer:end\": \"\\\"20\\\"^^<xmlns:int>\",\n    \"enhancer:selected-text\": \"\\\"Patrick Marshall\\\"^^<xmlns:string>\",\n    \"enhancer:selection-context\": \"\\\"Dr. Patrick Marshall (1869 - November 1950) was a geologist who lived in New Zealand and worked at the Univ
 ersity of Otago.\\\"^^<xmlns:string>\",\n    \"enhancer:start\": \"\\\"4\\\"^^<xmlns:int>\"\n}";
+        String result = serializedGraph.toString();
+        Assert.assertEquals(expected, result);
+    }
+
+    private ContentItem getContentItem(final String id, final String text) {
+        return new ContentItem() {
+
+            SimpleMGraph metadata = new SimpleMGraph();
+
+            public InputStream getStream() {
+                return new ByteArrayInputStream(text.getBytes());
+            }
+
+            public String getMimeType() {
+                return "text/plain";
+            }
+
+            public MGraph getMetadata() {
+                return metadata;
+            }
+
+            public String getId() {
+                return id;
+            }
+        };
+    }
+
+    private void getTextAnnotation(ContentItem ci, String annotationURNExtension, String namedEntity, String context, UriRef type) {
+        String content;
+        try {
+            content = IOUtils.toString(ci.getStream(),"UTF-8");
+        } catch (IOException e) {
+            // should never happen anyway!
+            content = "";
+        }
+        RdfEntityFactory factory = RdfEntityFactory.createInstance(ci.getMetadata());
+        TextAnnotation testAnnotation = factory.getProxy(new UriRef("urn:iks-project:enhancer:test:text-annotation:" + annotationURNExtension), TextAnnotation.class);
+        testAnnotation.setCreator(new UriRef("urn:iks-project:enhancer:test:dummyEngine"));
+
+        Calendar myCal = Calendar.getInstance();
+        myCal.set(2010, 9, 27, 12, 0, 0);
+        myCal.set(Calendar.MILLISECOND, 0);
+        myCal.setTimeZone(TimeZone.getTimeZone("UTC"));
+        testAnnotation.setCreated(myCal.getTime());
+        
+        this.expectedW3CFormattedDate = new W3CDateFormat().format(myCal.getTime());
+        
+        testAnnotation.setSelectedText(namedEntity);
+        testAnnotation.setSelectionContext(context);
+        testAnnotation.getDcType().add(type);
+        Integer start = content.indexOf(namedEntity);
+        if (start < 0) { // if not found in the content set start to 42
+            start = 42;
+        }
+        testAnnotation.setStart(start);
+        testAnnotation.setEnd(start + namedEntity.length());
+    }
+
+    @SuppressWarnings("unused")
+    private void toConsole(String result) {
+        System.out.println(result);
+        String s = result;
+        s = s.replaceAll("\\\\", "\\\\\\\\");
+        s = s.replace("\"", "\\\"");
+        s = s.replace("\n", "\\n");
+        System.out.println(s);
+    }
+
+}

Propchange: incubator/stanbol/trunk/commons/web/home/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Apr  4 13:02:49 2011
@@ -0,0 +1,5 @@
+target
+.project
+.classpath
+.settings
+

Added: incubator/stanbol/trunk/commons/web/home/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/pom.xml?rev=1088603&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/web/home/pom.xml (added)
+++ incubator/stanbol/trunk/commons/web/home/pom.xml Mon Apr  4 13:02:49 2011
@@ -0,0 +1,111 @@
+<?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>${stanbol-version}</version>
+    <relativePath>../../../parent</relativePath>
+  </parent>
+
+  <groupId>org.apache.stanbol</groupId>
+  <artifactId>org.apache.stanbol.commons.web.home</artifactId>
+  <version>${stanbol-version}</version>
+  <packaging>bundle</packaging>
+
+  <name>Apache Stanbol Commons Web Home Page</name>
+  <description>Home page and common stylesheets for documenting HTTP endpoints.</description>
+  <scm>
+    <connection>
+      scm:svn:http://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons/web/home
+    </connection>
+    <developerConnection>
+      scm:svn:https://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons/web/home
+    </developerConnection>
+    <url>http://incubator.apache.org/stanbol/</url>
+  </scm>
+
+  <build>
+    <!-- make it an OSGi bundle -->
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-scr-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Export-Package>
+              org.apache.stanbol.commons.web.home.*
+            </Export-Package>
+            <Import-Package>*</Import-Package>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+    </dependency>
+    
+    <!-- Jersey, servlet and freemarker -->
+    <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.freemarker</groupId>
+      <artifactId>freemarker</artifactId>
+    </dependency>
+
+    <!-- OSGi tax -->
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.compendium</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.apache.felix.scr.annotations</artifactId>
+    </dependency>
+
+    <!-- Stanbol -->
+    <dependency>
+      <groupId>org.apache.stanbol</groupId>
+      <artifactId>org.apache.stanbol.commons.web.base</artifactId>
+    </dependency>
+
+  </dependencies>
+
+</project>

Added: incubator/stanbol/trunk/commons/web/home/src/main/java/org/apache/stanbol/commons/web/home/HomeWebFragment.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/java/org/apache/stanbol/commons/web/home/HomeWebFragment.java?rev=1088603&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/web/home/src/main/java/org/apache/stanbol/commons/web/home/HomeWebFragment.java (added)
+++ incubator/stanbol/trunk/commons/web/home/src/main/java/org/apache/stanbol/commons/web/home/HomeWebFragment.java Mon Apr  4 13:02:49 2011
@@ -0,0 +1,95 @@
+package org.apache.stanbol.commons.web.home;
+
+import java.util.ArrayList;
+import java.util.Collections;
+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.commons.web.home.resource.StanbolRootResource;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.component.ComponentContext;
+
+import freemarker.cache.ClassTemplateLoader;
+import freemarker.cache.TemplateLoader;
+
+/**
+ * Statically define the list of available resources and providers to be contributed to the the Stanbol JAX-RS
+ * Endpoint.
+ */
+@Component(immediate = true, metatype = true)
+@Service
+public class HomeWebFragment implements WebFragment {
+
+    private static final String NAME = "home";
+
+    private static final String STATIC_RESOURCE_PATH = "/org/apache/stanbol/commons/web/home/static";
+
+    private static final String TEMPLATE_PATH = "/org/apache/stanbol/commons/web/home/templates";
+
+    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(StanbolRootResource.class);
+        return classes;
+    }
+
+    @Override
+    public Set<Object> getJaxrsResourceSingletons() {
+        return Collections.emptySet();
+    }
+
+    @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/stanbol.css", this, 0));
+        return resources;
+    }
+
+    @Override
+    public List<ScriptResource> getScriptResources() {
+        List<ScriptResource> resources = new ArrayList<ScriptResource>();
+        // resources.add(new ScriptResource("text/javascript", "scripts/jquery-1.4.2.js", this, 0));
+        return resources;
+    }
+
+    @Override
+    public BundleContext getBundleContext() {
+        return bundleContext;
+    }
+
+    @Override
+    public List<NavigationLink> getNavigationLinks() {
+        return Collections.emptyList();
+    }
+
+}

Added: incubator/stanbol/trunk/commons/web/home/src/main/java/org/apache/stanbol/commons/web/home/resource/StanbolRootResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/java/org/apache/stanbol/commons/web/home/resource/StanbolRootResource.java?rev=1088603&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/web/home/src/main/java/org/apache/stanbol/commons/web/home/resource/StanbolRootResource.java (added)
+++ incubator/stanbol/trunk/commons/web/home/src/main/java/org/apache/stanbol/commons/web/home/resource/StanbolRootResource.java Mon Apr  4 13:02:49 2011
@@ -0,0 +1,27 @@
+package org.apache.stanbol.commons.web.home.resource;
+
+import static javax.ws.rs.core.MediaType.TEXT_HTML;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Response;
+
+import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
+
+import com.sun.jersey.api.view.Viewable;
+
+/**
+ * Root JAX-RS resource. The HTML view is implicitly rendered by a freemarker template to be found in the
+ * META-INF/templates folder.
+ */
+@Path("/")
+public class StanbolRootResource extends BaseStanbolResource {
+
+    @GET
+    @Produces(TEXT_HTML)
+    public Response get() {
+        return Response.ok(new Viewable("index", this), TEXT_HTML).build();
+    }
+    
+}

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/ajax-loader.gif
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/ajax-loader.gif?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/ajax-loader.gif
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/anonymous_48.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/anonymous_48.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/anonymous_48.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/apache_stanbol_logo_cropped.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/apache_stanbol_logo_cropped.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/apache_stanbol_logo_cropped.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/black_gear_128.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/black_gear_128.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/black_gear_128.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/black_gear_16.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/black_gear_16.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/black_gear_16.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/compass_48.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/compass_48.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/compass_48.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/compass_map_48.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/compass_map_48.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/compass_map_48.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/download.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/download.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/download.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/download_rdf.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/download_rdf.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/download_rdf.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/external.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/external.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/external.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/favicon-black.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/favicon-black.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/favicon-black.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/favicon-sw.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/favicon-sw.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/favicon-sw.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/favicon.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/favicon.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/favicon.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/fise_logo_cropped.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/fise_logo_cropped.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/fise_logo_cropped.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/fise_logo_white.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/fise_logo_white.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/fise_logo_white.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/fise_logo_white_small.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/fise_logo_white_small.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/fise_logo_white_small.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/foldable_folded.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/foldable_folded.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/foldable_folded.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/foldable_unfolded.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/foldable_unfolded.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/foldable_unfolded.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/header_bg.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/header_bg.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/header_bg.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/iks_project_logo.jpg
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/iks_project_logo.jpg?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/iks_project_logo.jpg
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/next.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/next.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/next.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/organization_48.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/organization_48.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/organization_48.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/pin_map_32.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/pin_map_32.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/pin_map_32.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/pin_map_48.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/pin_map_48.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/pin_map_48.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/previous.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/previous.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/previous.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/rdf.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/rdf.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/rdf.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/rdf_flyer.64.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/rdf_flyer.64.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/rdf_flyer.64.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/rdf_flyer_16.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/rdf_flyer_16.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/rdf_flyer_16.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/rdf_flyer_24.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/rdf_flyer_24.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/rdf_flyer_24.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/sw-cube.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/sw-cube.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/sw-cube.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/user_48.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/user_48.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/user_48.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/user_group_48.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/user_group_48.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/user_group_48.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/wikipedia_w_16.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/wikipedia_w_16.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/wikipedia_w_16.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/world_map_1024_512.png
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/world_map_1024_512.png?rev=1088603&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/images/world_map_1024_512.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/style/stanbol.css
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/style/stanbol.css?rev=1088603&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/style/stanbol.css (added)
+++ incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/style/stanbol.css Mon Apr  4 13:02:49 2011
@@ -0,0 +1,416 @@
+body {
+  font: normal 13px/20px Arial,Helvetica,sans-serif;
+  padding: 0;
+  margin: 0;
+  background-color: #eff9f0;
+}
+
+img {
+  border: none;
+}
+
+a:link, a:visited, a:hover {
+  color: #c43187;
+}
+
+a:active {
+  color: black;  
+}
+
+a:focus {
+  outline: none;
+}
+
+dt, dd {
+  margin-top: 1em;
+}
+
+pre, textarea {
+  border: 1px solid #f8dcbb;
+  padding: 1em;
+  background-color: #f8f8f8;
+  font-size: 90%;  
+  overflow: auto;
+}
+
+textarea {
+  width: 100%;
+}
+
+pre {
+  white-space: pre-wrap;       /* css-3 */
+  white-space: -moz-pre-wrap;  /* Mozilla, since 1999 */
+  white-space: -pre-wrap;      /* Opera 4-6 */
+  white-space: -o-pre-wrap;    /* Opera 7 */
+  word-wrap: break-word;       /* Internet Explorer 5.5+ */  
+}
+
+form  {
+  margin-bottom: 2em;
+}
+
+.home {
+  position: absolute;
+}
+
+.header {
+  padding: 0.5em 1em;
+  background: #4c4c4c url("/static/images/header_bg.png") repeat-x top left;  
+  border-bottom: 1px solid black;
+}
+
+.header h1 {
+  float: left;
+}
+
+.header .mainNavigationMenu {
+  margin: 23px 1em 0;
+  text-align: right;
+}
+
+.header .mainNavigationMenu ul {
+  display: inline;
+}
+
+.header .mainNavigationMenu li {
+  display: inline;
+  margin-left: 0.5em;
+  border: 1px solid transparent;
+  padding: 0.3em 0.5em 0.5em 0.5em;
+  border-radius: 8px;
+}
+
+.header .mainNavigationMenu li.selected {
+  border: 1px solid #222;
+  background-color: #333;
+}
+
+.header .mainNavigationMenu a {
+  font-weight: bold;
+  color: #EFF9F0;
+}
+
+
+.restapitabs {
+  text-align: right;
+}
+
+.restapitabs ul {
+  display: inline;
+}
+
+.restapitabs li {
+  display: inline;
+  margin-left: 0.5em;
+  border: 1px solid transparent;
+  padding: 0.5em 0.5em 0.5em 0.5em;
+  border-radius: 8px;
+}
+
+.restapitabs a {
+  text-decoration: none;
+}
+
+.restapitabs li.selected {
+  font-weight: bold;
+}
+
+h1 {
+  color: #e9e9e9;
+  font-size: 18px;
+  font-weight: normal;
+  margin: 22px 0 3px;
+  padding: 0 0 0 200px;
+  text-shadow: 0 1px 0 #000;
+}
+
+h2 {
+  padding: 0;
+  margin: 1em 0;
+  font-size: 16px;
+}
+
+h3 {
+  padding: 0;
+  margin: 1em 0;
+  font-size: 14px;
+  font-weight:bold;
+}
+
+.content {
+  background-color: #fff;
+  border-color: #d1dfce;
+  border-style: solid;
+  border-width: 0 1px 2px;
+  margin: 0 auto 5em;
+  padding: 0.5em 2em 1em;
+  width: 75%;
+}
+
+.content img.preview {
+  border: 1px solid gray;  
+  max-width: 800px;  
+}
+
+.content fieldset {
+  border: 1px solid #d1dfce;
+}
+
+.footer {
+  background-color: #494949;
+  border-top: 2px solid #373737;
+  color: #d9d9d9;
+  font-size: 85%;
+  padding: 1em 1em 2em;
+  text-shadow: 0 1px 0 #111111;
+}
+
+.footer .column {
+  float: left;
+  width: 48%;
+  padding: 0.5em;
+}
+
+.column a img {
+  border: 1px solid #373737;
+}
+
+.footer img.swcube {
+  padding: 6px;
+  background-color: white;  
+}
+
+.right {
+  text-align: right;
+} 
+
+table {
+  text-align: left;
+  width: 100%;
+}
+
+.storeContents table {
+  border-collapse: collapse;
+  margin: 5px 0 0;
+}
+
+.storeContents th {  
+  color: #000;
+  font-size: 105%;
+  font-weight: normal;
+  padding: 6px 10px;
+  border-bottom: 1px solid #d1dfce;
+  background-color:#f8f8f8;
+}
+
+.storeContents th img {
+  vertical-align: top;
+  border: medium none;
+  margin: 0 0.1em;
+}
+
+.storeContents td {
+  padding: 4px 10px 5px;
+  border-bottom: 1px solid #ffe8f9;
+}
+
+.content h2 {
+  float: left;  
+}
+
+.content input.url {
+  width: 600px;
+}
+
+.content .contentItemPreview pre {
+  max-height: 200px;  
+}
+
+.content table {
+  font-size: 95%; 
+}
+
+.entitylistings {
+  margin-top: 20px;
+  }
+
+.entitylisting h3 {
+  text-align: center;  
+}
+
+.entitylisting {
+  float: left;
+  width: 33%;
+  margin: auto;
+}
+
+.entitylisting p {
+  margin: 0.2em;
+}
+
+.entitylisting table {
+  border: 1px solid #eee;
+  border-radius: 8px;
+  background: url("/static/images/foldable_unfolded.png") no-repeat scroll right 17px transparent;
+}
+
+.entitylisting table.collapsed {
+  background: url("/static/images/foldable_folded.png") no-repeat scroll right center transparent;
+  }
+
+.entitylisting .subheader {
+  height: 25px;
+}
+
+.entitylisting .subheader td {
+  background-color: #f9f9f9;
+  border-bottom: 1px solid #eee;
+  border-top: 1px solid #eee;
+  font-weight: bold;
+  padding: 0 10px;
+}
+
+.entitylisting img {
+  vertical-align: middle;
+  border: 1px solid transparent;
+}
+
+.entitylisting .thumb {
+  height: 44px;
+  width: 50px;
+  text-align: center;
+}
+
+.entitylisting .thumb img {
+  max-width: 48px;
+  max-height: 42px;
+}
+
+.entitylisting thead {
+  cursor: pointer;
+}
+
+.entitylisting tbody{
+  background-color: #fcfcfc;
+  }
+
+.entitylisting tbody tr {
+  height: 42px;
+}
+
+.entitylisting .collapsed tbody tr {
+  display: none;
+}
+
+.downloadLinks, .previousNext {
+  list-style: none;
+  text-align: right;
+  padding: 0;
+  }
+
+.downloadLinks li, .previousNext li {
+  border: 1px solid #c3c3c3;
+  display: inline;
+  margin: 0 0 0 30px;
+  padding: 4px 6px 5px;
+  background-color: #fafafa;
+  }
+
+.downloadLinks li a, .previousNext li a {
+  color: #333;
+  text-decoration: none;
+  }
+
+.downloadLinks li a:hover, .previousNext li a:hover {
+  text-decoration: underline;
+  }
+
+li.older a {
+  background: url("/static/images/next.png") no-repeat scroll right center transparent;
+  padding: 0 12px 0 0;
+  }
+  
+li.moreRecent a {
+  background: url("/static/images/previous.png") no-repeat scroll left center transparent;
+  padding: 0 0 0 13px;
+  }
+
+.download {
+  background: url("/static/images/download.png") no-repeat scroll left center transparent;
+  padding: 0 0 2px 20px;
+  }
+
+.downloadRDF {
+  background: url("/static/images/download_rdf.png") no-repeat scroll left center transparent;
+  padding: 0 0 2px 20px;
+  }
+
+.external {
+  background: url("/static/images/external.png") no-repeat scroll right center transparent;
+  padding: 0 18px 0 0;
+  }
+  
+#enginesOuputWaiter {
+  opacity: 90%;
+  font-style: italic;
+  text-align: center;  
+}
+
+#enginesOuput pre {
+  max-height: 200px;
+}
+
+.enginelisting {
+  padding: 0.5em;
+  border: 1px solid #eee;
+  border-radius: 8px;
+}
+
+.enginelisting .collapseheader {
+  margin: 0.1em;
+  cursor: pointer;
+  background: url("/static/images/foldable_unfolded.png") no-repeat scroll right center transparent;
+}
+
+.enginelisting .collapsed .collapseheader {
+  background: url("/static/images/foldable_folded.png") no-repeat scroll right center transparent;
+}
+
+.enginelisting ul {
+  padding-left: 0;
+}
+
+.enginelisting .collapsed .collapsable {
+  display: none;
+}
+
+.enginelisting li {
+  list-style: none;
+  padding-left: 20px; 
+  background: transparent url(/static/images/black_gear_16.png) no-repeat scroll 0% 50%;
+}
+
+#enginesInput .submitButtons {
+  text-align: right;  
+}
+
+p.note {
+  font-size: 90%;
+  font-style: italic;
+  text-align: right;
+}
+
+.mapContainer {
+  margin: 1em auto 1em auto; width: 800px;
+}
+
+.mapContainer img {
+  opacity: 0.6;
+}
+
+.mapContainer .olPopup {
+  border: 1px solid #333;
+  border-radius: 8px;
+  text-align: center;
+  font-size: 110%;
+}

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/templates/imports/common.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/templates/imports/common.ftl?rev=1088603&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/templates/imports/common.ftl (added)
+++ incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/templates/imports/common.ftl Mon Apr  4 13:02:49 2011
@@ -0,0 +1,78 @@
+<#macro page title hasrestapi>
+<html>
+  <head>
+
+    <title>${title?html} - Apache Stanbol</title>
+    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+
+    <!-- to be moved in the dedicated fragment -->
+    <link rel="stylesheet" href="${it.staticRootUrl}/home/style/stanbol.css" />
+    <link rel="icon" type="image/png" href="${it.staticRootUrl}/home/images/favicon.png" />
+
+    <#list it.registeredLinkResources as link>
+    <link rel="${link.rel}" href="${it.staticRootUrl}/${link.fragmentName}/${link.relativePath}" />
+    </#list>
+
+    <#list it.registeredScriptResources as script>
+    <script type="${script.type}" src="${it.staticRootUrl}/${script.fragmentName}/${script.relativePath}"></script>
+    </#list>
+
+  </head>
+
+  <body>
+    <div class="home"><a href="${it.rootUrl}"><img src="${it.staticRootUrl}/home/images/apache_stanbol_logo_cropped.png" alt="Stanbol Home" /></a></div>
+    <div class="header">
+      <h1>The RESTful Semantic Engine</h1>
+
+      <#if it?exists && it.mainMenuItems?exists>
+      <div class="mainNavigationMenu">
+      <ul>
+        <#list it.mainMenuItems as item>
+        <li class="${item.cssClass}"><a href="${it.publicBaseUri}${item.link}">${item.label}</a></li>
+        </#list>
+      </ul>
+      </div>
+      </#if>
+      <div style="clear: both"></div>
+    </div>
+
+    <div class="content">
+      <h2>${title?html}</h2>
+      <#if hasrestapi>
+      <div class="restapitabs">
+      <ul>
+        <li id="tab-webview" class="selected"><a href="#">Web View</a></li>
+        <li id="tab-restapi" ><a href="#">REST API</a></li>
+      <ul>
+      </div>
+<script>
+$(".restapitabs a").click(function () {
+  $(this).parents("ul").find("li").removeClass("selected");
+  $(this).parents("li").addClass("selected");
+  $(".panel").hide();
+  var panelId = $(this).parents("li")[0].id.split("-")[1];
+  $("#" + panelId).fadeIn();
+});
+</script>
+      </#if>
+      <div style="clear: both"></div>
+      <#nested>
+    </div>
+
+    <div class="footer">
+
+    <div class="column">
+      <a href="http://www.w3.org/standards/semanticweb/"><img class="swcube"
+        src="${it.staticRootUrl}/home/images/sw-cube.png"/></a>
+      <a href="http://www.iks-project.eu"><img
+        height="60px" alt="IKS Project" src="${it.staticRootUrl}/home/images/iks_project_logo.jpg" /></a>
+    </div>
+    <div class="column right">
+      <em>The research leading to these results has received funding from the European Community's
+          Seventh Framework Programme (FP7/2007-2013) under grant agreement n° 231527</em>
+    </div>
+    <div style="clear: both"></div>
+    </div>
+  </body>
+</html>
+</#macro>

Added: incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/templates/org/apache/stanbol/commons/web/home/resource/StanbolRootResource/index.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/templates/org/apache/stanbol/commons/web/home/resource/StanbolRootResource/index.ftl?rev=1088603&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/templates/org/apache/stanbol/commons/web/home/resource/StanbolRootResource/index.ftl (added)
+++ incubator/stanbol/trunk/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/templates/org/apache/stanbol/commons/web/home/resource/StanbolRootResource/index.ftl Mon Apr  4 13:02:49 2011
@@ -0,0 +1,40 @@
+<#import "/imports/common.ftl" as common>
+<#escape x as x?html>
+<@common.page title="Welcome to Apache Stanbol!" hasrestapi=false> 
+
+<p>Apache Stanbol is an Open Source HTTP service meant to help Content
+Management System developers to semi-automatically enhance unstructured
+content (text, image, ...) with semantic annotations to be able to link
+documents with related entities and topics.</p>
+
+<p>Please go to <a href="http://incubator.apache.org/stanbol">the
+official website</a> to learn more on the project, read the
+documentation and join the mailing list.</p>
+
+<p>Here are the main HTTP entry points. Each resource comes with a web
+view that documents the matching RESTful API for applications:</p>
+<dl>
+
+  <#list it.navigationLinks as link>
+  <#if link.hasDescriptionTemplate>
+    <dt><a href="${it.publicBaseUri}${link.path}">${link.label}</a><dt>
+    <dd><#include "${link.descriptionTemplate}"></dd>
+  </#if>
+  </#list>
+
+  <dt><a href="system/console">/system/console</a><dt>
+  <dd>
+    <p>This is the OSGi administration console (for administrators and developers). The initial
+       username / password is set to <em>admin / admin</em>.</p>
+    <p>Use the console to add new bundles and activate, de-activate and configure components.</p>
+    <p>The console can also be used to perform hot-(re)deployment of any OSGi bundles.
+       For instance to re-deploy a new version of this web interface, go to the <tt>$STANBOL_HOME/enhancer/jersey</tt>
+       source folder and run the following command:</p>
+<pre>
+mvn install -o -DskipTests -PinstallBundle -Dsling.url=${it.publicBaseUri}system/console
+</pre>
+  </dd>
+
+</dl>
+</...@common.page>
+</#escape>

Propchange: incubator/stanbol/trunk/commons/web/sparql/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Apr  4 13:02:49 2011
@@ -0,0 +1,5 @@
+target
+.project
+.classpath
+.settings
+

Added: incubator/stanbol/trunk/commons/web/sparql/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/sparql/pom.xml?rev=1088603&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/web/sparql/pom.xml (added)
+++ incubator/stanbol/trunk/commons/web/sparql/pom.xml Mon Apr  4 13:02:49 2011
@@ -0,0 +1,133 @@
+<?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>${stanbol-version}</version>
+    <relativePath>../../../parent</relativePath>
+  </parent>
+
+  <groupId>org.apache.stanbol</groupId>
+  <artifactId>org.apache.stanbol.commons.web.sparql</artifactId>
+  <version>${stanbol-version}</version>
+  <packaging>bundle</packaging>
+
+  <name>Apache Stanbol Commons Web SPARQL</name>
+  <description>SPARQL HTTP endpoint for Stanbol</description>
+  <scm>
+    <connection>
+      scm:svn:http://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons/web/sparql
+    </connection>
+    <developerConnection>
+      scm:svn:https://svn.apache.org/repos/asf/incubator/stanbol/trunk/commons/web/sparql
+    </developerConnection>
+    <url>http://incubator.apache.org/stanbol/</url>
+  </scm>
+
+  <build>
+    <!-- make it an OSGi bundle -->
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-scr-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Export-Package>
+              org.apache.stanbol.commons.web.sparql.*
+            </Export-Package>
+            <Import-Package>*</Import-Package>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.stanbol</groupId>
+      <artifactId>org.apache.stanbol.enhancer.servicesapi</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.stanbol</groupId>
+      <artifactId>org.apache.stanbol.commons.web.base</artifactId>
+    </dependency>
+
+    <!-- Jersey and servlet -->
+    <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.freemarker</groupId>
+      <artifactId>freemarker</artifactId>
+    </dependency>
+
+    <!-- generic tax -->
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+    </dependency>
+
+    <!-- OSGi tax -->
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.compendium</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.apache.felix.scr.annotations</artifactId>
+    </dependency>
+
+    <!-- Clerezza dependencies -->
+    <dependency>
+      <groupId>org.apache.clerezza</groupId>
+      <artifactId>org.apache.clerezza.rdf.core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.clerezza</groupId>
+      <artifactId>org.apache.clerezza.jaxrs.rdf.providers</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.clerezza</groupId>
+      <artifactId>org.apache.clerezza.rdf.jena.serializer</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.clerezza</groupId>
+      <artifactId>org.apache.clerezza.rdf.jena.parser</artifactId>
+    </dependency>
+
+  </dependencies>
+
+</project>

Added: incubator/stanbol/trunk/commons/web/sparql/src/main/java/org/apache/stanbol/commons/web/sparql/SparqlEndpointWebFragment.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/sparql/src/main/java/org/apache/stanbol/commons/web/sparql/SparqlEndpointWebFragment.java?rev=1088603&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/web/sparql/src/main/java/org/apache/stanbol/commons/web/sparql/SparqlEndpointWebFragment.java (added)
+++ incubator/stanbol/trunk/commons/web/sparql/src/main/java/org/apache/stanbol/commons/web/sparql/SparqlEndpointWebFragment.java Mon Apr  4 13:02:49 2011
@@ -0,0 +1,91 @@
+package org.apache.stanbol.commons.web.sparql;
+
+import java.util.ArrayList;
+import java.util.Collections;
+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.commons.web.sparql.resource.SparqlEndpointResource;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.component.ComponentContext;
+
+import freemarker.cache.ClassTemplateLoader;
+import freemarker.cache.TemplateLoader;
+
+/**
+ * Statically define the list of available resources and providers to be contributed to the the Stanbol JAX-RS
+ * Endpoint.
+ */
+@Component(immediate = true, metatype = true)
+@Service
+public class SparqlEndpointWebFragment implements WebFragment {
+
+    private static final String NAME = "sparql";
+
+    private static final String TEMPLATE_PATH = "/org/apache/stanbol/commons/web/sparql/templates";
+
+    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(SparqlEndpointResource.class);
+        return classes;
+    }
+
+    @Override
+    public Set<Object> getJaxrsResourceSingletons() {
+        return Collections.emptySet();
+    }
+
+    @Override
+    public String getStaticResourceClassPath() {
+        return null;
+    }
+
+    @Override
+    public TemplateLoader getTemplateLoader() {
+        return new ClassTemplateLoader(getClass(), TEMPLATE_PATH);
+    }
+
+    @Override
+    public List<LinkResource> getLinkResources() {
+        return Collections.emptyList();
+    }
+
+    @Override
+    public List<ScriptResource> getScriptResources() {
+        return Collections.emptyList();
+    }
+
+    @Override
+    public List<NavigationLink> getNavigationLinks() {
+        List<NavigationLink> links = new ArrayList<NavigationLink>();
+        links.add(new NavigationLink("sparql", "/sparql", "/imports/sparqlDescription.ftl", 50));
+        return links;
+    }
+
+    @Override
+    public BundleContext getBundleContext() {
+        return bundleContext;
+    }
+
+}

Added: incubator/stanbol/trunk/commons/web/sparql/src/main/java/org/apache/stanbol/commons/web/sparql/resource/SparqlEndpointResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/sparql/src/main/java/org/apache/stanbol/commons/web/sparql/resource/SparqlEndpointResource.java?rev=1088603&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/web/sparql/src/main/java/org/apache/stanbol/commons/web/sparql/resource/SparqlEndpointResource.java (added)
+++ incubator/stanbol/trunk/commons/web/sparql/src/main/java/org/apache/stanbol/commons/web/sparql/resource/SparqlEndpointResource.java Mon Apr  4 13:02:49 2011
@@ -0,0 +1,78 @@
+package org.apache.stanbol.commons.web.sparql.resource;
+
+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.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+
+import org.apache.clerezza.rdf.core.access.TcManager;
+import org.apache.clerezza.rdf.core.sparql.ParseException;
+import org.apache.clerezza.rdf.core.sparql.QueryParser;
+import org.apache.clerezza.rdf.core.sparql.query.ConstructQuery;
+import org.apache.clerezza.rdf.core.sparql.query.DescribeQuery;
+import org.apache.clerezza.rdf.core.sparql.query.Query;
+import org.apache.stanbol.commons.web.base.ContextHelper;
+import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
+import org.apache.stanbol.enhancer.servicesapi.Store;
+import org.apache.stanbol.enhancer.servicesapi.SparqlQueryEngine.SparqlQueryEngineException;
+
+import com.sun.jersey.api.view.Viewable;
+
+import static javax.ws.rs.core.MediaType.APPLICATION_FORM_URLENCODED;
+import static javax.ws.rs.core.MediaType.APPLICATION_XML;
+import static javax.ws.rs.core.MediaType.TEXT_HTML;
+
+/**
+ * Implementation of a SPARQL endpoint as defined by the W3C:
+ * 
+ * http://www.w3.org/TR/rdf-sparql-protocol/
+ * 
+ * (Might not be 100% compliant yet, please report bugs/missing features in the issue tracker).
+ * 
+ * If the "query" parameter is not present, then fallback to display and HTML view with an ajax-ified form to
+ * test the SPARQL endpoint from the browser.
+ */
+@Path("/sparql")
+public class SparqlEndpointResource extends BaseStanbolResource {
+
+    protected Store store;
+
+    protected TcManager tcManager;
+
+    public SparqlEndpointResource(@Context ServletContext ctx) {
+        tcManager = ContextHelper.getServiceFromContext(TcManager.class, ctx);
+        store = ContextHelper.getServiceFromContext(Store.class, ctx);
+    }
+
+    @GET
+    @Consumes(APPLICATION_FORM_URLENCODED)
+    @Produces({TEXT_HTML + ";qs=2", "application/sparql-results+xml", "application/rdf+xml", APPLICATION_XML})
+    public Object sparql(@QueryParam(value = "query") String sparqlQuery) throws SparqlQueryEngineException,
+                                                                         ParseException {
+        if (sparqlQuery == null) {
+            return Response.ok(new Viewable("index", this), TEXT_HTML).build();
+        }
+        Query query = QueryParser.getInstance().parse(sparqlQuery);
+        String mediaType = "application/sparql-results+xml";
+        if (query instanceof DescribeQuery || query instanceof ConstructQuery) {
+            mediaType = "application/rdf+xml";
+        }
+        Object result = tcManager.executeSparqlQuery(query, store.getEnhancementGraph());
+        return Response.ok(result, mediaType).build();
+    }
+
+    @POST
+    @Consumes(APPLICATION_FORM_URLENCODED)
+    @Produces({"application/sparql-results+xml", "application/rdf+xml", APPLICATION_XML})
+    public Object postSparql(@FormParam("query") String sparqlQuery) throws SparqlQueryEngineException,
+                                                                    ParseException {
+        return sparql(sparqlQuery);
+    }
+
+}

Added: incubator/stanbol/trunk/commons/web/sparql/src/main/resources/org/apache/stanbol/commons/web/sparql/templates/imports/sparql.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/web/sparql/src/main/resources/org/apache/stanbol/commons/web/sparql/templates/imports/sparql.ftl?rev=1088603&view=auto
==============================================================================
--- incubator/stanbol/trunk/commons/web/sparql/src/main/resources/org/apache/stanbol/commons/web/sparql/templates/imports/sparql.ftl (added)
+++ incubator/stanbol/trunk/commons/web/sparql/src/main/resources/org/apache/stanbol/commons/web/sparql/templates/imports/sparql.ftl Mon Apr  4 13:02:49 2011
@@ -0,0 +1,49 @@
+<#macro form>
+<form id="sparql" action="${it.publicBaseUri}sparql" method="GET"
+ enctype="application/x-www-form-urlencoded"
+ accept="application/sparql-results+xml, application/rdf+xml">
+<textarea class="query" rows="11" name="query">
+PREFIX fise: &lt;http://fise.iks-project.eu/ontology/&gt;
+PREFIX dc:   &lt;http://purl.org/dc/terms/&gt;
+SELECT distinct ?enhancement ?content ?engine ?extraction_time
+WHERE {
+  ?enhancement a fise:Enhancement .
+  ?enhancement fise:extracted-from ?content .
+  ?enhancement dc:creator ?engine .
+  ?enhancement dc:created ?extraction_time .
+}
+ORDER BY DESC(?extraction_time) LIMIT 5
+</textarea>
+<p><input type="submit" class="submit" value="Run SPARQL query" /></p>
+<pre class="prettyprint result" style="max-height: 200px; display: none" disabled="disabled">
+</pre>
+</form>
+<script language="javascript">
+function registersSparqlHandler() {
+   $("#sparql input.submit", this).click(function(e) {
+     // disable regular form click
+     e.preventDefault();
+     
+     // clean the result area
+     $("#sparql textarea.result").text('');
+     
+     // submit sparql query using Ajax
+     $.ajax({
+       type: "POST",
+       url: "${it.publicBaseUri}sparql",
+       data: {query: $("#sparql textarea.query").val()},
+       dataType: "html",
+       cache: false,
+       success: function(result) {
+         $("#sparql pre.result").text(result).css("display", "block");
+         prettyPrint();
+       },
+       error: function(result) {
+         $("#sparql pre.result").text('Invalid query.').css("display", "block");
+       }
+     });
+   });
+ }
+ $(document).ready(registersSparqlHandler);
+</script>
+</#macro>
\ No newline at end of file