You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by re...@apache.org on 2013/03/09 11:06:49 UTC
svn commit: r1454682 - in /stanbol/trunk: ./
development/archetypes/stateless-webmodule/
development/archetypes/stateless-webmodule/src/
development/archetypes/stateless-webmodule/src/main/
development/archetypes/stateless-webmodule/src/main/resources/...
Author: reto
Date: Sat Mar 9 10:06:48 2013
New Revision: 1454682
URL: http://svn.apache.org/r1454682
Log:
STANBOL-973: Added archetype creating a stateless webapp allowing to upload a file with a mutipart form
Added:
stanbol/trunk/development/archetypes/stateless-webmodule/ (with props)
stanbol/trunk/development/archetypes/stateless-webmodule/pom.xml
stanbol/trunk/development/archetypes/stateless-webmodule/src/
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/META-INF/
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/META-INF/maven/
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/META-INF/maven/archetype-metadata.xml
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/ (with props)
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/README.md
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/nbactions.xml
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/pom.xml
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/java/
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/java/ExampleMenuItem.java
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/java/MultiEnhancer.java
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/java/Ontology.java
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/META-INF/
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/META-INF/graphs/
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/META-INF/graphs/recipes/
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/META-INF/graphs/recipes/Enhancements.ttl
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/META-INF/resources/
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/META-INF/resources/example-service/
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/META-INF/resources/example-service/styles/
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/META-INF/resources/example-service/styles/multi-enhancer.css
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/templates/
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/templates/html/
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/templates/html/Enhancements.ftl
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/templates/html/MultiEnhancer.ftl
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/templates/html/includes/
stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/templates/html/includes/footer.ftl
stanbol/trunk/development/archetypes/stateless-webmodule/src/test/
stanbol/trunk/development/archetypes/stateless-webmodule/src/test/resources/
stanbol/trunk/development/archetypes/stateless-webmodule/src/test/resources/projects/
stanbol/trunk/development/archetypes/stateless-webmodule/src/test/resources/projects/basic/
stanbol/trunk/development/archetypes/stateless-webmodule/src/test/resources/projects/basic/archetype.properties
stanbol/trunk/development/archetypes/stateless-webmodule/src/test/resources/projects/basic/goal.txt
Modified:
stanbol/trunk/pom.xml
Propchange: stanbol/trunk/development/archetypes/stateless-webmodule/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Mar 9 10:06:48 2013
@@ -0,0 +1 @@
+target
Added: stanbol/trunk/development/archetypes/stateless-webmodule/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/development/archetypes/stateless-webmodule/pom.xml?rev=1454682&view=auto
==============================================================================
--- stanbol/trunk/development/archetypes/stateless-webmodule/pom.xml (added)
+++ stanbol/trunk/development/archetypes/stateless-webmodule/pom.xml Sat Mar 9 10:06:48 2013
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>stanbol-parent</artifactId>
+ <version>4-SNAPSHOT</version>
+ <relativePath>../../../parent</relativePath>
+ </parent>
+
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>stateless-webmodule-archetype</artifactId>
+ <version>0.12.0-SNAPSHOT</version>
+ <packaging>maven-archetype</packaging>
+
+ <name>Apache Stanbol Stateles Webmodule Archetype</name>
+
+ <!-- don't add line breaks to the description as archetype:generate only shows one line -->
+ <description>Archetype for a project that allows posting files and shows the computed enhancements.</description>
+
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.archetype</groupId>
+ <artifactId>archetype-packaging</artifactId>
+ <version>2.2</version>
+ </extension>
+ </extensions>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-archetype-plugin</artifactId>
+ <version>2.2</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+</project>
Added: stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/META-INF/maven/archetype-metadata.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/META-INF/maven/archetype-metadata.xml?rev=1454682&view=auto
==============================================================================
--- stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/META-INF/maven/archetype-metadata.xml (added)
+++ stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/META-INF/maven/archetype-metadata.xml Sat Mar 9 10:06:48 2013
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<archetype-descriptor xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0 http://maven.apache.org/xsd/archetype-descriptor-1.0.0.xsd" name="example-project"
+ xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-descriptor/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <fileSets>
+ <fileSet filtered="true" packaged="true" encoding="UTF-8">
+ <directory>src/main/java</directory>
+ <includes>
+ <include>**/*.java</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory>src/main/resources</directory>
+ <includes>
+ <include>**/*.ttl</include>
+ <include>**/*.css</include>
+ </includes>
+ </fileSet>
+ <fileSet packaged="true" encoding="UTF-8">
+ <directory>src/main/resources/templates/html</directory>
+ <includes>
+ <include>**/*.ftl</include>
+ </includes>
+ <excludes>
+ <exclude>includes/**</exclude>
+ </excludes>
+ </fileSet>
+ <fileSet encoding="UTF-8">
+ <directory>src/main/resources/templates/html/includes</directory>
+ <includes>
+ <include>**/*.ftl</include>
+ </includes>
+ </fileSet>
+ <fileSet filtered="true" encoding="UTF-8">
+ <directory></directory>
+ <includes>
+ <include>nbactions.xml</include>
+ <include>.gitignore</include>
+ <include>README.md</include>
+ </includes>
+ </fileSet>
+ </fileSets>
+</archetype-descriptor>
+
Propchange: stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Mar 9 10:06:48 2013
@@ -0,0 +1 @@
+.gitignore
Added: stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/README.md
URL: http://svn.apache.org/viewvc/stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/README.md?rev=1454682&view=auto
==============================================================================
--- stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/README.md (added)
+++ stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/README.md Sat Mar 9 10:06:48 2013
@@ -0,0 +1,18 @@
+Example Apache Stanbol Component
+===========
+
+This is an example Apache Stanbol component.
+
+To compile the engine run
+
+ mvn install
+
+To deploy the engine to a stanbol instance running on localhost port 8080 run
+
+ mvn org.apache.sling:maven-sling-plugin:install
+
+
+After installing a new menu item pointing you to /${artifactId} will appear.
+
+The example service allows to upload a file for which enhancement will be generated.
+The service can be accessed via browser as HTML or as RDF for machine clients.
Added: stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/nbactions.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/nbactions.xml?rev=1454682&view=auto
==============================================================================
--- stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/nbactions.xml (added)
+++ stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/nbactions.xml Sat Mar 9 10:06:48 2013
@@ -0,0 +1,14 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+<?xml version="1.0" encoding="UTF-8"?>
+<actions>
+ <action>
+ <actionName>CUSTOM-deploy to localhost:8080</actionName>
+ <displayName>deploy to localhost:8080</displayName>
+ <goals>
+ <goal>install</goal>
+ <goal>org.apache.sling:maven-sling-plugin:install</goal>
+ </goals>
+ </action>
+</actions>
Added: stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/pom.xml?rev=1454682&view=auto
==============================================================================
--- stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/pom.xml (added)
+++ stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/pom.xml Sat Mar 9 10:06:48 2013
@@ -0,0 +1,90 @@
+<?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>
+
+ <groupId>${groupId}</groupId>
+ <artifactId>${artifactId}</artifactId>
+ <version>${version}</version>
+
+ <packaging>bundle</packaging>
+
+ <name>Skeleton for ${artifactId}</name>
+ <description>Allows posting files and shows the computed enhancements.</description>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <build>
+ <!-- make it an OSGi bundle -->
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ <version>1.9.0</version>
+ <executions>
+ <execution>
+ <id>generate-scr-scrdescriptor</id>
+ <goals>
+ <goal>scr</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <version>2.3.7</version>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.commons.web.base</artifactId>
+ <version>0.12.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.enhancer.core</artifactId>
+ <version>0.10.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.commons.web.viewable</artifactId>
+ <version>0.12.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.6.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>rdf.ontologies</artifactId>
+ <version>0.11-incubating</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>rdf.utils</artifactId>
+ <version>0.13-incubating</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>4.3.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ <version>1.7.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>jaxrs.utils</artifactId>
+ <version>0.6-incubating</version>
+ </dependency>
+ </dependencies>
+</project>
Added: stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/java/ExampleMenuItem.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/java/ExampleMenuItem.java?rev=1454682&view=auto
==============================================================================
--- stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/java/ExampleMenuItem.java (added)
+++ stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/java/ExampleMenuItem.java Sat Mar 9 10:06:48 2013
@@ -0,0 +1,20 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+package ${package};
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.stanbol.commons.web.base.NavigationLink;
+
+@Component
+@Service(NavigationLink.class)
+public class ExampleMenuItem extends NavigationLink {
+
+ public ExampleMenuItem() {
+ super("${artifactId}",
+ "Example: ${artifactId}",
+ "An stateless service example", 300);
+ }
+
+}
Added: stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/java/MultiEnhancer.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/java/MultiEnhancer.java?rev=1454682&view=auto
==============================================================================
--- stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/java/MultiEnhancer.java (added)
+++ stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/java/MultiEnhancer.java Sat Mar 9 10:06:48 2013
@@ -0,0 +1,129 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+package ${package};
+
+import java.io.IOException;
+import javax.ws.rs.GET;
+import javax.ws.rs.HeaderParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.UriInfo;
+import org.apache.clerezza.jaxrs.utils.form.FormFile;
+import org.apache.clerezza.jaxrs.utils.form.MultiPartBody;
+import org.apache.clerezza.rdf.core.MGraph;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl;
+import org.apache.clerezza.rdf.ontologies.RDF;
+import org.apache.clerezza.rdf.ontologies.RDFS;
+import org.apache.clerezza.rdf.utils.GraphNode;
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.stanbol.commons.indexedgraph.IndexedMGraph;
+import org.apache.stanbol.commons.web.viewable.RdfViewable;
+import org.apache.stanbol.enhancer.servicesapi.Chain;
+import org.apache.stanbol.enhancer.servicesapi.ChainManager;
+import org.apache.stanbol.enhancer.servicesapi.ContentItem;
+import org.apache.stanbol.enhancer.servicesapi.ContentItemFactory;
+import org.apache.stanbol.enhancer.servicesapi.ContentSource;
+import org.apache.stanbol.enhancer.servicesapi.EnhancementException;
+import org.apache.stanbol.enhancer.servicesapi.EnhancementJobManager;
+import org.apache.stanbol.enhancer.servicesapi.impl.ByteArraySource;
+import org.osgi.service.component.ComponentContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Upload file for which the enhancements are to be computed
+ */
+@Component
+@Service(Object.class)
+@Property(name="javax.ws.rs", boolValue=true)
+@Path("${artifactId}")
+public class MultiEnhancer {
+
+ /**
+ * Using slf4j for logging
+ */
+ private static final Logger log = LoggerFactory.getLogger(MultiEnhancer.class);
+
+ @Reference
+ private ContentItemFactory contentItemFactory;
+
+ @Reference
+ private EnhancementJobManager enhancementJobManager;
+
+ @Reference
+ private ChainManager chainManager;
+
+ @Activate
+ protected void activate(ComponentContext context) {
+ log.info("The example service is being activated");
+ }
+
+ @Deactivate
+ protected void deactivate(ComponentContext context) {
+ log.info("The example service is being activated");
+ }
+
+ /**
+ * This method return an RdfViewable, this is an RDF serviceUri with associated
+ * presentational information.
+ */
+ @GET
+ public RdfViewable serviceEntry(@Context final UriInfo uriInfo,
+ @HeaderParam("user-agent") String userAgent) throws Exception {
+ final String resourcePath = uriInfo.getAbsolutePath().toString();
+ //The URI at which this service was accessed accessed, this will be the
+ //central serviceUri in the response
+ final UriRef serviceUri = new UriRef(resourcePath);
+ //the in memory graph to which the triples for the response are added
+ final MGraph responseGraph = new IndexedMGraph();
+ //This GraphNode represents the service within our result graph
+ final GraphNode node = new GraphNode(serviceUri, responseGraph);
+ //The triples will be added to the first graph of the union
+ //i.e. to the in-memory responseGraph
+ node.addProperty(RDF.type, Ontology.MultiEnhancer);
+ node.addProperty(RDFS.comment, new PlainLiteralImpl("A Multi Enhancer service"));
+ //What we return is the GraphNode we created with a template path
+ return new RdfViewable("MultiEnhancer", node, MultiEnhancer.class);
+ }
+
+ /**
+ * This service returns an RdfVieable describing the enhanced document.
+ */
+ @POST
+ public RdfViewable enhanceFile(MultiPartBody body) throws IOException, EnhancementException {
+ final String[] chainValues = body.getTextParameterValues("chain");
+ final String chainName = chainValues.length > 0 ? chainValues[0] : null;
+ final FormFile file = body.getFormFileParameterValues("file")[0];
+ final ContentSource contentSource = new ByteArraySource(
+ file.getContent(),
+ file.getMediaType().toString(),
+ file.getFileName());
+ final ContentItem contentItem = contentItemFactory.createContentItem(contentSource);
+ if ((chainName == null) || chainName.trim().equals("")) {
+ enhancementJobManager.enhanceContent(contentItem);
+ } else {
+ final Chain chain = chainManager.getChain(chainName);
+ if (chain == null) {
+ throw new RuntimeException("No chain by that name: "+chainName);
+ }
+ enhancementJobManager.enhanceContent(contentItem, chain);
+ }
+ //this contains the enhancement results
+ final MGraph resultGraph = contentItem.getMetadata();
+ //this is the IRI assigned to the subitted content
+ final UriRef contentIri = contentItem.getUri();
+ //this represent the submitted Content within the resultGraph
+ final GraphNode node = new GraphNode(contentIri, resultGraph);
+ //node is the "root" for rendering the results
+ return new RdfViewable("Enhancements", node, MultiEnhancer.class);
+ }
+
+}
Added: stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/java/Ontology.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/java/Ontology.java?rev=1454682&view=auto
==============================================================================
--- stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/java/Ontology.java (added)
+++ stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/java/Ontology.java Sat Mar 9 10:06:48 2013
@@ -0,0 +1,22 @@
+#set( $symbol_pound = '#' )
+#set( $symbol_dollar = '$' )
+#set( $symbol_escape = '\' )
+package ${package};
+
+import org.apache.clerezza.rdf.core.UriRef;
+
+
+/**
+ * Ideally this should be a dereferenceable ontology on the web. Given such
+ * an ontology a class of constant (similar to this) can be generated with
+ * the org.apache.clerezza:maven-ontologies-plugin
+ */
+public class Ontology {
+ /**
+ * Resources of this type handle HTTP POST requests with a multipart message
+ * containing the content to be enhance as one field and optionally the
+ * requested enhancment chain in the other.
+ */
+ public static final UriRef MultiEnhancer = new UriRef("http://example.org/service-description${symbol_pound}MultiEnhancer");
+
+}
Added: stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/META-INF/graphs/recipes/Enhancements.ttl
URL: http://svn.apache.org/viewvc/stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/META-INF/graphs/recipes/Enhancements.ttl?rev=1454682&view=auto
==============================================================================
--- stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/META-INF/graphs/recipes/Enhancements.ttl (added)
+++ stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/META-INF/graphs/recipes/Enhancements.ttl Sat Mar 9 10:06:48 2013
@@ -0,0 +1,10 @@
+@prefix foaf: <http://xmlns.com/foaf/0.1/> .
+@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
+@prefix recipe: <http://vocab.netlabs.org/recipe#> .
+
+[] a recipe:Recipe;
+ rdfs:label "When presenting an enhanced document the property of its enhancements should be presented too";
+ recipe:ingredient
+ [a recipe:Ingredient;
+ recipe:ingredientInverseProperty <http://fise.iks-project.eu/ontology/extracted-from>];
+ recipe:recipeDomain "${package.replace(".","/")}/Enhancements" .
Added: stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/META-INF/resources/example-service/styles/multi-enhancer.css
URL: http://svn.apache.org/viewvc/stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/META-INF/resources/example-service/styles/multi-enhancer.css?rev=1454682&view=auto
==============================================================================
--- stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/META-INF/resources/example-service/styles/multi-enhancer.css (added)
+++ stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/META-INF/resources/example-service/styles/multi-enhancer.css Sat Mar 9 10:06:48 2013
@@ -0,0 +1,3 @@
+h1 {
+ color: green
+}
\ No newline at end of file
Added: stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/templates/html/Enhancements.ftl
URL: http://svn.apache.org/viewvc/stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/templates/html/Enhancements.ftl?rev=1454682&view=auto
==============================================================================
--- stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/templates/html/Enhancements.ftl (added)
+++ stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/templates/html/Enhancements.ftl Sat Mar 9 10:06:48 2013
@@ -0,0 +1,25 @@
+<@namespace dct="http://purl.org/dc/terms/" />
+<@namespace fise="http://fise.iks-project.eu/ontology/" />
+
+<html>
+ <head>
+ <title>Enhancements</title>
+ <link type="text/css" rel="stylesheet" href="example-service/styles/multi-enhancer.css" />
+ </head>
+
+ <body>
+ <h1>Enhancements</h1>
+ The uploaded file hast URI: <@ldpath path="."/><br/>
+ <@ldpath path="^fise:extracted-from">
+ <p>Annotation: <@ldpath path="."/><br/>
+ <!-- unfortunately it doesn't seem to be possible to show all the properties and there values -->
+ Created by: <@ldpath path="dct:creator"/><br/>
+ <@ldpath path="rdf:type">
+ Of type: <@ldpath path="."/><br/>
+ </...@ldpath>
+ </p>
+ </...@ldpath>
+ <#include "/html/includes/footer.ftl">
+ </body>
+</html>
+
Added: stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/templates/html/MultiEnhancer.ftl
URL: http://svn.apache.org/viewvc/stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/templates/html/MultiEnhancer.ftl?rev=1454682&view=auto
==============================================================================
--- stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/templates/html/MultiEnhancer.ftl (added)
+++ stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/templates/html/MultiEnhancer.ftl Sat Mar 9 10:06:48 2013
@@ -0,0 +1,30 @@
+<@namespace ont="http://example.org/service-description#" />
+<@namespace ehub="http://stanbol.apache.org/ontology/entityhub/entityhub#" />
+<@namespace cc="http://creativecommons.org/ns#" />
+<@namespace dct="http://purl.org/dc/terms/" />
+
+<html>
+ <head>
+ <title>Multi-Enhancer Example Application - Apache Stanbol</title>
+ <link type="text/css" rel="stylesheet" href="example-service/styles/multi-enhancer.css" />
+ </head>
+
+ <body>
+ <h1>Enhance a file</h1>
+
+ <form method="POST" action="<@ldpath path="."/>" accept-charset="utf-8"
+ enctype="multipart/form-data">
+ <label for="file">File to enhance</label><input type="file" name="file"
+ size="90"/><br/>
+ <label for="chain">Chain to use</label><input type="text" name="chain"
+ size="30"/><br/>
+ <input type="submit" value="Get enhancements" />
+ <input type="submit" onclick="this.form.action = '<@ldpath path="."/>?header_Accept=application%2Frdf%2Bxml'"
+ value="Get enhancement as rdf/xml" />
+ <input type="submit" onclick="this.form.action = '<@ldpath path="."/>?header_Accept=text%2Fturtle'"
+ value="Get enhancement as turtle" />
+ </form>
+ <#include "/html/includes/footer.ftl">
+ </body>
+</html>
+
Added: stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/templates/html/includes/footer.ftl
URL: http://svn.apache.org/viewvc/stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/templates/html/includes/footer.ftl?rev=1454682&view=auto
==============================================================================
--- stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/templates/html/includes/footer.ftl (added)
+++ stanbol/trunk/development/archetypes/stateless-webmodule/src/main/resources/archetype-resources/src/main/resources/templates/html/includes/footer.ftl Sat Mar 9 10:06:48 2013
@@ -0,0 +1,3 @@
+<div>Thank you for trying out this example application.</div>
+<div>This text come from the /includes/footer.ftl template, if more than one bundle
+provides such a file it is not defined which one will be used.</div>
\ No newline at end of file
Added: stanbol/trunk/development/archetypes/stateless-webmodule/src/test/resources/projects/basic/archetype.properties
URL: http://svn.apache.org/viewvc/stanbol/trunk/development/archetypes/stateless-webmodule/src/test/resources/projects/basic/archetype.properties?rev=1454682&view=auto
==============================================================================
--- stanbol/trunk/development/archetypes/stateless-webmodule/src/test/resources/projects/basic/archetype.properties (added)
+++ stanbol/trunk/development/archetypes/stateless-webmodule/src/test/resources/projects/basic/archetype.properties Sat Mar 9 10:06:48 2013
@@ -0,0 +1,5 @@
+#Thu Mar 07 14:14:35 CET 2013
+package=it.pkg
+version=0.1-SNAPSHOT
+groupId=archetype.it
+artifactId=basic
Added: stanbol/trunk/development/archetypes/stateless-webmodule/src/test/resources/projects/basic/goal.txt
URL: http://svn.apache.org/viewvc/stanbol/trunk/development/archetypes/stateless-webmodule/src/test/resources/projects/basic/goal.txt?rev=1454682&view=auto
==============================================================================
(empty)
Modified: stanbol/trunk/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/pom.xml?rev=1454682&r1=1454681&r2=1454682&view=diff
==============================================================================
--- stanbol/trunk/pom.xml (original)
+++ stanbol/trunk/pom.xml Sat Mar 9 10:06:48 2013
@@ -87,6 +87,7 @@
<module>launchers/full-war</module>
<module>development/archetypes/statefull-webmodule</module>
+ <module>development/archetypes/stateless-webmodule</module>
<module>development/archetypes/enhancement-engine</module>
</modules>