summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/process
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2014-09-19 15:40:50 +0200
committerAndrew Branson <andrew.branson@cern.ch>2014-09-19 15:40:50 +0200
commit482b98e869d07802310e249d09d784c63f9a86b6 (patch)
treebd6c55d5d5ebf967fb22b5cf1ceb9f3f6a7bbdd9 /src/main/java/com/c2kernel/process
parent3743d182d99dbed9d2be84dc357f6839ffe4d2ec (diff)
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.
Diffstat (limited to 'src/main/java/com/c2kernel/process')
-rw-r--r--src/main/java/com/c2kernel/process/Bootstrap.java15
-rw-r--r--src/main/java/com/c2kernel/process/ItemHTTPBridge.java6
-rw-r--r--src/main/java/com/c2kernel/process/module/ModuleImport.java7
3 files changed, 14 insertions, 14 deletions
diff --git a/src/main/java/com/c2kernel/process/Bootstrap.java b/src/main/java/com/c2kernel/process/Bootstrap.java
index e269e09..d5fcaa0 100644
--- a/src/main/java/com/c2kernel/process/Bootstrap.java
+++ b/src/main/java/com/c2kernel/process/Bootstrap.java
@@ -23,6 +23,7 @@ import com.c2kernel.lifecycle.instance.predefined.server.ServerPredefinedStepCon
import com.c2kernel.lifecycle.instance.stateMachine.Transition;
import com.c2kernel.lookup.AgentPath;
import com.c2kernel.lookup.DomainPath;
+import com.c2kernel.lookup.InvalidItemPathException;
import com.c2kernel.lookup.ItemPath;
import com.c2kernel.lookup.LookupManager;
import com.c2kernel.lookup.Path;
@@ -98,14 +99,14 @@ public class Bootstrap
Logger.msg(1, "Boot data items complete");
}
- private static void verifyBootDataItems(String bootList, String ns, boolean reset) {
+ private static void verifyBootDataItems(String bootList, String ns, boolean reset) throws InvalidItemPathException {
StringTokenizer str = new StringTokenizer(bootList, "\n\r");
while (str.hasMoreTokens()) {
String thisItem = str.nextToken();
ItemPath itemPath = null;
String[] itemParts = thisItem.split("/");
if (itemParts.length == 3) { // includes UUID
- itemPath = new ItemPath(UUID.fromString(itemParts[2]));
+ itemPath = ItemPath.fromUUIDString(itemParts[2]);
}
String itemType = itemParts[0];
String itemName = itemParts[1];
@@ -281,7 +282,7 @@ public class Bootstrap
/**************************************************************************
* Checks for the existence of the admin users so you can use Cristal
**************************************************************************/
- private static void checkAgent(String name, String pass, RolePath rolePath, UUID uuid) throws Exception {
+ private static void checkAgent(String name, String pass, RolePath rolePath, String uuid) throws Exception {
Logger.msg(1, "Bootstrap.checkAgent() - Checking for existence of '"+name+"' user.");
LookupManager lookup = Gateway.getLookupManager();
@@ -294,7 +295,7 @@ public class Bootstrap
Logger.msg("Bootstrap.checkAgent() - User '"+name+"' not found. Creating.");
try {
- AgentPath agentPath = new AgentPath(new ItemPath(uuid), name);
+ AgentPath agentPath = new AgentPath(ItemPath.fromUUIDString(uuid), name);
agentPath.setPassword(pass);
Gateway.getCorbaServer().createAgent(agentPath);
lookup.add(agentPath);
@@ -324,14 +325,14 @@ public class Bootstrap
if (!adminRole.exists()) Gateway.getLookupManager().createRole(adminRole);
// check for import user
- checkAgent("system", adminPassword, adminRole, new UUID(0, 0));
+ checkAgent("system", adminPassword, adminRole, new UUID(0, 0).toString());
- checkAgent("admin", adminPassword, adminRole, new UUID(0, 1));
+ checkAgent("admin", adminPassword, adminRole, new UUID(0, 1).toString());
// check for local usercode user & role
RolePath usercodeRole = new RolePath(rootRole, "UserCode", true);
if (!usercodeRole.exists()) Gateway.getLookupManager().createRole(usercodeRole);
- checkAgent(InetAddress.getLocalHost().getHostName(), "uc", usercodeRole, UUID.randomUUID());
+ checkAgent(InetAddress.getLocalHost().getHostName(), "uc", usercodeRole, UUID.randomUUID().toString());
}
public static void createServerItem() throws Exception {
diff --git a/src/main/java/com/c2kernel/process/ItemHTTPBridge.java b/src/main/java/com/c2kernel/process/ItemHTTPBridge.java
index 86e3659..8e4329c 100644
--- a/src/main/java/com/c2kernel/process/ItemHTTPBridge.java
+++ b/src/main/java/com/c2kernel/process/ItemHTTPBridge.java
@@ -1,11 +1,11 @@
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.InvalidItemPathException;
import com.c2kernel.lookup.ItemPath;
import com.c2kernel.utils.server.HTTPRequestHandler;
@@ -33,8 +33,8 @@ public class ItemHTTPBridge extends HTTPRequestHandler {
String query = tok.nextToken();
ItemPath itemPath;
try {
- itemPath = new ItemPath(UUID.fromString(path));
- } catch (IllegalArgumentException ex) {
+ itemPath = ItemPath.fromUUIDString(path);
+ } catch (InvalidItemPathException ex) {
DomainPath domPath = new DomainPath(path);
if (!domPath.exists())
return error("404 Not Found", "The path "+path+" you requested was not found.");
diff --git a/src/main/java/com/c2kernel/process/module/ModuleImport.java b/src/main/java/com/c2kernel/process/module/ModuleImport.java
index f54b47d..346488b 100644
--- a/src/main/java/com/c2kernel/process/module/ModuleImport.java
+++ b/src/main/java/com/c2kernel/process/module/ModuleImport.java
@@ -1,13 +1,12 @@
package com.c2kernel.process.module;
-import java.util.UUID;
-
import com.c2kernel.common.CannotManageException;
import com.c2kernel.common.ObjectAlreadyExistsException;
import com.c2kernel.common.ObjectCannotBeUpdated;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.lookup.AgentPath;
import com.c2kernel.lookup.DomainPath;
+import com.c2kernel.lookup.InvalidItemPathException;
import com.c2kernel.lookup.ItemPath;
public abstract class ModuleImport {
@@ -23,9 +22,9 @@ public abstract class ModuleImport {
public abstract void create(AgentPath agentPath, boolean reset) throws ObjectNotFoundException,
ObjectCannotBeUpdated, CannotManageException, ObjectAlreadyExistsException;
- public void setID( String uuid )
+ public void setID( String uuid ) throws InvalidItemPathException
{
- if (uuid != null) itemPath = new ItemPath(UUID.fromString(uuid));
+ if (uuid != null) itemPath = ItemPath.fromUUIDString(uuid);
}
public String getID() {