You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2015/05/18 09:20:31 UTC
clerezza git commit: CLEREZZA-327: adapted code for site generation
to run with current modules.
Repository: clerezza
Updated Branches:
refs/heads/master 8d5b8bd0d -> dacd8c71c
CLEREZZA-327: adapted code for site generation to run with current modules.
Project: http://git-wip-us.apache.org/repos/asf/clerezza/repo
Commit: http://git-wip-us.apache.org/repos/asf/clerezza/commit/dacd8c71
Tree: http://git-wip-us.apache.org/repos/asf/clerezza/tree/dacd8c71
Diff: http://git-wip-us.apache.org/repos/asf/clerezza/diff/dacd8c71
Branch: refs/heads/master
Commit: dacd8c71cd01922958f1d5c5b435e2cb7d88e024
Parents: 8d5b8bd
Author: Reto Gmuer <re...@apache.org>
Authored: Mon May 18 07:20:13 2015 +0000
Committer: Reto Gmuer <re...@apache.org>
Committed: Mon May 18 07:20:13 2015 +0000
----------------------------------------------------------------------
parent/pom.xml | 3 +
provisioning/platform.content/pom.xml | 7 +-
site/pom.xml | 19 +-
site/src/main/scala/Activator.scala | 22 +-
site/src/main/scala/GlobalMenuRenderlet.scala | 83 +++----
site/src/main/scala/HeadedPageRenderlet.scala | 4 +-
site/src/main/scala/Ontology.scala | 4 +-
.../src/main/scala/TitledContentRenderlet.scala | 2 +-
tools.offline/pom.xml | 56 ++---
.../clerezza/tools/offline/Generator.java | 63 +++---
.../tools/offline/ThumbnailCondition.java | 214 -------------------
.../offline/utils/ConditionalOutputStream.java | 61 ------
.../tools/offline/utils/StreamCondition.java | 52 -----
.../clerezza/rdf/web/core/sparql-endpoint.ssp | 75 -------
.../tools/offline/ThumbnailConditionTest.java | 58 -----
15 files changed, 125 insertions(+), 598 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/clerezza/blob/dacd8c71/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 6c80e01..9484cb4 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -721,6 +721,9 @@
</goals>
</execution>
</executions>
+ <configuration>
+ <bundleStartLevel>30</bundleStartLevel>
+ </configuration>
</plugin>
</plugins>
</build>
http://git-wip-us.apache.org/repos/asf/clerezza/blob/dacd8c71/provisioning/platform.content/pom.xml
----------------------------------------------------------------------
diff --git a/provisioning/platform.content/pom.xml b/provisioning/platform.content/pom.xml
index 54a408e..fce2b25 100644
--- a/provisioning/platform.content/pom.xml
+++ b/provisioning/platform.content/pom.xml
@@ -74,12 +74,17 @@
<artifactId>rdf.stable.serializer</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
- <!-- this doesn't strictly belongs to here -->
+ <!-- thess don't strictly belong to here -->
<dependency>
<groupId>org.apache.stanbol</groupId>
<artifactId>org.apache.stanbol.commons.web.resources</artifactId>
<version>0.12.0</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>platform.xhtml2html</artifactId>
+ <version>0.6</version>
+ </dependency>
</dependencies>
<build>
http://git-wip-us.apache.org/repos/asf/clerezza/blob/dacd8c71/site/pom.xml
----------------------------------------------------------------------
diff --git a/site/pom.xml b/site/pom.xml
index a0c9a7c..3e067bb 100644
--- a/site/pom.xml
+++ b/site/pom.xml
@@ -3,7 +3,7 @@
<parent>
<groupId>org.apache.clerezza</groupId>
<artifactId>clerezza</artifactId>
- <version>0.5-SNAPSHOT</version>
+ <version>7-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<artifactId>website</artifactId>
@@ -22,32 +22,37 @@
<dependency>
<groupId>org.apache.clerezza</groupId>
<artifactId>platform.typerendering.core</artifactId>
- <version>0.3-SNAPSHOT</version>
+ <version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.clerezza</groupId>
<artifactId>platform.typerendering.scala</artifactId>
- <version>0.2-SNAPSHOT</version>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.clerezza</groupId>
+ <artifactId>platform.graphprovider.content</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.clerezza</groupId>
<artifactId>rdf.ontologies</artifactId>
- <version>0.12-SNAPSHOT</version>
+ <version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.clerezza</groupId>
<artifactId>rdf.utils</artifactId>
- <version>0.14-SNAPSHOT</version>
+ <version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.clerezza</groupId>
<artifactId>rdf.scala.utils</artifactId>
- <version>0.4-SNAPSHOT</version>
+ <version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.clerezza</groupId>
<artifactId>osgi.services</artifactId>
- <version>0.2-SNAPSHOT</version>
+ <version>0.2</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
http://git-wip-us.apache.org/repos/asf/clerezza/blob/dacd8c71/site/src/main/scala/Activator.scala
----------------------------------------------------------------------
diff --git a/site/src/main/scala/Activator.scala b/site/src/main/scala/Activator.scala
index 7b9224b..cc28730 100644
--- a/site/src/main/scala/Activator.scala
+++ b/site/src/main/scala/Activator.scala
@@ -3,11 +3,11 @@ package org.apache.clerezza.site
import org.osgi.framework.{BundleActivator, BundleContext, ServiceRegistration}
import scala.collection.JavaConversions.asJavaDictionary
import org.apache.clerezza.platform.typerendering.{TypeRenderlet, RenderletManager}
-import org.apache.clerezza.platform.graphprovider.content.ContentGraphProvider
+//import org.apache.clerezza.platform.graphprovider.content.ContentGraphProvider
import org.apache.clerezza.rdf.core.access.TcManager
import org.apache.clerezza.osgi.services.ServicesDsl
import org.apache.clerezza.platform.Constants
-import org.apache.clerezza.rdf.core.event.{GraphEvent, FilterTriple, GraphListener}
+//import org.apache.clerezza.rdf.core.event.{GraphEvent, FilterTriple, GraphListener}
import org.apache.clerezza.rdf.core.serializedform.{Serializer, SupportedFormat, Parser}
import java.io.{FileOutputStream, FileInputStream, File}
@@ -19,7 +19,7 @@ class Activator extends BundleActivator {
var renderletRegistration,
titledContentRenderletRegistration,
globalMenuRenderletRegistration: ServiceRegistration[TypeRenderlet] = null
- var graphListenerOption: Option[GraphListener] = null
+ //var graphListenerOption: Option[GraphListener] = null
/**
* called when the bundle is started, this method initializes the provided service
@@ -35,16 +35,16 @@ class Activator extends BundleActivator {
new TitledContentRenderlet, null)
globalMenuRenderletRegistration = context.registerService(classOf[TypeRenderlet],
new GlobalMenuRenderlet, null)
- context.installBundle("mvn:org.apache.clerezza/rdf.stable.serializer").start();
- context.installBundle("mvn:org.apache.clerezza/tools.offline").start();
+ //context.installBundle("mvn:org.apache.clerezza/rdf.stable.serializer").start();
+ //context.installBundle("mvn:org.apache.clerezza/tools.offline").start();
val path = {
val bl = context.getBundle.getLocation
bl.substring(bl.indexOf(':')+1)
}
- val graphFile = new File(new File(path), "graph.nt");
+ /*val graphFile = new File(new File(path), "graph.nt");
doWith {
(tcManager: TcManager, parser: Parser) => {
- val contentGraph = tcManager.getMGraph(Constants.CONTENT_GRAPH_URI)
+ val contentGraph = tcManager.getGraph(Constants.CONTENT_GRAPH_URI)
val fileGraph = parser.parse(new FileInputStream(graphFile), SupportedFormat.N_TRIPLE)
if (contentGraph.size > fileGraph.size) {
println("content graph if bigger than the graph from file, not replacing with the content from file and not " +
@@ -66,7 +66,7 @@ class Activator extends BundleActivator {
println("A GraphListener has been added that writes changes to the content graph to graph.nt")
}
}
- }
+ }*/
}
@@ -80,11 +80,11 @@ class Activator extends BundleActivator {
val servicesDsl = new ServicesDsl(context)
import servicesDsl._
val tcManager = $[TcManager]
- val contentGraph = tcManager.getMGraph(Constants.CONTENT_GRAPH_URI)
- graphListenerOption match {
+ val contentGraph = tcManager.getGraph(Constants.CONTENT_GRAPH_URI)
+ /*graphListenerOption match {
case Some(l) => contentGraph.removeGraphListener(l)
case None => ;
- }
+ }*/
println("bye")
}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/dacd8c71/site/src/main/scala/GlobalMenuRenderlet.scala
----------------------------------------------------------------------
diff --git a/site/src/main/scala/GlobalMenuRenderlet.scala b/site/src/main/scala/GlobalMenuRenderlet.scala
index 7f6e26b..2ac82f5 100644
--- a/site/src/main/scala/GlobalMenuRenderlet.scala
+++ b/site/src/main/scala/GlobalMenuRenderlet.scala
@@ -2,7 +2,7 @@ package org.apache.clerezza.site
import javax.ws.rs.core.MediaType
import org.apache.clerezza.platform.typerendering._
-import org.apache.clerezza.rdf.core.UriRef
+import org.apache.clerezza.commons.rdf.IRI
import org.apache.clerezza.rdf.utils.GraphNode
import org.apache.clerezza.rdf.ontologies._
import org.apache.clerezza.rdf.core._
@@ -23,53 +23,54 @@ class GlobalMenuRenderlet extends SRenderlet {
override def renderedPage(arguments: XmlResult.Arguments) = {
new XmlResult(arguments) {
def menuLink(href: String, label: String) =
- if ((res*).endsWith(href) || (res*).endsWith(href+"index")) {
- <a href={href} class="active">{label}</a>
- } else {
- <a href={href}>{label}</a>
- }
+ if ((res*).endsWith(href) || (res*).endsWith(href + "index")) {
+ <a href={ href } class="active">{ label }</a>
+ } else {
+ <a href={ href }>{ label }</a>
+ }
override def content = {
- def menu(s: Any) = new UriRef("http://clerezza.org/2009/11/global-menu#"+s)
-def rdfs(s: Any) = new UriRef("http://www.w3.org/2000/01/rdf-schema#"+s)
-def platform(s: Any) = new UriRef("http://clerezza.org/2009/08/platform#"+s)
-def dct(s: Any) = new UriRef("http://purl.org/dc/terms/"+s)
-
-resultDocModifier.addScriptReference("/style/scripts/login.js");
+ def menu(s: Any) = new IRI("http://clerezza.org/2009/11/global-menu#" + s)
+ def rdfs(s: Any) = new IRI("http://www.w3.org/2000/01/rdf-schema#" + s)
+ def platform(s: Any) = new IRI("http://clerezza.org/2009/08/platform#" + s)
+ def dct(s: Any) = new IRI("http://purl.org/dc/terms/" + s)
+ resultDocModifier.addScriptReference("/style/scripts/login.js");
-<div class="column nav">
- <ul>
-
-
- {for (menuItem <- res/menu("globalMenu")!!) yield
- <li class="top-nav-entry"><div class="title">
- {
- if ((menuItem/menu("path")).length > 0) {
- <a href={menuItem/menu("path")*}>{(menuItem/rdfs("label")*)}</a>
- } else {
- <a href="#" onclick="return false">{(menuItem/rdfs("label")*)}</a>
- }
- }
- </div>
- {
- ifx ((menuItem/menu("children")).length > 0) {
- <div>
- <ul class="nav-entries">
- {
- for (childMenuItem <- menuItem/menu("children")!!) yield {
- <li><a href={childMenuItem/menu("path")*}>{childMenuItem/rdfs("label")*}</a><span>{childMenuItem/dct("description")*}</span></li>
+ <div class="column nav">
+ <ul>
+ {
+ ifx((res / menu("globalMenu")).length > 0) {
+ for (menuItem <- res / menu("globalMenu")!!)
+ yield <li class="top-nav-entry">
+ <div class="title">
+ {
+ if ((menuItem / menu("path")).length > 0) {
+ <a href={ menuItem / menu("path")* }>{ (menuItem / rdfs("label")*) }</a>
+ } else {
+ <a href="#" onclick="return false">{ (menuItem / rdfs("label")*) }</a>
+ }
+ }
+ </div>
+ {
+ ifx((menuItem / menu("children")).length > 0) {
+ <div>
+ <ul class="nav-entries">
+ {
+ for (childMenuItem <- menuItem / menu("children")!!) yield {
+ <li><a href={ childMenuItem / menu("path")* }>{ childMenuItem / rdfs("label")* }</a><span>{ childMenuItem / dct("description")* }</span></li>
+ }
+ }
+ </ul>
+ </div>
+ }
+ }
+ </li>
}
- }
+ }
</ul>
</div>
- }
- }
- </li>
- }
- </ul>
-</div>
}
+
}
}
-
}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/dacd8c71/site/src/main/scala/HeadedPageRenderlet.scala
----------------------------------------------------------------------
diff --git a/site/src/main/scala/HeadedPageRenderlet.scala b/site/src/main/scala/HeadedPageRenderlet.scala
index 70f8275..6583c75 100644
--- a/site/src/main/scala/HeadedPageRenderlet.scala
+++ b/site/src/main/scala/HeadedPageRenderlet.scala
@@ -2,7 +2,7 @@ package org.apache.clerezza.site
import javax.ws.rs.core.MediaType
import org.apache.clerezza.platform.typerendering._
-import org.apache.clerezza.rdf.core.UriRef
+import org.apache.clerezza.commons.rdf.IRI
import org.apache.clerezza.rdf.utils.GraphNode
import org.apache.clerezza.rdf.ontologies._
import org.apache.clerezza.rdf.core._
@@ -67,7 +67,7 @@ resultDocModifier.addScriptReference("/scripts/status-message.js");
<div class="zz-control">
<div class="login">
{
- def platform(s: Any) = new UriRef("http://clerezza.org/2009/08/platform#"+s)
+ def platform(s: Any) = new IRI("http://clerezza.org/2009/08/platform#"+s)
val username = (context/platform("user")/platform("userName")*)
if((username).equals("anonymous")) {
<span>
http://git-wip-us.apache.org/repos/asf/clerezza/blob/dacd8c71/site/src/main/scala/Ontology.scala
----------------------------------------------------------------------
diff --git a/site/src/main/scala/Ontology.scala b/site/src/main/scala/Ontology.scala
index 9fba93e..3a2b94d 100644
--- a/site/src/main/scala/Ontology.scala
+++ b/site/src/main/scala/Ontology.scala
@@ -1,12 +1,12 @@
package skeleton
-import org.apache.clerezza.rdf.core.UriRef
+import org.apache.clerezza.commons.rdf.IRI
object Ontology {
/**
* The uri for the RDF type of HelloWordMessage
*/
- val HelloWordMessageType = new UriRef("http://example.org/skeleton#HelloWordMessage")
+ val HelloWordMessageType = new IRI("http://example.org/skeleton#HelloWordMessage")
}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/dacd8c71/site/src/main/scala/TitledContentRenderlet.scala
----------------------------------------------------------------------
diff --git a/site/src/main/scala/TitledContentRenderlet.scala b/site/src/main/scala/TitledContentRenderlet.scala
index 366d7d9..a223357 100644
--- a/site/src/main/scala/TitledContentRenderlet.scala
+++ b/site/src/main/scala/TitledContentRenderlet.scala
@@ -2,7 +2,7 @@ package org.apache.clerezza.site
import javax.ws.rs.core.MediaType
import org.apache.clerezza.platform.typerendering._
-import org.apache.clerezza.rdf.core.UriRef
+import org.apache.clerezza.commons.rdf.IRI
import org.apache.clerezza.rdf.utils.GraphNode
import org.apache.clerezza.rdf.ontologies._
import org.apache.clerezza.rdf.core._
http://git-wip-us.apache.org/repos/asf/clerezza/blob/dacd8c71/tools.offline/pom.xml
----------------------------------------------------------------------
diff --git a/tools.offline/pom.xml b/tools.offline/pom.xml
index 000af6d..f1022b5 100644
--- a/tools.offline/pom.xml
+++ b/tools.offline/pom.xml
@@ -24,7 +24,7 @@
<parent>
<groupId>org.apache.clerezza</groupId>
<artifactId>clerezza</artifactId>
- <version>0.5</version>
+ <version>7-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>
<groupId>org.apache.clerezza</groupId>
@@ -33,6 +33,14 @@
<version>1.0.0-SNAPSHOT</version>
<name>Clerezza - Tools Offline Site Generator</name>
<description>The core part of SCB Web Access</description>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
<dependencies>
<dependency>
<groupId>junit</groupId>
@@ -41,30 +49,18 @@
</dependency>
<dependency>
<groupId>org.apache.clerezza</groupId>
- <artifactId>platform.typerendering.core</artifactId>
- <version>0.3</version>
+ <artifactId>platform.graphprovider.content</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.clerezza</groupId>
- <artifactId>platform.typerendering.scalaserverpages</artifactId>
- <version>0.4</version>
+ <artifactId>platform.typerendering.core</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.clerezza</groupId>
<artifactId>rdf.core</artifactId>
- <version>0.14</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>rdf.jena.serializer</artifactId>
- <scope>test</scope>
- <version>0.11</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>rdf.jena.parser</artifactId>
- <scope>test</scope>
- <version>0.12</version>
+ <version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
@@ -72,33 +68,13 @@
</dependency>
<dependency>
<groupId>org.apache.clerezza</groupId>
- <artifactId>jaxrs.utils</artifactId>
- <version>0.9</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>rdf.ontologies</artifactId>
- <version>0.12</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>rdf.web.ontologies</artifactId>
- <version>0.4</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
<artifactId>web.fileserver</artifactId>
- <version>0.10</version>
+ <version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.clerezza</groupId>
<artifactId>utils</artifactId>
- <version>0.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.clerezza</groupId>
- <artifactId>platform.content.representations.core</artifactId>
- <version>0.2</version>
+ <version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/clerezza/blob/dacd8c71/tools.offline/src/main/java/org/apache/clerezza/tools/offline/Generator.java
----------------------------------------------------------------------
diff --git a/tools.offline/src/main/java/org/apache/clerezza/tools/offline/Generator.java b/tools.offline/src/main/java/org/apache/clerezza/tools/offline/Generator.java
index 4b43943..845ec8d 100644
--- a/tools.offline/src/main/java/org/apache/clerezza/tools/offline/Generator.java
+++ b/tools.offline/src/main/java/org/apache/clerezza/tools/offline/Generator.java
@@ -18,8 +18,7 @@
*/
package org.apache.clerezza.tools.offline;
-import java.util.logging.Level;
-import org.apache.clerezza.tools.offline.utils.ConditionalOutputStream;
+//import org.apache.clerezza.tools.offline.utils.ConditionalOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -44,14 +43,12 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;
import javax.ws.rs.core.Response.Status;
import org.apache.clerezza.platform.Constants;
-import org.apache.clerezza.platform.content.representations.core.ThumbnailService;
import org.apache.clerezza.platform.graphprovider.content.ContentGraphProvider;
import org.apache.clerezza.platform.typerendering.RendererFactory;
-import org.apache.clerezza.rdf.core.MGraph;
-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.commons.rdf.BlankNodeOrIRI;
+import org.apache.clerezza.commons.rdf.Triple;
+import org.apache.clerezza.commons.rdf.Graph;
+import org.apache.clerezza.commons.rdf.IRI;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
@@ -85,8 +82,8 @@ public class Generator {
@Reference
private RendererFactory rendererFactory;
- @Reference
- private ThumbnailService thumbnailService;
+ //@Reference
+ //private ThumbnailService thumbnailService;
private MediaTypeGuesser mediaTypeGuesser = MediaTypeGuesser.getInstance();
@@ -165,20 +162,20 @@ public class Generator {
private PathNode createFileHierarchy(String baseUri, String retrievalBaseUri, String targetUri,
String rootLinkPrefix, List<String> formatExtensions) throws IOException {
Hierarchy result = new Hierarchy("");
- MGraph contentGraph = cgp.getContentGraph();
- Set<UriRef> matchingUri = new HashSet<UriRef>();
+ Graph contentGraph = cgp.getContentGraph();
+ Set<IRI> matchingUri = new HashSet<IRI>();
for (Triple triple : contentGraph) {
- final NonLiteral subject = triple.getSubject();
- if ((subject instanceof UriRef) &&
- ((UriRef)subject).getUnicodeString().startsWith(baseUri)) {
- matchingUri.add((UriRef)subject);
+ final BlankNodeOrIRI subject = triple.getSubject();
+ if ((subject instanceof IRI) &&
+ ((IRI)subject).getUnicodeString().startsWith(baseUri)) {
+ matchingUri.add((IRI)subject);
}
}
- for (UriRef uriRef : matchingUri) {
- if (matchingUri.contains(new UriRef(uriRef.getUnicodeString()+"index"))) {
+ for (IRI uriRef : matchingUri) {
+ if (matchingUri.contains(new IRI(uriRef.getUnicodeString()+"index"))) {
continue;
}
- if (matchingUri.contains(new UriRef(uriRef.getUnicodeString()+"index.html"))) {
+ if (matchingUri.contains(new IRI(uriRef.getUnicodeString()+"index.html"))) {
continue;
}
generateFilesForResource(baseUri, retrievalBaseUri, targetUri,
@@ -193,29 +190,29 @@ public class Generator {
* handling of infodicscobits
*/
private void generateFilesForResource(String baseUri, String retrievalBaseUri,
- String targetBaseUri, String rootLinkPrefix, UriRef resourceUriRef, TripleCollection graph,
+ String targetBaseUri, String rootLinkPrefix, IRI resourceIRI, Graph graph,
List<String> formatExtensions, Hierarchy hierarchy) throws IOException {
- final String path = getPathForUriRef(resourceUriRef, baseUri);
- UriRef retreivalUriRef = new UriRef(retrievalBaseUri+path);
+ final String path = getPathForIRI(resourceIRI, baseUri);
+ IRI retreivalIRI = new IRI(retrievalBaseUri+path);
for (String formatExtension : formatExtensions) {
MediaType mediaType = mediaTypeGuesser.getTypeForExtension(formatExtension);
try {
- final byte[] variant = getVariant(retreivalUriRef, mediaType);
+ final byte[] variant = getVariant(retreivalIRI, mediaType);
if (mediaType.getSubtype().equals("png"))
logger.info("Got variant of length : {}",variant.length);
- final byte[] addedThumbnailUris = applyThumbnailService(variant);
- final byte[] dataPrefixApplied = applyRootLinkPrefix(addedThumbnailUris,
+ //final byte[] addedThumbnailUris = applyThumbnailService(variant);
+ final byte[] dataPrefixApplied = applyRootLinkPrefix(variant,
rootLinkPrefix, mediaType);
- final String filePath = resourceUriRef.getUnicodeString().endsWith("/") ? path+"index" : path;
+ final String filePath = resourceIRI.getUnicodeString().endsWith("/") ? path+"index" : path;
final String dottedExtension = "."+formatExtension;
final String extendedPath = filePath.endsWith(dottedExtension) ?
filePath : filePath + dottedExtension;
- if (mediaType.getSubtype().equals("png"))
- logger.info("Processed length : {}",dataPrefixApplied.length);
+ /*if (mediaType.getSubtype().equals("png"))
+ logger.info("Processed length : {}",dataPrefixApplied.length);*/
hierarchy.addChild(extendedPath,
changeBaseUri(dataPrefixApplied, baseUri, targetBaseUri));
} catch (VariantUnavailableException ex) {
- logger.debug("{} not available as {}", resourceUriRef, mediaType);
+ logger.debug("{} not available as {}", resourceIRI, mediaType);
}
}
}
@@ -237,7 +234,7 @@ public class Generator {
}
}
- private byte[] getVariant(UriRef uriRef, MediaType mediaType) throws
+ private byte[] getVariant(IRI uriRef, MediaType mediaType) throws
IOException, VariantUnavailableException {
logger.info("requested uri " + uriRef.getUnicodeString() + ",mediatype " + mediaType.toString());
try{
@@ -275,7 +272,7 @@ public class Generator {
}
}
- private String getPathForUriRef(UriRef uriRef, String baseUri) {
+ private String getPathForIRI(IRI uriRef, String baseUri) {
if (!uriRef.getUnicodeString().startsWith(baseUri)) {
throw new RuntimeException(uriRef+" doesn't start with "+baseUri);
}
@@ -316,7 +313,7 @@ public class Generator {
}
}
- private byte[] applyThumbnailService(byte[] variant) {
+ /*private byte[] applyThumbnailService(byte[] variant) {
try {
final ByteArrayOutputStream resultWriter = new ByteArrayOutputStream(variant.length);
OutputStream thumbnailCorrectingStream = new ConditionalOutputStream(resultWriter,
@@ -327,7 +324,7 @@ public class Generator {
} catch (IOException ex) {
throw new RuntimeException(ex);
}
- }
+ }*/
http://git-wip-us.apache.org/repos/asf/clerezza/blob/dacd8c71/tools.offline/src/main/java/org/apache/clerezza/tools/offline/ThumbnailCondition.java
----------------------------------------------------------------------
diff --git a/tools.offline/src/main/java/org/apache/clerezza/tools/offline/ThumbnailCondition.java b/tools.offline/src/main/java/org/apache/clerezza/tools/offline/ThumbnailCondition.java
deleted file mode 100644
index b628222..0000000
--- a/tools.offline/src/main/java/org/apache/clerezza/tools/offline/ThumbnailCondition.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Copyright 2010 mir.
- *
- * Licensed 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.
- * under the License.
- */
-package org.apache.clerezza.tools.offline;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import org.apache.clerezza.tools.offline.utils.StreamCondition;
-import org.apache.clerezza.platform.content.representations.core.ThumbnailService;
-import org.apache.clerezza.rdf.core.UriRef;
-
-/**
- *
- * @author mir
- */
-public class ThumbnailCondition implements StreamCondition {
-
- private final static byte[] SRC_BYTES = "src=\"".getBytes();
- private final static byte[] HREF_BYTES = "href=\"".getBytes();
- private final static byte QUOTE_BYTE = "\"".getBytes()[0];
- private final static byte[] THUMBNAIL_SERVICE_BYTES = "/thumbnail-service?".getBytes();
- private ThumbnailService thumbnailService;
- private boolean isScr = true;
- private boolean isHref = true;
- private boolean isSatisfied = false;
- private byte[] thumbnailBytes = null;
- private ByteArrayOutputStream cachedQueryParams = new ByteArrayOutputStream();
-
- private enum Phase {CHECK_TAG_ATTRIBUTE, CHECK_THUMBNAIL_SERVICE, LOOK_FOR_QUOTE};
- private Phase currentPhase = Phase.CHECK_TAG_ATTRIBUTE;
- private int arrayPosition = 0;
-
- public ThumbnailCondition(ThumbnailService thumbnailService) {
- this.thumbnailService = thumbnailService;
- }
-
- private void reset() {
- isScr = true;
- isHref = true;
- isSatisfied = false;
- arrayPosition = 0;
- cachedQueryParams.reset();
- thumbnailBytes = null;
- currentPhase = Phase.CHECK_TAG_ATTRIBUTE;
- }
-
- @Override
- public boolean feed(int b) {
- if (isSatisfied) {
- reset();
- }
- boolean result = false;
- if (currentPhase.equals(Phase.CHECK_TAG_ATTRIBUTE)) {
- result = checkTagAttribute(b);
- } else if (currentPhase.equals(Phase.CHECK_THUMBNAIL_SERVICE)) {
- result = checkThumbnailUri(b);
- } else if (currentPhase.equals(Phase.LOOK_FOR_QUOTE)) {
- result = lookForQuote(b);
- }
- return result;
- }
-
- private boolean checkTagAttribute(int b) {
- if (isScr) {
- if (SRC_BYTES[arrayPosition] != b) {
- isScr = false;
- } else if (SRC_BYTES.length == arrayPosition + 1) {
- currentPhase = Phase.CHECK_THUMBNAIL_SERVICE;
- arrayPosition = 0;
- return true;
- }
- }
- if (isHref) {
- if (HREF_BYTES[arrayPosition] != b) {
- isHref = false;
- } else if (HREF_BYTES.length == arrayPosition + 1) {
- currentPhase = Phase.CHECK_THUMBNAIL_SERVICE;
- arrayPosition = 0;
- return true;
- }
- }
- if (!isHref && !isScr) {
- reset();
- return false;
- }
- arrayPosition++;
- return true;
- }
-
- private boolean checkThumbnailUri(int b) {
- if (arrayPosition == 16) {
- }
- if (THUMBNAIL_SERVICE_BYTES[arrayPosition] != b) {
- reset();
- return false;
- } else if (THUMBNAIL_SERVICE_BYTES.length == arrayPosition + 1) {
- currentPhase = Phase.LOOK_FOR_QUOTE;
- }
- arrayPosition++;
- return true;
- }
-
- private boolean lookForQuote(int b) {
- if (b == QUOTE_BYTE) {
- prepareBytes();
- isSatisfied = true;
- return false;
- } else {
- cachedQueryParams.write(b);
- }
- return true;
- }
-
- private void prepareBytes() {
- ByteArrayOutputStream bous = new ByteArrayOutputStream();
- try {
- if (isHref) {
- bous.write(HREF_BYTES);
- } else {
- bous.write(SRC_BYTES);
- }
- bous.write(getThumbnailUri());
- bous.write(QUOTE_BYTE);
- thumbnailBytes = bous.toByteArray();
- } catch (IOException ex) {
- throw new RuntimeException(ex);
- }
- }
-
- private byte[] getThumbnailUri() {
- ThumbnailServiceParams params = parseThumbnailServiceParams();
- UriRef thumbnailUri = thumbnailService.getThumbnailUri(params.getUri(),
- params.getWidth(), params.getHeight(), params.getExact());
- return thumbnailUri.getUnicodeString().getBytes();
- }
-
- @Override
- public boolean isSatisfied() {
- return isSatisfied;
- }
-
- @Override
- public byte[] getBytes() {
- return thumbnailBytes;
- }
-
- private ThumbnailServiceParams parseThumbnailServiceParams() {
- Integer width = null, height = null;
- UriRef uri = null;
- boolean extact = false;
- String queryParams = cachedQueryParams.toString();
- queryParams = queryParams.replace("&", "&");
- String[] nameValues = queryParams.split("&");
- for (String nameValue : nameValues) {
- String[] nameValuePair = nameValue.split("=");
- if (nameValuePair.length == 2) {
- String name = nameValuePair[0];
- if (name.equals("uri")) {
- uri = new UriRef(nameValuePair[1]);
- } else if (name.equals("width")) {
- width = Integer.valueOf(nameValuePair[1]);
- } else if (name.equals("height")) {
- height = Integer.valueOf(nameValuePair[1]);
- } else if (name.equals("exact")) {
- extact = Boolean.valueOf(nameValuePair[1]);
- }
- }
- }
- return new ThumbnailServiceParams(width, height, uri, extact);
- }
-
- private class ThumbnailServiceParams {
- private Integer width, height;
- private UriRef uri;
- private boolean exact;
-
- public ThumbnailServiceParams(Integer width, Integer height, UriRef uri,
- boolean exact) {
- this.width = width;
- this.height = height;
- this.uri = uri;
- this.exact = exact;
- }
-
- public Integer getHeight() {
- return height;
- }
-
- public UriRef getUri() {
- return uri;
- }
-
- public Integer getWidth() {
- return width;
- }
-
- public boolean getExact() {
- return exact;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/dacd8c71/tools.offline/src/main/java/org/apache/clerezza/tools/offline/utils/ConditionalOutputStream.java
----------------------------------------------------------------------
diff --git a/tools.offline/src/main/java/org/apache/clerezza/tools/offline/utils/ConditionalOutputStream.java b/tools.offline/src/main/java/org/apache/clerezza/tools/offline/utils/ConditionalOutputStream.java
deleted file mode 100644
index f1f00be..0000000
--- a/tools.offline/src/main/java/org/apache/clerezza/tools/offline/utils/ConditionalOutputStream.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2010 mir.
- *
- * Licensed 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.
- * under the License.
- */
-
-package org.apache.clerezza.tools.offline.utils;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * The conditional output stream wraps an <code>OutputStream</code>. All bytes
- * written to the condition output stream are tested by the <code>StreamCondition</code>
- * given to the constructor of the conditional output stream. The stream condition
- * can modify the byte stream if it is satisfied.
- *
- * @author mir
- */
-public class ConditionalOutputStream extends OutputStream {
-
- private OutputStream out;
- private StreamCondition condition;
- private ByteArrayOutputStream cachedBytes = new ByteArrayOutputStream();
-
- public ConditionalOutputStream(OutputStream out, StreamCondition condition) {
- this.out = out;
- this.condition = condition;
- }
-
- @Override
- public void write(int b) throws IOException {
- if (condition.feed(b)) {
- cachedBytes.write(b);
- } else {
- if (condition.isSatisfied()) {
- out.write(condition.getBytes());
- cachedBytes.reset();
- } else {
- if (cachedBytes.size() > 0) {
- out.write(cachedBytes.toByteArray());
- cachedBytes.reset();
- }
- out.write(b);
- }
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/dacd8c71/tools.offline/src/main/java/org/apache/clerezza/tools/offline/utils/StreamCondition.java
----------------------------------------------------------------------
diff --git a/tools.offline/src/main/java/org/apache/clerezza/tools/offline/utils/StreamCondition.java b/tools.offline/src/main/java/org/apache/clerezza/tools/offline/utils/StreamCondition.java
deleted file mode 100644
index 50cd37e..0000000
--- a/tools.offline/src/main/java/org/apache/clerezza/tools/offline/utils/StreamCondition.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2010 mir.
- *
- * Licensed 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.
- * under the License.
- */
-
-package org.apache.clerezza.tools.offline.utils;
-
-/**
- *
- * @author mir
- */
-public interface StreamCondition {
-
- /**
- * This method is called by the ConditionalOutputStream. The conditional
- * output stream feeds the condition with bytes as long as the feed()-method
- * returns true. If false is returned, then the condition is either satified
- * or unsatisfied. This can be determined by calling isSatisfied() of this
- * condition.
- * After returning false, the condition can be fed again.
- *
- * @param b
- * @return
- */
- public boolean feed(int b);
-
- /**
- * Returns true if the condition is satisfied, false otherwise.
- * @return
- */
- public boolean isSatisfied();
-
- /**
- * The ConditionOutputStream will call this method if the condition is
- * satisfied. The returned bytes will be written into its underlying outputstream
- * instead of the bytes that were fed to the condition.
- * @return
- */
- public byte[] getBytes();
-}
http://git-wip-us.apache.org/repos/asf/clerezza/blob/dacd8c71/tools.offline/src/main/resources/org/apache/clerezza/rdf/web/core/sparql-endpoint.ssp
----------------------------------------------------------------------
diff --git a/tools.offline/src/main/resources/org/apache/clerezza/rdf/web/core/sparql-endpoint.ssp b/tools.offline/src/main/resources/org/apache/clerezza/rdf/web/core/sparql-endpoint.ssp
deleted file mode 100644
index 81c6776..0000000
--- a/tools.offline/src/main/resources/org/apache/clerezza/rdf/web/core/sparql-endpoint.ssp
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- *
- * 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.
- *
-*/
-
-def se(s: Any) = new UriRef("http://clerezza.org/2009/11/sparql-endpoint#"+s)
-<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en">
- <head>
- <title>SPARQL Endpoint</title>
- <script type="text/javascript">
- function toggle(checkbox){{
- var uri = document.getElementById('stylesheeturi');
- var urilable = document.getElementById('urilable');
- var server = document.getElementById('server');
- var serverlabel = document.getElementById('serverlabel');
- if (checkbox.checked){{
- uri.style.visibility = 'visible';
- urilable.style.visibility = 'visible';
- server.style.visibility = 'visible';
- serverlabel.style.visibility = 'visible';
- }} else {{
- uri.style.visibility = 'hidden';
- urilable.style.visibility = 'hidden';
- server.style.visibility = 'hidden';
- serverlabel.style.visibility = 'hidden';
- }}
- }}
- </script>
- </head>
- <body>
- <h1>SPARQL Endpoint</h1>
- <hr />
- <h4>SPARQL Query</h4>
- <form method="post" action="../sparql">
- <lable for="query">Type in your query:</lable>
- <br />
- <textarea cols="70" rows="10" name="query" />
- <br />
- <br />
- <label for="default-graph-uri">Select a graph URI:</label>
- <select name="default-graph-uri">
- {for (tc <- (res/se("tripleCollection"))) yield
- <option>{tc*}</option>
- }
- </select>
- <br />
- <lable for="apply-style-sheet">Add XSLT style sheet on the result: </lable>
- <input type="checkbox" name="apply-style-sheet" id="checkbox" onclick="toggle(this)" />
- <br />
- <label for="style-sheet-uri" id="urilable" style="visibility:hidden">URI of XSLT style sheet</label>
- <input type="text" name="style-sheet-uri" id="stylesheeturi" style="width:350px;visibility:hidden" value="http://www.w3.org/TR/rdf-sparql-XMLres/result-to-html.xsl" />
- <label id="serverlabel" style="visibility:hidden">Add stylesheet on server side</label>
- <input type="checkbox" name="server-side" id="server" checked="checked" style="visibility:hidden"/>
- <br />
- <br />
- <input type="submit" value="Submit Query" />
- </form>
- </body>
-</html>
http://git-wip-us.apache.org/repos/asf/clerezza/blob/dacd8c71/tools.offline/src/test/java/org/apache/clerezza/tools/offline/ThumbnailConditionTest.java
----------------------------------------------------------------------
diff --git a/tools.offline/src/test/java/org/apache/clerezza/tools/offline/ThumbnailConditionTest.java b/tools.offline/src/test/java/org/apache/clerezza/tools/offline/ThumbnailConditionTest.java
deleted file mode 100644
index eb7b594..0000000
--- a/tools.offline/src/test/java/org/apache/clerezza/tools/offline/ThumbnailConditionTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2010 mir.
- *
- * Licensed 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.
- * under the License.
- */
-
-package org.apache.clerezza.tools.offline;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import org.apache.clerezza.platform.content.representations.core.ThumbnailService;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.tools.offline.utils.ConditionalOutputStream;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- *
- * @author mir
- */
-public class ThumbnailConditionTest {
-
- private UriRef uri = new UriRef ("http://localhost:8080/html_export/digital-assets/2010/08/30/770a7f14-74a7-4036-8341-f9e50e944e06");
-
- private static final byte[] input = "<img href=\"/thumbnail-service?uri=http://localhost:8080/html_export/digital-assets/2010/08/30/770a7f14-74a7-4036-8341-f9e50e944e06&width=700&height=300&exact=true\" />".getBytes();
-
- @Test
- public void thumbnailConditionTest() throws IOException {
- ByteArrayOutputStream bous = new ByteArrayOutputStream();
- OutputStream out = new ConditionalOutputStream(bous,
- new ThumbnailCondition(new ThumbnailService() {
-
- @Override
- public UriRef getThumbnailUri(UriRef infoBitUri, Integer width, Integer height, boolean exact) {
- Assert.assertEquals(uri, infoBitUri);
- Assert.assertEquals(Integer.valueOf(700), width);
- Assert.assertEquals(Integer.valueOf(300), height);
- Assert.assertEquals(true, exact);
- return new UriRef("http://example.com/test");
- }
- }));
-
- out.write(input);
- Assert.assertEquals("<img href=\"http://example.com/test\" />", bous.toString());
- }
-}