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/03/24 11:51:41 UTC

[5/9] clerezza git commit: CLEREZZA-966: moved ported rdf.* modules to hierarchy

http://git-wip-us.apache.org/repos/asf/clerezza/blob/d0f43e94/rdf/storage.web/pom.xml
----------------------------------------------------------------------
diff --git a/rdf/storage.web/pom.xml b/rdf/storage.web/pom.xml
new file mode 100644
index 0000000..4315683
--- /dev/null
+++ b/rdf/storage.web/pom.xml
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<!--
+
+ 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.
+
+-->
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.clerezza</groupId>
+        <artifactId>clerezza</artifactId>
+        <version>7-SNAPSHOT</version>
+        <relativePath />
+    </parent>
+    <artifactId>rdf.storage.web</artifactId>
+    <version>1.0.0-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+    <name>Clerezza - RDF Storage Web (Caching Web Storage Provider)</name>
+    <description>A (currently read-only) storage provider retrieving graphs from the web. It
+        implements a caching proxy, relying on another provider for storing triples.</description>
+    <dependencies>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.clerezza</groupId>
+            <artifactId>rdf.ontologies</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.clerezza</groupId>
+            <artifactId>rdf.utils</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.clerezza</groupId>
+            <artifactId>rdf.scala.utils</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.clerezza</groupId>
+            <artifactId>osgi.services</artifactId>
+            <version>0.2</version>
+        </dependency>
+        <dependency>
+          <groupId>org.scala-lang</groupId>
+          <artifactId>scala-library</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.ws.rs</groupId>
+            <artifactId>jsr311-api</artifactId>
+        </dependency>
+        <dependency>
+          <groupId>org.apache.clerezza.ext</groupId>
+          <artifactId>slf4j-scala-api</artifactId>
+            <version>1.6.3</version>
+        </dependency>
+    </dependencies>
+    <build>
+        <sourceDirectory>src/main/scala</sourceDirectory>
+        <testSourceDirectory>src/test/scala</testSourceDirectory>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Service-Component>OSGI-INF/serviceComponents.xml</Service-Component>
+                        <Export-Package>${project.groupId}.${project.artifactId}</Export-Package>
+                        <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
+                    </instructions>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-eclipse-plugin</artifactId>
+                <configuration>
+                    <downloadSources>true</downloadSources>
+                    <downloadJavadocs>true</downloadJavadocs>
+                    <buildcommands>
+                        <buildcommand>ch.epfl.lamp.sdt.core.scalabuilder</buildcommand>
+                    </buildcommands>
+                    <additionalProjectnatures>
+                        <projectnature>ch.epfl.lamp.sdt.core.scalanature</projectnature>
+                    </additionalProjectnatures>
+                    <classpathContainers>
+                        <classpathContainer>org.eclipse.jdt.launching.JRE_CONTAINER
+                        </classpathContainer>
+                        <classpathContainer>ch.epfl.lamp.sdt.launching.SCALA_CONTAINER
+                        </classpathContainer>
+                    </classpathContainers>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.scala-tools</groupId>
+                <artifactId>maven-scala-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza/blob/d0f43e94/rdf/storage.web/src/main/resources/OSGI-INF/metatype/metatype.xml
----------------------------------------------------------------------
diff --git a/rdf/storage.web/src/main/resources/OSGI-INF/metatype/metatype.xml b/rdf/storage.web/src/main/resources/OSGI-INF/metatype/metatype.xml
new file mode 100644
index 0000000..e1bd1fb
--- /dev/null
+++ b/rdf/storage.web/src/main/resources/OSGI-INF/metatype/metatype.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+
+<metatype:MetaData xmlns:metatype="http://www.osgi.org/xmlns/metatype/v1.0.0" localization="OSGI-INF/metatype/metatype">
+    <OCD id="org.apache.clerezza.rdf.storage.web.WebProxy"
+         name="Clerezza SCB Web Storage Provider"
+         description="%org.apache.clerezza.rdf.storage.web.WebProxy.description">
+        <AD id="network-timeout" type="int" default="false" name="Network Timeout" description="Specifies the network timeout in ms."/>
+    </OCD>
+    <Designate pid="org.apache.clerezza.rdf.storage.web.WebProxy">
+        <Object ocdref="org.apache.clerezza.rdf.storage.web.WebProxy"/>
+    </Designate>
+</metatype:MetaData>

http://git-wip-us.apache.org/repos/asf/clerezza/blob/d0f43e94/rdf/storage.web/src/main/resources/OSGI-INF/serviceComponents.xml
----------------------------------------------------------------------
diff --git a/rdf/storage.web/src/main/resources/OSGI-INF/serviceComponents.xml b/rdf/storage.web/src/main/resources/OSGI-INF/serviceComponents.xml
new file mode 100644
index 0000000..ff9b296
--- /dev/null
+++ b/rdf/storage.web/src/main/resources/OSGI-INF/serviceComponents.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+
+<components xmlns:scr="http://www.osgi.org/xmlns/scr/v1.0.0">
+
+    <scr:component enabled="true" name="org.apache.clerezza.rdf.storage.web.WebProxy">
+        <implementation class="org.apache.clerezza.rdf.storage.web.WebProxy"/>
+        <service servicefactory="false">
+            <provide interface="org.apache.clerezza.rdf.storage.web.WebProxy"/>
+            <provide interface="org.apache.clerezza.rdf.core.access.WeightedTcProvider"/>
+        </service>
+        <!-- hard coded <property name="weight" type="Integer" value="0"/> -->
+        <reference name="weightedTcProvider" interface="org.apache.clerezza.rdf.core.access.WeightedTcProvider"
+                   cardinality="1..n" policy="dynamic" bind="bindWeightedTcProvider" unbind="unbindWeightedTcProvider"/>
+        <reference name="parser" interface="org.apache.clerezza.rdf.core.serializedform.Parser"
+        cardinality="1..1" policy="static" bind="bindParser" unbind="unbindParser"/>
+        <property name="network-timeout" value="3000" type="Integer"/>
+    </scr:component>
+
+</components>

http://git-wip-us.apache.org/repos/asf/clerezza/blob/d0f43e94/rdf/storage.web/src/main/scala/WebProxy.scala
----------------------------------------------------------------------
diff --git a/rdf/storage.web/src/main/scala/WebProxy.scala b/rdf/storage.web/src/main/scala/WebProxy.scala
new file mode 100644
index 0000000..3a03e3b
--- /dev/null
+++ b/rdf/storage.web/src/main/scala/WebProxy.scala
@@ -0,0 +1,271 @@
+/*
+ * 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.
+ */
+
+package org.apache.clerezza.rdf.storage.web
+
+
+import org.apache.commons.rdf.ImmutableGraph
+import org.apache.commons.rdf.Iri
+import org.apache.commons.rdf._
+import org.apache.commons.rdf.impl.utils.AbstractGraph
+import org.osgi.service.component.ComponentContext
+import java.io.IOException
+import java.net.{HttpURLConnection, URL}
+import org.apache.clerezza.rdf.core.serializedform.SupportedFormat
+import org.apache.clerezza.rdf.core.serializedform.Parser
+import java.security.{PrivilegedExceptionAction, PrivilegedActionException, AccessController}
+
+import org.slf4j.scala._
+import org.apache.clerezza.rdf.core.access._
+import org.apache.clerezza.rdf.core._
+import java.sql.Time
+
+/**
+ * The Web Proxy Service enables applications to request remote (and local) graphs.
+ * It keeps cached version of the remote graphs in store for faster delivery.
+ *
+ */
+class WebProxy extends WeightedTcProvider with Logging {
+
+  val networkTimeoutKey = "network-timeout"
+
+  private var networkTimeout: Int = _
+
+  private var tcProvider: TcProviderMultiplexer = new TcProviderMultiplexer
+
+  /**
+   * Register a provider
+   *
+   * @param provider
+   *            the provider to be registered
+   */
+  protected def bindWeightedTcProvider(provider: WeightedTcProvider): Unit = {
+    tcProvider.addWeightedTcProvider(provider)
+  }
+
+  /**
+   * Deregister a provider
+   *
+   * @param provider
+   *            the provider to be deregistered
+   */
+  protected def unbindWeightedTcProvider(provider: WeightedTcProvider): Unit = {
+    tcProvider.removeWeightedTcProvider(provider)
+  }
+
+  /**OSGI method, called on activation */
+  protected def activate(context: ComponentContext) = {
+    networkTimeout = Integer.parseInt(context.getProperties.get(networkTimeoutKey).toString)
+  }
+
+
+  private var parser: Parser = null
+
+  protected def bindParser(p: Parser) = {
+    parser = p
+  }
+
+  protected def unbindParser(p: Parser) = {
+    parser = null
+  }
+
+  def getWeight: Int = {
+    return 0
+  }
+
+  /**
+   * Any Graph is available as ImmutableGraph as well as immutable Graph
+   *
+   * @param name
+   * @return
+   * @throws NoSuchEntityException
+   */
+  def getMGraph(name: Iri): Graph = {
+    val graph = getImmutableGraph(name)
+    return new AbstractGraph() {
+      protected def performFilter(subject: BlankNodeOrIri, predicate: Iri, `object` : RdfTerm): java.util.Iterator[Triple] = {
+        graph.filter(subject, predicate, `object`)
+      }
+
+      def performSize = graph.size
+    }
+  }
+
+  def getImmutableGraph(name: Iri): ImmutableGraph = {
+    try {
+      getGraph(name, Cache.Fetch)
+    } catch {
+      case e: IOException => {
+          logger.debug("could not get graph by dereferencing uri", e)
+          throw new NoSuchEntityException(name)
+      }
+
+    }
+  }
+
+  def getGraph(name: Iri): Graph = {
+    return getMGraph(name)
+  }
+
+  def createGraph(name: Iri): Graph = {
+    throw new UnsupportedOperationException
+  }
+
+  def createImmutableGraph(name: Iri, triples: Graph): ImmutableGraph = {
+    throw new UnsupportedOperationException
+  }
+
+  def deleteGraph(name: Iri): Unit = {
+    throw new UnsupportedOperationException
+  }
+
+  def getNames(graph: ImmutableGraph): java.util.Set[Iri] = {
+    var result: java.util.Set[Iri] = new java.util.HashSet[Iri]
+    import collection.JavaConversions._
+    for (name <- listGraphs) {
+      if (getImmutableGraph(name).equals(graph)) {
+        result.add(name)
+      }
+    }
+    return result
+  }
+
+  def listGraphs: java.util.Set[Iri] = {
+    var result: java.util.Set[Iri] = new java.util.HashSet[Iri]
+    result.addAll(listMGraphs)
+    result.addAll(listImmutableGraphs)
+    return result
+  }
+
+  def listMGraphs: java.util.Set[Iri] = {
+    //or should we list graphs for which we have a cached version?
+    return java.util.Collections.emptySet[Iri]
+  }
+
+  def listImmutableGraphs: java.util.Set[Iri] = {
+    return java.util.Collections.emptySet[Iri]
+  }
+
+  /**
+   * The semantics of this resource
+   * @param update if a remote URI, update information on the resource first
+   */
+  def getGraph(name: Iri, updatePolicy: Cache.Value): ImmutableGraph = {
+    logger.debug("getting graph " + name)
+    if (name.getUnicodeString.indexOf('#') != -1) {
+      logger.debug("not dereferencing URI with hash sign. Please see CLEREZZA-533 for debate.")
+      throw new NoSuchEntityException(name)
+    }
+    if (name.getUnicodeString.startsWith("urn")) {
+      //these are not dereferenceable
+      throw new NoSuchEntityException(name)
+    }
+    val cacheGraphName = new Iri("urn:x-localinstance:/cache/" + name.getUnicodeString)
+    //todo: follow redirects and keep track of them
+    //todo: keep track of headers especially date and etag. test for etag similarity
+    //todo: for https connection allow user to specify his webid and send his key: ie allow web server to be an agent
+    //todo: add GRDDL functionality, so that other return types can be processed too
+    //todo: enable ftp and other formats (though content negotiation won't work there)
+    def updateGraph() {
+      val url = new URL(name.getUnicodeString)
+      val connection = url.openConnection()
+      connection match {
+        case hc: HttpURLConnection => {
+          hc.addRequestProperty("Accept", acceptHeader)
+          hc.setReadTimeout(networkTimeout)
+          hc.setConnectTimeout(networkTimeout)
+        };
+      }
+      connection.connect()
+      val in = connection.getInputStream()
+      val mediaType = connection.getContentType()
+      val remoteTriples = parser.parse(in, mediaType, name)
+      tcProvider.synchronized {
+        try {
+          tcProvider.deleteGraph(cacheGraphName)
+        } catch {
+          case e: NoSuchEntityException =>;
+        }
+        tcProvider.createImmutableGraph(cacheGraphName, remoteTriples)
+      }
+    }
+    try {
+      //the logic here is not quite right, as we don't look at time of previous fetch.
+      updatePolicy match {
+        case Cache.Fetch => try {
+          tcProvider.getImmutableGraph(cacheGraphName)
+        } catch {
+          case e: NoSuchEntityException => updateGraph(); tcProvider.getImmutableGraph(cacheGraphName)
+        }
+        case Cache.ForceUpdate => updateGraph(); tcProvider.getImmutableGraph(cacheGraphName)
+        case Cache.CacheOnly => tcProvider.getImmutableGraph(cacheGraphName)
+      }
+    } catch {
+      case ex: PrivilegedActionException => {
+        var cause: Throwable = ex.getCause
+        if (cause.isInstanceOf[UnsupportedOperationException]) {
+          throw cause.asInstanceOf[UnsupportedOperationException]
+        }
+        if (cause.isInstanceOf[EntityAlreadyExistsException]) {
+          throw cause.asInstanceOf[EntityAlreadyExistsException]
+        }
+        if (cause.isInstanceOf[RuntimeException]) {
+          throw cause.asInstanceOf[RuntimeException]
+        }
+        throw new RuntimeException(cause)
+      }
+    }
+  }
+
+
+  private lazy val acceptHeader = {
+
+    import scala.collection.JavaConversions._
+
+    (for (f <- parser.getSupportedFormats) yield {
+      val qualityOfFormat = {
+        f match {
+          //the default, well established format
+          case SupportedFormat.RDF_XML => "1.0";
+          //n3 is a bit less well defined and/or many parsers supports only subsets
+          case SupportedFormat.N3 => "0.6";
+          //we prefer most dedicated formats to (X)HTML, not because those are "better",
+          //but just because it is quite likely that the pure RDF format will be
+          //lighter (contain less presentation markup), and it is also possible that HTML does not
+          //contain any RDFa, but just points to another format.
+          case SupportedFormat.XHTML => "0.5";
+          //we prefer XHTML over html, because parsing (should) be easier
+          case SupportedFormat.HTML => "0.4";
+          //all other formats known currently are structured formats
+          case _ => "0.8"
+        }
+      }
+      f + "; q=" + qualityOfFormat + ","
+    }).mkString + " *; q=.1" //is that for GRDDL?
+  }
+}
+
+object Cache extends Enumeration {
+  /**fetch if not in cache, if version in cache is out of date, or return cache */
+  val Fetch = Value
+  /**fetch from source whatever is in cache */
+  val ForceUpdate = Value
+  /**only get cached version. If none exists return empty graph */
+  val CacheOnly = Value
+}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/d0f43e94/rdf/web/LICENSE
----------------------------------------------------------------------
diff --git a/rdf/web/LICENSE b/rdf/web/LICENSE
new file mode 100644
index 0000000..261eeb9
--- /dev/null
+++ b/rdf/web/LICENSE
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.

http://git-wip-us.apache.org/repos/asf/clerezza/blob/d0f43e94/rdf/web/pom.xml
----------------------------------------------------------------------
diff --git a/rdf/web/pom.xml b/rdf/web/pom.xml
new file mode 100644
index 0000000..7dc74da
--- /dev/null
+++ b/rdf/web/pom.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<!--
+
+ 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.
+
+-->
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.clerezza</groupId>
+        <artifactId>clerezza</artifactId>
+        <version>7-SNAPSHOT</version>
+        <relativePath />
+    </parent>
+    <groupId>org.apache.clerezza</groupId>
+    <artifactId>rdf.web</artifactId>
+    <packaging>pom</packaging>
+    <version>1.0.0-SNAPSHOT</version>
+    <name>Clerezza - RDF Web Access</name>
+    <description>Allows access to Clerezza graphs over HTTP with JAX-RS</description>
+    <modules>
+        <module>rdf.web.core</module>
+        <module>rdf.web.ontologies</module>
+    </modules>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza/blob/d0f43e94/rdf/web/rdf.web.core/LICENSE
----------------------------------------------------------------------
diff --git a/rdf/web/rdf.web.core/LICENSE b/rdf/web/rdf.web.core/LICENSE
new file mode 100644
index 0000000..261eeb9
--- /dev/null
+++ b/rdf/web/rdf.web.core/LICENSE
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.

http://git-wip-us.apache.org/repos/asf/clerezza/blob/d0f43e94/rdf/web/rdf.web.core/nbactions.xml
----------------------------------------------------------------------
diff --git a/rdf/web/rdf.web.core/nbactions.xml b/rdf/web/rdf.web.core/nbactions.xml
new file mode 100644
index 0000000..49e8307
--- /dev/null
+++ b/rdf/web/rdf.web.core/nbactions.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<actions>
+    <action>
+        <actionName>CUSTOM-deploy to localhost:8080</actionName>
+        <displayName>deploy to localhost:8080</displayName>
+        <goals>
+            <goal>install</goal>
+            <goal>org.apache.sling:maven-sling-plugin:install</goal>
+        </goals>
+    </action>
+</actions>

http://git-wip-us.apache.org/repos/asf/clerezza/blob/d0f43e94/rdf/web/rdf.web.core/pom.xml
----------------------------------------------------------------------
diff --git a/rdf/web/rdf.web.core/pom.xml b/rdf/web/rdf.web.core/pom.xml
new file mode 100644
index 0000000..2cad597
--- /dev/null
+++ b/rdf/web/rdf.web.core/pom.xml
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<!--
+
+ 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.
+
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.clerezza</groupId>
+        <artifactId>clerezza</artifactId>
+        <version>7-SNAPSHOT</version>
+        <relativePath />
+    </parent>
+    <groupId>org.apache.clerezza</groupId>
+    <artifactId>rdf.web.core</artifactId>
+    <packaging>bundle</packaging>
+    <version>1.0.0-SNAPSHOT</version>
+    <name>Clerezza - RDF Web Access Core</name>
+    <description>The core part of Clerezza RDF  Web Access</description>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.clerezza</groupId>
+            <artifactId>platform.typerendering.core</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.clerezza</groupId>
+            <artifactId>platform.typerendering.scalaserverpages</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.clerezza</groupId>
+            <artifactId>rdf.core</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.clerezza</groupId>
+            <artifactId>rdf.jena.serializer</artifactId>
+            <scope>test</scope>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.clerezza</groupId>
+            <artifactId>rdf.jena.parser</artifactId>
+            <scope>test</scope>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.easymock</groupId>
+            <artifactId>easymock</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.ws.rs</groupId>
+            <artifactId>jsr311-api</artifactId>
+        </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>1.0.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.clerezza</groupId>
+            <artifactId>rdf.web.ontologies</artifactId>
+            <version>1.0.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.clerezza</groupId>
+            <artifactId>platform.globalmenu.api</artifactId>
+            <version>0.3</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.clerezza</groupId>
+            <artifactId>permissiondescriptions</artifactId>
+            <version>0.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.clerezza</groupId>
+            <artifactId>web.fileserver</artifactId>
+            <version>0.10</version>
+        </dependency>
+    </dependencies>
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/clerezza/blob/d0f43e94/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Backup.java
----------------------------------------------------------------------
diff --git a/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Backup.java b/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Backup.java
new file mode 100644
index 0000000..440e877
--- /dev/null
+++ b/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Backup.java
@@ -0,0 +1,161 @@
+/*
+ * 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.
+ */
+package org.apache.clerezza.rdf.web.core;
+
+import org.apache.clerezza.platform.Constants;
+import org.apache.clerezza.platform.globalmenu.GlobalMenuItem;
+import org.apache.clerezza.platform.globalmenu.GlobalMenuItemsProvider;
+import org.apache.clerezza.platform.typerendering.scalaserverpages.ScalaServerPagesService;
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.Graph;
+import org.apache.clerezza.rdf.core.access.security.TcPermission;
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
+import org.apache.clerezza.rdf.ontologies.RDF;
+import org.apache.clerezza.rdf.utils.GraphNode;
+import org.apache.clerezza.rdf.web.ontologies.BACKUP;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.component.ComponentContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.clerezza.rdf.ontologies.PLATFORM;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import javax.ws.rs.core.Response.Status;
+import java.net.URL;
+import java.security.AccessControlException;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * This JAX-RS resource provides a method to retrieve a zip file containing
+ * all triple collections that the use may access. The triple collection are
+ * serialized in N-Triples format. The URI path of this resource is
+ * "/admin/backup".
+ *
+ * This class adds a global menu-item for users that can read the system graph
+ * (as there's currently no dedicated backup-permission).
+ *
+ * @author hasan, reto
+ */
+@Component
+@Service({Object.class, GlobalMenuItemsProvider.class})
+@Property(name = "javax.ws.rs", boolValue = true)
+@Path("/admin/backup")
+public class Backup implements GlobalMenuItemsProvider {
+
+    final Logger logger = LoggerFactory.getLogger(Backup.class);
+    @Reference
+    private ScalaServerPagesService scalaServerPagesService;
+    private Set<ServiceRegistration> serviceRegistrations = new HashSet<ServiceRegistration>();
+
+    /**
+     * The activate method is called when SCR activates the component configuration.
+     *
+     * @param componentContext
+     */
+    protected void activate(ComponentContext componentContext) {
+        URL templateURL = getClass().getResource("backup-management.ssp");
+        serviceRegistrations.add(scalaServerPagesService.registerScalaServerPage(templateURL, BACKUP.BackupAdminPage, "naked",
+                MediaType.APPLICATION_XHTML_XML_TYPE));
+    }
+
+    protected void deactivate(ComponentContext context) {
+        for (ServiceRegistration r : serviceRegistrations) {
+            r.unregister();
+        }
+    }
+
+    /**
+     * Get a zipped file containing all triple collections which the
+     * user may access. The resource is accessible through the URI path
+     * "/admin/backup/download".
+     * The triple collections are serialized in N-Triples format before being
+     * archived in a single zipped file.
+     * A mapping of the names of the files in the archive to triple collection
+     * names is available as well in the archive as a text file named
+     * triplecollections.nt.
+     *
+     * @return a response that will cause the creation of a zipped file
+     */
+    @GET
+    @Path("download")
+    @Produces("application/zip")
+    public Response download() {
+        AccessController.checkPermission(new BackupPermission());
+        return AccessController.doPrivileged(new PrivilegedAction<Response>() {
+
+            @Override
+            public Response run() {
+                ResponseBuilder responseBuilder = Response.status(Status.OK).
+                        entity(Backup.this);
+                responseBuilder.header("Content-Disposition",
+                        "attachment; filename=backup" + getCurrentDate() + ".zip");
+                return responseBuilder.build();
+            }
+        });
+
+    }
+
+    @GET
+    public GraphNode overviewPage() {
+        Graph resultGraph = new SimpleGraph();
+        GraphNode result = new GraphNode(new BlankNode(), resultGraph);
+        result.addProperty(RDF.type, BACKUP.BackupAdminPage);
+        result.addProperty(RDF.type, PLATFORM.HeadedPage);
+        return result;
+    }
+
+    private String getCurrentDate() {
+        DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
+        Date date = new Date();
+        return dateFormat.format(date);
+    }
+
+    @Override
+    public Set<GlobalMenuItem> getMenuItems() {
+        //need backup or restore permission for the menu item to be shown
+        Set<GlobalMenuItem> result = new HashSet<GlobalMenuItem>();
+        try {
+            AccessController.checkPermission(new BackupPermission());
+        } catch (AccessControlException e) {
+            try {
+                AccessController.checkPermission(new RestorePermission());
+            } catch (AccessControlException e1) {
+                return result;
+            }
+        }
+        result.add(new GlobalMenuItem("/admin/backup",
+                "BCK", "Backup and Restore", 5, "Administration"));
+        return result;
+    }
+}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/d0f43e94/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/BackupMessageBodyWriter.java
----------------------------------------------------------------------
diff --git a/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/BackupMessageBodyWriter.java b/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/BackupMessageBodyWriter.java
new file mode 100644
index 0000000..5029eea
--- /dev/null
+++ b/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/BackupMessageBodyWriter.java
@@ -0,0 +1,180 @@
+/*
+ * 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.
+ */
+package org.apache.clerezza.rdf.web.core;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.locks.Lock;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.Status;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+import org.apache.clerezza.rdf.core.LiteralFactory;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.commons.rdf.Graph;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Iri;
+import org.apache.clerezza.rdf.core.access.TcManager;
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
+import org.apache.commons.rdf.impl.utils.TripleImpl;
+import org.apache.clerezza.rdf.core.serializedform.Serializer;
+import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
+import org.apache.clerezza.rdf.core.serializedform.UnsupportedFormatException;
+import org.apache.clerezza.rdf.ontologies.RDF;
+import org.apache.clerezza.rdf.web.ontologies.BACKUP;
+
+/**
+ * This does the actual work of producing a backup
+ * 
+ * @author hasan, reto
+ */
+@Component
+@Service(Object.class)
+@Property(name="javax.ws.rs", boolValue=true)
+@Produces("application/zip")
+@Provider
+public class BackupMessageBodyWriter implements MessageBodyWriter<Backup> {
+
+    @Reference
+    TcManager tcManager;
+
+    @Reference
+    Serializer serializer;
+
+    final Logger logger = LoggerFactory.getLogger(BackupMessageBodyWriter.class);
+
+    private final String folder = "graphs/";
+
+
+    byte[] createBackup() {
+        ByteArrayOutputStream result = new ByteArrayOutputStream();
+        writeBackup(result);
+        return result.toByteArray();
+    }
+
+    private void archive(ZipOutputStream compressedTcs, 
+            Graph tripleCollection,
+            String fileName) throws IOException, UnsupportedFormatException {
+        Lock readLock = null;
+        compressedTcs.putNextEntry(new ZipEntry(fileName));
+        if (tripleCollection instanceof Graph) {
+            readLock = ((Graph) tripleCollection).getLock().readLock();
+            readLock.lock();
+        }
+        try {
+            serializer.serialize(compressedTcs, tripleCollection,
+                    SupportedFormat.N_TRIPLE);
+        } finally {
+            if (readLock != null) {
+                readLock.unlock();
+            }
+        }
+    }
+
+    private String getTcFileName(Iri tcUri, String extension,
+            Map<String, Integer> fileNameCount) {
+        String fileName = tcUri.getUnicodeString();
+        fileName = fileName.substring(fileName.lastIndexOf("/")+1);
+        Integer count = fileNameCount.get(fileName);
+        if (count == null) {
+            fileNameCount.put(fileName, 0);
+        } else {
+            count++;
+            fileNameCount.put(fileName, count);
+            fileName = fileName.concat("_" + count);
+        }
+        return  fileName.concat(extension);
+    }
+
+    private void writeBackup(OutputStream result) {
+        Map<String, Integer> fileNameCount = new HashMap<String, Integer>();
+        Graph backupContents = new SimpleGraph();
+        try {
+            ZipOutputStream compressedTcs = new ZipOutputStream(result);
+
+            compressedTcs.putNextEntry(new ZipEntry(folder));
+
+            Set<Iri> tripleCollections = tcManager.listGraphs();
+            Iterator<Iri> tcIris = tripleCollections.iterator();
+            while (tcIris.hasNext()) {
+                Iri tcUri = tcIris.next();
+                String fileName = folder + getTcFileName(tcUri, ".nt",
+                        fileNameCount);
+                Graph tripleCollection = tcManager.getGraph(tcUri);
+                archive(compressedTcs, tripleCollection, fileName);
+                if (tripleCollection instanceof Graph) {
+                    backupContents.add(new TripleImpl(tcUri, RDF.type,
+                            BACKUP.Graph));
+                } else {
+                    backupContents.add(new TripleImpl(tcUri, RDF.type,
+                            BACKUP.Graph));
+                }
+                backupContents.add(new TripleImpl(tcUri, BACKUP.file,
+                        LiteralFactory.getInstance().createTypedLiteral(
+                        fileName)));
+            }
+            archive(compressedTcs, backupContents, "triplecollections.nt");
+            compressedTcs.close();
+
+        } catch (UnsupportedFormatException ufe) {
+            throw new WebApplicationException(Response.status(
+                    Status.NOT_ACCEPTABLE).entity(ufe.getMessage()).build());
+        } catch (IOException ex) {
+            throw new WebApplicationException(ex);
+        }
+    }
+
+    @Override
+    public boolean isWriteable(Class<?> type, Type genericType,
+            Annotation[] annotations, MediaType mediaType) {
+        return Backup.class.isAssignableFrom(type);
+    }
+
+    @Override
+    public long getSize(Backup t, Class<?> type, Type genericType,
+            Annotation[] annotations, MediaType mediaType) {
+        return -1;
+    }
+
+    @Override
+    public void writeTo(Backup t, Class<?> type, Type genericType,
+            Annotation[] annotations, MediaType mediaType,
+            MultivaluedMap<String, Object> httpHeaders,
+            OutputStream entityStream) throws IOException, WebApplicationException {
+        writeBackup(entityStream);
+    }
+}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/d0f43e94/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/BackupPermission.java
----------------------------------------------------------------------
diff --git a/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/BackupPermission.java b/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/BackupPermission.java
new file mode 100644
index 0000000..caf5d18
--- /dev/null
+++ b/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/BackupPermission.java
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ */
+package org.apache.clerezza.rdf.web.core;
+
+import org.apache.clerezza.permissiondescriptions.PermissionInfo;
+
+import java.security.Permission;
+
+/**
+ * Permission to retrieve a backup copy of all graphs provided by TcManager
+ *
+ * @author reto
+ */
+@PermissionInfo(value="Backup Permission", description="Permission " +
+    "to retrieve a backup of all Triple Collections")
+public class BackupPermission extends Permission {
+
+
+    public BackupPermission() {
+        super("ImmutableGraph Management permission");
+    }
+    /**
+     *
+     * @param target ignored
+     * @param action ignored
+     */
+    public BackupPermission(String target, String actions) {
+        super("ImmutableGraph Management permission");
+    }
+
+    @Override
+    public boolean implies(Permission permission) {
+        return equals(permission);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        return getClass().equals(obj.getClass());
+    }
+
+    @Override
+    public int hashCode() {
+        return 77988;
+    }
+
+    @Override
+    public String getActions() {
+        return "";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/d0f43e94/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Delete.java
----------------------------------------------------------------------
diff --git a/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Delete.java b/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Delete.java
new file mode 100644
index 0000000..c00bf1b
--- /dev/null
+++ b/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Delete.java
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ */
+package org.apache.clerezza.rdf.web.core;
+
+import javax.ws.rs.FormParam;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+import org.apache.clerezza.jaxrs.utils.RedirectUtil;
+import org.apache.clerezza.platform.typerendering.RenderletManager;
+import org.apache.commons.rdf.Graph;
+import org.apache.commons.rdf.Graph;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.commons.rdf.Iri;
+import org.apache.clerezza.rdf.core.access.NoSuchEntityException;
+import org.apache.clerezza.rdf.core.access.TcManager;
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
+import org.apache.commons.rdf.impl.utils.TripleImpl;
+import org.apache.clerezza.rdf.ontologies.FOAF;
+import org.apache.clerezza.rdf.ontologies.OWL;
+import org.apache.clerezza.rdf.ontologies.PLATFORM;
+import org.apache.clerezza.rdf.ontologies.RDF;
+import org.apache.clerezza.rdf.utils.Smusher;
+import org.osgi.service.component.ComponentContext;
+
+/**
+ * Provides a method to remove duplicate noded from (aka smush) a ImmutableGraph
+ * 
+ * @author reto
+ */
+@Component
+@Service(Object.class)
+@Property(name="javax.ws.rs", boolValue=true)
+@Path("/admin/graphs/delete")
+public class Delete {
+    
+    @Reference
+    private TcManager tcManager;
+
+    
+    @POST
+    public Response delete(@Context UriInfo uriInfo, @FormParam("graphName") Iri graphName) {
+        tcManager.deleteGraph(graphName);
+        return RedirectUtil.createSeeOtherResponse("./", uriInfo);
+    }
+}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/d0f43e94/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/GraphManagement.java
----------------------------------------------------------------------
diff --git a/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/GraphManagement.java b/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/GraphManagement.java
new file mode 100644
index 0000000..886d1e7
--- /dev/null
+++ b/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/GraphManagement.java
@@ -0,0 +1,120 @@
+/*
+ * 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.
+ */
+package org.apache.clerezza.rdf.web.core;
+
+import java.net.URL;
+import java.security.AccessControlException;
+import java.security.AccessController;
+import java.util.HashSet;
+import java.util.Set;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
+import org.apache.clerezza.jaxrs.utils.TrailingSlash;
+import org.apache.clerezza.platform.globalmenu.GlobalMenuItem;
+import org.apache.clerezza.platform.globalmenu.GlobalMenuItemsProvider;
+import org.apache.clerezza.platform.typerendering.RenderletManager;
+import org.apache.clerezza.platform.typerendering.scalaserverpages.ScalaServerPagesRenderlet;
+import org.apache.commons.rdf.BlankNode;
+import org.apache.commons.rdf.ImmutableGraph;
+import org.apache.clerezza.rdf.core.LiteralFactory;
+import org.apache.commons.rdf.Graph;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.commons.rdf.Iri;
+import org.apache.clerezza.rdf.core.access.TcManager;
+import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
+import org.apache.commons.rdf.impl.utils.TripleImpl;
+import org.apache.clerezza.rdf.ontologies.PLATFORM;
+import org.apache.clerezza.rdf.ontologies.RDF;
+import org.apache.clerezza.rdf.ontologies.TCPROVIDER;
+import org.apache.clerezza.rdf.utils.GraphNode;
+import org.apache.clerezza.rdf.web.ontologies.GRAPHMANAGEMENT;
+import org.osgi.service.component.ComponentContext;
+
+/**
+ * This JAX-RS resource provides an interface designed to allow various management
+ * functions on triple collections. The URI path of this resource is
+ * "/admin/graph-management".
+ * 
+ * @author reto
+ */
+@Component
+@Service({Object.class, GlobalMenuItemsProvider.class})
+@Property(name="javax.ws.rs", boolValue=true)
+@Path("/admin/graphs")
+public class GraphManagement implements GlobalMenuItemsProvider {
+
+    @Reference
+    private TcManager tcManager;
+
+    @Reference
+    private RenderletManager renderletManager;
+
+    protected void activate(ComponentContext componentContext) {
+        URL templateURL = getClass().getResource("graph-management.ssp");
+        renderletManager.registerRenderlet(ScalaServerPagesRenderlet.class.getName(),
+                new Iri(templateURL.toString()), GRAPHMANAGEMENT.GraphManagementPage,
+                "naked", MediaType.APPLICATION_XHTML_XML_TYPE, true);
+    }
+
+    @GET
+    public GraphNode mainPage(@Context UriInfo uriInfo) {
+        AccessController.checkPermission(new GraphManagementAppPermission());
+        TrailingSlash.enforcePresent(uriInfo);
+        final SimpleGraph resultGraph = new SimpleGraph();
+        GraphNode graphNode = new GraphNode(new BlankNode(), resultGraph);
+        Set<Iri> tripleCollections = tcManager.listGraphs();
+        for (Iri uriRef : tripleCollections) {
+            graphNode.addProperty(GRAPHMANAGEMENT.tripleCollection, uriRef);
+            final Graph tripleCollection = tcManager.getGraph(uriRef);
+            resultGraph.add(new TripleImpl(uriRef,GRAPHMANAGEMENT.size,
+                    LiteralFactory.getInstance().createTypedLiteral(
+                    tripleCollection.size())));
+            if (tripleCollection instanceof ImmutableGraph) {
+                resultGraph.add(new TripleImpl(uriRef,RDF.type, TCPROVIDER.Graph));
+            } else {
+                resultGraph.add(new TripleImpl(uriRef,RDF.type, TCPROVIDER.Graph));
+            }
+        }
+        graphNode.addProperty(RDF.type, GRAPHMANAGEMENT.GraphManagementPage);
+        graphNode.addProperty(RDF.type, PLATFORM.HeadedPage);
+        return graphNode;
+    }
+
+    @Override
+    public Set<GlobalMenuItem> getMenuItems() {
+
+        Set<GlobalMenuItem> items = new HashSet<GlobalMenuItem>();
+        try {
+            AccessController.checkPermission(
+                    new GraphManagementAppPermission());
+        } catch (AccessControlException e) {
+            return items;
+        }
+        String path = "/admin/graphs";
+        items.add(new GlobalMenuItem(path, "GM", "Graphs", 5,"Administration"));
+        return items;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/d0f43e94/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/GraphManagementAppPermission.java
----------------------------------------------------------------------
diff --git a/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/GraphManagementAppPermission.java b/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/GraphManagementAppPermission.java
new file mode 100644
index 0000000..09ec04d
--- /dev/null
+++ b/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/GraphManagementAppPermission.java
@@ -0,0 +1,67 @@
+/*
+ * 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.
+ */
+package org.apache.clerezza.rdf.web.core;
+
+import java.security.Permission;
+import org.apache.clerezza.permissiondescriptions.PermissionInfo;
+
+/**
+ * Permission to use the ImmutableGraph-Management page. Nothe that the user
+ * additioonally needs permssion on the Graphs they manipulate.
+ *
+ * @author reto
+ */
+@PermissionInfo(value="ImmutableGraph Management Access Permission", description="Grants access " +
+    "to the ImmutableGraph Management page")
+public class GraphManagementAppPermission extends Permission {
+
+
+    public GraphManagementAppPermission() {
+        super("ImmutableGraph Management permission");
+    }
+    /**
+     * 
+     * @param target ignored
+     * @param action ignored
+     */
+    public GraphManagementAppPermission(String target, String actions) {
+        super("ImmutableGraph Management permission");
+    }
+
+    @Override
+    public boolean implies(Permission permission) {
+        return equals(permission);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        return getClass().equals(obj.getClass());
+    }
+
+    @Override
+    public int hashCode() {
+        return 77985;
+    }
+
+    @Override
+    public String getActions() {
+        return "";
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/d0f43e94/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/PlatformRestorer.java
----------------------------------------------------------------------
diff --git a/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/PlatformRestorer.java b/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/PlatformRestorer.java
new file mode 100644
index 0000000..2d96602
--- /dev/null
+++ b/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/PlatformRestorer.java
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+package org.apache.clerezza.rdf.web.core;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.Response.ResponseBuilder;
+import javax.ws.rs.core.UriInfo;
+import org.apache.clerezza.jaxrs.utils.RedirectUtil;
+import org.apache.clerezza.jaxrs.utils.form.FormFile;
+import org.apache.clerezza.jaxrs.utils.form.MultiPartBody;
+import org.apache.clerezza.rdf.core.access.TcManager;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+
+/**
+ * A service to restore the triple collections of a clerezza platform instance
+ *
+ * @author reto
+ */
+@Component
+@Service({Object.class, PlatformRestorer.class})
+@Property(name = "javax.ws.rs", boolValue = true)
+@Path("/admin/backup/restore")
+public class PlatformRestorer {
+
+    @Reference
+    private Restorer restorer;
+
+    @Reference
+    private TcManager tcManager;
+
+    /**
+     * Restores the triple collection of TcManager from a backup
+     *
+     * @param backupData the backup data
+     */
+    public void restore(InputStream backupData) throws IOException {
+        restorer.restore(backupData, tcManager);
+    }
+
+    @POST
+    public Response restore(MultiPartBody body, @Context final UriInfo uriInfo) 
+            throws Throwable {
+        AccessController.checkPermission(new RestorePermission());
+        FormFile[] files = body.getFormFileParameterValues("file");
+        if (files.length != 1) {
+            throw new RuntimeException("Must submit exactly one file");
+        }
+        final FormFile file = files[0];
+        try {
+            return AccessController.doPrivileged(new PrivilegedExceptionAction<Response>() {
+
+                @Override
+                public Response run() throws IOException {
+                    restore(new ByteArrayInputStream(file.getContent()));
+                    return RedirectUtil.createSeeOtherResponse("/admin/backup", uriInfo);
+                }
+            });
+        } catch (PrivilegedActionException ex) {
+            throw ex.getCause();
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/d0f43e94/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/RestorePermission.java
----------------------------------------------------------------------
diff --git a/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/RestorePermission.java b/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/RestorePermission.java
new file mode 100644
index 0000000..6080df9
--- /dev/null
+++ b/rdf/web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/RestorePermission.java
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+package org.apache.clerezza.rdf.web.core;
+
+import org.apache.clerezza.permissiondescriptions.PermissionInfo;
+
+import java.security.Permission;
+
+/**
+ * Permission to restore all graphs provided by TcManager from a backup copy.
+ *
+ * This a very powerfull permission as it allows to write to all graphs.
+ *
+ * @author reto
+ */
+@PermissionInfo(value="Restore Permission", description="Permission " +
+    "to replace all triple collections with the contents of backup file")
+public class RestorePermission extends Permission {
+
+
+    public RestorePermission() {
+        super("Restore permission");
+    }
+    /**
+     *
+     * @param target ignored
+     * @param action ignored
+     */
+    public RestorePermission(String target, String actions) {
+        super("Restore permission");
+    }
+
+    @Override
+    public boolean implies(Permission permission) {
+        return equals(permission);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        return getClass().equals(obj.getClass());
+    }
+
+    @Override
+    public int hashCode() {
+        return 77965;
+    }
+
+    @Override
+    public String getActions() {
+        return "";
+    }
+
+}