summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/lookup
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/c2kernel/lookup')
-rw-r--r--src/main/java/com/c2kernel/lookup/AgentPath.java12
-rw-r--r--src/main/java/com/c2kernel/lookup/ItemPath.java25
-rw-r--r--src/main/java/com/c2kernel/lookup/Lookup.java3
3 files changed, 28 insertions, 12 deletions
diff --git a/src/main/java/com/c2kernel/lookup/AgentPath.java b/src/main/java/com/c2kernel/lookup/AgentPath.java
index fb4ce0e..f6d6ca4 100644
--- a/src/main/java/com/c2kernel/lookup/AgentPath.java
+++ b/src/main/java/com/c2kernel/lookup/AgentPath.java
@@ -33,7 +33,7 @@ public class AgentPath extends ItemPath
private String mAgentName=null;
private String mPassword=null;
- public AgentPath(SystemKey syskey) throws InvalidAgentPathException {
+ public AgentPath(SystemKey syskey) throws InvalidAgentPathException, InvalidItemPathException {
super(syskey);
try {
findAgentName();
@@ -41,7 +41,7 @@ public class AgentPath extends ItemPath
throw new InvalidAgentPathException();
}
}
- public AgentPath(UUID uuid) throws InvalidAgentPathException {
+ protected AgentPath(UUID uuid) throws InvalidAgentPathException, InvalidItemPathException {
super(uuid);
try {
findAgentName();
@@ -132,6 +132,14 @@ public class AgentPath extends ItemPath
digest.append(Base64.encode(hash));
return digest.toString();
}
+
+ public static AgentPath fromUUIDString(String uuid) throws InvalidAgentPathException {
+ try {
+ return new AgentPath(ItemPath.fromUUIDString(uuid));
+ } catch (InvalidItemPathException ex) {
+ throw new InvalidAgentPathException(ex.getMessage());
+ }
+ }
}
diff --git a/src/main/java/com/c2kernel/lookup/ItemPath.java b/src/main/java/com/c2kernel/lookup/ItemPath.java
index 2219c8a..793a0ed 100644
--- a/src/main/java/com/c2kernel/lookup/ItemPath.java
+++ b/src/main/java/com/c2kernel/lookup/ItemPath.java
@@ -27,19 +27,15 @@ public class ItemPath extends Path
{
public ItemPath() {
- this(UUID.randomUUID());
+ setSysKey(UUID.randomUUID());
}
- public ItemPath(UUID uuid) {
+ protected ItemPath(UUID uuid) {
setSysKey(uuid);
- mPath = new String[1];
- mPath[0] = mUUID.toString();
}
public ItemPath(SystemKey syskey) {
setSysKey(syskey);
- mPath = new String[1];
- mPath[0] = mUUID.toString();
}
/*
@@ -82,13 +78,15 @@ public class ItemPath extends Path
public byte[] getOID() {
if (mType == Path.CONTEXT) return null;
ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
- bb.putLong(mUUID.getMostSignificantBits());
- bb.putLong(mUUID.getLeastSignificantBits());
+ bb.putLong(mSysKey.msb);
+ bb.putLong(mSysKey.lsb);
return bb.array();
}
protected void setSysKey(UUID uuid) {
mUUID = uuid;
+ mPath = new String[1];
+ mPath[0] = mUUID.toString();
mSysKey = new SystemKey(uuid.getMostSignificantBits(), uuid.getLeastSignificantBits());
mType = Path.ENTITY;
}
@@ -96,7 +94,18 @@ public class ItemPath extends Path
protected void setSysKey(SystemKey sysKey) {
mSysKey = sysKey;
mUUID = new UUID(sysKey.msb, sysKey.lsb);
+ mPath = new String[1];
+ mPath[0] = mUUID.toString();
mType = Path.ENTITY;
}
+
+ public static ItemPath fromUUIDString(String uuid) throws InvalidItemPathException {
+ if (uuid == null) throw new InvalidItemPathException("Null uuid");
+ try {
+ return new ItemPath(UUID.fromString(uuid));
+ } catch (IllegalArgumentException ex) {
+ throw new InvalidItemPathException("Illegal uuid: "+uuid);
+ }
+ }
}
diff --git a/src/main/java/com/c2kernel/lookup/Lookup.java b/src/main/java/com/c2kernel/lookup/Lookup.java
index 6627ea4..1b362f7 100644
--- a/src/main/java/com/c2kernel/lookup/Lookup.java
+++ b/src/main/java/com/c2kernel/lookup/Lookup.java
@@ -1,7 +1,6 @@
package com.c2kernel.lookup;
import java.util.Iterator;
-import java.util.UUID;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.process.auth.Authenticator;
@@ -36,7 +35,7 @@ public interface Lookup {
* @throws InvalidItemPathException When the system key is invalid/out-of-range
* @throws ObjectNotFoundException When the Item does not exist in the directory.
*/
- public ItemPath getItemPath(UUID sysKey) throws InvalidItemPathException, ObjectNotFoundException;
+ public ItemPath getItemPath(String sysKey) throws InvalidItemPathException, ObjectNotFoundException;
/**
* Find the ItemPath for which a DomainPath is an alias.