summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/lookup/AgentPath.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/lookup/AgentPath.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/lookup/AgentPath.java')
-rw-r--r--src/main/java/com/c2kernel/lookup/AgentPath.java71
1 files changed, 43 insertions, 28 deletions
diff --git a/src/main/java/com/c2kernel/lookup/AgentPath.java b/src/main/java/com/c2kernel/lookup/AgentPath.java
index a0bb7fd..fb4ce0e 100644
--- a/src/main/java/com/c2kernel/lookup/AgentPath.java
+++ b/src/main/java/com/c2kernel/lookup/AgentPath.java
@@ -12,10 +12,12 @@ package com.c2kernel.lookup;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+import java.util.UUID;
import org.apache.xerces.impl.dv.util.Base64;
import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.SystemKey;
import com.c2kernel.process.Gateway;
@@ -31,29 +33,40 @@ public class AgentPath extends ItemPath
private String mAgentName=null;
private String mPassword=null;
- public AgentPath(int syskey, String agentName)
- throws InvalidAgentPathException,InvalidItemPathException
- {
- super(syskey);
- if (agentName!=null && agentName.length()>0)
- setAgentName(agentName);
- else
+ public AgentPath(SystemKey syskey) throws InvalidAgentPathException {
+ super(syskey);
+ try {
+ findAgentName();
+ } catch (ObjectNotFoundException e) {
+ throw new InvalidAgentPathException();
+ }
+ }
+ public AgentPath(UUID uuid) throws InvalidAgentPathException {
+ super(uuid);
+ try {
+ findAgentName();
+ } catch (ObjectNotFoundException e) {
throw new InvalidAgentPathException();
+ }
}
-
- public AgentPath(int syskey)
- throws InvalidItemPathException
- {
- super(syskey);
+
+ public AgentPath(ItemPath itemPath) throws InvalidAgentPathException {
+ super(itemPath.mUUID);
+ try {
+ findAgentName();
+ } catch (ObjectNotFoundException e) {
+ throw new InvalidAgentPathException();
+ }
}
-
- public AgentPath(ItemPath entity) {
- super();
- try {
- setSysKey(entity.getSysKey());
- } catch (InvalidItemPathException ex) {
- //won't happen as the entity path was valid
- }
+
+ public AgentPath(ItemPath itemPath, String agentName) {
+ super(itemPath.mUUID);
+ mAgentName = agentName;
+ }
+
+ public AgentPath(String agentName) {
+ super();
+ mAgentName = agentName;
}
public void setAgentName(String agentID)
@@ -64,14 +77,16 @@ public class AgentPath extends ItemPath
public String getAgentName()
{
if (mAgentName==null)
- {
- try {
- mAgentName = Gateway.getLookup().getAgentName(this);
- } catch (ObjectNotFoundException e) {
- mAgentName = "";
- }
- }
- return mAgentName;
+ try {
+ findAgentName();
+ } catch (ObjectNotFoundException e) {
+ return null;
+ }
+ return mAgentName;
+ }
+
+ private void findAgentName() throws ObjectNotFoundException {
+ mAgentName = Gateway.getLookup().getAgentName(this);
}
public RolePath[] getRoles()