From d6cfc7505be13b3b09adf423206cf75d9f806c12 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Mon, 18 Feb 2013 15:01:46 +0100 Subject: Initial Interface creation. Some compilation problems remain. --- src/main/java/com/c2kernel/entity/CorbaServer.java | 6 +- .../com/c2kernel/entity/agent/ActiveEntity.java | 4 +- src/main/java/com/c2kernel/entity/agent/Job.java | 2 +- .../java/com/c2kernel/entity/proxy/AgentProxy.java | 2 +- .../c2kernel/entity/proxy/EntityProxyManager.java | 4 +- .../com/c2kernel/entity/transfer/TransferItem.java | 8 +- .../com/c2kernel/entity/transfer/TransferSet.java | 2 +- .../com/c2kernel/lifecycle/instance/Activity.java | 4 +- .../com/c2kernel/lifecycle/instance/WfVertex.java | 2 +- .../instance/predefined/AddDomainPath.java | 4 +- .../predefined/CreateItemFromDescription.java | 8 +- .../lifecycle/instance/predefined/Erase.java | 6 +- .../instance/predefined/RemoveDomainPath.java | 4 +- .../predefined/entitycreation/NewAgent.java | 8 +- .../predefined/entitycreation/NewItem.java | 6 +- src/main/java/com/c2kernel/lookup/AgentPath.java | 8 +- src/main/java/com/c2kernel/lookup/DomainPath.java | 2 +- src/main/java/com/c2kernel/lookup/LDAPLookup.java | 39 +++++--- src/main/java/com/c2kernel/lookup/LDAPPathSet.java | 2 +- .../java/com/c2kernel/lookup/LDAPRoleManager.java | 24 +++-- src/main/java/com/c2kernel/lookup/Lookup.java | 100 +++++++++++++++++++++ src/main/java/com/c2kernel/lookup/Path.java | 10 +-- src/main/java/com/c2kernel/lookup/RoleManager.java | 79 ++++++++++++++++ src/main/java/com/c2kernel/lookup/RolePath.java | 6 +- .../c2kernel/persistency/LDAPClusterStorage.java | 7 +- .../java/com/c2kernel/persistency/ProxyLoader.java | 8 +- src/main/java/com/c2kernel/process/Bootstrap.java | 22 ++--- src/main/java/com/c2kernel/process/Gateway.java | 30 ++++--- .../java/com/c2kernel/process/module/Module.java | 6 +- src/main/java/com/c2kernel/scripting/Script.java | 2 +- .../java/com/c2kernel/scripting/ScriptConsole.java | 2 +- 31 files changed, 309 insertions(+), 108 deletions(-) create mode 100644 src/main/java/com/c2kernel/lookup/Lookup.java create mode 100644 src/main/java/com/c2kernel/lookup/RoleManager.java (limited to 'src/main/java/com/c2kernel') diff --git a/src/main/java/com/c2kernel/entity/CorbaServer.java b/src/main/java/com/c2kernel/entity/CorbaServer.java index 84d2ef2..3083315 100644 --- a/src/main/java/com/c2kernel/entity/CorbaServer.java +++ b/src/main/java/com/c2kernel/entity/CorbaServer.java @@ -31,7 +31,7 @@ import com.c2kernel.utils.SoftCache; public class CorbaServer { - private Map mEntityCache; + private final Map mEntityCache; private POA mRootPOA; private POA mItemPOA; private POA mAgentPOA; @@ -126,7 +126,7 @@ public class CorbaServer { if (entity == null) { Logger.msg(7, "Creating new servant for "+sysKey); - Class entityClass = Gateway.getLDAPLookup().getEntityClass(entityPath); + Class entityClass = Gateway.getLookup().getEntityClass(entityPath); if (entityClass == TraceableEntity.class) { if (poa == null) poa = mItemPOA; @@ -167,7 +167,7 @@ public class CorbaServer { public Servant createEntity(EntityPath entityPath) throws CannotManageException, ObjectAlreadyExistsException { try { if (entityPath == null) - entityPath = Gateway.getLDAPLookup().getNextKeyManager().generateNextEntityKey(); + entityPath = Gateway.getLookup().getNextKeyManager().generateNextEntityKey(); } catch (Exception ex) { Logger.error(ex); throw new CannotManageException("Cannot generate next entity key"); diff --git a/src/main/java/com/c2kernel/entity/agent/ActiveEntity.java b/src/main/java/com/c2kernel/entity/agent/ActiveEntity.java index d20fc1e..cc59b35 100644 --- a/src/main/java/com/c2kernel/entity/agent/ActiveEntity.java +++ b/src/main/java/com/c2kernel/entity/agent/ActiveEntity.java @@ -260,7 +260,7 @@ public class ActiveEntity extends AgentPOA @Override public void addRole(String roleName) throws CannotManageException, ObjectNotFoundException { - RolePath newRole = Gateway.getLDAPLookup().getRoleManager().getRolePath(roleName); + RolePath newRole = Gateway.getLookup().getRoleManager().getRolePath(roleName); try { newRole.addAgent(new AgentPath(mSystemKey)); } catch (InvalidEntityPathException ex) { @@ -272,7 +272,7 @@ public class ActiveEntity extends AgentPOA @Override public void removeRole(String roleName) throws CannotManageException, ObjectNotFoundException { - RolePath rolePath = Gateway.getLDAPLookup().getRoleManager().getRolePath(roleName); + RolePath rolePath = Gateway.getLookup().getRoleManager().getRolePath(roleName); try { rolePath.removeAgent(new AgentPath(mSystemKey)); } catch (InvalidEntityPathException e) { diff --git a/src/main/java/com/c2kernel/entity/agent/Job.java b/src/main/java/com/c2kernel/entity/agent/Job.java index 216a88d..1537234 100644 --- a/src/main/java/com/c2kernel/entity/agent/Job.java +++ b/src/main/java/com/c2kernel/entity/agent/Job.java @@ -174,7 +174,7 @@ public class Job implements C2KLocalObject public int getAgentId() throws ObjectNotFoundException { if (mAgentId == -1) - mAgentId = Gateway.getLDAPLookup().getRoleManager().getAgentPath(getAgentName()).getSysKey(); + mAgentId = Gateway.getLookup().getRoleManager().getAgentPath(getAgentName()).getSysKey(); return mAgentId; } diff --git a/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java b/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java index 22e9016..6d2b17d 100644 --- a/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java +++ b/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java @@ -257,7 +257,7 @@ public class AgentProxy extends EntityProxy /** Let scripts resolve items */ public ItemProxy searchItem(String name) throws ObjectNotFoundException { - Enumeration results = Gateway.getLDAPLookup().search(new DomainPath(""),name); + Enumeration results = Gateway.getLookup().search(new DomainPath(""),name); Path returnPath = null; if (!results.hasMoreElements()) diff --git a/src/main/java/com/c2kernel/entity/proxy/EntityProxyManager.java b/src/main/java/com/c2kernel/entity/proxy/EntityProxyManager.java index 192a984..9ed562b 100644 --- a/src/main/java/com/c2kernel/entity/proxy/EntityProxyManager.java +++ b/src/main/java/com/c2kernel/entity/proxy/EntityProxyManager.java @@ -47,7 +47,7 @@ public class EntityProxyManager { Logger.msg(5, "EntityProxyManager - Starting....."); - Enumeration servers = Gateway.getLDAPLookup().searchEntities(new DomainPath("/servers")); + Enumeration servers = Gateway.getLookup().searchEntities(new DomainPath("/servers")); while(servers.hasMoreElements()) { Path thisServerPath = servers.nextElement(); try { @@ -233,7 +233,7 @@ public class EntityProxyManager //convert namePath to dn format Logger.msg(8,"EntityProxyFactory::getProxy(" + path.toString() + ")"); boolean isItem = !(path.getEntity() instanceof AgentPath); - return getProxy( Gateway.getLDAPLookup().getIOR(path), + return getProxy( Gateway.getLookup().resolve(path), path.getSysKey(), isItem ); diff --git a/src/main/java/com/c2kernel/entity/transfer/TransferItem.java b/src/main/java/com/c2kernel/entity/transfer/TransferItem.java index 520063a..36b8354 100644 --- a/src/main/java/com/c2kernel/entity/transfer/TransferItem.java +++ b/src/main/java/com/c2kernel/entity/transfer/TransferItem.java @@ -26,7 +26,7 @@ public class TransferItem { public TransferItem() throws Exception { try { - importAgentId = Gateway.getLDAPLookup().getRoleManager().getAgentPath("system").getSysKey(); + importAgentId = Gateway.getLookup().getRoleManager().getAgentPath("system").getSysKey(); } catch (ObjectNotFoundException e) { Logger.error("TransferItem - System user not found!"); throw e; @@ -37,7 +37,7 @@ public class TransferItem { this.sysKey = sysKey; domainPaths = new ArrayList(); Property name = (Property)Gateway.getStorage().get(sysKey, ClusterStorage.PROPERTY + "/Name", null); - Enumeration paths = Gateway.getLDAPLookup().search(new DomainPath(), name.getValue()); + Enumeration paths = Gateway.getLookup().search(new DomainPath(), name.getValue()); while (paths.hasMoreElements()) { DomainPath thisPath = (DomainPath)paths.nextElement(); domainPaths.add(thisPath.toString()); @@ -91,7 +91,7 @@ public class TransferItem { // create item EntityPath entityPath = new EntityPath(sysKey); TraceableEntity newItem = (TraceableEntity)Gateway.getCorbaServer().createEntity(entityPath); - Gateway.getLDAPLookup().add(entityPath); + Gateway.getLookup().add(entityPath); PropertyArrayList props = new PropertyArrayList(); Workflow wf = null; @@ -118,7 +118,7 @@ public class TransferItem { // add domPaths for (String element : domainPaths) { DomainPath newPath = new DomainPath(element, entityPath); - Gateway.getLDAPLookup().add(newPath); + Gateway.getLookup().add(newPath); } } diff --git a/src/main/java/com/c2kernel/entity/transfer/TransferSet.java b/src/main/java/com/c2kernel/entity/transfer/TransferSet.java index 7a3ba2e..5a8fd07 100644 --- a/src/main/java/com/c2kernel/entity/transfer/TransferSet.java +++ b/src/main/java/com/c2kernel/entity/transfer/TransferSet.java @@ -84,7 +84,7 @@ public class TransferSet { try { // find the current last key - NextKeyManager nextKeyMan = Gateway.getLDAPLookup().getNextKeyManager(); + NextKeyManager nextKeyMan = Gateway.getLookup().getNextKeyManager(); EntityPath lastKey = nextKeyMan.getLastEntityPath(); Logger.msg(1, "Last key imported was "+packageLastKey+". LDAP lastkey was "+lastKey.getSysKey()); diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Activity.java b/src/main/java/com/c2kernel/lifecycle/instance/Activity.java index 38ed626..5ba4175 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/Activity.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/Activity.java @@ -19,7 +19,7 @@ import com.c2kernel.lifecycle.instance.stateMachine.Transitions; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.EntityPath; import com.c2kernel.lookup.InvalidEntityPathException; -import com.c2kernel.lookup.LDAPRoleManager; +import com.c2kernel.lookup.RoleManager; import com.c2kernel.lookup.RolePath; import com.c2kernel.persistency.ClusterStorage; import com.c2kernel.persistency.TransactionManager; @@ -614,7 +614,7 @@ public class Activity extends WfVertex String agentRole = getCurrentAgentRole(); if (agentRole == null || agentRole.length()==0) return; - LDAPRoleManager roleMan = Gateway.getLDAPLookup().getRoleManager(); + RoleManager roleMan = Gateway.getLookup().getRoleManager(); RolePath myRole; try { myRole = roleMan.getRolePath(agentRole); diff --git a/src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java b/src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java index b74aac8..ecf95ce 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java @@ -134,7 +134,7 @@ public abstract class WfVertex extends GraphableVertex script.setInputParamValue("item", Gateway.getProxyManager().getProxy(entity)); } if (requiredInput.containsKey("agent")) { - AgentPath systemAgent = Gateway.getLDAPLookup().getRoleManager().getAgentPath("system"); + AgentPath systemAgent = Gateway.getLookup().getRoleManager().getAgentPath("system"); script.setInputParamValue("agent", Gateway.getProxyManager().getProxy(systemAgent)); } Object retVal = script.execute(); diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddDomainPath.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddDomainPath.java index 2cf619e..6627cb2 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddDomainPath.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddDomainPath.java @@ -17,7 +17,7 @@ import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.DomainPath; import com.c2kernel.lookup.EntityPath; import com.c2kernel.lookup.InvalidEntityPathException; -import com.c2kernel.lookup.LDAPLookup; +import com.c2kernel.lookup.Lookup; import com.c2kernel.process.Gateway; import com.c2kernel.utils.Logger; @@ -36,7 +36,7 @@ public class AddDomainPath extends PredefinedStep InvalidDataException { Logger.msg(8,"AddAlias::request()"); - LDAPLookup lookupManager = Gateway.getLDAPLookup(); + Lookup lookupManager = Gateway.getLookup(); Logger.msg(1,"AddAlias::request() - Starting."); diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/CreateItemFromDescription.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/CreateItemFromDescription.java index ff049f4..7e5d951 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/CreateItemFromDescription.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/CreateItemFromDescription.java @@ -29,7 +29,7 @@ import com.c2kernel.lifecycle.instance.stateMachine.Transitions; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.DomainPath; import com.c2kernel.lookup.EntityPath; -import com.c2kernel.lookup.LDAPLookup; +import com.c2kernel.lookup.Lookup; import com.c2kernel.persistency.ClusterStorage; import com.c2kernel.persistency.TransactionManager; import com.c2kernel.process.Gateway; @@ -69,7 +69,7 @@ public class CreateItemFromDescription extends PredefinedStep PropertyArrayList props = new PropertyArrayList(); Logger.msg(1, "AddNewItem::request() - Starting."); TransactionManager storage = Gateway.getStorage(); - LDAPLookup lookup = Gateway.getLDAPLookup(); + Lookup lookup = Gateway.getLookup(); EntityPath myPath = getItemEntityPath(); checkAccessRights(agent); @@ -144,7 +144,7 @@ public class CreateItemFromDescription extends PredefinedStep CorbaServer factory = Gateway.getCorbaServer(); if (factory == null) throw new AccessRightsException("This process cannot create new Items", ""); TraceableEntity newItem = (TraceableEntity)factory.createEntity(entityPath); - Gateway.getLDAPLookup().add(entityPath); + Gateway.getLookup().add(entityPath); // initialise it with its properties and workflow @@ -169,7 +169,7 @@ public class CreateItemFromDescription extends PredefinedStep // add its domain path Logger.msg(3, "CreateItemFromDescription - Creating "+context); context.setEntity(entityPath); - Gateway.getLDAPLookup().add(context); + Gateway.getLookup().add(context); } catch (ObjectAlreadyExistsException e) { Logger.error(e); throw e; diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/Erase.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/Erase.java index 84b1b78..6f4e8b6 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/Erase.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/Erase.java @@ -58,19 +58,19 @@ public class Erase extends PredefinedStep Property name = (Property)Gateway.getStorage().get(entityPath.getSysKey(), ClusterStorage.PROPERTY+"/Name", null); // get all domain paths - Enumeration domPaths = Gateway.getLDAPLookup().search(new DomainPath(), name.getValue()); + Enumeration domPaths = Gateway.getLookup().search(new DomainPath(), name.getValue()); while (domPaths.hasMoreElements()) { DomainPath path = (DomainPath)domPaths.nextElement(); // delete them if (path.getSysKey() == entityPath.getSysKey()) - Gateway.getLDAPLookup().delete(path); + Gateway.getLookup().delete(path); } //clear out all storages Gateway.getStorage().removeCluster(entityPath.getSysKey(), "", null); //remove domain path - Gateway.getLDAPLookup().delete(entityPath); + Gateway.getLookup().delete(entityPath); } catch( Exception ex ) { diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java index 19ff7c6..378e034 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java @@ -15,7 +15,7 @@ import com.c2kernel.common.InvalidDataException; import com.c2kernel.common.InvalidTransitionException; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.DomainPath; -import com.c2kernel.lookup.LDAPLookup; +import com.c2kernel.lookup.Lookup; import com.c2kernel.process.Gateway; import com.c2kernel.utils.Logger; @@ -34,7 +34,7 @@ public class RemoveDomainPath extends PredefinedStep InvalidDataException { Logger.msg(8,"RemoveDomainPath::request()"); - LDAPLookup lookupManager = Gateway.getLDAPLookup(); + Lookup lookupManager = Gateway.getLookup(); Logger.msg(1,"RemoveDomainPath::request() - Starting."); 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 index f13bced..678db20 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewAgent.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewAgent.java @@ -32,11 +32,11 @@ public class NewAgent extends ModuleImport implements java.io.Serializable { } public void create(int agentId) throws ObjectNotFoundException, ObjectCannotBeUpdated, NoSuchAlgorithmException, CannotManageException, ObjectAlreadyExistsException { - AgentPath newAgent = Gateway.getLDAPLookup().getNextKeyManager().generateNextAgentKey(); + AgentPath newAgent = Gateway.getLookup().getNextKeyManager().generateNextAgentKey(); newAgent.setAgentName(name); newAgent.setPassword(password); ActiveEntity newAgentEnt = (ActiveEntity)Gateway.getCorbaServer().createEntity(newAgent); - Gateway.getLDAPLookup().add(newAgent); + Gateway.getLookup().add(newAgent); // assemble properties properties.add(new com.c2kernel.property.Property("Name", name)); properties.add(new com.c2kernel.property.Property("Type", "Agent")); @@ -49,9 +49,9 @@ public class NewAgent extends ModuleImport implements java.io.Serializable { for (String role : roles) { RolePath thisRole; try { - thisRole = Gateway.getLDAPLookup().getRoleManager().getRolePath(role); + thisRole = Gateway.getLookup().getRoleManager().getRolePath(role); } catch (ObjectNotFoundException ex) { - thisRole = Gateway.getLDAPLookup().getRoleManager().createRole(role, false); + thisRole = Gateway.getLookup().getRoleManager().createRole(role, false); } thisRole.addAgent(newAgent); } diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java index 3c5a16e..7242d19 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java @@ -66,9 +66,9 @@ public class NewItem extends ModuleImport { throw new ObjectAlreadyExistsException(domPath+" already exists!", ""); // create item - EntityPath entPath = Gateway.getLDAPLookup().getNextKeyManager().generateNextEntityKey(); + EntityPath entPath = Gateway.getLookup().getNextKeyManager().generateNextEntityKey(); TraceableEntity newItem = (TraceableEntity)Gateway.getCorbaServer().createEntity(entPath); - Gateway.getLDAPLookup().add(entPath); + Gateway.getLookup().add(entPath); // set the name property properties.add(new Property("Name", name)); @@ -130,7 +130,7 @@ public class NewItem extends ModuleImport { } // register domain path domPath.setEntity(entPath); - Gateway.getLDAPLookup().add(domPath); + Gateway.getLookup().add(domPath); } @Override diff --git a/src/main/java/com/c2kernel/lookup/AgentPath.java b/src/main/java/com/c2kernel/lookup/AgentPath.java index 5ff6988..8c83251 100644 --- a/src/main/java/com/c2kernel/lookup/AgentPath.java +++ b/src/main/java/com/c2kernel/lookup/AgentPath.java @@ -70,7 +70,7 @@ public class AgentPath extends EntityPath if (mAgentName==null) { try { - LDAPEntry agentEntry = LDAPLookupUtils.getEntry(Gateway.getLDAPLookup().getConnection(), this.getDN() + mLocalPath); + LDAPEntry agentEntry = LDAPLookupUtils.getEntry(Gateway.getLookup().getConnection(), this.getDN() + mLocalPath); mAgentName = LDAPLookupUtils.getFirstAttributeValue(agentEntry,"uid"); } catch (ObjectNotFoundException e) { mAgentName = ""; @@ -81,16 +81,16 @@ public class AgentPath extends EntityPath public RolePath[] getRoles() { - return Gateway.getLDAPLookup().getRoleManager().getRoles(this); + return Gateway.getLookup().getRoleManager().getRoles(this); } public boolean hasRole(RolePath role) { - return Gateway.getLDAPLookup().getRoleManager().hasRole(this, role); + return Gateway.getLookup().getRoleManager().hasRole(this, role); } public boolean hasRole(String role) { try { - return hasRole(Gateway.getLDAPLookup().getRoleManager().getRolePath(role)); + return hasRole(Gateway.getLookup().getRoleManager().getRolePath(role)); } catch (ObjectNotFoundException ex) { return false; } diff --git a/src/main/java/com/c2kernel/lookup/DomainPath.java b/src/main/java/com/c2kernel/lookup/DomainPath.java index ce849ce..523ac49 100644 --- a/src/main/java/com/c2kernel/lookup/DomainPath.java +++ b/src/main/java/com/c2kernel/lookup/DomainPath.java @@ -108,7 +108,7 @@ public class DomainPath extends Path public void checkType() { try { - setEntity(Gateway.getLDAPLookup().resolvePath(this)); + setEntity(Gateway.getLookup().resolvePath(this)); } catch (InvalidEntityPathException ex) { Logger.error(ex); mType = CONTEXT; diff --git a/src/main/java/com/c2kernel/lookup/LDAPLookup.java b/src/main/java/com/c2kernel/lookup/LDAPLookup.java index d581dfd..ab5992c 100644 --- a/src/main/java/com/c2kernel/lookup/LDAPLookup.java +++ b/src/main/java/com/c2kernel/lookup/LDAPLookup.java @@ -37,7 +37,7 @@ import com.novell.ldap.LDAPSearchResults; * @author $Author: abranson $ */ -public class LDAPLookup +public class LDAPLookup implements Lookup { private LDAPConnection mLDAPConn; @@ -111,7 +111,8 @@ public class LDAPLookup * Gets the entity key generator, used to get a unique system key for new entities. * @return the global NextKeyManager */ - public NextKeyManager getNextKeyManager() + @Override + public NextKeyManager getNextKeyManager() { return mNextKeyManager; } @@ -127,7 +128,8 @@ public class LDAPLookup * Gets the role manager, that is used to add and remove roles and agents. * @return Returns the mRoleManager. */ - public LDAPRoleManager getRoleManager() { + @Override + public LDAPRoleManager getRoleManager() { return mRoleManager; } @@ -149,7 +151,8 @@ public class LDAPLookup /** * Disconnects the connection with the LDAP server during shutdown */ - public void disconnect() { + @Override + public void disconnect() { Logger.msg(1, "LDAP Lookup: Shutting down LDAP connection."); if (mLDAPConn != null) { try { @@ -167,7 +170,8 @@ public class LDAPLookup * @return the CORBA object * @throws ObjectNotFoundException When the path does not exist */ - public org.omg.CORBA.Object getIOR(Path path) + @Override + public org.omg.CORBA.Object resolve(Path path) throws ObjectNotFoundException { return resolveObject(path.getFullDN()); @@ -208,7 +212,8 @@ public class LDAPLookup * @throws InvalidEntityPathException * @throws ObjectNotFoundException */ - protected EntityPath resolvePath(DomainPath domPath) + @Override + public EntityPath resolvePath(DomainPath domPath) throws InvalidEntityPathException, ObjectNotFoundException { EntityPath referencedPath = null; LDAPEntry domEntry = LDAPLookupUtils.getEntry(getConnection(), domPath @@ -228,7 +233,8 @@ public class LDAPLookup } - public LDAPEntry add(Path path) + @Override + public void add(Path path) throws ObjectCannotBeUpdated, ObjectAlreadyExistsException { try { @@ -238,7 +244,6 @@ public class LDAPLookup LDAPLookupUtils.addEntry(getConnection(),newEntry); if (path instanceof DomainPath) EntityProxyManager.sendProxyEvent(new ProxyMessage(ProxyMessage.NA, path.toString(), ProxyMessage.ADDED)); - return newEntry; } catch (LDAPException ex) { if (ex.getResultCode() == LDAPException.ENTRY_ALREADY_EXISTS) throw new ObjectAlreadyExistsException(ex.getLDAPErrorMessage(), ""); @@ -249,7 +254,8 @@ public class LDAPLookup //deletes a node //throws LDAPexception if node cannot be deleted (eg node is not a leaf) - public void delete(Path path) throws ObjectCannotBeUpdated + @Override + public void delete(Path path) throws ObjectCannotBeUpdated { try { LDAPLookupUtils.delete(getConnection(),path.getDN()+Path.mLocalPath); @@ -302,7 +308,8 @@ public class LDAPLookup LDAPLookupUtils.createCristalContext(getConnection(), Path.mLocalPath); } - public void install() throws ObjectNotFoundException + @Override + public void install() throws ObjectNotFoundException { createBootTree(); initTree( Resource.getTextResource(null, "boot/LDAPboot.txt")); @@ -322,7 +329,8 @@ public class LDAPLookup } //typically search for cn=barcode - public LDAPPathSet search(Path start, String filter) + @Override + public LDAPPathSet search(Path start, String filter) { Logger.msg(8,"LDAPLookup::search() From " + start.getDN() + " for cn=" + filter ); return search(start.getFullDN(),"cn="+LDAPLookupUtils.escapeSearchFilter(filter)); @@ -364,7 +372,8 @@ public class LDAPLookup return search(startDN,LDAPConnection.SCOPE_SUB,filter,searchCons); } - public LDAPPathSet searchEntities(Path start) { + @Override + public LDAPPathSet searchEntities(Path start) { LDAPSearchConstraints searchCons = new LDAPSearchConstraints(); searchCons.setBatchSize(0); searchCons.setDereference(LDAPSearchConstraints.DEREF_SEARCHING); @@ -378,11 +387,13 @@ public class LDAPLookup return search(start.getFullDN(), LDAPConnection.SCOPE_SUB, "objectClass=aliasObject", searchCons); } - public boolean exists(Path path) { + @Override + public boolean exists(Path path) { return LDAPLookupUtils.exists(getConnection(), path.getFullDN()); } - public Class getEntityClass(Path path) throws ObjectNotFoundException { + @Override + public Class getEntityClass(Path path) throws ObjectNotFoundException { String[] attr = { LDAPConnection.ALL_USER_ATTRS }; try { LDAPEntry anEntry=getConnection().read(path.getDN()+Path.mLocalPath,attr); diff --git a/src/main/java/com/c2kernel/lookup/LDAPPathSet.java b/src/main/java/com/c2kernel/lookup/LDAPPathSet.java index d3cf7d9..1ebd97d 100644 --- a/src/main/java/com/c2kernel/lookup/LDAPPathSet.java +++ b/src/main/java/com/c2kernel/lookup/LDAPPathSet.java @@ -54,7 +54,7 @@ public class LDAPPathSet implements Enumeration { try { if (nextEntry == null) nextEntry = results.next(); - Path nextPath = Gateway.getLDAPLookup().nodeToPath(nextEntry); + Path nextPath = ((LDAPLookup)Gateway.getLookup()).nodeToPath(nextEntry); nextEntry = null; return nextPath; } catch (Exception ex) { diff --git a/src/main/java/com/c2kernel/lookup/LDAPRoleManager.java b/src/main/java/com/c2kernel/lookup/LDAPRoleManager.java index 0536d6c..e046550 100644 --- a/src/main/java/com/c2kernel/lookup/LDAPRoleManager.java +++ b/src/main/java/com/c2kernel/lookup/LDAPRoleManager.java @@ -22,7 +22,7 @@ import com.novell.ldap.LDAPSearchConstraints; **************************************************************************/ // public static final String codeRevision = "$Revision: 1.1 $ $Date: 2005/04/26 06:48:12 $ $Author: abranson $"; -public class LDAPRoleManager { +public class LDAPRoleManager implements RoleManager { /** * @@ -41,7 +41,8 @@ public class LDAPRoleManager { //NOTE: A role must have at LEAST 1 userDN, cannot be empty... //Creates a cristalRole //CristalRole is-a specialized CristalContext which contains multi-valued uniqueMember attribute pointing to cristalagents - public RolePath createRole(String roleName, boolean jobList) + @Override + public RolePath createRole(String roleName, boolean jobList) throws ObjectAlreadyExistsException, ObjectCannotBeUpdated { @@ -74,7 +75,8 @@ public class LDAPRoleManager { } } - protected void addRole(AgentPath agent, RolePath role) + @Override + public void addRole(AgentPath agent, RolePath role) throws ObjectCannotBeUpdated, ObjectNotFoundException { LDAPEntry roleEntry = LDAPLookupUtils.getEntry(mLdap.getConnection(), role.getFullDN()); @@ -85,7 +87,7 @@ public class LDAPRoleManager { throw new ObjectCannotBeUpdated("Agent " + agent.getAgentName() + " already has role " + role.getName()); } - protected void removeRole(AgentPath agent, RolePath role) + public void removeRole(AgentPath agent, RolePath role) throws ObjectCannotBeUpdated, ObjectNotFoundException { LDAPEntry roleEntry = LDAPLookupUtils.getEntry(mLdap.getConnection(), role.getFullDN()); @@ -95,7 +97,7 @@ public class LDAPRoleManager { throw new ObjectCannotBeUpdated("Agent did not have that role"); } - protected boolean hasRole(AgentPath agent, RolePath role) { + public boolean hasRole(AgentPath agent, RolePath role) { String filter = "(&(objectclass=cristalrole)(uniqueMember="+agent.getFullDN()+")(cn="+role.getName()+"))"; LDAPSearchConstraints searchCons = new LDAPSearchConstraints(); searchCons.setBatchSize(0); @@ -103,7 +105,8 @@ public class LDAPRoleManager { return mLdap.search(mRolePath,LDAPConnection.SCOPE_SUB,filter,searchCons).hasMoreElements(); } - protected AgentPath[] getAgents(RolePath role) + @Override + public AgentPath[] getAgents(RolePath role) throws ObjectNotFoundException { //get the roleDN entry, and its uniqueMember entry pointing to @@ -133,7 +136,8 @@ public class LDAPRoleManager { } //returns the role/s of a user - protected RolePath[] getRoles(AgentPath agentPath) + @Override + public RolePath[] getRoles(AgentPath agentPath) { //search the mDomainPath tree uniqueMember=userDN //filter = objectclass=cristalrole AND uniqueMember=userDN @@ -163,7 +167,8 @@ public class LDAPRoleManager { * @return * @throws ObjectNotFoundException */ - public AgentPath getAgentPath(String agentName) throws ObjectNotFoundException + @Override + public AgentPath getAgentPath(String agentName) throws ObjectNotFoundException { //search to get the userDN equivalent of the userID LDAPSearchConstraints searchCons = new LDAPSearchConstraints(); @@ -180,7 +185,8 @@ public class LDAPRoleManager { throw new ObjectNotFoundException("Entry was not an Agent"); } - public RolePath getRolePath(String roleName) throws ObjectNotFoundException + @Override + public RolePath getRolePath(String roleName) throws ObjectNotFoundException { LDAPSearchConstraints searchCons = new LDAPSearchConstraints(); searchCons.setBatchSize(0); diff --git a/src/main/java/com/c2kernel/lookup/Lookup.java b/src/main/java/com/c2kernel/lookup/Lookup.java new file mode 100644 index 0000000..0ddc448 --- /dev/null +++ b/src/main/java/com/c2kernel/lookup/Lookup.java @@ -0,0 +1,100 @@ +/* + * Lookup.java + * + * Copyright (c) 2013, The CRISTAL Consortium. All rights reserved. + * + * CRISTAL kernel is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see: + * http://www.gnu.org/licenses/ + */ + +package com.c2kernel.lookup; + +import java.util.Enumeration; + +import org.omg.CORBA.Object; + +import com.c2kernel.common.ObjectAlreadyExistsException; +import com.c2kernel.common.ObjectCannotBeUpdated; +import com.c2kernel.common.ObjectNotFoundException; + +public interface Lookup { + + /** + * @param path + * @return + */ + public Class getEntityClass(Path path) throws ObjectNotFoundException; + + /** + * @return + */ + public NextKeyManager getNextKeyManager(); + + /** + * @return + */ + public RoleManager getRoleManager(); + + /** + * @param path + * @return + */ + public Object resolve(Path path) throws ObjectNotFoundException; + + /** + * @param path + * @param name + * @return + */ + public Enumeration search(Path path, String name); + + /** + * @param newPath + */ + public void add(Path newPath) throws ObjectCannotBeUpdated, ObjectAlreadyExistsException; + + /** + * @param domainPath + * @return + */ + public Enumeration searchEntities(Path path); + + /** + * @param path + */ + public void delete(Path path) throws ObjectCannotBeUpdated; + + /** + * @param path + * @return + */ + public boolean exists(Path path); + + /** + * @param domainPath + * @return + */ + public EntityPath resolvePath(DomainPath domainPath) throws InvalidEntityPathException, ObjectNotFoundException; + + /** + * + */ + public void disconnect(); + + /** + * + */ + public void install() throws ObjectNotFoundException; + +} diff --git a/src/main/java/com/c2kernel/lookup/Path.java b/src/main/java/com/c2kernel/lookup/Path.java index 16d4f07..3ede4b6 100644 --- a/src/main/java/com/c2kernel/lookup/Path.java +++ b/src/main/java/com/c2kernel/lookup/Path.java @@ -227,7 +227,7 @@ public abstract class Path implements Serializable } public boolean exists() { - return Gateway.getLDAPLookup().exists(this); + return Gateway.getLookup().exists(this); } /** Queries the lookup for the IOR @@ -236,9 +236,9 @@ public abstract class Path implements Serializable public org.omg.CORBA.Object getIOR() { org.omg.CORBA.Object newIOR = null; if (mIOR==null) { // if not cached try to resolve - LDAPLookup myLookup = Gateway.getLDAPLookup(); + Lookup myLookup = Gateway.getLookup(); try { - newIOR = myLookup.getIOR(this); + newIOR = myLookup.resolve(this); } catch (ObjectNotFoundException ex) { } setIOR(newIOR); @@ -264,11 +264,11 @@ public abstract class Path implements Serializable LDAPSearchConstraints searchCons = new LDAPSearchConstraints(); searchCons.setBatchSize(10); searchCons.setDereference(LDAPSearchConstraints.DEREF_FINDING ); - return Gateway.getLDAPLookup().search(getFullDN(), LDAPConnection.SCOPE_ONE,filter,searchCons); + return Gateway.getLookup().search(getFullDN(), LDAPConnection.SCOPE_ONE,filter,searchCons); } public Path find(String name) throws ObjectNotFoundException { - Enumeration e = Gateway.getLDAPLookup().search(this, name); + Enumeration e = Gateway.getLookup().search(this, name); if (e.hasMoreElements()) { Path thisPath = e.nextElement(); if (e.hasMoreElements()) diff --git a/src/main/java/com/c2kernel/lookup/RoleManager.java b/src/main/java/com/c2kernel/lookup/RoleManager.java new file mode 100644 index 0000000..a483559 --- /dev/null +++ b/src/main/java/com/c2kernel/lookup/RoleManager.java @@ -0,0 +1,79 @@ +/* + * RoleManager.java + * + * Copyright (c) 2013, The CRISTAL Consortium. All rights reserved. + * + * CRISTAL kernel is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see: + * http://www.gnu.org/licenses/ + */ + +package com.c2kernel.lookup; + +import com.c2kernel.common.ObjectAlreadyExistsException; +import com.c2kernel.common.ObjectCannotBeUpdated; +import com.c2kernel.common.ObjectNotFoundException; + +public interface RoleManager { + + /** + * @param agentName + * @return + */ + public AgentPath getAgentPath(String agentName) throws ObjectNotFoundException; + + /** + * @param roleName + * @return + */ + public RolePath getRolePath(String roleName) throws ObjectNotFoundException; + + /** + * @param role + * @param b + * @return + */ + public RolePath createRole(String role, boolean b) throws ObjectAlreadyExistsException, ObjectCannotBeUpdated; + + /** + * @param agent + * @param rolePath + */ + public void addRole(AgentPath agent, RolePath rolePath) throws ObjectCannotBeUpdated, ObjectNotFoundException; + + /** + * @param rolePath + * @return + */ + public AgentPath[] getAgents(RolePath rolePath) throws ObjectNotFoundException; + + /** + * @param agentPath + * @return + */ + public RolePath[] getRoles(AgentPath agentPath); + + /** + * @param agentPath + * @param role + * @return + */ + public boolean hasRole(AgentPath agentPath, RolePath role); + + /** + * @param agent + * @param rolePath + */ + public void removeRole(AgentPath agent, RolePath role) throws ObjectCannotBeUpdated, ObjectNotFoundException; + +} diff --git a/src/main/java/com/c2kernel/lookup/RolePath.java b/src/main/java/com/c2kernel/lookup/RolePath.java index e6593ea..cdda034 100644 --- a/src/main/java/com/c2kernel/lookup/RolePath.java +++ b/src/main/java/com/c2kernel/lookup/RolePath.java @@ -73,7 +73,7 @@ public class RolePath extends DomainPath public AgentPath[] getAgentsWithRole() { try { - return Gateway.getLDAPLookup().getRoleManager().getAgents(this); + return Gateway.getLookup().getRoleManager().getAgents(this); } catch (ObjectNotFoundException ex) { Logger.error("Cannot retrieve agent list. Role "+getName()+" does not exist in LDAP"); return new AgentPath[0]; @@ -81,11 +81,11 @@ public class RolePath extends DomainPath } public void addAgent(AgentPath agent) throws ObjectCannotBeUpdated, ObjectNotFoundException { - Gateway.getLDAPLookup().getRoleManager().addRole(agent, this); + Gateway.getLookup().getRoleManager().addRole(agent, this); } public void removeAgent(AgentPath agent) throws ObjectCannotBeUpdated, ObjectNotFoundException { - Gateway.getLDAPLookup().getRoleManager().removeRole(agent, this); + Gateway.getLookup().getRoleManager().removeRole(agent, this); } @Override diff --git a/src/main/java/com/c2kernel/persistency/LDAPClusterStorage.java b/src/main/java/com/c2kernel/persistency/LDAPClusterStorage.java index 16ac7a0..8e35fae 100644 --- a/src/main/java/com/c2kernel/persistency/LDAPClusterStorage.java +++ b/src/main/java/com/c2kernel/persistency/LDAPClusterStorage.java @@ -6,6 +6,7 @@ import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.lookup.EntityPath; import com.c2kernel.lookup.InvalidEntityPathException; +import com.c2kernel.lookup.LDAPLookup; import com.c2kernel.lookup.LDAPPropertyManager; import com.c2kernel.process.Gateway; import com.c2kernel.property.Property; @@ -16,8 +17,10 @@ public class LDAPClusterStorage extends ClusterStorage { @Override public void open() throws ClusterStorageException { - ldapStore = Gateway.getLDAPLookup().getPropManager(); - + if (Gateway.getLookup() instanceof LDAPLookup) + ldapStore = ((LDAPLookup)Gateway.getLookup()).getPropManager(); + else + throw new ClusterStorageException("Can't use LDAP storage when not using LDAP lookup."); } @Override diff --git a/src/main/java/com/c2kernel/persistency/ProxyLoader.java b/src/main/java/com/c2kernel/persistency/ProxyLoader.java index e93c1ff..69847ca 100644 --- a/src/main/java/com/c2kernel/persistency/ProxyLoader.java +++ b/src/main/java/com/c2kernel/persistency/ProxyLoader.java @@ -7,7 +7,7 @@ import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.entity.ItemHelper; import com.c2kernel.entity.ManageableEntity; import com.c2kernel.lookup.EntityPath; -import com.c2kernel.lookup.LDAPLookup; +import com.c2kernel.lookup.Lookup; import com.c2kernel.persistency.outcome.Outcome; import com.c2kernel.process.Gateway; import com.c2kernel.utils.Logger; @@ -18,11 +18,11 @@ import com.c2kernel.utils.Logger; public class ProxyLoader extends ClusterStorage { HashMap entities = new HashMap(); - LDAPLookup lookup; + Lookup lookup; @Override public void open() throws ClusterStorageException { - lookup = Gateway.getLDAPLookup(); + lookup = Gateway.getLookup(); } @Override @@ -109,7 +109,7 @@ public class ProxyLoader extends ClusterStorage { try { Logger.msg(7, "ProxyLoader.getIOR() - Resolving "+sysKey+"."); - org.omg.CORBA.Object ior = lookup.getIOR(new EntityPath(sysKey.intValue())); + org.omg.CORBA.Object ior = lookup.resolve(new EntityPath(sysKey.intValue())); ManageableEntity thisEntity = null; try { diff --git a/src/main/java/com/c2kernel/process/Bootstrap.java b/src/main/java/com/c2kernel/process/Bootstrap.java index 0d22cb3..b4e192c 100644 --- a/src/main/java/com/c2kernel/process/Bootstrap.java +++ b/src/main/java/com/c2kernel/process/Bootstrap.java @@ -22,7 +22,7 @@ import com.c2kernel.lifecycle.instance.stateMachine.Transitions; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.DomainPath; import com.c2kernel.lookup.EntityPath; -import com.c2kernel.lookup.LDAPLookup; +import com.c2kernel.lookup.Lookup; import com.c2kernel.lookup.Path; import com.c2kernel.lookup.RolePath; import com.c2kernel.persistency.ClusterStorage; @@ -114,7 +114,7 @@ public class Bootstrap public static void verifyResource(String ns, String itemName, String itemType, String data) throws Exception { Logger.msg(1, "Bootstrap.verifyResource() - Verifying data of "+getDataType(itemType)+" "+itemName); - Enumeration en = Gateway.getLDAPLookup().search(getTypeRoot(itemType), itemName); + Enumeration en = Gateway.getLookup().search(getTypeRoot(itemType), itemName); ItemProxy thisProxy; Outcome newOutcome = new Outcome(0, data, getDataType(itemType), 0); @@ -183,16 +183,16 @@ public class Bootstrap ca = (CompositeActivity) ((CompositeActivityDef)LocalObjectLoader.getActDef(wf, "last")).instantiate(); } - EntityPath entityPath = Gateway.getLDAPLookup().getNextKeyManager().generateNextEntityKey(); + EntityPath entityPath = Gateway.getLookup().getNextKeyManager().generateNextEntityKey(); TraceableEntity newItem = (TraceableEntity)Gateway.getCorbaServer().createEntity(entityPath); - Gateway.getLDAPLookup().add(entityPath); + Gateway.getLookup().add(entityPath); newItem.initialise( 1, Gateway.getMarshaller().marshall(props), Gateway.getMarshaller().marshall(ca)); DomainPath newDomPath = new DomainPath(getTypeRoot(itemType).toString()+"/system/"+(ns==null?"kernel":ns)+"/"+itemName); newDomPath.setEntity(entityPath); - Gateway.getLDAPLookup().add(newDomPath); + Gateway.getLookup().add(newDomPath); return (ItemProxy)Gateway.getProxyManager().getProxy(entityPath); } @@ -224,7 +224,7 @@ public class Bootstrap **************************************************************************/ private static void checkAgent(String name, String pass, String role, boolean joblist) throws Exception { Logger.msg(1, "Bootstrap.checkAgent() - Checking for existence of '"+name+"' user."); - LDAPLookup lookup = Gateway.getLDAPLookup(); + Lookup lookup = Gateway.getLookup(); try { lookup.getRoleManager().getAgentPath(name); Logger.msg(3, "Bootstrap.checkAgent() - User '"+name+"' found."); @@ -244,7 +244,7 @@ public class Bootstrap AgentPath agentPath = new AgentPath(entityPath.getSysKey(), name); agentPath.setPassword(pass); Gateway.getCorbaServer().createEntity(agentPath); - Gateway.getLDAPLookup().add(agentPath); + Gateway.getLookup().add(agentPath); // assign admin role Logger.msg("Bootstrap.checkAgent() - Assigning role '"+role+"'"); @@ -282,11 +282,11 @@ public class Bootstrap serverEntity = thisServerPath.getEntity(); } catch (ObjectNotFoundException ex) { Logger.msg("Creating server item "+thisServerPath); - serverEntity = Gateway.getLDAPLookup().getNextKeyManager().generateNextEntityKey(); + serverEntity = Gateway.getLookup().getNextKeyManager().generateNextEntityKey(); Gateway.getCorbaServer().createEntity(serverEntity); - Gateway.getLDAPLookup().add(serverEntity); + Gateway.getLookup().add(serverEntity); thisServerPath.setEntity(serverEntity); - Gateway.getLDAPLookup().add(thisServerPath); + Gateway.getLookup().add(thisServerPath); } Gateway.getStorage().put(serverEntity.getSysKey(), new Property("Name", serverName), null); Gateway.getStorage().put(serverEntity.getSysKey(), new Property("Type", "Server"), null); @@ -306,7 +306,7 @@ public class Bootstrap PredefinedStepContainer predef = (PredefinedStepContainer)wf.search("workflow/predefined"); wf.getChildGraphModel().removeVertex(predef); wf.addChild(new ServerPredefinedStepContainer(), predef.getCentrePoint()); - wf.initialise(thisServerPath.getSysKey(), Gateway.getLDAPLookup().getRoleManager().getAgentPath("system")); + wf.initialise(thisServerPath.getSysKey(), Gateway.getLookup().getRoleManager().getAgentPath("system")); Gateway.getStorage().put(thisServerPath.getSysKey(), wf, null); } } diff --git a/src/main/java/com/c2kernel/process/Gateway.java b/src/main/java/com/c2kernel/process/Gateway.java index 2bbe638..14d1d8f 100644 --- a/src/main/java/com/c2kernel/process/Gateway.java +++ b/src/main/java/com/c2kernel/process/Gateway.java @@ -17,6 +17,7 @@ import com.c2kernel.entity.proxy.EntityProxyManager; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.LDAPLookup; import com.c2kernel.lookup.LDAPProperties; +import com.c2kernel.lookup.Lookup; import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.persistency.TransactionManager; import com.c2kernel.process.module.ModuleManager; @@ -52,7 +53,7 @@ public class Gateway static private Properties mC2KProps; static private ModuleManager mModules; static private org.omg.CORBA.ORB mORB; - static private LDAPLookup mLDAPLookup; + static private Lookup mLookup; static private TransactionManager mStorage; static private EntityProxyManager mProxyManager; static private CorbaServer mCorbaServer; @@ -130,7 +131,7 @@ public class Gateway static public void startServer() throws InvalidDataException { try { // check top level LDAP contexts - mLDAPLookup.install(); + mLookup.install(); // start entity proxy server EntityProxyManager.initServer(); @@ -190,6 +191,7 @@ public class Gateway throws InvalidDataException, ClusterStorageException { + //Class lookupClass = Class.forName(getProperty("Lookup", "com.c2kernel.lookup.LDAPLookup")); LDAPProperties ldapProps = new LDAPProperties(); if( ldapProps.mHost != null && ldapProps.mPort != null && @@ -197,7 +199,7 @@ public class Gateway { try { - mLDAPLookup = new LDAPLookup(ldapProps); + mLookup = new LDAPLookup(ldapProps); } catch (Exception ex) { @@ -228,7 +230,7 @@ public class Gateway LDAPProperties ldapProps = new LDAPProperties(); AgentPath agentPath; try { - agentPath = mLDAPLookup.getRoleManager().getAgentPath(agentName); + agentPath = mLookup.getRoleManager().getAgentPath(agentName); } catch (Exception ex) { Logger.error(ex); throw new ObjectNotFoundException("Could not resolve agent", ""); @@ -239,7 +241,7 @@ public class Gateway try { LDAPLookup.createConnection(ldapProps); - return (AgentProxy)getProxyManager().getProxy(mLDAPLookup.getRoleManager().getAgentPath(agentName)); + return (AgentProxy)getProxyManager().getProxy(mLookup.getRoleManager().getAgentPath(agentName)); } catch (Exception ex) { Logger.error(ex); throw new InvalidDataException("Could not log in", ""); @@ -265,16 +267,16 @@ public class Gateway try { ldapProps.mUser = ""; ldapProps.mPassword = ""; - mLDAPLookup = new LDAPLookup(ldapProps); - String agentDN = mLDAPLookup.getRoleManager().getAgentPath(agentName).getFullDN(); + mLookup = new LDAPLookup(ldapProps); + String agentDN = mLookup.getRoleManager().getAgentPath(agentName).getFullDN(); //found agentDN, try to log in with it ldapProps.mUser = agentDN; ldapProps.mPassword = agentPassword; - mLDAPLookup = new LDAPLookup(ldapProps); + mLookup = new LDAPLookup(ldapProps); // find agent proxy - AgentPath agentPath = mLDAPLookup.getRoleManager().getAgentPath(agentName); + AgentPath agentPath = mLookup.getRoleManager().getAgentPath(agentName); if (agentPath!=null) { @@ -348,9 +350,9 @@ public class Gateway mStorage = null; // disconnect from ldap - if (mLDAPLookup != null) - mLDAPLookup.disconnect(); - mLDAPLookup = null; + if (mLookup != null) + mLookup.disconnect(); + mLookup = null; // shut down proxy manager if (mProxyManager != null) @@ -372,9 +374,9 @@ public class Gateway return mORB; } - static public LDAPLookup getLDAPLookup() + static public Lookup getLookup() { - return mLDAPLookup; + return mLookup; } static public CorbaServer getCorbaServer() diff --git a/src/main/java/com/c2kernel/process/module/Module.java b/src/main/java/com/c2kernel/process/module/Module.java index 91c43b2..ff9aba6 100644 --- a/src/main/java/com/c2kernel/process/module/Module.java +++ b/src/main/java/com/c2kernel/process/module/Module.java @@ -93,17 +93,17 @@ public class Module { continue; } catch (ObjectNotFoundException ex) { } Logger.msg("Module.importAll() - Item '"+thisItem.name+"' not found. Creating."); - thisItem.create(Gateway.getLDAPLookup().getRoleManager().getAgentPath("system").getSysKey()); + thisItem.create(Gateway.getLookup().getRoleManager().getAgentPath("system").getSysKey()); } else if (thisImp instanceof NewAgent) { NewAgent thisAgent = (NewAgent)thisImp; try { - Gateway.getLDAPLookup().getRoleManager().getAgentPath(thisAgent.name); + Gateway.getLookup().getRoleManager().getAgentPath(thisAgent.name); Logger.msg(3, "Module.importAll() - User '"+thisAgent.name+"' found."); continue; } catch (ObjectNotFoundException ex) { } Logger.msg("Module.importAll() - User '"+thisAgent.name+"' not found. Creating."); - thisAgent.create(Gateway.getLDAPLookup().getRoleManager().getAgentPath("system").getSysKey()); + thisAgent.create(Gateway.getLookup().getRoleManager().getAgentPath("system").getSysKey()); } } } diff --git a/src/main/java/com/c2kernel/scripting/Script.java b/src/main/java/com/c2kernel/scripting/Script.java index 7e0c3f2..7d81f62 100644 --- a/src/main/java/com/c2kernel/scripting/Script.java +++ b/src/main/java/com/c2kernel/scripting/Script.java @@ -135,7 +135,7 @@ public class Script beans.put("storage", Gateway.getStorage()); beans.put("db", Gateway.getStorage().getDb()); beans.put("proxy", Gateway.getProxyManager()); - beans.put("lookup", Gateway.getLDAPLookup()); + beans.put("lookup", Gateway.getLookup()); beans.put("orb", Gateway.getORB()); beans.put("agent", agent); beans.put("output", out); diff --git a/src/main/java/com/c2kernel/scripting/ScriptConsole.java b/src/main/java/com/c2kernel/scripting/ScriptConsole.java index 9b70641..e7eb10e 100644 --- a/src/main/java/com/c2kernel/scripting/ScriptConsole.java +++ b/src/main/java/com/c2kernel/scripting/ScriptConsole.java @@ -141,7 +141,7 @@ public class ScriptConsole implements SocketHandler { AgentProxy user = Gateway.getCurrentUser(); try { if (user == null) user = (AgentProxy)Gateway.getProxyManager().getProxy( - Gateway.getLDAPLookup().getRoleManager().getAgentPath("system")); + Gateway.getLookup().getRoleManager().getAgentPath("system")); } catch (Exception ex) { output.println("System agent unavailable"); } -- cgit v1.2.3