summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/process/ItemHTTPBridge.java
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2014-09-09 12:13:21 +0200
committerAndrew Branson <andrew.branson@cern.ch>2014-09-09 12:13:21 +0200
commitda731d2bb81666b9c697d9099da632e7dfcdc0f7 (patch)
tree567693c3c48f3d15ecbb2dac4f9db03bb6e58c72 /src/main/java/com/c2kernel/process/ItemHTTPBridge.java
parentae1e79e33fd30e3d8bcedbef8891a14a048276d7 (diff)
Replaced int sysKey Item identifier with UUID, which is now portable.
ItemPath objects are now used to identify Items throughout the kernel, replacing ints and Integers.
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());