diff options
Diffstat (limited to 'source/com/c2kernel/process/ItemHTTPBridge.java')
| -rwxr-xr-x | source/com/c2kernel/process/ItemHTTPBridge.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/source/com/c2kernel/process/ItemHTTPBridge.java b/source/com/c2kernel/process/ItemHTTPBridge.java new file mode 100755 index 0000000..8ef2e58 --- /dev/null +++ b/source/com/c2kernel/process/ItemHTTPBridge.java @@ -0,0 +1,52 @@ +package com.c2kernel.process;
+
+import java.util.StringTokenizer;
+
+import com.c2kernel.entity.C2KLocalObject;
+import com.c2kernel.lookup.DomainPath;
+import com.c2kernel.lookup.EntityPath;
+import com.c2kernel.utils.CastorXMLUtility;
+import com.c2kernel.utils.server.HTTPRequestHandler;
+
+/* QueryData over HTTP Socket Handler
+ * Processes an HTTP request consisting of /<path to item>/<path to kernel object>
+ * and returns that kernel object as XML
+ * Currently supports GET requests.
+ * REVISIT: POST calls Item.request()
+ */
+
+public class ItemHTTPBridge extends HTTPRequestHandler {
+
+ public ItemHTTPBridge() { }
+
+ public String getName() {
+ return "Item HTTP Server";
+ }
+
+ public String processRequest() {
+ System.out.println("ItemHTTPBridge::ProcessRequest()");
+ StringTokenizer tok = new StringTokenizer(resource, "?");
+ String itemPath = tok.nextToken();
+ String query = tok.nextToken();
+ int sysKey = -1;
+ //Path path = Gateway.getLDAPLookup().;
+ if (method.equals("GET")) {
+ try {
+ DomainPath domPath = new DomainPath(itemPath);
+ EntityPath entityPath = domPath.getEntity();
+
+ if (sysKey > -1) {
+ C2KLocalObject response = Gateway.getStorage().get(sysKey, query, null);
+ return CastorXMLUtility.marshall(response);
+ }
+ else
+ return error("404 Not Found", "The entity "+sysKey+" you requested was not found.");
+ }
+ catch (Exception e) {
+ return error("400 Bad Request", "Usage: GET <path to item>?<path to kernel object><br>"+e.getClass().getName());
+ }
+ }
+ return(super.processRequest());
+ }
+
+}
|
