diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2014-06-05 16:47:41 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2014-06-05 16:47:41 +0200 |
| commit | e73468fd08cc27aa31f76a27c916e45d5987c628 (patch) | |
| tree | 36e5683c7e79f21d4f610c956a3267179da64983 /src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewAgent.java | |
| parent | 8dbf947eb6e84ec6a3c6e9ba421c682d847a8b00 (diff) | |
Moved old entitycreation package from the predefined step package to a
new 'imports' package under entity. Renamed most classed with an
'Import' prefix to avoid clashes with other API classes. Fixes #194
Diffstat (limited to 'src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewAgent.java')
| -rw-r--r-- | src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewAgent.java | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewAgent.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewAgent.java deleted file mode 100644 index 10e5e6f..0000000 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewAgent.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.c2kernel.lifecycle.instance.predefined.entitycreation;
-
-import java.security.NoSuchAlgorithmException;
-import java.util.ArrayList;
-
-import com.c2kernel.common.CannotManageException;
-import com.c2kernel.common.ObjectAlreadyExistsException;
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.entity.agent.ActiveEntity;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.RolePath;
-import com.c2kernel.process.Gateway;
-import com.c2kernel.process.module.ModuleImport;
-import com.c2kernel.property.Property;
-import com.c2kernel.property.PropertyArrayList;
-import com.c2kernel.utils.Logger;
-
-public class NewAgent extends ModuleImport implements java.io.Serializable {
-
- public String password;
-
- public ArrayList<String> roles = new ArrayList<String>();
- public ArrayList<Property> properties = new ArrayList<Property>();
-
- public NewAgent() {
- }
-
- public NewAgent(String name, String password) {
- this.name = name;
- this.password = password;
- }
-
- public void create(int agentId) throws ObjectNotFoundException, ObjectCannotBeUpdated, NoSuchAlgorithmException, CannotManageException, ObjectAlreadyExistsException {
- AgentPath newAgent = Gateway.getNextKeyManager().generateNextAgentKey();
- newAgent.setAgentName(name);
- newAgent.setPassword(password);
- ActiveEntity newAgentEnt = (ActiveEntity)Gateway.getCorbaServer().createEntity(newAgent);
- Gateway.getLookup().add(newAgent);
- // assemble properties
- properties.add(new com.c2kernel.property.Property("Name", name, true));
- properties.add(new com.c2kernel.property.Property("Type", "Agent", false));
- try {
- newAgentEnt.initialise(agentId, Gateway.getMarshaller().marshall(new PropertyArrayList(properties)), null, null);
- } catch (Exception ex) {
- Logger.error(ex);
- throw new CannotManageException("Error initialising new agent");
- }
- for (String role : roles) {
- RolePath thisRole;
- try {
- thisRole = Gateway.getLookup().getRolePath(role);
- } catch (ObjectNotFoundException ex) {
- throw new ObjectNotFoundException("Role "+role+" does not exist.");
- }
- thisRole.addAgent(newAgent);
- }
-
- }
-}
|
