changeset 0:33d1589a61a7 default tip

initial
author dwinter
date Thu, 08 Dec 2011 09:18:00 +0100
parents
children
files .classpath .project .settings/.jsdtscope .settings/org.eclipse.jdt.core.prefs .settings/org.eclipse.wst.common.component .settings/org.eclipse.wst.common.project.facet.core.xml .settings/org.eclipse.wst.jsdt.ui.superType.container .settings/org.eclipse.wst.jsdt.ui.superType.name WebContent/META-INF/MANIFEST.MF WebContent/WEB-INF/web.xml libs/log4j-1.2.15.jar libs/openrdf-sesame-2.3.2-onejar.jar libs/org.json.jar libs/org.restlet.ext.jaas.jar libs/org.restlet.ext.json.jar libs/org.restlet.ext.servlet.jar libs/org.restlet.jar src/org/digitalhps/storage/triplestoreimplementation/annotations/RDFInstanceURL.java src/org/digitalhps/storage/triplestoreimplementation/annotations/RDFPredicate.java src/org/digitalhps/storage/triplestoreimplementation/annotations/RDFType.java src/org/digitalhps/storage/triplestoreimplementation/events/CreationEvent.java src/org/digitalhps/storage/triplestoreimplementation/events/Main.java src/org/digitalhps/storage/triplestoreimplementation/events/RelationEvent.java src/org/digitalhps/storage/triplestoreimplementation/exceptions/JSONToObjectTransformException.java src/org/digitalhps/storage/triplestoreimplementation/exceptions/JSONandClassMissmatchException.java src/org/digitalhps/storage/triplestoreimplementation/exceptions/ObjectToJSONTransformException.java src/org/digitalhps/storage/triplestoreimplementation/handler/events/CreationEvent.java src/org/digitalhps/storage/triplestoreimplementation/handler/events/RelationEvents.java src/org/digitalhps/storage/triplestoreimplementation/restlet/MyCallBackHandler.java src/org/digitalhps/storage/triplestoreimplementation/restlet/RestServer.java src/org/digitalhps/storage/triplestoreimplementation/tests/EventsTest.java src/org/digitalhps/storage/triplestoreimplementation/utils/JSONTools.java
diffstat 32 files changed, 1278 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.classpath	Thu Dec 08 09:18:00 2011 +0100
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v6.0">
+		<attributes>
+			<attribute name="owner.project.facets" value="jst.web"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
+	<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JRE 1.6"/>
+	<classpathentry kind="lib" path="libs/log4j-1.2.15.jar"/>
+	<classpathentry kind="lib" path="libs/org.json.jar"/>
+	<classpathentry kind="lib" path="libs/org.restlet.ext.json.jar"/>
+	<classpathentry kind="lib" path="libs/org.restlet.ext.servlet.jar"/>
+	<classpathentry kind="lib" path="libs/org.restlet.jar"/>
+	<classpathentry kind="lib" path="libs/org.restlet.ext.jaas.jar"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/org.digitalhps.storage.objects"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/TripleStoreManager"/>
+	<classpathentry kind="output" path="build/classes"/>
+</classpath>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.project	Thu Dec 08 09:18:00 2011 +0100
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.digitalhps.storage.triplestoreimplementation</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.wst.jsdt.core.javascriptValidator</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.wst.common.project.facet.core.builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.wst.validation.validationbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
+		<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
+		<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
+	</natures>
+</projectDescription>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.settings/.jsdtscope	Thu Dec 08 09:18:00 2011 +0100
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="WebContent"/>
+	<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
+		<attributes>
+			<attribute name="hide" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
+	<classpathentry kind="output" path=""/>
+</classpath>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.settings/org.eclipse.jdt.core.prefs	Thu Dec 08 09:18:00 2011 +0100
@@ -0,0 +1,12 @@
+#Mon Dec 05 19:22:10 CET 2011
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.settings/org.eclipse.wst.common.component	Thu Dec 08 09:18:00 2011 +0100
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-modules id="moduleCoreId" project-version="1.5.0">
+    <wb-module deploy-name="org.digitalhps.storage.triplestoreimplementation">
+        <wb-resource deploy-path="/" source-path="/WebContent"/>
+        <wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
+        <property name="java-output-path" value="/tomcat6/build/classes"/>
+        <property name="context-root" value="org.digitalhps.storage.triplestoreimplementation"/>
+    </wb-module>
+</project-modules>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.settings/org.eclipse.wst.common.project.facet.core.xml	Thu Dec 08 09:18:00 2011 +0100
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faceted-project>
+  <runtime name="Apache Tomcat v6.0"/>
+  <fixed facet="java"/>
+  <fixed facet="jst.web"/>
+  <fixed facet="wst.jsdt.web"/>
+  <installed facet="java" version="1.6"/>
+  <installed facet="jst.web" version="2.5"/>
+  <installed facet="wst.jsdt.web" version="1.0"/>
+</faceted-project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.settings/org.eclipse.wst.jsdt.ui.superType.container	Thu Dec 08 09:18:00 2011 +0100
@@ -0,0 +1,1 @@
+org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.settings/org.eclipse.wst.jsdt.ui.superType.name	Thu Dec 08 09:18:00 2011 +0100
@@ -0,0 +1,1 @@
+Window
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebContent/META-INF/MANIFEST.MF	Thu Dec 08 09:18:00 2011 +0100
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path: 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WebContent/WEB-INF/web.xml	Thu Dec 08 09:18:00 2011 +0100
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app id="WebApp_ID" version="2.4"
+xmlns="http://java.sun.com/xml/ns/j2ee"
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
+<display-name>RESTfulJavaWebServices-Restlet</display-name>
+<!-- Application classname --><context-param>
+<param-name>org.restlet.application</param-name>
+<param-value>org.digitalhps.storage.triplestoreimplementation.restlet.RestServer</param-value>
+</context-param>
+<!-- Paramas for Metdatamanager -->
+<!--  <context-param>
+<param-name>de.mpwig.itgroup.personSearch.index</param-name>
+<param-value>/Users/dwinter/Documents/Projekte/ECHO-eSciDoc-MPDL/escidocMPIWG/NamedIdentityManager/data/tripleIndex</param-value>
+</context-param>
+-->
+
+
+<context-param>
+<param-name>org.digitalhps.storage.triplestoreimplementation.jaas.configFilePath</param-name>
+<param-value>file:///etc/jaasAuth.conf</param-value>
+</context-param>
+
+<!-- Restletadapter -->
+<servlet>
+<servlet-name>RestletServlet</servlet-name>
+<servlet-class>
+org.restlet.ext.servlet.ServerServlet
+</servlet-class>
+</servlet>
+
+<!-- Catchallrequests -->
+<servlet-mapping>
+<servlet-name>RestletServlet</servlet-name>
+<url-pattern>/*</url-pattern>
+</servlet-mapping>
+</web-app>
\ No newline at end of file
Binary file libs/log4j-1.2.15.jar has changed
Binary file libs/openrdf-sesame-2.3.2-onejar.jar has changed
Binary file libs/org.json.jar has changed
Binary file libs/org.restlet.ext.jaas.jar has changed
Binary file libs/org.restlet.ext.json.jar has changed
Binary file libs/org.restlet.ext.servlet.jar has changed
Binary file libs/org.restlet.jar has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/digitalhps/storage/triplestoreimplementation/annotations/RDFInstanceURL.java	Thu Dec 08 09:18:00 2011 +0100
@@ -0,0 +1,9 @@
+package org.digitalhps.storage.triplestoreimplementation.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface RDFInstanceURL {
+	String value(); 
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/digitalhps/storage/triplestoreimplementation/annotations/RDFPredicate.java	Thu Dec 08 09:18:00 2011 +0100
@@ -0,0 +1,9 @@
+package org.digitalhps.storage.triplestoreimplementation.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface RDFPredicate {
+	String value(); 
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/digitalhps/storage/triplestoreimplementation/annotations/RDFType.java	Thu Dec 08 09:18:00 2011 +0100
@@ -0,0 +1,9 @@
+package org.digitalhps.storage.triplestoreimplementation.annotations;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+@Retention(RetentionPolicy.RUNTIME)
+public @interface RDFType {
+	String value(); 
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/digitalhps/storage/triplestoreimplementation/events/CreationEvent.java	Thu Dec 08 09:18:00 2011 +0100
@@ -0,0 +1,73 @@
+/**
+ * created on:06.12.2011
+ */
+package org.digitalhps.storage.triplestoreimplementation.events;
+
+import java.net.URI;
+import java.util.Date;
+
+import org.digitalhps.storage.objects.interfaces.elements.IActor;
+import org.digitalhps.storage.objects.interfaces.elements.ISourceReference;
+import org.digitalhps.storage.objects.interfaces.events.ICreationEvent;
+
+/**
+ * @author dwinter
+ *
+ */
+public class CreationEvent implements ICreationEvent {
+
+	/* (non-Javadoc)
+	 * @see org.digitalhps.storage.objects.interfaces.elements.IElement#getId()
+	 */
+	@Override
+	public URI getId() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.digitalhps.storage.objects.interfaces.events.ICreationEvent#getSourceReference()
+	 */
+	@Override
+	public ISourceReference getSourceReference() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.digitalhps.storage.objects.interfaces.events.ICreationEvent#getCreator()
+	 */
+	@Override
+	public IActor getCreator() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.digitalhps.storage.objects.interfaces.events.ICreationEvent#getCreationDate()
+	 */
+	@Override
+	public Date getCreationDate() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.digitalhps.storage.objects.interfaces.events.ICreationEvent#getCreationPlace()
+	 */
+	@Override
+	public String getCreationPlace() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.digitalhps.storage.objects.interfaces.events.ICreationEvent#getPredecessors()
+	 */
+	@Override
+	public ICreationEvent[] getPredecessors() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/digitalhps/storage/triplestoreimplementation/events/Main.java	Thu Dec 08 09:18:00 2011 +0100
@@ -0,0 +1,46 @@
+package org.digitalhps.storage.triplestoreimplementation.events;
+
+import org.apache.log4j.Logger;
+import org.restlet.data.Form;
+import org.restlet.representation.Representation;
+import org.restlet.representation.StringRepresentation;
+import org.restlet.resource.Get;
+import org.restlet.resource.Options;
+import org.restlet.resource.ServerResource;
+
+
+
+public class Main extends ServerResource {
+
+private Logger logger = Logger.getRootLogger();
+	
+	/**
+	 * Erlaubt cross scripting bei Aufruf aus Javascript
+	 * @param entity
+	 */
+	@Options
+	public void doOptions(Representation entity) {
+	    Form responseHeaders = (Form) getResponse().getAttributes().get("org.restlet.http.headers");
+	    if (responseHeaders == null) {
+	        responseHeaders = new Form();
+	        getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders);
+	    }
+	    responseHeaders.add("Access-Control-Allow-Origin", "*");
+	    responseHeaders.add("Access-Control-Allow-Methods", "POST,OPTIONS,GET");
+	    responseHeaders.add("Access-Control-Allow-Headers", "Content-Type");
+	    responseHeaders.add("Access-Control-Allow-Credentials", "false");
+	    responseHeaders.add("Access-Control-Max-Age", "60");
+	}
+
+
+	
+	@Get("html")
+	public Representation getHTML(){
+		
+		Representation rep = new StringRepresentation("test");
+		return rep;
+		
+	}
+	
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/digitalhps/storage/triplestoreimplementation/events/RelationEvent.java	Thu Dec 08 09:18:00 2011 +0100
@@ -0,0 +1,88 @@
+package org.digitalhps.storage.triplestoreimplementation.events;
+
+import java.net.URI;
+import java.util.Date;
+
+import org.digitalhps.storage.objects.interfaces.elements.IActor;
+import org.digitalhps.storage.objects.interfaces.elements.IRelation;
+import org.digitalhps.storage.objects.interfaces.elements.ISourceReference;
+import org.digitalhps.storage.objects.interfaces.events.ICreationEvent;
+import org.digitalhps.storage.objects.interfaces.events.IRelationEvent;
+import org.digitalhps.storage.triplestoreimplementation.annotations.RDFPredicate;
+import org.digitalhps.storage.triplestoreimplementation.annotations.RDFType;
+import org.digitalhps.storage.triplestoreimplementation.annotations.RDFInstanceURL;
+
+@RDFType("test://relationEvent")
+@RDFInstanceURL("test://relationEvent/")
+public class RelationEvent implements IRelationEvent {
+
+	@RDFPredicate("test://has_source")
+	public String sourceReference;
+	
+	@RDFPredicate("test://has_creator")
+	public String creator;
+	
+	@RDFPredicate("test://has_creationDate")
+	public String creationDate;
+	
+	@RDFPredicate("test://has_creationPlace")
+	public String creationPlace;
+	
+	@RDFPredicate("test://has_creationPredecessors")
+	public RelationEvent[] predecessors;
+	
+	@RDFPredicate("test://has_id") // FIXME das sollte eigentlich die uri der ressource im triplestore sein, daher kein predicate
+	public String id;
+	
+	@RDFPredicate("test://has_relation")
+	public String relation;
+	
+	@Override
+	public ISourceReference getSourceReference() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public IActor getCreator() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Date getCreationDate() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public String getCreationPlace() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public ICreationEvent[] getPredecessors() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public URI getId() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public IRelation getRelation() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public IActor getRelationCreator() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/digitalhps/storage/triplestoreimplementation/exceptions/JSONToObjectTransformException.java	Thu Dec 08 09:18:00 2011 +0100
@@ -0,0 +1,10 @@
+package org.digitalhps.storage.triplestoreimplementation.exceptions;
+
+public class JSONToObjectTransformException extends Exception {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 8370631682450250333L;
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/digitalhps/storage/triplestoreimplementation/exceptions/JSONandClassMissmatchException.java	Thu Dec 08 09:18:00 2011 +0100
@@ -0,0 +1,5 @@
+package org.digitalhps.storage.triplestoreimplementation.exceptions;
+
+public class JSONandClassMissmatchException extends Exception {
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/digitalhps/storage/triplestoreimplementation/exceptions/ObjectToJSONTransformException.java	Thu Dec 08 09:18:00 2011 +0100
@@ -0,0 +1,10 @@
+package org.digitalhps.storage.triplestoreimplementation.exceptions;
+
+public class ObjectToJSONTransformException extends Exception {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 564885965525175495L;
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/digitalhps/storage/triplestoreimplementation/handler/events/CreationEvent.java	Thu Dec 08 09:18:00 2011 +0100
@@ -0,0 +1,50 @@
+package org.digitalhps.storage.triplestoreimplementation.handler.events;
+
+import java.net.URI;
+import java.util.Date;
+
+import org.digitalhps.storage.objects.interfaces.elements.IActor;
+import org.digitalhps.storage.objects.interfaces.elements.ISourceReference;
+import org.digitalhps.storage.objects.interfaces.events.ICreationEvent;
+
+public class CreationEvent implements ICreationEvent {
+
+	public CreationEvent(){};
+	
+	@Override
+	public URI getId() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public ISourceReference getSourceReference() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public IActor getCreator() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Date getCreationDate() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public String getCreationPlace() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public ICreationEvent[] getPredecessors() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/digitalhps/storage/triplestoreimplementation/handler/events/RelationEvents.java	Thu Dec 08 09:18:00 2011 +0100
@@ -0,0 +1,251 @@
+/**
+ * Manage Relationsevents in the Triplestore
+ * @see {org.digitalhps.storage.objects.interfaces.events.IRelationEvent}
+ * 
+ * @author dwinter
+ *
+ */
+
+package org.digitalhps.storage.triplestoreimplementation.handler.events;
+
+import java.io.IOException;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Array;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.Calendar;
+
+import org.apache.log4j.Logger;
+import org.digitalhps.storage.triplestoreimplementation.annotations.RDFPredicate;
+import org.digitalhps.storage.triplestoreimplementation.annotations.RDFInstanceURL;
+import org.digitalhps.storage.triplestoreimplementation.annotations.RDFType;
+
+import org.digitalhps.storage.triplestoreimplementation.events.RelationEvent;
+import org.digitalhps.storage.triplestoreimplementation.exceptions.JSONToObjectTransformException;
+import org.digitalhps.storage.triplestoreimplementation.exceptions.JSONandClassMissmatchException;
+import org.digitalhps.storage.triplestoreimplementation.exceptions.ObjectToJSONTransformException;
+import org.digitalhps.storage.triplestoreimplementation.utils.JSONTools;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.openrdf.repository.RepositoryException;
+import org.restlet.data.Form;
+import org.restlet.data.MediaType;
+import org.restlet.data.Status;
+import org.restlet.ext.json.JsonRepresentation;
+import org.restlet.representation.Representation;
+import org.restlet.representation.StringRepresentation;
+import org.restlet.resource.Get;
+import org.restlet.resource.Options;
+import org.restlet.resource.Post;
+import org.restlet.resource.ServerResource;
+
+
+import de.mpiwg.itgroup.triplestoremanager.exceptions.TripleStoreHandlerException;
+import de.mpiwg.itgroup.triplestoremanager.owl.TripleStoreHandler;
+import de.mpiwg.itgroup.triplestoremanager.owl.TripleStoreHandler.Quadruple;
+
+
+public class RelationEvents extends ServerResource {
+
+	public static String RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+	private Logger logger = Logger.getRootLogger();
+
+	/**
+	 * Erlaubt cross scripting bei Aufruf aus Javascript
+	 * @param entity
+	 */
+	@Options
+	public void doOptions(Representation entity) {
+		Form responseHeaders = (Form) getResponse().getAttributes().get("org.restlet.http.headers");
+		if (responseHeaders == null) {
+			responseHeaders = new Form();
+			getResponse().getAttributes().put("org.restlet.http.headers", responseHeaders);
+		}
+		responseHeaders.add("Access-Control-Allow-Origin", "*");
+		responseHeaders.add("Access-Control-Allow-Methods", "POST,OPTIONS,GET");
+		responseHeaders.add("Access-Control-Allow-Headers", "Content-Type");
+		responseHeaders.add("Access-Control-Allow-Credentials", "false");
+		responseHeaders.add("Access-Control-Max-Age", "60");
+	}
+
+
+	@Get("html")
+	public Representation getHTML(){
+		setStatus(Status.SERVER_ERROR_NOT_IMPLEMENTED);
+		Representation rep = new StringRepresentation("not implemented yet");
+		return rep;
+
+	}
+
+	@Post
+	public Representation doPost(Representation entity) {
+
+		if (entity.getMediaType().equals(MediaType.APPLICATION_JSON)){
+			return handleJSON(entity);
+		}
+		setStatus(Status.CLIENT_ERROR_UNSUPPORTED_MEDIA_TYPE);
+		return null;
+
+	}
+
+
+	public Representation handleJSON(Representation entity) {
+		JsonRepresentation retRep;
+		try {
+			retRep = new JsonRepresentation(entity);
+		} catch (IOException e) {
+			setStatus(Status.SERVER_ERROR_INTERNAL);
+			e.printStackTrace();
+			return null;
+		}
+
+
+		//RelationEvent re = new RelationEvent();
+		JSONObject jo;
+
+
+		try {
+			jo = retRep.getJsonObject();
+		} catch (JSONException e) {
+			setStatus(Status.SERVER_ERROR_INTERNAL);
+			e.printStackTrace();
+			return null;
+		}
+		RelationEvent re;
+		try {
+			re = (RelationEvent) JSONTools.createObject(RelationEvent.class, jo);
+		} catch (JSONToObjectTransformException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			setStatus(Status.SERVER_ERROR_INTERNAL);
+			return null;
+		} catch (JSONandClassMissmatchException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			setStatus(Status.SERVER_ERROR_INTERNAL);
+			return null;
+		}
+
+
+
+		try {
+			writeEventToTripleStore(re, true);
+		} catch (TripleStoreHandlerException e1) {
+			// TODO Auto-generated catch block
+			e1.printStackTrace();
+		} catch (ObjectToJSONTransformException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (RepositoryException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+
+		JSONObject retObject;
+		try {
+			retObject = (JSONObject) JSONTools.transformToJson(re);
+		} catch (ObjectToJSONTransformException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			setStatus(Status.SERVER_ERROR_INTERNAL);
+			return null;
+		}
+		return new JsonRepresentation(retObject);
+	}
+
+
+
+	public String writeEventToTripleStore(Object re, boolean forceCreation) throws TripleStoreHandlerException, ObjectToJSONTransformException, RepositoryException {
+
+		//FIXME implement force creation = false, dann sollte nur geprueft werden, ob es im Triplestore schone ein Object
+		//mit der id die im Object abgespeichert ist gibt.
+		// schon im triplestore 
+		
+		//TripleStoreHandler th = new TripleStoreHandler("XX", "YY", "ZZ");
+
+		if (re==null)
+			return null;
+		ArrayList<TripleStoreHandler.Quadruple> quadruples = new ArrayList<TripleStoreHandler.Quadruple>();
+
+		String instanceUrlBase=re.getClass().getAnnotation(RDFInstanceURL.class).value();
+		String type=re.getClass().getAnnotation(RDFType.class).value();
+
+
+		String instanceUrl=createRessourceURL(instanceUrlBase, "annots");
+
+		quadruples.add(new TripleStoreHandler.Quadruple(instanceUrl, RDF+"type", type, "file://xx"));
+
+		Class<?>cls = re.getClass();
+
+		Field[] fs=cls.getFields();
+
+		for(int i=0;i<fs.length;i++){
+
+			Field field=fs[i];
+
+			String predicate = field.getAnnotation(RDFPredicate.class).value();
+
+			Class<?> T = field.getType();
+			String fieldName=field.getName();
+			Object fieldValue;
+			try {
+				fieldValue = field.get(re);
+			} catch (IllegalArgumentException e) {
+				throw new ObjectToJSONTransformException();
+			} catch (IllegalAccessException e) {
+				throw new ObjectToJSONTransformException();
+			}
+			
+			if (fieldValue==null)
+				continue;
+
+			//van only be string, an object or an array.
+			if (String.class.isInstance(fieldValue)){	
+				quadruples.add(new TripleStoreHandler.LiteralQuadruple(instanceUrl, predicate, (String)fieldValue, "file://xx"));
+			} else if (!T.isArray()){
+				addToQuadruples(quadruples,instanceUrl,predicate,fieldValue);
+			} else {
+				for (int j=0;j<Array.getLength(fieldValue);j++){
+
+					Object arrayElement = Array.get(fieldValue, j);
+					addToQuadruples(quadruples,instanceUrl,predicate,arrayElement);
+				}
+
+			}
+		}
+		//th.write(quadruples);
+		return instanceUrl;
+	}
+
+
+	private void addToQuadruples(ArrayList<Quadruple> quadruples,
+			String instanceUrl, String predicate, Object fieldValue) throws TripleStoreHandlerException, ObjectToJSONTransformException, RepositoryException {
+		
+		//erzeuge oder hole url
+		String subInstanceUrl = writeEventToTripleStore(fieldValue,false);
+		quadruples.add(new TripleStoreHandler.Quadruple(instanceUrl, predicate, subInstanceUrl, "file://xx"));
+		
+	
+
+	}
+
+
+	/**
+	 * Erzeuge eine urn aus der aktullen Zeit in millis
+	 * @return
+	 */
+	private String createRessourceURL(String urlBase,String prefix) {
+
+
+
+
+		Calendar cal = Calendar.getInstance();
+
+		long time = cal.getTimeInMillis();
+
+		return String.format("%s%s%s", urlBase,prefix,time);
+
+
+
+	}
+}	
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/digitalhps/storage/triplestoreimplementation/restlet/MyCallBackHandler.java	Thu Dec 08 09:18:00 2011 +0100
@@ -0,0 +1,48 @@
+package org.digitalhps.storage.triplestoreimplementation.restlet;
+
+import java.io.IOException;
+
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.ConfirmationCallback;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.TextOutputCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+public class MyCallBackHandler implements CallbackHandler {
+
+	
+	private String username;
+	private String password;
+
+	public MyCallBackHandler(String username, String password) {
+		this.username=username;
+		this.password=password;
+	}
+
+	@Override
+	public void handle(Callback[] callbacks) throws IOException,
+			UnsupportedCallbackException {
+		 	for (int i = 0; i < callbacks.length; i++) {
+		 		if (callbacks[i] instanceof TextOutputCallback) {
+			      
+	 			//	do nothing			      
+			    } else if (callbacks[i] instanceof NameCallback) {
+			  
+			      NameCallback nc = (NameCallback)callbacks[i];
+			      nc.setName(username);
+			 
+			    } else if (callbacks[i] instanceof PasswordCallback) {
+			  
+		    	   	PasswordCallback nc = (PasswordCallback)callbacks[i];
+					nc.setPassword(password.toCharArray());
+			    } else {
+			        throw new UnsupportedCallbackException
+			         (callbacks[i], "Unrecognized Callback");
+			    }
+			  }
+		
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/digitalhps/storage/triplestoreimplementation/restlet/RestServer.java	Thu Dec 08 09:18:00 2011 +0100
@@ -0,0 +1,172 @@
+package org.digitalhps.storage.triplestoreimplementation.restlet;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.security.auth.Subject;
+import javax.security.auth.login.Configuration;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+
+import org.apache.log4j.BasicConfigurator;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.digitalhps.storage.triplestoreimplementation.events.Main;
+import org.restlet.Application;
+import org.restlet.Context;
+import org.restlet.Request;
+import org.restlet.Response;
+import org.restlet.Restlet;
+import org.restlet.data.ChallengeScheme;
+import org.restlet.data.ClientInfo;
+import org.restlet.ext.jaas.JaasVerifier;
+import org.restlet.routing.Router;
+import org.restlet.security.ChallengeAuthenticator;
+import org.restlet.security.User;
+
+import com.sun.security.auth.login.ConfigFile;
+
+public class RestServer extends Application {
+
+	private ChallengeAuthenticator authenticator;
+
+
+	public RestServer(Context parentContext){
+		super(parentContext);
+		
+		Logger rl = Logger.getRootLogger();
+		BasicConfigurator.configure();
+		rl.setLevel(Level.DEBUG);
+	}
+	
+	
+	  /** Erzeuge einen Authenticator
+     * @return
+     */
+    private ChallengeAuthenticator createAuthenticator() {
+        Context context = getContext();
+        boolean optional = true;
+        ChallengeScheme challengeScheme = ChallengeScheme.HTTP_BASIC;
+        String realm = "Annotation Service";
+
+        JaasVerifier verifier = new JaasVerifier("BasicJaasAuthenticationApplication");
+        
+        
+        Configuration jaasConfig;
+        jaasConfig = createConfiguration();
+        
+        
+		verifier.setConfiguration(jaasConfig);
+        verifier.setUserPrincipalClassName("com.sun.security.auth.UserPrincipal");
+        
+        ChallengeAuthenticator auth = new ChallengeAuthenticator(context, optional, challengeScheme, realm, verifier) {
+            @Override
+            protected boolean authenticate(Request request, Response response) {
+                if (request.getChallengeResponse() == null) {
+                    return false;
+                } else {
+                    return super.authenticate(request, response);
+                }
+            }
+        };
+
+        return auth;
+    }
+
+	/**
+	 * Konfiguration fŸr den Authentificator in Jaas. Pfad zum JAAS-Konfigurationsfile liegt im Context-Parameter 
+	 * "de.mpiwg.itgroup.annotationManager.jaas.configFilePath".
+	 * @return
+	 */
+	protected Configuration createConfiguration() {
+		Configuration jaasConfig;
+		URI confUri;
+	
+		Context context = getContext();
+		String configFilePath = context.getParameters().getFirstValue("org.digitalhps.storage.triplestoreimplementation.jaas.configFilePath");
+		
+		
+		try {
+			confUri = new URI(configFilePath);
+		} catch (URISyntaxException e) {
+			e.printStackTrace();
+			confUri = null;
+		}
+		
+		jaasConfig= new ConfigFile(confUri);
+		return jaasConfig;
+	}
+	
+	
+	 /**
+	  * Authentifiziere den Benutzer aus dem Request (BasicAuthenfication)
+	 * @param request
+	 * @param response
+	 * @return
+	 */
+	public boolean authenticate(Request request, Response response) {
+	        if (!request.getClientInfo().isAuthenticated()) {
+	            authenticator.challenge(response, false);
+	            return false;
+	        }
+	 
+	        if(request.getClientInfo().getUser()==null) //FIXME sometimes ist authenticated true, but no user
+	        {
+	        	authenticator.challenge(response, false);
+	            return false;
+	        }
+	        
+	        
+	        return true;
+	    }
+
+	/**
+	 * Authentifiziere den Benutzer 
+	 * 
+	 * @param username
+	 * @param password
+	 * @param request
+	 * @return
+	 */
+	public boolean authenticate(String username, String password,Request request) {
+		LoginContext lc;
+		
+		try {
+			Configuration conf = createConfiguration();
+			
+			lc = new LoginContext("BasicJaasAuthenticationApplication", null, new MyCallBackHandler(username,password),conf);
+			lc.login();
+		} catch (LoginException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			return false;
+		}
+		
+		Subject subject = lc.getSubject();
+		ClientInfo clientInfo = new ClientInfo();
+		User user = new User(username);
+		clientInfo.setAuthenticated(true);
+		clientInfo.setUser(user);
+		
+		request.setClientInfo(clientInfo);
+		return true;
+	}
+	
+    
+	public synchronized Restlet createInboundRoot(){
+		
+		this.authenticator = createAuthenticator();
+
+		Router router = new Router(getContext());
+		
+		router.attach("/",Main.class);
+		
+		
+		authenticator.setNext(router);
+	    return authenticator;
+
+		
+		
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/digitalhps/storage/triplestoreimplementation/tests/EventsTest.java	Thu Dec 08 09:18:00 2011 +0100
@@ -0,0 +1,84 @@
+package org.digitalhps.storage.triplestoreimplementation.tests;
+
+
+import org.digitalhps.storage.triplestoreimplementation.events.CreationEvent;
+import org.digitalhps.storage.triplestoreimplementation.events.RelationEvent;
+import org.digitalhps.storage.triplestoreimplementation.exceptions.JSONToObjectTransformException;
+import org.digitalhps.storage.triplestoreimplementation.exceptions.JSONandClassMissmatchException;
+import org.digitalhps.storage.triplestoreimplementation.exceptions.ObjectToJSONTransformException;
+import org.digitalhps.storage.triplestoreimplementation.handler.events.RelationEvents;
+import org.digitalhps.storage.triplestoreimplementation.utils.JSONTools;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.openrdf.repository.RepositoryException;
+import org.restlet.ext.json.JsonRepresentation;
+import org.restlet.representation.Representation;
+
+import de.mpiwg.itgroup.triplestoremanager.exceptions.TripleStoreHandlerException;
+
+
+public class EventsTest {
+
+	/**
+	 * @param args
+	 */
+	public static void main(String[] args) {
+		RelationEvents relEv = new RelationEvents();
+		
+		CreationEvent ce = new CreationEvent();
+		System.out.println(ce.getId());
+		String source = "{\"sourceReference\":\"sr\"," +
+				" \"predecessors\":[{\"id\":\"1\"},{\"id\":\"1\"}] "+
+				"}"; 
+		
+		System.out.println(source);
+		JSONObject map;
+		try {
+			map = new JSONObject(source);
+		} catch (JSONException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			return;
+		}
+		
+		Object ob;
+		try {
+			ob = JSONTools.createObject(RelationEvent.class, map);
+		} catch (JSONandClassMissmatchException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			return;
+		} catch (JSONToObjectTransformException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			return;
+		}
+		Object ret;
+		try {
+			ret = JSONTools.transformToJson(ob);
+		} catch (ObjectToJSONTransformException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			return;
+		}
+		
+		System.out.println(ret);
+		Representation example = new JsonRepresentation(map);
+		relEv.handleJSON(example);
+		System.out.println(relEv);
+		
+		try {
+			relEv.writeEventToTripleStore(ob, false);
+		} catch (RepositoryException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (TripleStoreHandlerException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		} catch (ObjectToJSONTransformException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/digitalhps/storage/triplestoreimplementation/utils/JSONTools.java	Thu Dec 08 09:18:00 2011 +0100
@@ -0,0 +1,272 @@
+package org.digitalhps.storage.triplestoreimplementation.utils;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Field;
+import java.util.Iterator;
+
+import org.digitalhps.storage.triplestoreimplementation.exceptions.JSONToObjectTransformException;
+import org.digitalhps.storage.triplestoreimplementation.exceptions.JSONandClassMissmatchException;
+import org.digitalhps.storage.triplestoreimplementation.exceptions.ObjectToJSONTransformException;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.restlet.data.Status;
+
+/**
+ * Tools zum Umwandlen von Java-Objekten in JSON und umgekehrt
+ * 
+ * @author dwinter
+ *
+ */
+public class JSONTools {
+
+	/**
+	 * @param inputObject Nimmt ein Java object und Ÿbersetzen des Felder des Objectes in JSON, dazu mŸssen die Felder "public" sein.
+	 * @return JSONArray oder JSONObject je nach Type des inputObjectes (Arrays werden in Arrays Ÿbersetzt), Null wird in ein leeres JSONObject Ÿbersetzt.
+	 * @throws ObjectToJSONTransformException
+	 */
+	static public Object transformToJson(Object inputObject) throws ObjectToJSONTransformException {
+		
+		if (inputObject==null) // special case, generate empty object.
+			return new JSONObject();
+			
+		Object ret=null;
+		Class<?>cls = inputObject.getClass();
+		
+		
+		if (!cls.isArray()){ // kein Array
+				
+			JSONObject retObject = new JSONObject();
+			Field[] fs=cls.getFields();
+
+			for(int i=0;i<fs.length;i++){
+			
+			Field field=fs[i];
+				
+			Class<?> T = field.getType();
+			String fieldName=field.getName();
+			
+			
+			Object fieldValue;
+			try {
+				fieldValue = field.get(inputObject);
+			} catch (IllegalArgumentException e) {
+				throw new ObjectToJSONTransformException();
+			} catch (IllegalAccessException e) {
+				throw new ObjectToJSONTransformException();
+			}
+			
+	         
+			//van only be string, an object or an array.
+			if (String.class.isInstance(fieldValue)){	
+				try {
+					retObject.put(fieldName, (String)fieldValue);
+				} catch (JSONException e) {
+					throw new ObjectToJSONTransformException();
+				}
+					
+				} else if (!T.isArray()) { //field is not an array}
+					JSONObject jsonsubObject = (JSONObject) transformToJson(fieldValue);
+						
+					try {
+						retObject.put(fieldName, jsonsubObject);
+					} catch (JSONException e) {
+						// TODO Auto-generated catch block
+						e.printStackTrace();
+					}
+					
+				} else if  (T.isArray()){ // Feldwert ist ein Array 
+					JSONArray ja = new JSONArray();
+					if (fieldValue!=null){
+					
+					for (int j=0;j<Array.getLength(fieldValue);j++){
+						
+						Object arrayElement = Array.get(fieldValue, j);
+						
+						
+						ja.put(transformToJson(arrayElement));
+					}
+	         
+					try {
+						retObject.put(fieldName, ja);
+					} catch (JSONException e) {
+						// TODO Auto-generated catch block
+						e.printStackTrace();
+					}
+	       
+				}
+				}
+			}
+			ret = retObject;
+			
+		} else if(cls.isArray()){// Object ist ein Array
+			JSONArray retObject = new JSONArray();
+			
+			for (int j=0;j<Array.getLength(inputObject);j++){
+				
+				Object arrayElement = Array.get(inputObject, j);
+				
+				retObject.put(transformToJson(arrayElement));
+			}
+			ret=retObject;
+		}
+			return ret;
+		}
+
+
+	/**
+	 * Erzeugt ein JAVA Object aus einem JSON Object
+	 * @param cls Klasses die Erzeugt werden soll, falls das jsonObject vom Typ JSONArray sein, muss cls ein Arraytyp sein.
+	 * @param jsonObject Object das umgewandelt werden soll.
+	 * @return
+	 * @throws JSONandClassMissmatchException jsonObject ist ein Array und cls keins oder umgekehert.
+	 * @throws JSONToObjectTransformException Fehler bei Transformierten, i.a. tritt das aus falls die Felder in der Javaclass nicht schreibbar sind. Fehlende Felder werden ignoriert.
+	 */
+	static public Object createObject(Class<?> cls, Object jsonObject) throws JSONandClassMissmatchException, JSONToObjectTransformException {
+		
+		Object newObject;
+		
+		try {
+			newObject = cls.newInstance();
+		} catch (InstantiationException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			return null;
+		} catch (IllegalAccessException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			return null;
+		}
+		
+	if (JSONObject.class.isInstance(jsonObject)){
+		
+		if (cls.isArray()){
+			throw new JSONandClassMissmatchException();
+		}
+		
+		JSONObject jo = (JSONObject)jsonObject;
+		
+		
+		Iterator keys = jo.keys();
+		while (keys.hasNext()){
+			String key=(String) keys.next();
+			
+			
+			
+			Field f;
+			try {
+				f = cls.getField(key);
+			} catch (SecurityException e) {
+				throw new JSONToObjectTransformException();
+			} catch (NoSuchFieldException e) {
+				e.printStackTrace(); // Feld fehlt, dieses kann ignoriert werden.
+				continue;
+			}
+			
+			Class<?> T = f.getType();
+			String name= T.getName();
+
+         
+			//van only be string, an object or an array.
+			if (name.equals("java.lang.String")){	
+			String value;
+				try {
+					value = jo.getString(key);
+				} catch (JSONException e) {
+					e.printStackTrace();
+					throw new JSONToObjectTransformException();
+				}
+                try {
+					f.set(newObject,value);
+				} catch (IllegalArgumentException e) {
+					throw new JSONToObjectTransformException();
+				} catch (IllegalAccessException e) {
+					throw new JSONToObjectTransformException();
+				}
+			} else if (!T.isArray()) { // Feld ist kein Array und kein String}
+				JSONObject jsonsubObject;
+				try {
+					jsonsubObject = jo.getJSONObject(key);
+				} catch (JSONException e) {
+					throw new JSONToObjectTransformException();
+				}
+				Class<?> c = T.getClass();
+				Object newObject2=createObject(c,jsonsubObject);
+				try {
+					f.set(newObject, newObject2);
+				} catch (IllegalArgumentException e) {
+					throw new JSONToObjectTransformException();
+				} catch (IllegalAccessException e) {
+					throw new JSONToObjectTransformException();
+				}
+				
+			} else if  (T.isArray()){ // Feld is ein array 
+				JSONArray ja;
+				Class<?> c = T.getComponentType();
+				Object objects;
+				
+				int objectCounter=0;
+				try {
+					ja = jo.getJSONArray(key);
+					objects= Array.newInstance(c, ja.length());
+					
+					
+				} catch (JSONException e) {
+					throw new JSONToObjectTransformException();
+				}
+				
+				
+				for (int i=0;i<ja.length();i++){
+					Object jsonArryelement;
+					try {
+						jsonArryelement = ja.get(i);
+					} catch (JSONException e) {
+						throw new JSONToObjectTransformException();
+					}
+					//schaue welches Klasse das nach definition in RelationEvent sein soll
+							
+					
+					
+					//speichere das object
+					Array.set(objects,objectCounter,createObject(c,jsonArryelement));
+					objectCounter++;
+				}
+         
+				try {
+					f.set(newObject,objects);
+				} catch (IllegalArgumentException e) {
+					throw new JSONToObjectTransformException();
+				} catch (IllegalAccessException e) {
+					throw new JSONToObjectTransformException();
+				}
+       
+			}
+		}
+		
+	} else if (JSONArray.class.isInstance(jsonObject)){ //JSONArray wurde Ÿbergeben.
+		JSONArray ja = (JSONArray)jsonObject;
+		
+		if (!cls.isArray()){
+			throw new JSONandClassMissmatchException();
+		}
+		
+		newObject = Array.newInstance(cls.getComponentType(), ja.length());
+		for(int i=0;i<ja.length();i++){
+			try {
+				Array.set(newObject, i, createObject(cls.getComponentType(), ja.get(i)));
+			} catch (ArrayIndexOutOfBoundsException e) {
+				// TODO Auto-generated catch block
+				e.printStackTrace();
+			} catch (IllegalArgumentException e) {
+				throw new JSONToObjectTransformException();
+				
+			} catch (JSONException e) {
+				throw new JSONToObjectTransformException();
+				
+			}
+		}
+	}
+		return newObject;
+	};
+
+}