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/04/14 15:13:39 UTC

[64/87] [abbrv] clerezza git commit: CLEREZZA-966: moved ported rdf.* modules to hierarchy

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/ResultSetMessageBodyWriter.java
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/ResultSetMessageBodyWriter.java b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/ResultSetMessageBodyWriter.java
deleted file mode 100644
index f3678a7..0000000
--- a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/ResultSetMessageBodyWriter.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.clerezza.rdf.web.core;
-
-import java.io.OutputStream;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.ext.MessageBodyWriter;
-import javax.ws.rs.ext.Provider;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-import javax.ws.rs.ext.Providers;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.Source;
-import javax.xml.transform.dom.DOMSource;
-
-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.BlankNode;
-import org.apache.commons.rdf.Language;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Iri;
-import org.apache.clerezza.rdf.core.access.TcManager;
-import org.apache.clerezza.rdf.core.sparql.ResultSet;
-import org.apache.clerezza.rdf.core.sparql.SolutionMapping;
-import org.apache.clerezza.rdf.core.sparql.query.Variable;
-import org.apache.commons.rdf.Literal;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * MessageBodyWirter for <code>ResultSet</code>.
- * 
- * @author mir, reto
- */
-@Component
-@Service(Object.class)
-@Property(name="javax.ws.rs", boolValue=true)
-@Produces({"application/xml", "text/xml", "application/sparql-results+xml"})
-@Provider
-public class ResultSetMessageBodyWriter implements MessageBodyWriter<ResultSet> {
-
-    @Reference
-    TcManager tcManager;
-
-
-    private Providers providers;
-
-    final Logger logger = LoggerFactory.getLogger(ResultSetMessageBodyWriter.class);
-
-    @Override
-    public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations,
-            MediaType mediaType) {
-        return ResultSet.class.isAssignableFrom(type);
-    }
-
-    @Override
-    public long getSize(ResultSet t, Class<?> type, Type genericType,
-            Annotation[] annotations, MediaType mediaType) {
-        return -1;
-    }
-
-    @Override
-    public void writeTo(ResultSet resultSet, Class<?> type, Type genericType,
-            Annotation[] annotations, MediaType mediaType, MultivaluedMap<String,
-            Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException {
-
-        Source source = toXmlSource(resultSet);
-        MessageBodyWriter<Source> sourceMessageBodyWriter = 
-                providers.getMessageBodyWriter(Source.class, null, null, mediaType);
-        sourceMessageBodyWriter.writeTo(source, Source.class, null, null, mediaType,
-                httpHeaders, entityStream);
-    }
-
-    @Context
-    public void setProviders(Providers providers) {
-        this.providers = providers;
-    }
-
-    /**
-     * Helper: transforms a {@link ResultSet} or a {@link Boolean} to a
-     * {@link DOMSource}
-     *
-     * @param queryResult
-     * @param query
-     * @param applyStyle
-     */
-    private Source toXmlSource(ResultSet queryResult) {
-        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-        try {
-            Document doc = dbf.newDocumentBuilder().newDocument();
-            // adding root element
-            Element root = doc.createElement("sparql");
-            root.setAttribute("xmlns", "http://www.w3.org/2005/sparql-results#");
-            doc.appendChild(root);
-            Element head = doc.createElement("head");
-            root.appendChild(head);
-            Set<Object> variables = new HashSet<Object>();
-            Element results = doc.createElement("results");
-            SolutionMapping solutionMapping = null;
-            while (queryResult.hasNext()) {
-                solutionMapping = queryResult.next();                
-                createResultElement(solutionMapping, results, doc);                
-            }
-            createVariable(solutionMapping, head, doc);
-            root.appendChild(results);
-
-            DOMSource source = new DOMSource(doc);
-            return source;
-
-        } catch (ParserConfigurationException e) {
-            throw createWebApplicationException(e);
-        }
-    }
-
-    /**
-     * Creates a WebApplicationexception and prints a logger entry
-     */
-    private WebApplicationException createWebApplicationException(Exception e) {
-        return new WebApplicationException(Response.status(Status.BAD_REQUEST)
-                .entity(e.getMessage().replace("<", "&lt;").replace("\n",
-                        "<br/>")).build());
-    }
-
-
-    /**
-     * Helper: creates value element from {@link RdfTerm} depending on its
-     * class
-     *
-     */
-    private Element createValueElement(RdfTerm resource, Document doc) {
-        Element value = null;
-        if (resource instanceof Iri) {
-            value = doc.createElement("uri");
-            value.appendChild(doc.createTextNode(((Iri) resource)
-                    .getUnicodeString()));
-        } else if (resource instanceof Literal) {
-            value = doc.createElement("literal");
-            value.appendChild(doc.createTextNode(((Literal) resource)
-                    .getLexicalForm()));
-            value.setAttribute("datatype", (((Literal) resource)
-                    .getDataType().getUnicodeString()));
-            Language lang = ((Literal) resource).getLanguage();
-            if (lang != null) {
-                value.setAttribute("xml:lang", (lang.toString()));
-            }
-        } else {
-            value = doc.createElement("bnode");
-            value.appendChild(doc.createTextNode(((BlankNode) resource).toString()));
-        }
-        return value;
-    }
-
-    /**
-     * Helper: creates results element from ResultSet
-     *
-     */
-    private void createResultElement(SolutionMapping solutionMap, Element results, Document doc) {
-        Set<Variable> keys = solutionMap.keySet();
-        Element result = doc.createElement("result");
-        results.appendChild(result);
-        for (Variable key : keys) {
-            Element bindingElement = doc.createElement("binding");
-            bindingElement.setAttribute("name", key.getName());
-            bindingElement.appendChild(createValueElement(
-                    (RdfTerm) solutionMap.get(key), doc));
-            result.appendChild(bindingElement);
-        }
-    }
-
-    private void createVariable(SolutionMapping solutionMap, Element head, Document doc) {
-        Set<Variable> keys = solutionMap.keySet();
-        for (Variable key : keys) {
-            Element varElement = doc.createElement("variable");
-            varElement.setAttribute("name", key.getName());
-            head.appendChild(varElement);
-        }
-    }
-}

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/Smush.java
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Smush.java b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Smush.java
deleted file mode 100644
index fa29fde..0000000
--- a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/Smush.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-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.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/smush")
-public class Smush {
-    private final Iri tBoxName = new Iri("urn:x-localinstance:/tbox.graph");
-
-    @Reference
-    private TcManager tcManager;
-
-    @Reference
-    private RenderletManager renderletManager;
-
-    private Graph tBox;
-
-    protected void activate(ComponentContext componentContext) {
-        try {
-            //getting the tBox here means no read right on Tbox is necessary
-            //when smushing
-            tBox = tcManager.getGraph(tBoxName);
-        } catch (NoSuchEntityException e) {
-            tBox = new SimpleGraph();
-            tBox.add(new TripleImpl(FOAF.mbox, RDF.type, OWL.InverseFunctionalProperty));
-            tBox.add(new TripleImpl(FOAF.mbox_sha1sum, RDF.type, OWL.InverseFunctionalProperty));
-            tBox.add(new TripleImpl(PLATFORM.userName, RDF.type, OWL.InverseFunctionalProperty));
-            tBox = tcManager.createImmutableGraph(tBoxName, tBox);
-        }
-    }
-
-
-    
-    @POST
-    public Response smush(@Context UriInfo uriInfo, @FormParam("graphName") Iri graphName) {
-        Graph mGraph = tcManager.getGraph(graphName);
-        Smusher.smush(mGraph, tBox);
-        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/SparqlEndpoint.java
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/SparqlEndpoint.java b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/SparqlEndpoint.java
deleted file mode 100644
index 69f318f..0000000
--- a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/SparqlEndpoint.java
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.clerezza.rdf.web.core;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.net.URL;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.GET;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-import javax.ws.rs.core.UriInfo;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMResult;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-
-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.clerezza.jaxrs.utils.TrailingSlash;
-import org.apache.clerezza.platform.Constants;
-import org.apache.clerezza.platform.typerendering.RenderletManager;
-import org.apache.clerezza.platform.typerendering.scalaserverpages.ScalaServerPagesRenderlet;
-import org.osgi.service.component.ComponentContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.commons.rdf.BlankNode;
-import org.apache.commons.rdf.ImmutableGraph;
-import org.apache.commons.rdf.Language;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.RdfTerm;
-import org.apache.commons.rdf.Graph;
-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.clerezza.rdf.core.sparql.ParseException;
-import org.apache.clerezza.rdf.core.sparql.QueryParser;
-import org.apache.clerezza.rdf.core.sparql.ResultSet;
-import org.apache.clerezza.rdf.core.sparql.SolutionMapping;
-import org.apache.clerezza.rdf.core.sparql.query.Query;
-import org.apache.clerezza.rdf.core.sparql.query.SelectQuery;
-import org.apache.clerezza.rdf.core.sparql.query.Variable;
-import org.apache.clerezza.rdf.ontologies.RDF;
-import org.apache.clerezza.rdf.utils.GraphNode;
-import org.apache.clerezza.rdf.web.ontologies.SPARQLENDPOINT;
-import org.apache.commons.rdf.Literal;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.ProcessingInstruction;
-
-/**
- * Provides methods to query a graph over the web.
- * 
- * @author ali, hasan
- * 
- */
-@Component
-@Service(Object.class)
-@Property(name = "javax.ws.rs", boolValue = true)
-@Path("/sparql")
-public class SparqlEndpoint {
-
-    private final Logger logger = LoggerFactory.getLogger(getClass());
-    
-    
-    @Reference
-    TcManager tcManager;
-
-    @Reference
-    private RenderletManager renderletManager;
-
-    /**
-     * The activate method is called when SCR activates the component configuration.
-     * @param componentContext
-     */
-    protected void activate(ComponentContext componentContext) {
-        URL templateURL = getClass().getResource("sparql-endpoint.ssp");
-        renderletManager.registerRenderlet(ScalaServerPagesRenderlet.class.getName(),
-                new Iri(templateURL.toString()), SPARQLENDPOINT.SparqlEndpoint,
-                null, MediaType.APPLICATION_XHTML_XML_TYPE, true);
-    }
-
-    @GET
-    @Path("form")
-    public GraphNode getAvailableGraphUris(@Context UriInfo uriInfo) {
-        AccessController.checkPermission(new SparqlEndpointAccessPermission());
-        TrailingSlash.enforceNotPresent(uriInfo);
-        GraphNode graphNode = new GraphNode(new BlankNode(), new SimpleGraph());
-        Set<Iri> tripleCollections = tcManager.listGraphs();
-        for (Iri uriRef : tripleCollections) {
-            graphNode.addProperty(SPARQLENDPOINT.tripleCollection, uriRef);
-        }
-        graphNode.addProperty(RDF.type, SPARQLENDPOINT.SparqlEndpoint);
-        return graphNode;
-    }
-
-    /**
-     * Returns either a {@link ImmutableGraph} or a {@link DOMSource}. A {@link ImmutableGraph} is
-     * returned if a CONSTRUCT or a DESCRIBE sparql query was submitted and
-     * successfully carried out. A {@link DOMSource} is returned if an ASK or a
-     * SELECT sparql query was submitted and successfully carried out. The query
-     * is performed against a specified graph with the URI
-     * <code>defaultGrapfUri</code>
-     * 
-     * @param queryString
-     *            URL encoded sparql query
-     * @param defaultGraphUri
-     *            URI of the default graph, an {@link Iri} is expected
-     * @param applyStyleSheet
-     * @param serverSide
-     * @param styleSheetUri 
-     * @return either a {@link ImmutableGraph} or a {@link DOMSource}
-     */
-    @POST
-    public Object runFormQuery(@FormParam("query") String queryString,
-            @FormParam("default-graph-uri") Iri defaultGraphUri,
-            @FormParam("apply-style-sheet") String applyStyleSheet,
-            @FormParam("server-side") String serverSide,
-            @FormParam("style-sheet-uri") String styleSheetUri) {
-        AccessController.checkPermission(new SparqlEndpointAccessPermission());
-        logger.info("Executing SPARQL Query: " + queryString);
-        boolean applyStyle;
-        if (applyStyleSheet != null && applyStyleSheet.equals("on")) {
-            applyStyle = true;
-        } else {
-            applyStyle = false;
-        }
-        boolean applyServerSide;
-        if (serverSide != null && serverSide.equals("on")){
-            applyServerSide = true;
-        } else {
-            applyServerSide = false;
-        }
-        //Graph defaultGraph = null;
-        Object result = null;
-        try {
-            if (defaultGraphUri == null
-                    || defaultGraphUri.getUnicodeString().equals("")) {
-                defaultGraphUri = new Iri(Constants.CONTENT_GRAPH_URI_STRING);
-                //defaultGraph = contentGraph;
-            } else {
-                //defaultGraph = tcManager.getTriples(defaultGraphUri);
-            }
-            //this is now only used to get the variable names
-            //TODO use ResultSet.getResultVars instead
-            Query query = QueryParser.getInstance().parse(queryString);
-            result = tcManager.executeSparqlQuery(queryString, defaultGraphUri);
-            if (result instanceof ImmutableGraph) {
-                return (ImmutableGraph) result;
-            } else if ((result instanceof ResultSet)
-                    || (result instanceof Boolean)) {
-                Source source = toXmlSource(result, query, applyStyle,
-                        applyServerSide, styleSheetUri);
-                if (applyStyle && applyServerSide) {
-                    Response.ResponseBuilder rb = Response.ok(source).type(
-                            MediaType.APPLICATION_XHTML_XML_TYPE);
-                    return rb.build();
-                }
-                return source;
-            } else {
-                throw new WebApplicationException(
-                        Response.status(Status.BAD_REQUEST).entity("Only " +
-                        "queries yielding to a ImmutableGraph, a ResultSet or " +
-                        "Boolean are supported").build());
-            }
-        } catch (ParseException e) {
-            throw createWebApplicationException(e);
-        } catch (NoSuchEntityException e) {
-            throw createWebApplicationException(e);
-        }
-    }
-
-    /**
-     * Returns either a {@link ImmutableGraph} or a {@link DOMSource}. A {@link ImmutableGraph} is
-     * returned if a CONSTRUCT or a DESCRIBE sparql query was submitted and
-     * successfully carried out. A {@link DOMSource} is returned if an ASK or a
-     * SELECT sparql query was submitted and successfully carried out. The query
-     * is performed against a specified graph with the URI
-     * <code>defaultGrapfUri</code>
-     * 
-     * @param queryString
-     * @param defaultGraphUri
-     * @param styleSheetUri
-     * @param serverSide
-     * @return
-     */
-    @GET
-    public Object runGetQuery(@QueryParam("query") String queryString,
-            @QueryParam("default-graph-uri") Iri defaultGraphUri,
-            @QueryParam("style-sheet-uri") String styleSheetUri,
-            @QueryParam("server-side") String serverSide) {
-        AccessController.checkPermission(new SparqlEndpointAccessPermission());
-        String applyStyleSheet = null;
-        if(styleSheetUri != null){
-            applyStyleSheet = "on";
-        }
-        if(serverSide != null && serverSide.equals("true")){
-            serverSide = "on";
-        }
-        return runFormQuery(queryString, defaultGraphUri, applyStyleSheet,
-                serverSide,    styleSheetUri);
-    }
-
-    /**
-     * Helper: returns the variables of a sparql {@link SelectQuery}
-     * 
-     * @param queryString
-     * @return
-     */
-    private List<Variable> getVariables(Query query) {
-        if (query instanceof SelectQuery) {
-            return ((SelectQuery) query).getSelection();
-        } else {
-            return new ArrayList<Variable>();
-        }
-    }
-
-    /**
-     * Helper: transforms a {@link ResultSet} or a {@link Boolean} to a
-     * {@link DOMSource}
-     * 
-     * @param queryResult
-     * @param query
-     * @param applyStyle 
-     */
-    private Source toXmlSource(Object queryResult, Query query,
-            boolean applyStyle, boolean applyServerSide, String styleSheetUri) {
-        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-        try {
-            Document doc = dbf.newDocumentBuilder().newDocument();
-            // adding root element
-            Element root = doc.createElement("sparql");
-            root.setAttribute("xmlns", "http://www.w3.org/2005/sparql-results#");
-            doc.appendChild(root);
-            Element head = doc.createElement("head");
-            root.appendChild(head);
-            if (queryResult instanceof Boolean) {
-                Element booleanElement = doc.createElement("boolean");
-                booleanElement.appendChild(doc.createTextNode(queryResult
-                        .toString()));
-                root.appendChild(booleanElement);
-            } else {
-                List<Variable> variables = getVariables(query);
-                for (Variable var : variables) {
-                    Element varElement = doc.createElement("variable");
-                    varElement.setAttribute("name", var.getName());
-                    head.appendChild(varElement);
-                }
-                root.appendChild(createResultsElement((ResultSet) queryResult,
-                        doc));
-            }
-            DOMSource source = new DOMSource(doc);
-            if (applyStyle) {
-                ProcessingInstruction instruction = doc
-                        .createProcessingInstruction("xml-stylesheet",
-                                "type=\"text/xsl\" href=\"" + styleSheetUri + "\"");
-                doc.insertBefore(instruction, root);
-                if (applyServerSide) {
-                    return applyStyleServerSide(source, styleSheetUri);
-                }
-            }
-            return source;
-
-        } catch (ParserConfigurationException e) {
-            throw createWebApplicationException(e);
-        }
-    }
-
-    /**
-     * Applies a style sheet to a XML on server side
-     * @param source
-     *            XML result
-     * @param styleSheetUri
-     *            URI of the style sheet
-     * @return
-     * @throws TransformerException
-     * @throws IOException
-     */
-    private Source applyStyleServerSide(final DOMSource source,
-            final String styleSheetUri) {
-        return AccessController.doPrivileged(new PrivilegedAction<DOMSource>() {
-            @Override
-            public DOMSource run() {
-                try {
-                    StreamResult streamResult = new StreamResult(
-                            new ByteArrayOutputStream());
-                    final TransformerFactory tf = TransformerFactory
-                            .newInstance();
-                    Transformer transformer = tf.newTransformer();
-                    transformer.transform(source, streamResult);
-                    final URL stylesheet = new URL(styleSheetUri);
-                    Source streamSource = new StreamSource(
-                            new ByteArrayInputStream(
-                            ((ByteArrayOutputStream) streamResult
-                                    .getOutputStream()).toByteArray()));
-                    DOMResult domResult = new DOMResult();
-                    StreamSource xslFileSource = new StreamSource(stylesheet
-                            .openStream());
-                    Transformer xslTransformer = tf.newTransformer(xslFileSource);
-                    xslTransformer.transform(streamSource, domResult);
-                    return new DOMSource(domResult.getNode());
-                } catch (TransformerConfigurationException ex) {
-                    throw createWebApplicationException(ex);
-                } catch (TransformerException ex) {
-                    throw createWebApplicationException(ex);
-                } catch (IOException ex) {
-                    throw createWebApplicationException(ex);
-                }
-            }
-        });
-    }
-
-    /**
-     * Creates a WebApplicationexception and prints a logger entry
-     */
-    private WebApplicationException createWebApplicationException(Exception e) {
-        logger.info(e.getClass().getSimpleName() + ": {}", e.getMessage());
-        return new WebApplicationException(Response.status(Status.BAD_REQUEST)
-                .entity(e.getMessage().replace("<", "&lt;").replace("\n",
-                        "<br/>")).build());
-    }
-
-    /**
-     * Helper: creates results element from ResultSet
-     * 
-     */
-    private Element createResultsElement(ResultSet resultSet, Document doc) {
-        Element results = doc.createElement("results");
-        while (resultSet.hasNext()) {
-            SolutionMapping solutionMap = resultSet.next();
-            Set<Variable> keys = solutionMap.keySet();
-            Element result = doc.createElement("result");
-            results.appendChild(result);
-
-            for (Variable key : keys) {
-                Element bindingElement = doc.createElement("binding");
-                bindingElement.setAttribute("name", key.getName());
-                bindingElement.appendChild(createValueElement(
-                        (RdfTerm) solutionMap.get(key), doc));
-                result.appendChild(bindingElement);
-            }
-        }
-        return results;
-    }
-
-    /**
-     * Helper: creates value element from {@link RdfTerm} depending on its
-     * class
-     * 
-     */
-    private Element createValueElement(RdfTerm resource, Document doc) {
-        Element value = null;
-        if (resource instanceof Iri) {
-            value = doc.createElement("uri");
-            value.appendChild(doc.createTextNode(((Iri) resource)
-                    .getUnicodeString()));
-        } else if (resource instanceof Literal) {
-            value = doc.createElement("literal");
-            value.appendChild(doc.createTextNode(((Literal) resource)
-                    .getLexicalForm()));
-            value.setAttribute("datatype", (((Literal) resource)
-                    .getDataType().getUnicodeString()));
-            Language lang = ((Literal) resource).getLanguage();
-            if (lang != null) {
-                value.setAttribute("xml:lang", (lang.toString()));
-            }
-        } else {
-            value = doc.createElement("bnode");
-            value.appendChild(doc.createTextNode(((BlankNode) resource).toString()));
-        }
-        return value;
-    }
-}

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/SparqlEndpointAccessPermission.java
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/SparqlEndpointAccessPermission.java b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/SparqlEndpointAccessPermission.java
deleted file mode 100644
index 4dd93a3..0000000
--- a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/SparqlEndpointAccessPermission.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.clerezza.rdf.web.core;
-
-import java.security.Permission;
-import org.apache.clerezza.permissiondescriptions.PermissionInfo;
-
-/**
- * Permission to use the Sparql Endpoint GUI. Note that the user
- * additionally needs permission to read a graph.
- *
- * @author tio
- */
-@PermissionInfo(value="Sparql Endpoint Access Permission", description="Grants access " +
-    "to the Sparql Endpoint")
-public class SparqlEndpointAccessPermission extends Permission{
-
-    public SparqlEndpointAccessPermission() {
-        super("Sparql Endpoint Access permission");
-    }
-    /**
-     *
-     * @param target ignored
-     * @param action ignored
-     */
-    public SparqlEndpointAccessPermission(String target, String actions) {
-        super("Sparql Endpoint Access 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 577987;
-    }
-
-    @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/WebAccess.java
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/WebAccess.java b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/WebAccess.java
deleted file mode 100644
index 6a71c01..0000000
--- a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/WebAccess.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.
- * See the NOTICE file distributed with this work for additional
- * information regarding copyright ownership.
- * The ASF licenses this file to you under the Apache License,
- * Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License.
- * You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
- * either express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- */
-package org.apache.clerezza.rdf.web.core;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.security.AccessController;
-import java.util.concurrent.locks.Lock;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.Response.Status;
-import javax.ws.rs.core.UriInfo;
-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.clerezza.jaxrs.utils.RedirectUtil;
-import org.apache.clerezza.jaxrs.utils.form.FormFile;
-import org.apache.clerezza.jaxrs.utils.form.MultiPartBody;
-import org.apache.commons.rdf.ImmutableGraph;
-import org.apache.commons.rdf.Graph;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Graph;
-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.clerezza.rdf.core.serializedform.Parser;
-import org.apache.clerezza.web.fileserver.util.MediaTypeGuesser;
-
-/**
- * Provides methods to GET, PUT, and POST an SCB graph over the web.
- * To be deployed in a JAX-RS runtime.
- * 
- * @author hasan
- */
-@Component
-@Service(Object.class)
-@Property(name="javax.ws.rs", boolValue=true)
-@Path("/graph")
-public class WebAccess {
-
-    @Reference
-    TcManager tcManager;
-
-    @Reference
-    private Parser parser;
-
-    final Logger logger = LoggerFactory.getLogger(WebAccess.class);
-
-    /**
-     * Gets the Graph with specified name
-     *
-     * @param name
-     * @return
-     */
-    @GET
-    public Graph getTriples(@QueryParam("name") Iri name) {
-        AccessController.checkPermission(new WebAccessPermission());
-        if (name == null) {
-            Response r = Response.status(Response.Status.BAD_REQUEST)
-                    .entity("must specify a graph name")
-                    .type(MediaType.TEXT_PLAIN_TYPE).build();
-            throw new WebApplicationException(r);
-        }
-        Graph result = tcManager.getGraph(name);
-        logger.debug("Got graph of size {} ", result.size());
-        int i = 1;
-        if (logger.isDebugEnabled()) {
-            for (Triple triple : result) {
-                logger.debug("({}) with triples {}", i++, triple.toString());
-            }
-            logger.debug("returning");
-        }
-        return result;
-    }
-
-    /**
-     * Puts the triples replacing the triples of the existing Graph with the
-     * specified name. If the graph doesn't exist creates a new <code>Graph</code> 
-     * with the specified name and puts the triples
-     * 
-     *
-     * @param name
-     * @param triples
-     */
-    @PUT
-    public void putTriples(@QueryParam("name") Iri name, Graph triples) {
-        AccessController.checkPermission(new WebAccessPermission());
-        Graph mGraph;
-        try {
-            mGraph = tcManager.getGraph(name);
-        } catch (NoSuchEntityException e) {
-            mGraph = tcManager.createGraph(name);
-        }
-        Lock writeLock = mGraph.getLock().writeLock();
-        writeLock.lock();
-        try {
-            mGraph.clear();
-            mGraph.addAll(triples);
-        } finally {
-            writeLock.unlock();
-        }
-    }
-
-    /**
-     * Posts triples to be placed into an {@link Graph} of the specified name.
-     * If an {@link Graph} with this name doesn't already exist, a new one
-     * is created and filled with the triples posted.
-     * @param form
-     *        a multipart/form-data consisting of:
-     *        - a {@link FormFile} labeled "graph" containing the triples and
-     *            the mime-type.
-     *        - a text field labeled "name" specifying the name of the Graph.
-     *        - an optional text field labeled "mode" specifying the mode.
-     *            If the mode is "replace", existing triples of the Graph will be
-     *            deleted before new triples are added. If the mode is not
-     *            specified or is "append", posted triples are added to the Graph.
-     *        - an optional text field labeled "redirection" specifying an URI
-     *            which the client should be redirected to in case of success.
-     * @return
-     *        {@link Response}. A response with status code BAD REQUEST (400) is
-     *        returned if the required data are missing. If the request can be
-     *        satisfied, one of the following responses is returned:
-     *        - SEE OTHER (303), if redirection is specified.
-     *        - CREATED (201), if redirection is not specified and a new
-     *            {@link Graph} is created.
-     *        - NO CONTENT (204), if redirection is not specified and no new
-     *            {@link Graph} is created.
-     */
-    @POST
-    @Consumes("multipart/form-data")
-    public Response postTriples(MultiPartBody form, @Context UriInfo uriInfo) {
-
-        AccessController.checkPermission(new WebAccessPermission());
-        FormFile[] formFiles = form.getFormFileParameterValues("graph");
-        if (formFiles.length == 0) {
-            responseWithBadRequest("form file parameter 'graph' is missing");
-        }
-        FormFile formFile = formFiles[0];
-        byte[] graph = formFile.getContent();
-        if (graph == null || (graph.length == 0)) {
-            responseWithBadRequest("no triples uploaded");
-        }
-        MediaType mediaType = formFile.getMediaType();
-        if (mediaType == null) {
-            responseWithBadRequest("mime-type not specified");
-        }
-        if (mediaType.equals(MediaType.APPLICATION_OCTET_STREAM_TYPE)) {
-            MediaType guessedType = MediaTypeGuesser.getInstance().guessTypeForName(formFile.getFileName());
-            if (guessedType != null) {
-                mediaType = guessedType;
-            }
-        }
-        String graphName = getFirstTextParameterValue(form, "name", true);
-        if (graphName == null) {
-            responseWithBadRequest("graph name not specified");
-        }
-        String mode = getFirstTextParameterValue(form, "mode", false);
-        if (mode != null) {
-            if (!(mode.equals("replace") || mode.equals("append"))) {
-                responseWithBadRequest("unknown mode");
-            }
-        } else {
-            mode = "append";
-        }
-        InputStream is = new ByteArrayInputStream(graph);
-        ImmutableGraph parsedGraph = parser.parse(is, mediaType.toString());
-        Iri graphUri = new Iri(graphName);
-        Graph mGraph;
-        boolean newGraph = false;
-        try {
-            mGraph = tcManager.getGraph(graphUri);
-        } catch (NoSuchEntityException e) {
-            mGraph = tcManager.createGraph(graphUri);
-            newGraph = true;
-        }
-        Lock writeLock = mGraph.getLock().writeLock();
-        writeLock.lock();
-        try {
-            if (!newGraph && mode.equals("replace")) {
-                mGraph.clear();
-            }
-            mGraph.addAll(parsedGraph);
-        } finally {
-            writeLock.unlock();
-        }
-        String redirection = getFirstTextParameterValue(form, "redirection", false);
-        if (redirection == null) {
-            if (newGraph) {
-                return Response.status(Status.CREATED).build();
-            } else {
-                return Response.status(Status.NO_CONTENT).build();
-            }
-        }
-        return RedirectUtil.createSeeOtherResponse(redirection, uriInfo);
-    }
-
-    @GET
-    @Path("upload-form")
-    @Produces("application/xhtml+xml")
-    public InputStream getUploadForm() {
-        AccessController.checkPermission(new WebAccessPermission());
-        return getClass().getResourceAsStream("upload-form.xhtml");
-    }
-
-    private void responseWithBadRequest(String message) {
-        logger.warn(message);
-        throw new WebApplicationException(Response.status(Status.BAD_REQUEST)
-                .entity(message).build());
-    }
-
-    private String getFirstTextParameterValue(MultiPartBody form,
-            String parameterName, boolean mandatory) {
-        String[] paramValues = form.getTextParameterValues(parameterName);
-        if (paramValues.length == 0) {
-            if (mandatory) {
-                responseWithBadRequest("text parameter '" + parameterName +
-                        "' is missing");
-            }
-            return null;
-        }
-        return paramValues[0];
-    }
-}

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/WebAccessPermission.java
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/WebAccessPermission.java b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/WebAccessPermission.java
deleted file mode 100644
index 8964eda..0000000
--- a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/WebAccessPermission.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.clerezza.rdf.web.core;
-
-import java.security.Permission;
-import org.apache.clerezza.permissiondescriptions.PermissionInfo;
-
-/**
- * Permission to use the ImmutableGraph via Web. Note that the user
- * additionally needs permission to read a graph.
- *
- * @author mir
- */
-@PermissionInfo(value="ImmutableGraph via Web Access Permission", description="Grants access " +
-    "to the ImmutableGraph via Web")
-public class WebAccessPermission extends Permission{
-
-    public WebAccessPermission() {
-        super("ImmutableGraph via Web access permission");
-    }
-    /**
-     *
-     * @param target ignored
-     * @param action ignored
-     */
-    public WebAccessPermission(String target, String actions) {
-        super("ImmutableGraph via Web access 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 477987;
-    }
-
-    @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/utils/ResultSetsWrapper.java
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/utils/ResultSetsWrapper.java b/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/utils/ResultSetsWrapper.java
deleted file mode 100644
index 3187d42..0000000
--- a/rdf.web/rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/utils/ResultSetsWrapper.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- *  Copyright 2010 mir.
- * 
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at
- * 
- *       http://www.apache.org/licenses/LICENSE-2.0
- * 
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *  under the License.
- */
-package org.apache.clerezza.rdf.web.core.utils;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import org.apache.clerezza.rdf.core.sparql.ResultSet;
-import org.apache.clerezza.rdf.core.sparql.SolutionMapping;
-
-/**
- * Wrapps a set of <code>ResultSet</code>s so it acts like a single ResultSet.
- *
- * @author mir
- */
-public class ResultSetsWrapper implements ResultSet {
-
-    private Iterator<ResultSet> resultSetsIter;
-    private ResultSet currentResultSet;
-    private List<String> varNames;
-
-    public ResultSetsWrapper(Set<ResultSet> resultSets) {
-        this.resultSetsIter = resultSets.iterator();
-        this.currentResultSet = resultSetsIter.next();
-
-        Set<String> uniqueVarNames = new HashSet<String>();
-        for (ResultSet resultSet : resultSets) {
-			uniqueVarNames.addAll(resultSet.getResultVars());
-		}
-    	this.varNames = new ArrayList<String>(uniqueVarNames);
-    }
-
-    @Override
-    public boolean hasNext() {
-        if (currentResultSet.hasNext()) {
-            return true;
-        } else {
-            if (resultSetsIter.hasNext()) {
-                currentResultSet = resultSetsIter.next();
-                return hasNext();
-            }
-        }
-        return false;
-    }
-
-    @Override
-    public SolutionMapping next() {
-        hasNext();
-        return currentResultSet.next();
-    }
-
-    @Override
-    public void remove() {
-        currentResultSet.remove();
-    }
-    
-    @Override
-    public List<String> getResultVars() {
-    	return varNames;
-    }
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/d0f43e94/rdf.web/rdf.web.core/src/main/resources/META-INF/documentation.nt
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.core/src/main/resources/META-INF/documentation.nt b/rdf.web/rdf.web.core/src/main/resources/META-INF/documentation.nt
deleted file mode 100644
index daf3e2e..0000000
--- a/rdf.web/rdf.web.core/src/main/resources/META-INF/documentation.nt
+++ /dev/null
@@ -1,52 +0,0 @@
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e99 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#Entry> .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e99 <http://discobits.org/ontology#pos> "1" .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e99 <http://discobits.org/ontology#holds> <bundle:///scb-web-content> .
-<bundle:///scb-web-title> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#XHTMLInfoDiscoBit> .
-<bundle:///scb-web-title> <http://discobits.org/ontology#infoBit> "SCB Web"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral> .
-<bundle:///scb-web-content> <http://discobits.org/ontology#contains> _:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e98 .
-<bundle:///scb-web-content> <http://discobits.org/ontology#contains> _:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e97 .
-<bundle:///scb-web-content> <http://discobits.org/ontology#contains> _:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e96 .
-<bundle:///scb-web-content> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#OrderedContent> .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e98 <http://discobits.org/ontology#pos> "2" .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e98 <http://discobits.org/ontology#holds> <bundle:///scb-web-content-el/2> .
-<bundle:///scb-web-content-el/0-title> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#XHTMLInfoDiscoBit> .
-<bundle:///scb-web-content-el/0-title> <http://discobits.org/ontology#infoBit> "Upload Triples with a POST Request"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral> .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e98 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#Entry> .
-<bundle:///scb-web-content-el/2> <http://discobits.org/ontology#contains> _:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e95 .
-<bundle:///scb-web-content-el/2> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#TitledContent> .
-<bundle:///scb-web-content-el/2> <http://discobits.org/ontology#contains> _:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e94 .
-<bundle:///scb-web-content-el/1> <http://discobits.org/ontology#infoBit> "The bundle SCB Web allows access to SCB graphs over HTTP with JAX-RS."^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral> .
-<bundle:///scb-web-content-el/1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#XHTMLInfoDiscoBit> .
-<bundle:///scb-web-content-el/0> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#TitledContent> .
-<bundle:///scb-web-content-el/0> <http://discobits.org/ontology#contains> _:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e93 .
-<bundle:///scb-web-content-el/0> <http://discobits.org/ontology#contains> _:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e92 .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e94 <http://discobits.org/ontology#holds> <bundle:///scb-web-content-el/2-content> .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e94 <http://discobits.org/ontology#pos> "1" .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e94 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#Entry> .
-<bundle:///scb-web-content-el/0-content> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#XHTMLInfoDiscoBit> .
-<bundle:///scb-web-content-el/0-content> <http://discobits.org/ontology#infoBit> "To upload triples with a POST request, a client can use the URI path \"/graph\" and place the triples and other required information into the body as multipart/form-data which consists of\n<ul xmlns=\"http://www.w3.org/1999/xhtml\">\n<li>a file labeled \"graph\" containing the triples and specifying the mime-type.</li>\n<li>a text field labeled \"name\" specifying the name of the MGraph. If an MGraph with this name does not already exist, a new one will be created.</li>\n<li>an optional text field labeled \"mode\" specifying the mode. If the mode is \"replace\", existing triples of the MGraph will be deleted before new triples are added. If the mode is not specified or is \"append\", posted triples will be added to the MGraph.</li>\n<li>an optional text field labeled \"redirection\" specifying an URI which the client should be redirected to in case of success.</li>\n</ul>\nA response with the status co
 de BAD REQUEST (400) is returned if the required data are missing. If the request can be satisfied, one of the following responses is returned:\n<ul xmlns=\"http://www.w3.org/1999/xhtml\">\n<li>SEE OTHER (303), if redirection is specified.</li>\n<li>CREATED (201), if redirection is not specified and a new MGraph is created.</li>\n<li>NO CONTENT (204), if redirection is not specified and no new MGraph is created.</li>\n</ul>\n<p xmlns=\"http://www.w3.org/1999/xhtml\">\nFor your convenience you may access a web-form at the Uri-Path <code>/graph/upload-form</code>.</p>\n"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral> .
-<bundle:///scb-web-content-el/2-title> <http://discobits.org/ontology#infoBit> "Backup of Triple Collections"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral> .
-<bundle:///scb-web-content-el/2-title> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#XHTMLInfoDiscoBit> .
-<bundle:///scb-web-content-el/2-content> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#XHTMLInfoDiscoBit> .
-<bundle:///scb-web-content-el/2-content> <http://discobits.org/ontology#infoBit> "The platform allows the current user to download all triple collections that he has access to through the URI path \"/admin/backup/download\". The resulted file is a compressed archive in zip format. All triple collections in this file are serialized in N-Triples format. Furthermore, a file called \"triplecollections.nt\" is contained in backup.zip, which describes the mapping of file names to triple collection names.\n"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral> .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e97 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#Entry> .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e97 <http://discobits.org/ontology#pos> "1" .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e97 <http://discobits.org/ontology#holds> <bundle:///scb-web-content-el/0> .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e95 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#Entry> .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e95 <http://discobits.org/ontology#pos> "0" .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e95 <http://discobits.org/ontology#holds> <bundle:///scb-web-content-el/2-title> .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e93 <http://discobits.org/ontology#holds> <bundle:///scb-web-content-el/0-title> .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e93 <http://discobits.org/ontology#pos> "0" .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e93 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#Entry> .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e92 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#Entry> .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e92 <http://discobits.org/ontology#pos> "1" .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e92 <http://discobits.org/ontology#holds> <bundle:///scb-web-content-el/0-content> .
-<bundle:///scb-web> <http://discobits.org/ontology#contains> _:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e99 .
-<bundle:///scb-web> <http://discobits.org/ontology#contains> _:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e91 .
-<bundle:///scb-web> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#TitledContent> .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e96 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#Entry> .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e96 <http://discobits.org/ontology#pos> "0" .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e96 <http://discobits.org/ontology#holds> <bundle:///scb-web-content-el/1> .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e91 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://discobits.org/ontology#Entry> .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e91 <http://discobits.org/ontology#pos> "0" .
-_:AX2dX5ddb458X3aX126d34f9135X3aXX2dX7e91 <http://discobits.org/ontology#holds> <bundle:///scb-web-title> .

http://git-wip-us.apache.org/repos/asf/clerezza/blob/d0f43e94/rdf.web/rdf.web.core/src/main/resources/org/apache/clerezza/rdf/web/core/backup-management.ssp
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.core/src/main/resources/org/apache/clerezza/rdf/web/core/backup-management.ssp b/rdf.web/rdf.web.core/src/main/resources/org/apache/clerezza/rdf/web/core/backup-management.ssp
deleted file mode 100644
index 0c43b13..0000000
--- a/rdf.web/rdf.web.core/src/main/resources/org/apache/clerezza/rdf/web/core/backup-management.ssp
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-resultDocModifier.setTitle("Backup and restore");
-
-<div class="tx-content">
-	<p>
-		<form method="get" action="/admin/backup/download">
-    Retrieve a backup of all graphs. WARNING: while creating the backup parts of clerezza migh be irresponsive.
-			<input type="submit" value="Retrieve Backup" />
-		</form>
-	</p>
-	<p>
-		<form method="post" action="/admin/backup/restore" enctype="multipart/form-data">
-			<input type="file" name="file" />
-			<input type="submit" value="Restore from backup" />
-		</form>
-	</p>
-</div>

http://git-wip-us.apache.org/repos/asf/clerezza/blob/d0f43e94/rdf.web/rdf.web.core/src/main/resources/org/apache/clerezza/rdf/web/core/graph-management.ssp
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.core/src/main/resources/org/apache/clerezza/rdf/web/core/graph-management.ssp b/rdf.web/rdf.web.core/src/main/resources/org/apache/clerezza/rdf/web/core/graph-management.ssp
deleted file mode 100644
index 0b71676..0000000
--- a/rdf.web/rdf.web.core/src/main/resources/org/apache/clerezza/rdf/web/core/graph-management.ssp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-def gm(s: Any) = new UriRef("http://clerezza.org/2010/03/graph-management#"+s)
-def rdf(s: Any) = new UriRef("http://www.w3.org/1999/02/22-rdf-syntax-ns#"+s)
-def tcp(s: Any) = new UriRef("http://clerezza.org/2009/06/tcprovider#"+s)
-
-resultDocModifier.setTitle("Manage Triple Collections");
-resultDocModifier.addNodes2Elem("tx-module", <h1>Manage Triple Collections</h1>);
-
-import org.apache.clerezza.rdf.scala.utils.RichGraphNode
-
-<div id="tx-content">
-<table>
-	<tr><th>Name</th><th>Size</th><th>type</th><th colspan="3">Actions</th></tr>
-				{for (tc <- (res/gm("tripleCollection")).sortBy(tc => tc*)) yield
-					<tr>
-						<td>{tc*}</td>
-						<td>{tc/gm("size")*}</td>
-						<td>{if ((tc/rdf("type")).indexOf(new RichGraphNode(
-						new GraphNode(tcp("MGraph"), res.getGraph))) != -1) {
-						<span>MGraph</span> } else {
-						<span>Graph</span>
-						}
-						}
-						</td>
-						<td>{ifx ((tc/rdf("type")).indexOf(new RichGraphNode(
-						new GraphNode(tcp("MGraph"), res.getGraph))) != -1) {<form action="smush" method="post"><div>
-							<input type="hidden" name="graphName" value={tc*} />
-						<input type="submit" value="smush" /></div></form>}
-						}</td>
-                                                <td><form action="delete" method="post" onsubmit="return confirm('Are you sure you want to delete this graph?');"><div>
-							<input type="hidden" name="graphName" value={tc*} />
-						<input type="submit" value="delete" /></div></form>
-						</td>
-						<td><form action="/graph" method="get"><div>
-							<input type="hidden" name="name" value={tc*} />
-						<input type="submit" value="get" /></div></form>
-						</td>
-					</tr>
-				}
-</table>
-<p><a href="/graph/upload-form">UploadGraph</a></p>
-</div>

http://git-wip-us.apache.org/repos/asf/clerezza/blob/d0f43e94/rdf.web/rdf.web.core/src/main/resources/org/apache/clerezza/rdf/web/core/sparql-endpoint.ssp
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.core/src/main/resources/org/apache/clerezza/rdf/web/core/sparql-endpoint.ssp b/rdf.web/rdf.web.core/src/main/resources/org/apache/clerezza/rdf/web/core/sparql-endpoint.ssp
deleted file mode 100644
index 1e6e233..0000000
--- a/rdf.web/rdf.web.core/src/main/resources/org/apache/clerezza/rdf/web/core/sparql-endpoint.ssp
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-def se(s: Any) = new UriRef("http://clerezza.org/2009/11/sparql-endpoint#"+s)
-<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en">
-	<head>
-		<title>SPARQL Endpoint</title>
-		<script type="text/javascript">
-			function toggle(checkbox){{
-				var uri = document.getElementById('stylesheeturi');
-				var urilable = document.getElementById('urilable');
-				var server = document.getElementById('server');
-				var serverlabel = document.getElementById('serverlabel');
-				if (checkbox.checked){{
-					uri.style.visibility = 'visible';
-					urilable.style.visibility = 'visible';
-					server.style.visibility = 'visible';
-					serverlabel.style.visibility = 'visible';
-				}} else {{
-					uri.style.visibility = 'hidden';
-					urilable.style.visibility = 'hidden';
-					server.style.visibility = 'hidden';
-					serverlabel.style.visibility = 'hidden';
-				}}
-			}}
-		</script>
-	</head>
-	<body>
-		<h1>SPARQL Endpoint</h1>
-		<hr />
-		<h4>SPARQL Query</h4>
-		<form method="post" action="../sparql">
-			<lable for="query">Type in your query:</lable>
-			<br />
-			<textarea cols="70" rows="10" name="query" >
-PREFIX rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#>
-PREFIX disco: &lt;http://discobits.org/ontology#>
-SELECT ?c where {{?c rdf:type disco:TitledContent}}
-			</textarea>
-			<br />
-			<br />
-			<label for="default-graph-uri">Select a graph URI:</label>
-			<select	name="default-graph-uri">
-				{for (tc <- (res/se("tripleCollection"))) yield
-					<option>{tc*}</option>
-				}
-			</select>
-			<br />
-			<lable for="apply-style-sheet">Add XSLT style sheet on the result: </lable>
-			<input type="checkbox" name="apply-style-sheet" id="checkbox" onclick="toggle(this)" />
-			<br />
-			<label for="style-sheet-uri" id="urilable" style="visibility:hidden">URI of XSLT style sheet</label>
-			<input type="text" name="style-sheet-uri" id="stylesheeturi" style="width:350px;visibility:hidden" value="http://www.w3.org/TR/rdf-sparql-XMLres/result-to-html.xsl" />
-			<label id="serverlabel" style="visibility:hidden">Add stylesheet on server side</label>
-			<input type="checkbox" name="server-side" id="server" checked="checked" style="visibility:hidden"/>
-			<br />
-			<br />
-			<input type="submit" value="Submit Query" />
-		</form>
-	</body>
-</html>

http://git-wip-us.apache.org/repos/asf/clerezza/blob/d0f43e94/rdf.web/rdf.web.core/src/main/resources/org/apache/clerezza/rdf/web/core/upload-form.xhtml
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.core/src/main/resources/org/apache/clerezza/rdf/web/core/upload-form.xhtml b/rdf.web/rdf.web.core/src/main/resources/org/apache/clerezza/rdf/web/core/upload-form.xhtml
deleted file mode 100644
index f2d1283..0000000
--- a/rdf.web/rdf.web.core/src/main/resources/org/apache/clerezza/rdf/web/core/upload-form.xhtml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?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.
-
--->
-
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-    <head>
-        <title>Upload triples</title>
-    </head>
-    <body>
-        
-            <form method="post" enctype="multipart/form-data" action="/graph">
-				<div>
-				<label for="graph">RDF File: </label><input id="graph" type="file" name="graph" /><br/>
-				<label for="name">Graph Name: </label>
-				<input type="text" id="name" name="name" value="urn:x-localinstance:/content.graph" size="80"/><br/>
-				<label for="mode">Insertion Mode (for existing Graphs): </label><select name="mode">
-					<option value="append">Append</option>
-					<option value="replace">Replace</option>
-				</select>
-				<input type="hidden" name="redirection" value="/graph/upload-form" /><br/>
-				<input type="submit" />
-				</div>
-			</form>
-
-    </body>
-</html>

http://git-wip-us.apache.org/repos/asf/clerezza/blob/d0f43e94/rdf.web/rdf.web.core/src/test/java/org/apache/clerezza/rdf/web/core/BackupAndRestoreTest.java
----------------------------------------------------------------------
diff --git a/rdf.web/rdf.web.core/src/test/java/org/apache/clerezza/rdf/web/core/BackupAndRestoreTest.java b/rdf.web/rdf.web.core/src/test/java/org/apache/clerezza/rdf/web/core/BackupAndRestoreTest.java
deleted file mode 100644
index a43a6a2..0000000
--- a/rdf.web/rdf.web.core/src/test/java/org/apache/clerezza/rdf/web/core/BackupAndRestoreTest.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.clerezza.rdf.web.core;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-import org.apache.commons.rdf.ImmutableGraph;
-import org.apache.commons.rdf.Graph;
-import org.apache.commons.rdf.Triple;
-import org.apache.commons.rdf.Graph;
-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.clerezza.rdf.core.access.TcProvider;
-import org.apache.commons.rdf.impl.utils.simple.SimpleGraph;
-import org.apache.commons.rdf.impl.utils.TripleImpl;
-import org.apache.clerezza.rdf.core.serializedform.Parser;
-import org.apache.clerezza.rdf.core.serializedform.ParsingProvider;
-import org.apache.clerezza.rdf.core.serializedform.Serializer;
-import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
-import org.apache.clerezza.rdf.jena.parser.JenaParserProvider;
-import org.apache.clerezza.rdf.jena.serializer.JenaSerializerProvider;
-import org.apache.clerezza.rdf.ontologies.RDF;
-import org.apache.clerezza.rdf.web.ontologies.BACKUP;
-import org.apache.commons.rdf.Literal;
-import org.easymock.EasyMock;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Tests backup functionality.
- *
- * @author hasan
- */
-public class BackupAndRestoreTest {
-
-    private static String testGraphFileName = "test.graph";
-
-    private static Graph testGraph0 = new SimpleGraph();
-    private static Iri testGraphUri0 = // the URI of testGraph0
-            new Iri("http://localhost/test0/"+testGraphFileName);
-    // a resource in testGraph0
-    private    static Iri uri0 = new Iri("http://localhost/test0/testuri");
-
-    private static Graph testGraph1 = new SimpleGraph();
-    private static Iri testGraphUri1 = // the URI of testGraph1
-            new Iri("http://localhost/test1/"+testGraphFileName);
-
-    // a resource in testGraph1
-    private    static Iri uri1 = new Iri("http://localhost/test1/testuri");
-
-    private static ImmutableGraph testGraphA;
-    private static Iri testGraphUriA = // the URI of testGraphA
-            new Iri("http://localhost/testA/"+testGraphFileName);
-
-    // a resource in testGraphA
-    private    static Iri uriA = new Iri("http://localhost/testA/testuri");
-    
-
-    private static String backupContentFileName = "triplecollections.nt";
-    private static BackupMessageBodyWriter backup;
-    private static Parser parser = Parser.getInstance();
-
-    @Before
-    public void setUp() {
-        backup = new BackupMessageBodyWriter();
-        backup.tcManager = new TestTcManager();
-        backup.serializer = Serializer.getInstance();
-        backup.serializer.bindSerializingProvider(
-                new JenaSerializerProvider());
-        testGraph0.add(new TripleImpl(uri0, uri0, uri0));
-        testGraph1.add(new TripleImpl(uri1, uri1, uri1));
-        Graph graphBuilder = new SimpleGraph();
-        graphBuilder.add(new TripleImpl(uriA, uriA, uriA));
-        testGraphA = graphBuilder.getImmutableGraph();
-    }
-
-    @Test
-    public void testBackup() throws IOException {
-        //ImmutableGraph downloadedTestGraphX = null;
-        //ImmutableGraph downloadedTestGraphY = null;
-        ImmutableGraph downloadedBackupContentsGraph = null;
-
-        byte[] download = backup.createBackup();
-        ByteArrayInputStream bais = new ByteArrayInputStream(download);
-        ZipInputStream compressedTcs = new ZipInputStream(bais);
-
-        Map<String, Graph> extractedTc = new HashMap<String, Graph>();
-        String folder = "";
-        ZipEntry entry;
-        while ((entry = compressedTcs.getNextEntry()) != null) {
-            String entryName = entry.getName();
-            if (entry.isDirectory()) {
-                folder = entryName;
-            } else {
-                Assert.assertTrue(entryName.startsWith(folder+testGraphFileName)
-                        || entryName.equals(backupContentFileName));
-                ByteArrayOutputStream baos = new ByteArrayOutputStream(download.length);
-                int count;
-                byte buffer[] = new byte[2048];
-                while ((count = compressedTcs.read(buffer, 0, 2048)) != -1) {
-                    baos.write(buffer, 0, count);
-                }
-                ByteArrayInputStream serializedGraph = new ByteArrayInputStream(
-                        baos.toByteArray());
-                /*if (entryName.equals(folder+testGraphFileName + ".nt")) {
-                    downloadedTestGraphX = parser.parse(serializedGraph,
-                            SupportedFormat.N_TRIPLE, null);
-                } else if (entryName.startsWith(folder+testGraphFileName)) {
-                    downloadedTestGraphY = parser.parse(serializedGraph,
-                            SupportedFormat.N_TRIPLE, null);
-                }*/
-                if (entryName.equals(backupContentFileName)) {
-                    downloadedBackupContentsGraph = parser.parse(serializedGraph,
-                            SupportedFormat.N_TRIPLE, null);
-                } else {
-                    ImmutableGraph deserializedGraph = parser.parse(serializedGraph,
-                            SupportedFormat.N_TRIPLE, null);
-                    extractedTc.put(entryName, deserializedGraph);
-                }
-                baos.flush();
-                baos.close();
-            }
-        }
-        compressedTcs.close();
-        checkDownloadedGraphs(extractedTc,
-                downloadedBackupContentsGraph, folder);
-    }
-
-    @Test
-    public void restoreFromBackup() throws IOException {
-        byte[] backupData = backup.createBackup();
-        TcProvider tcProvider = EasyMock.createMock(TcProvider.class);
-        EasyMock.expect(tcProvider.getGraph(testGraphUri0)).andReturn(
-                EasyMock.createNiceMock(Graph.class));
-        EasyMock.expect(tcProvider.getGraph(testGraphUri1)).andReturn(
-                EasyMock.createNiceMock(Graph.class));
-        tcProvider.deleteGraph(testGraphUriA);
-        EasyMock.expect(tcProvider.createImmutableGraph(EasyMock.eq(testGraphUriA),
-                EasyMock.notNull(Graph.class))).andReturn(new SimpleGraph().getImmutableGraph());
-        EasyMock.replay(tcProvider);
-        Restorer restore = new Restorer();
-        restore.parser = Parser.getInstance();
-        restore.restore(new ByteArrayInputStream(backupData), tcProvider);
-        EasyMock.verify(tcProvider);
-    }
-
-    private void checkDownloadedGraphs(Map<String, Graph> extractedTc,
-            ImmutableGraph downloadedBackupContentsGraph, String folder) {
-        Assert.assertFalse(extractedTc.isEmpty());
-        Assert.assertNotNull(downloadedBackupContentsGraph);
-
-        Assert.assertTrue(downloadedBackupContentsGraph.contains(new TripleImpl(
-                testGraphUri0, RDF.type, BACKUP.Graph)));
-
-        Iterator<Triple> triples = downloadedBackupContentsGraph.filter(
-                testGraphUri0, BACKUP.file, null);
-        Assert.assertTrue(triples.hasNext());
-
-        String fileName0 = ((Literal) triples.next().getObject()).getLexicalForm();
-        Assert.assertTrue(fileName0.startsWith(folder+testGraphFileName));
-
-        Graph extracted0 = extractedTc.get(fileName0);
-        Assert.assertNotNull(extracted0);
-        Assert.assertTrue(extracted0.filter(uri0, uri0, uri0).hasNext());
-
-        Assert.assertTrue(downloadedBackupContentsGraph.contains(new TripleImpl(
-                testGraphUri1, RDF.type, BACKUP.Graph)));
-
-        triples = downloadedBackupContentsGraph.filter(
-                testGraphUri1, BACKUP.file, null);
-        Assert.assertTrue(triples.hasNext());
-
-        String fileName1 = ((Literal) triples.next().getObject()).getLexicalForm();
-        Assert.assertTrue(fileName1.startsWith(folder+testGraphFileName));
-
-        Graph extracted1 = extractedTc.get(fileName1);
-        Assert.assertNotNull(extracted1);
-
-        Assert.assertTrue(extracted1.filter(uri1, uri1, uri1).hasNext());
-    
-
-
-        Assert.assertTrue(downloadedBackupContentsGraph.contains(new TripleImpl(
-                testGraphUriA, RDF.type, BACKUP.Graph)));
-
-        triples = downloadedBackupContentsGraph.filter(
-                testGraphUriA, BACKUP.file, null);
-        Assert.assertTrue(triples.hasNext());
-
-        String fileNameA = ((Literal) triples.next().getObject()).getLexicalForm();
-        Assert.assertTrue(fileNameA.startsWith(folder+testGraphFileName));
-        Graph extractedA = extractedTc.get(fileNameA);
-        Assert.assertNotNull(extractedA);
-
-        Assert.assertTrue(extractedA.filter(uriA, uriA, uriA).hasNext());
-
-    }
-
-    private class TestTcManager extends TcManager {
-
-        // Associates testGraphUri0 with testGraph0 and testGraphUri1 with testGraph1
-        @Override
-        public Graph getGraph(Iri name) throws NoSuchEntityException {
-            if (name.equals(testGraphUri0)) {
-                return testGraph0;
-            } else if (name.equals(testGraphUri1)) {
-                return testGraph1;
-            } else if (name.equals(testGraphUriA)) {
-                return testGraphA;
-            }
-            return null;
-        }
-
-        @Override
-        public Set<Iri> listGraphs() {
-            Set<Iri> result = new HashSet<Iri>();
-            result.add(testGraphUri0);
-            result.add(testGraphUri1);
-            result.add(testGraphUriA);
-            return result;
-        }
-    }
-}
\ No newline at end of file