Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,21 @@ RDFpad therefore supports quick and dirty vocabulary development, without the ha
A running demo is available at http://rdfpad.lodum.de/
This [blog post](http://lodum.de/rdfpad/) explains the idea behind RDFpad in a bit more detail

## Required Libraries
You'll need the libs that come with [Jena](http://jena.sourceforge.net/) (tested with version 2.6.4) and [Jetty](http://jetty.codehaus.org/jetty/) (tested with version 7.3.0). RDFpad is an embedded server, so there is no need for a servlet container (Tomcat or the like).
## Build

You can build RDFPad with maven by executing:

mvn clean compile assembly:single

Maven should resolve all dependencies automatically. Otherwise, you'll need the libs that come with [Jena](http://jena.sourceforge.net/) (tested with version 2.6.4) and [Jetty](http://jetty.codehaus.org/jetty/) (tested with version 7.3.0). RDFpad is an embedded server, so there is no need for a servlet container (Tomcat or the like).

##Running RDFpad

Assuming you have the required libs on your path, simply start the server via
If you have built RDFpad with maven, you can start RDFpad with

java de.lodum.rdfpad.RDFpadServer [port]
java -jar rdfpad-1.0-jar-with-dependencies.jar [port]

For example, `java de.lodum.rdfpad.RDFpadServer 8080` . Note that there are some caveats if you want to run RDFpad on port 80 on a Unix-based system.
Note that there are some caveats if you want to run RDFpad on port 80 on a Unix-based system.

## License

Expand Down
68 changes: 68 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<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>

<groupId>de.lodum</groupId>
<artifactId>rdfpad</artifactId>
<version>1.0</version>
<packaging>jar</packaging>

<name>rdfpad</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.hp.hpl.jena</groupId>
<artifactId>jena</artifactId>
<version>2.6.4</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>7.6.16.v20140903</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.7</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.7</version>
</dependency>



</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>de.lodum.rdfpad.RDFpadServer</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2011 Carsten Ke�ler, carsten.kessler@uni-muenster.de
// Copyright 2011 Carsten Ke�ler, carsten.kessler@uni-muenster.de
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -43,19 +43,17 @@ public class RDFpad extends AbstractHandler {
private HTMLModel html;

/**
* Entry point for the server, handles all incoming requests.
* Entry point for the server, handles all incoming requests.
*/
@Override
public void handle(String target, Request baseRequest,
HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {

// drop any requests that are looking for static files;
// they will be handled by the ResourceHandler in RDFpadServer:
if(request.getRequestURI().startsWith("/files"))
if (request.getRequestURI().startsWith("/files"))
return;



this.logger = LoggerFactory.getLogger(RDFpad.class);

// forward an input from the form to the permanent URL for the contents
Expand Down Expand Up @@ -95,7 +93,6 @@ public void handle(String target, Request baseRequest,

}


/**
* Forwards to a URI with a file extension that is comliant with the MIME
* type preferred by the client.
Expand Down Expand Up @@ -141,28 +138,29 @@ private void getRDF(Request baseRequest, HttpServletRequest request,
.substring(0, lastDot))));
response.setCharacterEncoding("UTF-8");
PrintWriter writer = response.getWriter();


// we try to build a Jena model and then serialize it:
// we try to build a Jena model and then serialize it:

Model model = ModelFactory.createDefaultModel();
try {
// BufferedReader in = new BufferedReader( new InputStreamReader(new URL(exportURL).openStream(),"UTF-8"));
//model.read(exportURL, "TTL");
model.read(exportURL,exportURL, "TTL");
// BufferedReader in = new BufferedReader( new InputStreamReader(new
// URL(exportURL).openStream(),"UTF-8"));
// model.read(exportURL, "TTL");
model.read(exportURL, exportURL, "TTL");
} catch (Exception e) {
html.showForm(true, e.getLocalizedMessage(), baseRequest, request,
response);
return;
}
//PrintWriter out = new PrintWriter(new OutputStreamWriter(respne.getOutputStream(), "UTF8"));
// PrintWriter out = new PrintWriter(new
// OutputStreamWriter(respne.getOutputStream(), "UTF8"));

if (requestURI.endsWith(".ttl")) {
response.setContentType("text/turtle; charset=UTF-8");
response.setStatus(HttpServletResponse.SC_OK);
baseRequest.setHandled(true);
model.write(writer, "TURTLE");
}else if (requestURI.endsWith(".rdf")) {
} else if (requestURI.endsWith(".rdf")) {
response.setContentType("application/rdf+xml; charset=UTF-8");
response.setStatus(HttpServletResponse.SC_OK);
baseRequest.setHandled(true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2011 Carsten Ke�ler, carsten.kessler@uni-muenster.de
// Copyright 2011 Carsten Ke�ler, carsten.kessler@uni-muenster.de
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -35,23 +35,22 @@ public static void main(String[] args) throws Exception {
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(new Integer(args[0]));


//connector.setPort(new Integer(args[0]));
server.addConnector(connector);

ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
resource_handler.setWelcomeFiles(new String[]{ "" });

resource_handler.setResourceBase(".");

HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { new RDFpad(), resource_handler });
server.setHandler(handlers);

server.start();
server.join();

// connector.setPort(new Integer(args[0]));
server.addConnector(connector);

ResourceHandler resource_handler = new ResourceHandler();
resource_handler.setDirectoriesListed(true);
resource_handler.setWelcomeFiles(new String[] { "" });

resource_handler.setResourceBase(".");

HandlerList handlers = new HandlerList();
handlers.setHandlers(new Handler[] { new RDFpad(), resource_handler });
server.setHandler(handlers);

server.start();
server.join();

}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2011 Carsten Ke�ler, carsten.kessler@uni-muenster.de
// Copyright 2011 Carsten Ke�ler, carsten.kessler@uni-muenster.de
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -45,10 +45,10 @@ public AcceptHeader(HttpServletRequest request) {
accepts = request.getHeaders("ACCEPT");

// seems like no header has been sent; we'll assume text/html
if (!accepts.hasMoreElements() || request.getHeader("accept")!=null) {
//check if its given
preferredMIMEType =request.getParameter("accept");
if(preferredMIMEType==null || preferredMIMEType==""){
if (!accepts.hasMoreElements() || request.getHeader("accept") != null) {
// check if its given
preferredMIMEType = request.getParameter("accept");
if (preferredMIMEType == null || preferredMIMEType == "") {
preferredMIMEType = "text/html";
}
} else {
Expand All @@ -73,7 +73,7 @@ public AcceptHeader(HttpServletRequest request) {
String thisPart = entryParts[j];
if (thisPart.startsWith("q=")) {
thisQ = new Double(thisPart.split("=")[1])
.doubleValue();
.doubleValue();
j = entryParts.length; // stop here
}
}
Expand All @@ -83,21 +83,19 @@ public AcceptHeader(HttpServletRequest request) {
if (thisQ == 0.0)
thisQ = 1.0;

// done disentangling stuff:
if(thisQ > largestQ){
// done disentangling stuff:
if (thisQ > largestQ) {
currentlyPreferred = thisType;
largestQ = thisQ;
}


}

}
this.preferredMIMEType = currentlyPreferred;

}


}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2011 Carsten Ke�ler, carsten.kessler@uni-muenster.de
// Copyright 2011 Carsten Ke�ler, carsten.kessler@uni-muenster.de
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -39,13 +39,14 @@
public class HTMLModel {

private static String FOOTER = "<hr /><p align=\"right\"><small><a href=\"http://ifgi.uni-muenster.de/~kessler/rdfpad/\">RDFpad is free and open source software</a>. Contact: <a property=\"dc:creator\" "
+ "href=\"http://ifgi.uni-muenster.de/~kessler/\">Carsten Ke�ler</small></p>\n"
+ "href=\"http://ifgi.uni-muenster.de/~kessler/\">Carsten Ke�ler</small></p>\n"
+ "</div>\n</div>\n</body>\n</html>";

/**
* Shows the input form for the etherpad URL.
*
* @param error if set to true, the msg will be shown in red.
* @param error
* if set to true, the msg will be shown in red.
* @param msg
* @param baseRequest
* @param response
Expand Down Expand Up @@ -97,7 +98,7 @@ public void showForm(boolean error, String msg, Request baseRequest,
* @return
*/
public String getRequestBaseURL(HttpServletRequest request) {
//request.setAttribute(arg0, arg1)
// request.setAttribute(arg0, arg1)
return ("http://" + request.getServerName() + ":" + request
.getServerPort());
}
Expand Down Expand Up @@ -190,8 +191,9 @@ public void getHTML(Request baseRequest, HttpServletRequest request,
+ padPath + ".n3\">N3</a> &ndash; "
+ "View in <a href=\"http://inspector.sindice.com/inspect?url="
+ exportURL + "\">Sindice Inspector</a>&ndash;"
+ " Query with <a href=\"http://query.lodum.de?queryFrom="+getRequestBaseURL(request) + padPath+".rdf\">SPARQLfly</a></p>"
); // TODO
+ " Query with <a href=\"http://query.lodum.de?queryFrom="
+ getRequestBaseURL(request) + padPath
+ ".rdf\">SPARQLfly</a></p>"); // TODO
writer.println(FOOTER);
}

Expand Down Expand Up @@ -236,18 +238,18 @@ public String getPadContentURL(URL padURL) throws IOException {

// construct the export URI; looks like
// http://ifgipedia.uni-muenster.de/ep/pad/export/foaf-carsten/latest?format=txt
//String exportURL = padURL.getProtocol() + "://" + padURL.getHost()
// + "/p/" + padname + "/export/txt";
String exportURL = padURL.getProtocol() + "://" + padURL.getHost()
+ "/ep/pad/export/" + padname + "/latest?format=txt";
URL url= new URL(exportURL);
// String exportURL = padURL.getProtocol() + "://" + padURL.getHost()
// + "/p/" + padname + "/export/txt";
String exportURL = padURL.getProtocol() + "://" + padURL.getHost()
+ "/ep/pad/export/" + padname + "/latest?format=txt";
URL url = new URL(exportURL);
URLConnection con = url.openConnection();

con.connect();
if(con.getContentLength()==-1){
// System.out.println("geht nicht");
exportURL = padURL.getProtocol() + "://" + padURL.getHost()
+ "/p/" + padname + "/export/txt";
if (con.getContentLength() == -1) {
// System.out.println("geht nicht");
exportURL = padURL.getProtocol() + "://" + padURL.getHost() + "/p/"
+ padname + "/export/txt";
}

return exportURL;
Expand Down
Loading