summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/process/ItemHTTPBridge.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/c2kernel/process/ItemHTTPBridge.java')
-rw-r--r--src/main/java/com/c2kernel/process/ItemHTTPBridge.java33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/main/java/com/c2kernel/process/ItemHTTPBridge.java b/src/main/java/com/c2kernel/process/ItemHTTPBridge.java
index 6ad8e01..86e3659 100644
--- a/src/main/java/com/c2kernel/process/ItemHTTPBridge.java
+++ b/src/main/java/com/c2kernel/process/ItemHTTPBridge.java
@@ -1,8 +1,12 @@
package com.c2kernel.process;
import java.util.StringTokenizer;
+import java.util.UUID;
+import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.entity.C2KLocalObject;
+import com.c2kernel.lookup.DomainPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.utils.server.HTTPRequestHandler;
/* QueryData over HTTP Socket Handler
@@ -25,21 +29,26 @@ public class ItemHTTPBridge extends HTTPRequestHandler {
public String processRequest() {
System.out.println("ItemHTTPBridge::ProcessRequest()");
StringTokenizer tok = new StringTokenizer(resource, "?");
- //String itemPath = tok.nextToken();
+ String path = tok.nextToken();
String query = tok.nextToken();
- int sysKey = -1;
- //Path path = Gateway.getLDAPLookup().;
+ ItemPath itemPath;
+ try {
+ itemPath = new ItemPath(UUID.fromString(path));
+ } catch (IllegalArgumentException ex) {
+ DomainPath domPath = new DomainPath(path);
+ if (!domPath.exists())
+ return error("404 Not Found", "The path "+path+" you requested was not found.");
+ try {
+ itemPath = domPath.getItemPath();
+ } catch (ObjectNotFoundException e) {
+ return error("404 Not Found", "The path "+path+" you requested was not found.");
+ }
+ }
+
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 Gateway.getMarshaller().marshall(response);
- }
- else
- return error("404 Not Found", "The entity "+sysKey+" you requested was not found.");
+ C2KLocalObject response = Gateway.getStorage().get(itemPath, query, null);
+ return Gateway.getMarshaller().marshall(response);
}
catch (Exception e) {
return error("400 Bad Request", "Usage: GET &lt;path to item&gt;?&lt;path to kernel object&gt;<br>"+e.getClass().getName());