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/02/13 23:33:26 UTC
svn commit: r1445962 - in /stanbol/trunk: commons/ldpathtemplate/
commons/security/usermanagement/ commons/web/viewable-ldpath/
commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/webfragment/
commons/web/viewable-l...
Author: reto
Date: Wed Feb 13 22:33:26 2013
New Revision: 1445962
URL: http://svn.apache.org/r1445962
Log:
STANBOL-910: fixed OSGi package instructions
Added:
stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/writer/impl/
stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/writer/impl/LdViewableWriter.java
- copied, changed from r1445905, stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/writer/LdViewableWriter.java
Removed:
stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/webfragment/
stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/writer/LdViewableWriter.java
Modified:
stanbol/trunk/commons/ldpathtemplate/pom.xml
stanbol/trunk/commons/security/usermanagement/pom.xml
stanbol/trunk/commons/web/viewable-ldpath/pom.xml
stanbol/trunk/commons/web/viewable-writer/pom.xml
stanbol/trunk/commons/web/viewable-writer/src/main/java/org/apache/stanbol/commons/viewable/writer/impl/ViewableWriter.java
stanbol/trunk/launchers/bundlelists/stanbolcommons/src/main/bundles/list.xml
Modified: stanbol/trunk/commons/ldpathtemplate/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/ldpathtemplate/pom.xml?rev=1445962&r1=1445961&r2=1445962&view=diff
==============================================================================
--- stanbol/trunk/commons/ldpathtemplate/pom.xml (original)
+++ stanbol/trunk/commons/ldpathtemplate/pom.xml Wed Feb 13 22:33:26 2013
@@ -55,15 +55,8 @@
<extensions>true</extensions>
<configuration>
<instructions>
- <Import-Package>
- at.newmedialab.ldpath.template.engine,
- at.newmedialab.ldpath.template.model.freemarker,
- at.newmedialab.ldpath.template.model.transformers,
- at.newmedialab.ldpath.template.util,
- *
- </Import-Package>
<Export-Package>
- at.newmedialab.ldpath.template.*;version=0.9.5
+ org.apache.stanbol.commons.ldpathtemplate
</Export-Package>
</instructions>
</configuration>
Modified: stanbol/trunk/commons/security/usermanagement/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/security/usermanagement/pom.xml?rev=1445962&r1=1445961&r2=1445962&view=diff
==============================================================================
--- stanbol/trunk/commons/security/usermanagement/pom.xml (original)
+++ stanbol/trunk/commons/security/usermanagement/pom.xml Wed Feb 13 22:33:26 2013
@@ -71,7 +71,6 @@
javax.ws.rs.*; version="[0,2)",
org.apache.stanbol.commons.web.base; provide:=true,
org.apache.felix.webconsole; provide:=true,
- at.newmedialab.ldpath.template.engine; version="[0.9.5,1)",
*
</Import-Package>
<Export-Package>
Modified: stanbol/trunk/commons/web/viewable-ldpath/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/web/viewable-ldpath/pom.xml?rev=1445962&r1=1445961&r2=1445962&view=diff
==============================================================================
--- stanbol/trunk/commons/web/viewable-ldpath/pom.xml (original)
+++ stanbol/trunk/commons/web/viewable-ldpath/pom.xml Wed Feb 13 22:33:26 2013
@@ -58,15 +58,8 @@
<extensions>true</extensions>
<configuration>
<instructions>
- <Private-Package>
- org.apache.stanbol.commons.web.viewable.ldpath.webfragment;version=${project.version},
- org.apache.stanbol.commons.web.viewable.ldpath.writer;version=${project.version}
- </Private-Package>
- <Embed-Transitive>true</Embed-Transitive>
<Import-Package>
- javax.servlet.*; version="[2.5.0,4.0.0)",
javax.ws.rs.*; version="[0,2)",
- org.apache.stanbol.commons.web.base; provide:=true,
*
</Import-Package>
</instructions>
@@ -78,11 +71,6 @@
<dependencies>
<dependency>
<groupId>org.apache.stanbol</groupId>
- <artifactId>org.apache.stanbol.commons.ldpath.clerezza</artifactId>
- <version>0.11.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.stanbol</groupId>
<artifactId>org.apache.stanbol.commons.web.viewable</artifactId>
<version>0.12.0-SNAPSHOT</version>
</dependency>
@@ -92,12 +80,6 @@
<version>0.12.0-SNAPSHOT</version>
</dependency>
<dependency>
- <groupId>org.apache.stanbol</groupId>
- <artifactId>org.apache.stanbol.commons.web.base</artifactId>
- <version>0.12.0-SNAPSHOT</version>
- </dependency>
-
- <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
@@ -105,16 +87,10 @@
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>rdf.ontologies</artifactId>
- </dependency>
<dependency>
<groupId>org.apache.clerezza</groupId>
<artifactId>rdf.utils</artifactId>
</dependency>
-
-
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.annotations</artifactId>
Copied: stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/writer/impl/LdViewableWriter.java (from r1445905, stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/writer/LdViewableWriter.java)
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/writer/impl/LdViewableWriter.java?p2=stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/writer/impl/LdViewableWriter.java&p1=stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/writer/LdViewableWriter.java&r1=1445905&r2=1445962&rev=1445962&view=diff
==============================================================================
--- stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/writer/LdViewableWriter.java (original)
+++ stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/writer/impl/LdViewableWriter.java Wed Feb 13 22:33:26 2013
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.stanbol.commons.web.viewable.ldpath.writer;
+package org.apache.stanbol.commons.web.viewable.ldpath.writer.impl;
import java.io.IOException;
import java.io.OutputStream;
@@ -22,82 +22,55 @@ import java.io.OutputStreamWriter;
import java.io.Writer;
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 org.apache.clerezza.rdf.core.Resource;
-import org.apache.clerezza.rdf.utils.GraphNode;
-import org.apache.stanbol.commons.ldpath.clerezza.ClerezzaBackend;
+import org.apache.felix.scr.annotations.Component;
+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.ldpathtemplate.LdRenderer;
import org.apache.stanbol.commons.web.viewable.RdfViewable;
-import at.newmedialab.ldpath.api.backend.RDFBackend;
-import at.newmedialab.ldpath.template.engine.TemplateEngine;
-
-import freemarker.cache.TemplateLoader;
-import freemarker.template.TemplateException;
-
+/**
+* Renders an RdfVieable using the LdRenderer with the template path prefix
+* with html
+*
+* TODO: support more media types associated to other prefixes
+*/
+@Component
+@Service(Object.class)
+@Property(name="javax.ws.rs", boolValue=true)
@Produces(MediaType.TEXT_HTML)
@Provider
public class LdViewableWriter implements MessageBodyWriter<RdfViewable> {
- private TemplateLoader templateLoader;
-
- public LdViewableWriter(TemplateLoader templateLoader) {
- if(templateLoader == null){
- throw new IllegalArgumentException("The parsed TemplateLoader MUST NOT be NULL!");
- }
- this.templateLoader = templateLoader;
+ @Reference
+ private LdRenderer ldRenderer;
+
+ @Override
+ public boolean isWriteable(Class<?> type, Type genericType,
+ Annotation[] annotations, MediaType mediaType) {
+ return RdfViewable.class.isAssignableFrom(type);
+ }
+
+ @Override
+ public long getSize(RdfViewable t, Class<?> type, Type genericType,
+ Annotation[] annotations, MediaType mediaType) {
+ return -1;
}
@Override
- public boolean isWriteable(Class<?> type, Type genericType,
- Annotation[] annotations, MediaType mediaType) {
- return RdfViewable.class.isAssignableFrom(type);
- }
-
- @Override
- public long getSize(RdfViewable t, Class<?> type, Type genericType,
- Annotation[] annotations, MediaType mediaType) {
- return -1;
- }
-
- @Override
- public void writeTo(RdfViewable t, Class<?> type, Type genericType,
- Annotation[] annotations, MediaType mediaType,
- MultivaluedMap<String, Object> httpHeaders,
- OutputStream entityStream) throws IOException,
- WebApplicationException {
- Writer out = new OutputStreamWriter(entityStream, "utf-8");
- render(t.getGraphNode(), "html/"+t.getTemplatePath(), out);
- out.flush();
- }
- /**
- * Renders a GraphNode with a template located in the templates
- * folder of any active bundle
- *
- * @param node the GraphNode to be rendered
- * @param templatePath the freemarker path to the template
- * @param out where the result is written to
- */
- private void render(GraphNode node, final String templatePath, Writer out) {
- //A GraphNode backend could be graph unspecific, so the same engine could be
- //reused, possibly being signifantly more performant (caching, etc.)
- RDFBackend<Resource> backend = new ClerezzaBackend(node.getGraph());
- Resource context = node.getNode();
- TemplateEngine<Resource> engine = new TemplateEngine<Resource>(backend);
- engine.setTemplateLoader(templateLoader);
- try {
- engine.processFileTemplate(context, templatePath, null, out);
- out.flush();
- } catch (IOException e) {
- throw new RuntimeException(e);
- } catch (TemplateException e) {
- throw new RuntimeException(e);
- }
+ public void writeTo(RdfViewable t, Class<?> type, Type genericType,
+ Annotation[] annotations, MediaType mediaType,
+ MultivaluedMap<String, Object> httpHeaders,
+ OutputStream entityStream) throws IOException,
+ WebApplicationException {
+ Writer out = new OutputStreamWriter(entityStream, "utf-8");
+ ldRenderer.render(t.getGraphNode(), "html/" + t.getTemplatePath(), out);
+ out.flush();
}
}
Modified: stanbol/trunk/commons/web/viewable-writer/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/web/viewable-writer/pom.xml?rev=1445962&r1=1445961&r2=1445962&view=diff
==============================================================================
--- stanbol/trunk/commons/web/viewable-writer/pom.xml (original)
+++ stanbol/trunk/commons/web/viewable-writer/pom.xml Wed Feb 13 22:33:26 2013
@@ -56,7 +56,6 @@
<configuration>
<instructions>
<Import-Package>
- javax.servlet.*; version="[2.5.0,4.0.0)",
javax.ws.rs.*; version="[0,2)",
org.apache.stanbol.commons.web.base; provide:=true,
*
Modified: stanbol/trunk/commons/web/viewable-writer/src/main/java/org/apache/stanbol/commons/viewable/writer/impl/ViewableWriter.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/web/viewable-writer/src/main/java/org/apache/stanbol/commons/viewable/writer/impl/ViewableWriter.java?rev=1445962&r1=1445961&r2=1445962&view=diff
==============================================================================
--- stanbol/trunk/commons/web/viewable-writer/src/main/java/org/apache/stanbol/commons/viewable/writer/impl/ViewableWriter.java (original)
+++ stanbol/trunk/commons/web/viewable-writer/src/main/java/org/apache/stanbol/commons/viewable/writer/impl/ViewableWriter.java Wed Feb 13 22:33:26 2013
@@ -43,7 +43,7 @@ import org.apache.felix.scr.annotations.
@Component
@Service(Object.class)
@Property(name="javax.ws.rs", boolValue=true)
-@Produces("text/html")
+@Produces(MediaType.TEXT_HTML)
@Provider
public class ViewableWriter implements MessageBodyWriter<Viewable> {
Modified: stanbol/trunk/launchers/bundlelists/stanbolcommons/src/main/bundles/list.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/launchers/bundlelists/stanbolcommons/src/main/bundles/list.xml?rev=1445962&r1=1445961&r2=1445962&view=diff
==============================================================================
--- stanbol/trunk/launchers/bundlelists/stanbolcommons/src/main/bundles/list.xml (original)
+++ stanbol/trunk/launchers/bundlelists/stanbolcommons/src/main/bundles/list.xml Wed Feb 13 22:33:26 2013
@@ -513,6 +513,11 @@
<artifactId>org.apache.stanbol.commons.web.viewable.ldpath</artifactId>
<version>0.12.0-SNAPSHOT</version>
</bundle>
+ <bundle>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.commons.web.viewable.writer</artifactId>
+ <version>0.12.0-SNAPSHOT</version>
+ </bundle>
</startLevel>