From da731d2bb81666b9c697d9099da632e7dfcdc0f7 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Tue, 9 Sep 2014 12:13:21 +0200 Subject: 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. --- .../predefined/agent/CreateAgentFromDescription.java | 17 +++++++++-------- .../instance/predefined/agent/RemoveAgent.java | 13 +++++++------ .../instance/predefined/agent/SetAgentPassword.java | 7 ++++--- .../instance/predefined/agent/SetAgentRoles.java | 7 ++++--- 4 files changed, 24 insertions(+), 20 deletions(-) (limited to 'src/main/java/com/c2kernel/lifecycle/instance/predefined/agent') diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/CreateAgentFromDescription.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/CreateAgentFromDescription.java index a7971f3..520f70f 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/CreateAgentFromDescription.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/CreateAgentFromDescription.java @@ -19,6 +19,7 @@ import com.c2kernel.entity.CorbaServer; import com.c2kernel.entity.agent.ActiveEntity; import com.c2kernel.lifecycle.instance.predefined.item.CreateItemFromDescription; import com.c2kernel.lookup.AgentPath; +import com.c2kernel.lookup.ItemPath; import com.c2kernel.lookup.RolePath; import com.c2kernel.process.Gateway; import com.c2kernel.utils.Logger; @@ -42,7 +43,7 @@ public class CreateAgentFromDescription extends CreateItemFromDescription * @see com.c2kernel.lifecycle.instance.predefined.item.CreateItemFromDescription#runActivityLogic(com.c2kernel.lookup.AgentPath, int, int, java.lang.String) */ @Override - protected String runActivityLogic(AgentPath agent, int itemSysKey, + protected String runActivityLogic(AgentPath agent, ItemPath itemPath, int transitionID, String requestData) throws InvalidDataException { String[] input = getDataList(requestData); @@ -67,8 +68,8 @@ public class CreateAgentFromDescription extends CreateItemFromDescription } catch (ObjectNotFoundException ex) { } // generate new entity key - Logger.msg(6, "CreateItemFromDescription - Requesting new sysKey"); - AgentPath newAgentPath = Gateway.getNextKeyManager().generateNextAgentKey(); + Logger.msg(6, "CreateItemFromDescription - Requesting new agent path"); + AgentPath newAgentPath = new AgentPath(newName); // resolve the item factory Logger.msg(6, "CreateItemFromDescription - Resolving item factory"); @@ -77,7 +78,7 @@ public class CreateAgentFromDescription extends CreateItemFromDescription Logger.msg(3, "CreateItemFromDescription - Creating Item"); CorbaServer factory = Gateway.getCorbaServer(); if (factory == null) throw new AccessRightsException("This process cannot create new Items", ""); - ActiveEntity newAgent = (ActiveEntity)factory.createEntity(newAgentPath); + ActiveEntity newAgent = factory.createAgent(newAgentPath); Gateway.getLookupManager().add(newAgentPath); // initialise it with its properties and workflow @@ -85,10 +86,10 @@ public class CreateAgentFromDescription extends CreateItemFromDescription Logger.msg(3, "CreateItemFromDescription - Initializing Item"); newAgent.initialise( - agent.getSysKey(), - Gateway.getMarshaller().marshall(getNewProperties(itemSysKey, newName, agent)), - Gateway.getMarshaller().marshall(getNewWorkflow(itemSysKey)), - Gateway.getMarshaller().marshall(getNewCollections(itemSysKey)) + agent.getSystemKey(), + Gateway.getMarshaller().marshall(getNewProperties(itemPath, newName, agent)), + Gateway.getMarshaller().marshall(getNewWorkflow(itemPath)), + Gateway.getMarshaller().marshall(getNewCollections(itemPath)) ); // add roles if given diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/RemoveAgent.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/RemoveAgent.java index 0630f6c..735a17d 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/RemoveAgent.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/RemoveAgent.java @@ -6,7 +6,8 @@ import com.c2kernel.common.ObjectCannotBeUpdated; import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.lifecycle.instance.predefined.PredefinedStep; import com.c2kernel.lookup.AgentPath; -import com.c2kernel.lookup.InvalidItemPathException; +import com.c2kernel.lookup.InvalidAgentPathException; +import com.c2kernel.lookup.ItemPath; import com.c2kernel.lookup.RolePath; import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.process.Gateway; @@ -19,16 +20,16 @@ public class RemoveAgent extends PredefinedStep { } @Override - protected String runActivityLogic(AgentPath agent, int itemSysKey, + protected String runActivityLogic(AgentPath agent, ItemPath itemPath, int transitionID, String requestData) throws InvalidDataException { Logger.msg(1, "RemoveAgent::request() - Starting."); AgentPath targetAgent; try { - targetAgent = new AgentPath(itemSysKey); - } catch (InvalidItemPathException ex) { - throw new InvalidDataException("Could not resolve syskey "+itemSysKey+" as an Agent."); + targetAgent = new AgentPath(itemPath); + } catch (InvalidAgentPathException ex) { + throw new InvalidDataException("Could not resolve "+itemPath+" as an Agent."); } String agentName = targetAgent.getAgentName(); @@ -49,7 +50,7 @@ public class RemoveAgent extends PredefinedStep { //clear out all storages try { - Gateway.getStorage().removeCluster(targetAgent.getSysKey(), "", null); + Gateway.getStorage().removeCluster(targetAgent, "", null); } catch (ClusterStorageException e) { Logger.error(e); throw new InvalidDataException("Error deleting storage for "+agentName, ""); diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/SetAgentPassword.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/SetAgentPassword.java index 09fdefe..6c0caaa 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/SetAgentPassword.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/SetAgentPassword.java @@ -9,6 +9,7 @@ import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.lifecycle.instance.predefined.PredefinedStep; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.InvalidItemPathException; +import com.c2kernel.lookup.ItemPath; import com.c2kernel.process.Gateway; import com.c2kernel.utils.Logger; @@ -19,16 +20,16 @@ public class SetAgentPassword extends PredefinedStep { } @Override - protected String runActivityLogic(AgentPath agent, int itemSysKey, + protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData) throws InvalidDataException { Logger.msg(1, "SetAgentPassword::request() - Starting."); AgentPath targetAgent; try { - targetAgent = new AgentPath(itemSysKey); + targetAgent = new AgentPath(item); } catch (InvalidItemPathException ex) { - throw new InvalidDataException("Could not resolve syskey "+itemSysKey+" as an Agent."); + throw new InvalidDataException("Could not resolve syskey "+item+" as an Agent."); } String agentName = targetAgent.getAgentName(); diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/SetAgentRoles.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/SetAgentRoles.java index 8bcba30..8cdcc49 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/SetAgentRoles.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/SetAgentRoles.java @@ -7,6 +7,7 @@ import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.lifecycle.instance.predefined.PredefinedStep; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.InvalidItemPathException; +import com.c2kernel.lookup.ItemPath; import com.c2kernel.lookup.RolePath; import com.c2kernel.process.Gateway; import com.c2kernel.utils.Logger; @@ -18,7 +19,7 @@ public class SetAgentRoles extends PredefinedStep { } @Override - protected String runActivityLogic(AgentPath agent, int itemSysKey, + protected String runActivityLogic(AgentPath agent, ItemPath item, int transitionID, String requestData) throws InvalidDataException { Logger.msg(1, "SetAgentRoles::request() - Starting."); @@ -26,9 +27,9 @@ public class SetAgentRoles extends PredefinedStep { String[] params = getDataList(requestData); AgentPath targetAgent; try { - targetAgent = new AgentPath(itemSysKey); + targetAgent = new AgentPath(item); } catch (InvalidItemPathException ex) { - throw new InvalidDataException("Could not resolve syskey "+itemSysKey+" as an Agent."); + throw new InvalidDataException("Could not resolve syskey "+item+" as an Agent."); } RolePath[] currentRoles = targetAgent.getRoles(); -- cgit v1.2.3