From 482b98e869d07802310e249d09d784c63f9a86b6 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Fri, 19 Sep 2014 15:40:50 +0200 Subject: Introduced static method ItemPath.fromUUIDString and made the UUID constructor protected to better handle ItemPath and AgentPath construction with String UUIDs, throwing the right exceptions. --- src/main/java/com/c2kernel/lookup/AgentPath.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/main/java/com/c2kernel/lookup/AgentPath.java') 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()); + } + } } -- cgit v1.2.3