[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java
From: |
Benja Fallenstein |
Subject: |
[Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java |
Date: |
Sat, 24 May 2003 10:38:55 -0400 |
CVSROOT: /cvsroot/storm
Module name: storm
Changes by: Benja Fallenstein <address@hidden> 03/05/24 10:38:55
Modified files:
org/nongnu/storm/util: HTTPProxy.java
Log message:
Creating new pointers through web interface
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/storm/storm/org/nongnu/storm/util/HTTPProxy.java.diff?tr1=1.40&tr2=1.41&r1=text&r2=text
Patches:
Index: storm/org/nongnu/storm/util/HTTPProxy.java
diff -u storm/org/nongnu/storm/util/HTTPProxy.java:1.40
storm/org/nongnu/storm/util/HTTPProxy.java:1.41
--- storm/org/nongnu/storm/util/HTTPProxy.java:1.40 Sat May 24 08:19:41 2003
+++ storm/org/nongnu/storm/util/HTTPProxy.java Sat May 24 10:38:55 2003
@@ -222,6 +222,21 @@
writeRewriteLinks(w, rewrite);
+ w.write("<h2>New pointer</h2>\n\n");
+
+ w.write("<FORM action=\"/new-pointer\" method=\"post\">\n");
+ w.write("<P>\n");
+ w.write("Title: <INPUT type=\"text\" name=\"title\">");
+ w.write("<SELECT name=\"target\">\n");
+ w.write("<OPTION selected
value=\"urn:x-storm:1.0:text/plain,3i42h3s6nnfq2msvx7xzkyayscx5qbyj.lwpnacqdbzryxw3vhjvcj64qbznghohhhzwclnq\">Text
file</OPTION>\n");
+ w.write("<OPTION
value=\"urn:x-storm:1.0:application/vnd.kde.kword,ly3m5evqznmuxnuxyduv43ikvor2dkze.gxeygfionykrrizvwkoyevkdysdnrksw4t5i2yi\">KWord
file</OPTION>\n");
+ w.write("</SELECT>\n");
+ w.write("<INPUT type=\"submit\" value=\"Create\">\n");
+ w.write("</P>\n");
+ w.write("</FORM>\n\n");
+
+ w.write("<h2>Pointers</h2>\n\n");
+
PointerIndex pIndex =
(PointerIndex)pool.getIndex(PointerIndex.uri);
@@ -253,7 +268,7 @@
}
}
- w.write("<p>");
+ w.write("<h2>Blocks</h2>\n\n");
synchronized(ids) {
for(Iterator i=ids.iterator(); i.hasNext();) {
@@ -392,6 +407,9 @@
return resp;
}
+ /** PUTting to a pointer creates a new block
+ * and points the pointer to it.
+ */
protected HTTPResponse doPut(HTTPRequest req, HTTPResponse.Factory
resf)
throws IOException {
@@ -446,6 +464,72 @@
if(dbg) p("Return response");
return resp;
}
+
+ /** POSTing to /new-pointer creates a new pointer.
+ * Options are <code>title</code>, the title of the
+ * new pointer, and <code>target</code>, the URI
+ * of the block the new pointer will point to first.
+ */
+ protected HTTPResponse doPost(HTTPRequest req, HTTPResponse.Factory
resf)
+ throws IOException {
+
+ String uri = req.getRequestURI();
+ System.out.println("POST: "+uri);
+
+ if(!acceptPut)
+ return doUnknown(req, resf);
+
+ if(!uri.equals("/new-pointer"))
+ return resf.makeError(404, "Not found");
+
+ String formdata =
+ CopyUtil.readString(req.getInputStream());
+ if(dbg) p("Form data: "+formdata);
+
+ int i = formdata.indexOf("title=") + "title=".length();
+ int j = formdata.indexOf('&', i);
+ if(j < 0) j = formdata.length();
+ String title =
+ java.net.URLDecoder.decode(formdata.substring(i,j));
+
+ i = formdata.indexOf("target=") + "target=".length();
+ j = formdata.indexOf('&', i);
+ if(j < 0) j = formdata.length();
+ String targetURI =
+ java.net.URLDecoder.decode(formdata.substring(i,j));
+ p(targetURI);
+ BlockId target = new BlockId(targetURI);
+
+ PointerId id;
+ PointerIndex idx =
+ (PointerIndex)pool.getIndex(PointerIndex.uri);
+
+ try {
+ id = new PointerId(keyPair.getPublic());
+ if(title.trim().equals(""))
+ idx.set(id, target, keyPair, null);
+ else
+ idx.set(id, target, keyPair, title);
+ } catch(Exception _) {
+ _.printStackTrace();
+ throw new Error("Exception while creating pointer XXX");
+ }
+
+ HTTPResponse resp = resf.makeResponse(203, "Created");
+ resp.setField("Content-Type", "text/html");
+ resp.setField("Location", target.getURI());
+ Writer w = new OutputStreamWriter(resp.getOutputStream(),
+ "US-ASCII");
+ w.write("<html><head><title>Created</title></head><body>");
+ w.write("New pointer created at: \n");
+ w.write("<a href=\""+id.getURI()+"\">"+id.getURI()+"</a>\n");
+ w.write("<p><a href=\"/\">Back to the home page.</a>\n");
+ w.write("</body></html>");
+ w.close();
+
+ if(dbg) p("Return response");
+ return resp;
+ }
}
protected BlockId getBlockId(String uri) {
- [Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java, (continued)
- [Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java, Tuukka Hastrup, 2003/05/08
- [Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java, Tuukka Hastrup, 2003/05/08
- [Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java, Tuukka Hastrup, 2003/05/08
- [Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java, Tuukka Hastrup, 2003/05/08
- [Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java, Tuukka Hastrup, 2003/05/13
- [Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java, Benja Fallenstein, 2003/05/21
- [Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java, Benja Fallenstein, 2003/05/21
- [Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java, Benja Fallenstein, 2003/05/22
- [Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java, Benja Fallenstein, 2003/05/22
- [Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java, Benja Fallenstein, 2003/05/22
- [Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java,
Benja Fallenstein <=
- [Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java, Benja Fallenstein, 2003/05/24
- [Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java, Benja Fallenstein, 2003/05/25
- [Gzz-commits] storm/org/nongnu/storm/util HTTPProxy.java, Tuukka Hastrup, 2003/05/26