Author: reto
Date: Tue Feb 16 10:33:26 2010
New Revision: 910455
URL: http://svn.apache.org/viewvc?rev=910455&view=rev
Log:
CLEREZZA-127: added form for triples upload
Added:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.rdf.web/org.apache.clerezza.rdf.web.core/src/main/resources/org/apache/clerezza/rdf/web/core/upload-form.xhtml
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.rdf.web/org.apache.clerezza.rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/WebAccess.java
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.rdf.web/org.apache.clerezza.rdf.web.core/src/main/resources/META-INF/documentation.nt
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.rdf.web/org.apache.clerezza.rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/WebAccess.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.rdf.web/org.apache.clerezza.rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/WebAccess.java?rev=910455&r1=910454&r2=910455&view=diff
==============================================================================
---
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.rdf.web/org.apache.clerezza.rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/WebAccess.java
(original)
+++
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.rdf.web/org.apache.clerezza.rdf.web.core/src/main/java/org/apache/clerezza/rdf/web/core/WebAccess.java
Tue Feb 16 10:33:26 2010
@@ -16,203 +16,211 @@
* 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 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.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.clerezza.rdf.core.Graph;
-import org.apache.clerezza.rdf.core.MGraph;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.clerezza.rdf.core.Triple;
-import org.apache.clerezza.rdf.core.TripleCollection;
-import org.apache.clerezza.rdf.core.UriRef;
-import org.apache.clerezza.rdf.core.access.NoSuchEntityException;
-import org.apache.clerezza.rdf.core.access.TcManager;
-import org.apache.clerezza.rdf.core.serializedform.Parser;
-
-/**
- * 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 TripleCollection with specified name
- *
- * @param name
- * @return
- */
- @GET
- public TripleCollection getTriples(@QueryParam("name") UriRef name) {
- 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);
- }
- TripleCollection result = tcManager.getTriples(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 MGraph with
the
- * specified name. If the graph doesn't exist creates a new
<code>MGraph</code>
- * with the specified name and puts the triples
- *
- *
- * @param name
- * @param triples
- */
- @PUT
- public void putTriples(@QueryParam("name") UriRef name,
TripleCollection triples) {
- TripleCollection tc;
- try {
- tc = tcManager.getTriples(name);
- tc.clear();
- } catch (NoSuchEntityException e) {
- tc = tcManager.createMGraph(name);
- }
- tc.addAll(triples);
- }
-
- /**
- * Posts triples to be placed into an {...@link MGraph} of the
specified name.
- * If an {...@link MGraph} 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 MGraph.
- * - 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 are
added to the MGraph.
- * - 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 MGraph} is created.
- * - NO CONTENT (204), if redirection is not specified and
no new
- * {...@link MGraph} is created.
- */
- @POST
- @Consumes("multipart/form")
- public Response postTriples(MultiPartBody form, @Context UriInfo
uriInfo) {
-
- 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");
- }
- InputStream is = new ByteArrayInputStream(graph);
-
- MediaType mediaType = formFile.getMediaType();
- if (mediaType == null) {
- responseWithBadRequest("mime-type not specified");
- }
- Graph parsedGraph = parser.parse(is, mediaType.toString());
-
- String graphName = getFirstTextParameterValue(form, "name",
true);
- if (graphName == null) {
- responseWithBadRequest("graph name not specified");
- }
- UriRef graphUri = new UriRef(graphName);
- TripleCollection tc;
- boolean newGraph = false;
- try {
- tc = tcManager.getTriples(graphUri);
- String mode = getFirstTextParameterValue(form, "mode",
false);
- if (mode != null) {
- if (mode.equals("replace")) {
- tc.clear();
- } else if (!mode.equals("append")) {
- responseWithBadRequest("unknown mode");
- }
- }
- } catch (NoSuchEntityException e) {
- tc = tcManager.createMGraph(graphUri);
- newGraph = true;
- }
- tc.addAll(parsedGraph);
- 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);
- }
-
- 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];
- }
-}
+package org.apache.clerezza.rdf.web.core;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+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.clerezza.rdf.core.Graph;
+import org.apache.clerezza.rdf.core.MGraph;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.clerezza.rdf.core.Triple;
+import org.apache.clerezza.rdf.core.TripleCollection;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.access.NoSuchEntityException;
+import org.apache.clerezza.rdf.core.access.TcManager;
+import org.apache.clerezza.rdf.core.serializedform.Parser;
+
+/**
+ * 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 TripleCollection with specified name
+ *
+ * @param name
+ * @return
+ */
+ @GET
+ public TripleCollection getTriples(@QueryParam("name") UriRef name) {
+ 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);
+ }
+ TripleCollection result = tcManager.getTriples(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 MGraph with
the
+ * specified name. If the graph doesn't exist creates a new
<code>MGraph</code>
+ * with the specified name and puts the triples
+ *
+ *
+ * @param name
+ * @param triples
+ */
+ @PUT
+ public void putTriples(@QueryParam("name") UriRef name,
TripleCollection triples) {
+ TripleCollection tc;
+ try {
+ tc = tcManager.getTriples(name);
+ tc.clear();
+ } catch (NoSuchEntityException e) {
+ tc = tcManager.createMGraph(name);
+ }
+ tc.addAll(triples);
+ }
+
+ /**
+ * Posts triples to be placed into an {...@link MGraph} of the
specified name.
+ * If an {...@link MGraph} 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 MGraph.
+ * - 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 are
added to the MGraph.
+ * - 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 MGraph} is created.
+ * - NO CONTENT (204), if redirection is not specified and
no new
+ * {...@link MGraph} is created.
+ */
+ @POST
+ @Consumes("multipart/form")
+ public Response postTriples(MultiPartBody form, @Context UriInfo
uriInfo) {
+
+ 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");
+ }
+ InputStream is = new ByteArrayInputStream(graph);
+
+ MediaType mediaType = formFile.getMediaType();
+ if (mediaType == null) {
+ responseWithBadRequest("mime-type not specified");
+ }
+ Graph parsedGraph = parser.parse(is, mediaType.toString());
+
+ String graphName = getFirstTextParameterValue(form, "name",
true);
+ if (graphName == null) {
+ responseWithBadRequest("graph name not specified");
+ }
+ UriRef graphUri = new UriRef(graphName);
+ TripleCollection tc;
+ boolean newGraph = false;
+ try {
+ tc = tcManager.getTriples(graphUri);
+ String mode = getFirstTextParameterValue(form, "mode",
false);
+ if (mode != null) {
+ if (mode.equals("replace")) {
+ tc.clear();
+ } else if (!mode.equals("append")) {
+ responseWithBadRequest("unknown mode");
+ }
+ }
+ } catch (NoSuchEntityException e) {
+ tc = tcManager.createMGraph(graphUri);
+ newGraph = true;
+ }
+ tc.addAll(parsedGraph);
+ 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() {
+ 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];
+ }
+}
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.rdf.web/org.apache.clerezza.rdf.web.core/src/main/resources/META-INF/documentation.nt
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.rdf.web/org.apache.clerezza.rdf.web.core/src/main/resources/META-INF/documentation.nt?rev=910455&r1=910454&r2=910455&view=diff
==============================================================================
---
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.rdf.web/org.apache.clerezza.rdf.web.core/src/main/resources/META-INF/documentation.nt
(original)
+++
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.rdf.web/org.apache.clerezza.rdf.web.core/src/main/resources/META-INF/documentation.nt
Tue Feb 16 10:33:26 2010
@@ -1,52 +1,52 @@
-_:A68e2cd06X3aX12545840449X3aXX2dX7a91
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://discobits.org/ontology#Entry> .
-_:A68e2cd06X3aX12545840449X3aXX2dX7a91 <http://discobits.org/ontology#pos> "1"
.
-_:A68e2cd06X3aX12545840449X3aXX2dX7a91 <http://discobits.org/ontology#holds>
<bundle:///scb-web-content> .
+_: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> .
-_:A68e2cd06X3aX12545840449X3aXX2dX7a90 <http://discobits.org/ontology#holds>
<bundle:///scb-web-content-el/0-title> .
-_:A68e2cd06X3aX12545840449X3aXX2dX7a90 <http://discobits.org/ontology#pos> "0"
.
-_:A68e2cd06X3aX12545840449X3aXX2dX7a90
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://discobits.org/ontology#Entry> .
-<bundle:///scb-web-content> <http://discobits.org/ontology#contains>
_:A68e2cd06X3aX12545840449X3aXX2dX7a8f .
-<bundle:///scb-web-content> <http://discobits.org/ontology#contains>
_:A68e2cd06X3aX12545840449X3aXX2dX7a8e .
-<bundle:///scb-web-content> <http://discobits.org/ontology#contains>
_:A68e2cd06X3aX12545840449X3aXX2dX7a8d .
+<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> .
-<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://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/2> <http://discobits.org/ontology#contains>
_:A68e2cd06X3aX12545840449X3aXX2dX7a8c .
+<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>
_:A68e2cd06X3aX12545840449X3aXX2dX7a8b .
-_:A68e2cd06X3aX12545840449X3aXX2dX7a8b <http://discobits.org/ontology#holds>
<bundle:///scb-web-content-el/2-title> .
-_:A68e2cd06X3aX12545840449X3aXX2dX7a8b <http://discobits.org/ontology#pos> "0"
.
-_:A68e2cd06X3aX12545840449X3aXX2dX7a8b
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://discobits.org/ontology#Entry> .
-<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/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/0> <http://discobits.org/ontology#contains>
_:A68e2cd06X3aX12545840449X3aXX2dX7a8a .
-<bundle:///scb-web-content-el/0> <http://discobits.org/ontology#contains>
_:A68e2cd06X3aX12545840449X3aXX2dX7a90 .
+<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> .
-_:A68e2cd06X3aX12545840449X3aXX2dX7a8e
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://discobits.org/ontology#Entry> .
-_:A68e2cd06X3aX12545840449X3aXX2dX7a8e <http://discobits.org/ontology#pos> "1"
.
-_:A68e2cd06X3aX12545840449X3aXX2dX7a8e <http://discobits.org/ontology#holds>
<bundle:///scb-web-content-el/0> .
-_:A68e2cd06X3aX12545840449X3aXX2dX7a8a
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://discobits.org/ontology#Entry> .
-_:A68e2cd06X3aX12545840449X3aXX2dX7a8a <http://discobits.org/ontology#pos> "1"
.
-_:A68e2cd06X3aX12545840449X3aXX2dX7a8a <http://discobits.org/ontology#holds>
<bundle:///scb-web-content-el/0-content> .
-<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/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 s
tatus 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:\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"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral>
.
+<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 s
tatus 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:\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> .
-_:A68e2cd06X3aX12545840449X3aXX2dX7a8d
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://discobits.org/ontology#Entry> .
-_:A68e2cd06X3aX12545840449X3aXX2dX7a8d <http://discobits.org/ontology#pos> "0"
.
-_:A68e2cd06X3aX12545840449X3aXX2dX7a8d <http://discobits.org/ontology#holds>
<bundle:///scb-web-content-el/1> .
<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> .
-_:A68e2cd06X3aX12545840449X3aXX2dX7a8f
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://discobits.org/ontology#Entry> .
-_:A68e2cd06X3aX12545840449X3aXX2dX7a8f <http://discobits.org/ontology#pos> "2"
.
-_:A68e2cd06X3aX12545840449X3aXX2dX7a8f <http://discobits.org/ontology#holds>
<bundle:///scb-web-content-el/2> .
-_:A68e2cd06X3aX12545840449X3aXX2dX7a89
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://discobits.org/ontology#Entry> .
-_:A68e2cd06X3aX12545840449X3aXX2dX7a89 <http://discobits.org/ontology#pos> "0"
.
-_:A68e2cd06X3aX12545840449X3aXX2dX7a89 <http://discobits.org/ontology#holds>
<bundle:///scb-web-title> .
-<bundle:///scb-web> <http://discobits.org/ontology#contains>
_:A68e2cd06X3aX12545840449X3aXX2dX7a91 .
-<bundle:///scb-web> <http://discobits.org/ontology#contains>
_:A68e2cd06X3aX12545840449X3aXX2dX7a89 .
+_: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> .
-_:A68e2cd06X3aX12545840449X3aXX2dX7a8c
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://discobits.org/ontology#Entry> .
-_:A68e2cd06X3aX12545840449X3aXX2dX7a8c <http://discobits.org/ontology#pos> "1"
.
-_:A68e2cd06X3aX12545840449X3aXX2dX7a8c <http://discobits.org/ontology#holds>
<bundle:///scb-web-content-el/2-content> .
+_: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> .
Added:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.rdf.web/org.apache.clerezza.rdf.web.core/src/main/resources/org/apache/clerezza/rdf/web/core/upload-form.xhtml
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.rdf.web/org.apache.clerezza.rdf.web.core/src/main/resources/org/apache/clerezza/rdf/web/core/upload-form.xhtml?rev=910455&view=auto
==============================================================================
---
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.rdf.web/org.apache.clerezza.rdf.web.core/src/main/resources/org/apache/clerezza/rdf/web/core/upload-form.xhtml
(added)
+++
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.webapp.parent/org.apache.clerezza.rdf.web/org.apache.clerezza.rdf.web.core/src/main/resources/org/apache/clerezza/rdf/web/core/upload-form.xhtml
Tue Feb 16 10:33:26 2010
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!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="http://tpf.localhost/content.graph" size="80"/><br/>
+ <input type="hidden" name="redirection"
value="/graph/upload-form" /><br/>
+ <input type="submit" />
+ </div>
+ </form>
+
+ </body>
+</html>