From 2353f4fc4252f7067478d6a9d8993daeb5d66e6a Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Fri, 6 Jun 2014 17:14:26 +0200 Subject: Partial javadoc and scope tightening of the new interfaces. --- src/main/java/com/c2kernel/lookup/Lookup.java | 173 ++++++++++++++++++++++++-- 1 file changed, 166 insertions(+), 7 deletions(-) (limited to 'src/main/java/com/c2kernel/lookup/Lookup.java') diff --git a/src/main/java/com/c2kernel/lookup/Lookup.java b/src/main/java/com/c2kernel/lookup/Lookup.java index 026ad19..5c6d1e9 100644 --- a/src/main/java/com/c2kernel/lookup/Lookup.java +++ b/src/main/java/com/c2kernel/lookup/Lookup.java @@ -9,68 +9,227 @@ import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.process.auth.Authenticator; import com.c2kernel.property.PropertyDescriptionList; +/** + * @author abranson + * + */ public interface Lookup { + /** + * Called when a server starts up. The Lookup implementation should ensure that the initial structure of its directory is valid, and create it on first boot. + * + * @throws ObjectNotFoundException When initialization data is not found + */ public void initializeDirectory() throws ObjectNotFoundException; + /** + * Connect to the directory using the credentials supplied in the Authenticator. + * + * @param user The connected Authenticator. The Lookup implementation may use the AuthObject in this to communicate with the database. + */ public void open(Authenticator user); + /** + * Shutdown the lookup + */ public void close(); // Path resolution + /** + * Decide whether a path references an Item or an Agent, from its directory data + * @param path The path of the Item or Agent + * @return TraceableEntity.class or ActiveEntity.class + * @throws ObjectNotFoundException When the path doesn't exist in the directory + */ public Class getItemClass(Path path) throws ObjectNotFoundException; - public ItemPath resolvePath(DomainPath domainPath) throws InvalidItemPathException, ObjectNotFoundException; - + /** + * Find the ItemPath for which a DomainPath is an alias. + * + * @param domainPath The path to resolve + * @return The ItemPath it points to (should be an AgentPath if the path references an Agent) + * @throws InvalidItemPathException + * @throws ObjectNotFoundException + */ + public ItemPath resolvePath(DomainPath domainPath) throws InvalidItemPathException, ObjectNotFoundException; + + /** + * Resolve a path to a CORBA Object Item or Agent + * + * @param path The path to be resolved + * @return The CORBA Object + * @throws ObjectNotFoundException When the Path doesn't exist, or doesn't have an IOR associated with it + */ public org.omg.CORBA.Object resolve(Path path) throws ObjectNotFoundException; // Path management + /** + * Register a new a Path in the directory. + * + * @param newPath The path to add + * @throws ObjectCannotBeUpdated When there is an error writing to the directory + * @throws ObjectAlreadyExistsException When the Path has already been registered + */ public void add(Path newPath) throws ObjectCannotBeUpdated, ObjectAlreadyExistsException; + /** + * Remove a Path from the directory + * @param path The path to remove + * @throws ObjectCannotBeUpdated When an error occurs writing to the directory + */ public void delete(Path path) throws ObjectCannotBeUpdated; // Path finding and searching + /** + * Checks if a particular Path exists in the directory + * @param path The path to check + * @return boolean true if the path exists, false if it doesn't + */ public boolean exists(Path path); + /** + * List the next-level-deep children of a Path + * + * @param path The parent Path + * @return An Iterator of child Paths + */ public Iterator getChildren(Path path); - public Iterator search(Path path, String name); - + /** + * Find a path with a particular name (last component) + * + * @param start Search root + * @param name The name to search for + * @return An Iterator of matching Paths. Should be an empty Iterator if there are no matches. + */ + public Iterator search(Path start, String name); + + /** + * Search for Items in the specified path with the given property name and value + * @param start Search root + * @param propname Property name + * @param propvalue The property value to search for + * @return An Iterator of matching Paths + */ public Iterator search(Path start, String propname, String propvalue); + /** + * Search for Items of a particular type, based on its PropertyDescription outcome + * @param start Search root + * @param props Properties unmarshalled from an ItemDescription's property description outcome. + * @return An Iterator of matching Paths + */ public Iterator search(Path start, PropertyDescriptionList props); - public Iterator searchEntities(Path path); + /** + * Find all ItemPaths in a given subtree of the directory. + * + * @param start Search root + * @return An Iterator of matching Paths + */ + public Iterator searchEntities(Path start); + /** + * Find all DomainPaths in a given subtree of the directory + * + * @param start Search root + * @return An Iterator of matching Paths + */ public Iterator searchAliases(DomainPath start); + /** + * Find all DomainPaths that are aliases for a particular Item or Agent + * @param itemPath The ItemPath + * @return An Iterator of DomainPaths that are aliases for that Item + */ public Iterator searchAliases(ItemPath itemPath); // Role and agent management + /** + * @param agentName + * @return + * @throws ObjectNotFoundException + */ public AgentPath getAgentPath(String agentName) throws ObjectNotFoundException; + /** + * @param roleName + * @return + * @throws ObjectNotFoundException + */ public RolePath getRolePath(String roleName) throws ObjectNotFoundException; - public RolePath createRole(String role, boolean b) throws ObjectAlreadyExistsException, ObjectCannotBeUpdated; - + /** + * @param role + * @param hasJobList + * @return + * @throws ObjectAlreadyExistsException + * @throws ObjectCannotBeUpdated + */ + public RolePath createRole(String role, boolean hasJobList) throws ObjectAlreadyExistsException, ObjectCannotBeUpdated; + + /** + * @param agent + * @param rolePath + * @throws ObjectCannotBeUpdated + * @throws ObjectNotFoundException + */ public void addRole(AgentPath agent, RolePath rolePath) throws ObjectCannotBeUpdated, ObjectNotFoundException; + /** + * @param rolePath + * @return + * @throws ObjectNotFoundException + */ 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 role + * @throws ObjectCannotBeUpdated + * @throws ObjectNotFoundException + */ public void removeRole(AgentPath agent, RolePath role) throws ObjectCannotBeUpdated, ObjectNotFoundException; + /** + * @param agentPath + * @return + * @throws ObjectNotFoundException + */ public String getAgentName(AgentPath agentPath) throws ObjectNotFoundException; + /** + * @param agent + * @param newPassword + * @throws ObjectNotFoundException + * @throws ObjectCannotBeUpdated + * @throws NoSuchAlgorithmException + */ public void setAgentPassword(AgentPath agent, String newPassword) throws ObjectNotFoundException, ObjectCannotBeUpdated, NoSuchAlgorithmException; + /** + * @param role + * @param hasJobList + * @throws ObjectNotFoundException + * @throws ObjectCannotBeUpdated + */ public void setHasJobList(RolePath role, boolean hasJobList) throws ObjectNotFoundException, ObjectCannotBeUpdated; -- cgit v1.2.3 From c45ee34928eaa7d148c60fb520f279362414af5a Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Thu, 12 Jun 2014 10:24:01 +0200 Subject: Separate PredefinedStepContainers for Agents and Items (and Server Item) --- src/main/java/com/c2kernel/entity/CorbaServer.java | 33 +++++++++++----------- src/main/java/com/c2kernel/lookup/Lookup.java | 15 +++++----- 2 files changed, 24 insertions(+), 24 deletions(-) (limited to 'src/main/java/com/c2kernel/lookup/Lookup.java') diff --git a/src/main/java/com/c2kernel/entity/CorbaServer.java b/src/main/java/com/c2kernel/entity/CorbaServer.java index 3a01ed7..60c10a8 100644 --- a/src/main/java/com/c2kernel/entity/CorbaServer.java +++ b/src/main/java/com/c2kernel/entity/CorbaServer.java @@ -117,29 +117,28 @@ public class CorbaServer { /************************************************************************** * Returns a CORBA servant for a pre-existing entity **************************************************************************/ - private Servant getEntity(int sysKey, org.omg.PortableServer.POA poa) throws ObjectNotFoundException { + private Servant getItem(int sysKey, org.omg.PortableServer.POA poa) throws ObjectNotFoundException { try { - ItemPath entityPath = new ItemPath(sysKey); - Servant entity = null; + ItemPath itemPath = Gateway.getLookup().getItemPath(sysKey); + Servant item = null; synchronized (mEntityCache) { - entity = mEntityCache.get(entityPath); - if (entity == null) { + item = mEntityCache.get(itemPath); + if (item == null) { Logger.msg(7, "Creating new servant for "+sysKey); - Class entityClass = Gateway.getLookup().getItemClass(entityPath); - - if (entityClass == TraceableEntity.class) { - if (poa == null) poa = mItemPOA; - entity = new TraceableEntity(sysKey, poa); - } - else if (entityClass == ActiveEntity.class) { + if (itemPath instanceof AgentPath) { if (poa == null) poa = mAgentPOA; - entity = new ActiveEntity(sysKey, poa); + item = new ActiveEntity(sysKey, poa); + } + else if (itemPath instanceof ItemPath) { + if (poa == null) poa = mItemPOA; + item = new TraceableEntity(sysKey, poa); } - mEntityCache.put(entityPath, entity); + + mEntityCache.put(itemPath, item); } } - return entity; + return item; } catch (InvalidItemPathException ex) { throw new ObjectNotFoundException("Invalid Entity Key", ""); @@ -150,14 +149,14 @@ public class CorbaServer { * Wrapper for fetching Items **************************************************************************/ public TraceableEntity getItem(int sysKey) throws ObjectNotFoundException { - return (TraceableEntity)getEntity(sysKey, mItemPOA); + return (TraceableEntity)getItem(sysKey, mItemPOA); } /************************************************************************** * Wrapper for fetching Agents **************************************************************************/ public ActiveEntity getAgent(int sysKey) throws ObjectNotFoundException { - return (ActiveEntity)getEntity(sysKey, mAgentPOA); + return (ActiveEntity)getItem(sysKey, mAgentPOA); } /** diff --git a/src/main/java/com/c2kernel/lookup/Lookup.java b/src/main/java/com/c2kernel/lookup/Lookup.java index 5c6d1e9..d71034f 100644 --- a/src/main/java/com/c2kernel/lookup/Lookup.java +++ b/src/main/java/com/c2kernel/lookup/Lookup.java @@ -35,15 +35,16 @@ public interface Lookup { public void close(); // Path resolution - /** - * Decide whether a path references an Item or an Agent, from its directory data - * @param path The path of the Item or Agent - * @return TraceableEntity.class or ActiveEntity.class - * @throws ObjectNotFoundException When the path doesn't exist in the directory + * Fetch the correct subclass class of ItemPath for a particular Item, derived from its lookup entry. This is used by Item + * + * @param sysKey The system key of the Item + * @return an ItemPath or AgentPath + * @throws InvalidItemPathException When the system key is invalid/out-of-range + * @throws ObjectNotFoundException When the Item does not exist in the directory. */ - public Class getItemClass(Path path) throws ObjectNotFoundException; - + public ItemPath getItemPath(int sysKey) throws InvalidItemPathException, ObjectNotFoundException; + /** * Find the ItemPath for which a DomainPath is an alias. * -- cgit v1.2.3 From 4c4da2ce679efc0d53b7e62fa26d43c164cae7d4 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Thu, 12 Jun 2014 11:36:57 +0200 Subject: Combine various Lookup.search methods into a general search(Path, Property...) --- .../java/com/c2kernel/entity/proxy/ProxyManager.java | 2 +- src/main/java/com/c2kernel/lookup/Lookup.java | 19 ++----------------- 2 files changed, 3 insertions(+), 18 deletions(-) (limited to 'src/main/java/com/c2kernel/lookup/Lookup.java') diff --git a/src/main/java/com/c2kernel/entity/proxy/ProxyManager.java b/src/main/java/com/c2kernel/entity/proxy/ProxyManager.java index 2b2e0e9..ae02fc5 100644 --- a/src/main/java/com/c2kernel/entity/proxy/ProxyManager.java +++ b/src/main/java/com/c2kernel/entity/proxy/ProxyManager.java @@ -40,7 +40,7 @@ public class ProxyManager { Logger.msg(5, "ProxyManager - Starting....."); - Iterator servers = Gateway.getLookup().searchEntities(new DomainPath("/servers")); + Iterator servers = Gateway.getLookup().search(new DomainPath("/servers")); while(servers.hasNext()) { Path thisServerPath = servers.next(); try { diff --git a/src/main/java/com/c2kernel/lookup/Lookup.java b/src/main/java/com/c2kernel/lookup/Lookup.java index d71034f..1c7c6c7 100644 --- a/src/main/java/com/c2kernel/lookup/Lookup.java +++ b/src/main/java/com/c2kernel/lookup/Lookup.java @@ -7,6 +7,7 @@ import com.c2kernel.common.ObjectAlreadyExistsException; import com.c2kernel.common.ObjectCannotBeUpdated; import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.process.auth.Authenticator; +import com.c2kernel.property.Property; import com.c2kernel.property.PropertyDescriptionList; /** @@ -115,7 +116,7 @@ public interface Lookup { * @param propvalue The property value to search for * @return An Iterator of matching Paths */ - public Iterator search(Path start, String propname, String propvalue); + public Iterator search(Path start, Property... props); /** * Search for Items of a particular type, based on its PropertyDescription outcome @@ -124,22 +125,6 @@ public interface Lookup { * @return An Iterator of matching Paths */ public Iterator search(Path start, PropertyDescriptionList props); - - /** - * Find all ItemPaths in a given subtree of the directory. - * - * @param start Search root - * @return An Iterator of matching Paths - */ - public Iterator searchEntities(Path start); - - /** - * Find all DomainPaths in a given subtree of the directory - * - * @param start Search root - * @return An Iterator of matching Paths - */ - public Iterator searchAliases(DomainPath start); /** * Find all DomainPaths that are aliases for a particular Item or Agent -- cgit v1.2.3 From d0fc327008394ef34c7796976ed6e20c01a64775 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Mon, 23 Jun 2014 14:44:35 +0200 Subject: Finished half-finished doc sentence. --- src/main/java/com/c2kernel/lookup/Lookup.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/main/java/com/c2kernel/lookup/Lookup.java') diff --git a/src/main/java/com/c2kernel/lookup/Lookup.java b/src/main/java/com/c2kernel/lookup/Lookup.java index 1c7c6c7..039c368 100644 --- a/src/main/java/com/c2kernel/lookup/Lookup.java +++ b/src/main/java/com/c2kernel/lookup/Lookup.java @@ -37,7 +37,8 @@ public interface Lookup { // Path resolution /** - * Fetch the correct subclass class of ItemPath for a particular Item, derived from its lookup entry. This is used by Item + * Fetch the correct subclass class of ItemPath for a particular Item, derived from its lookup entry. + * This is used by the CORBA Server to make sure the correct Item subclass is used. * * @param sysKey The system key of the Item * @return an ItemPath or AgentPath -- cgit v1.2.3 From 2495be9ecfa8aea47e285f63b5bb27b0c133b1f8 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Mon, 30 Jun 2014 23:03:03 +0200 Subject: Separated modifying Lookup methods into LookupManager, which is only present in a server process. This stops clients trying to write to the directory without relying on their permissions. --- .../com/c2kernel/entity/imports/ImportAgent.java | 2 +- .../com/c2kernel/entity/imports/ImportItem.java | 4 +- .../com/c2kernel/entity/imports/ImportRole.java | 5 +- .../com/c2kernel/entity/proxy/ProxyManager.java | 3 +- .../com/c2kernel/entity/transfer/TransferItem.java | 4 +- .../instance/predefined/AddDomainPath.java | 7 +- .../instance/predefined/RemoveDomainPath.java | 8 +- .../agent/CreateAgentFromDescription.java | 4 +- .../instance/predefined/agent/RemoveAgent.java | 7 +- .../predefined/agent/SetAgentPassword.java | 5 +- .../predefined/item/CreateItemFromDescription.java | 4 +- .../lifecycle/instance/predefined/item/Erase.java | 4 +- .../predefined/server/AddDomainContext.java | 5 +- .../predefined/server/RemoveDomainContext.java | 5 +- src/main/java/com/c2kernel/lookup/Lookup.java | 71 ------------------ .../java/com/c2kernel/lookup/LookupManager.java | 85 ++++++++++++++++++++++ src/main/java/com/c2kernel/lookup/RolePath.java | 14 ++-- src/main/java/com/c2kernel/process/Bootstrap.java | 24 +++--- src/main/java/com/c2kernel/process/Gateway.java | 21 +++++- src/main/java/com/c2kernel/property/Property.java | 6 ++ 20 files changed, 172 insertions(+), 116 deletions(-) create mode 100644 src/main/java/com/c2kernel/lookup/LookupManager.java (limited to 'src/main/java/com/c2kernel/lookup/Lookup.java') diff --git a/src/main/java/com/c2kernel/entity/imports/ImportAgent.java b/src/main/java/com/c2kernel/entity/imports/ImportAgent.java index 26e3325..2aa6533 100644 --- a/src/main/java/com/c2kernel/entity/imports/ImportAgent.java +++ b/src/main/java/com/c2kernel/entity/imports/ImportAgent.java @@ -36,7 +36,7 @@ public class ImportAgent extends ModuleImport implements java.io.Serializable { newAgent.setAgentName(name); newAgent.setPassword(password); ActiveEntity newAgentEnt = (ActiveEntity)Gateway.getCorbaServer().createEntity(newAgent); - Gateway.getLookup().add(newAgent); + Gateway.getLookupManager().add(newAgent); // assemble properties properties.add(new com.c2kernel.property.Property("Name", name, true)); properties.add(new com.c2kernel.property.Property("Type", "Agent", false)); diff --git a/src/main/java/com/c2kernel/entity/imports/ImportItem.java b/src/main/java/com/c2kernel/entity/imports/ImportItem.java index a27d88d..3847fbf 100644 --- a/src/main/java/com/c2kernel/entity/imports/ImportItem.java +++ b/src/main/java/com/c2kernel/entity/imports/ImportItem.java @@ -79,7 +79,7 @@ public class ImportItem extends ModuleImport { // create item entPath = Gateway.getNextKeyManager().generateNextEntityKey(); newItem = (TraceableEntity)Gateway.getCorbaServer().createEntity(entPath); - Gateway.getLookup().add(entPath); + Gateway.getLookupManager().add(entPath); } // set the name property @@ -181,7 +181,7 @@ public class ImportItem extends ModuleImport { // register domain path (before collections in case of recursive collections) if (!domPath.exists()) { domPath.setEntity(entPath); - Gateway.getLookup().add(domPath); + Gateway.getLookupManager().add(domPath); } } } diff --git a/src/main/java/com/c2kernel/entity/imports/ImportRole.java b/src/main/java/com/c2kernel/entity/imports/ImportRole.java index 8313c24..5749b06 100644 --- a/src/main/java/com/c2kernel/entity/imports/ImportRole.java +++ b/src/main/java/com/c2kernel/entity/imports/ImportRole.java @@ -1,5 +1,6 @@ package com.c2kernel.entity.imports; +import com.c2kernel.common.CannotManageException; import com.c2kernel.common.ObjectAlreadyExistsException; import com.c2kernel.common.ObjectCannotBeUpdated; import com.c2kernel.process.Gateway; @@ -12,8 +13,8 @@ public class ImportRole extends ModuleImport { public ImportRole() { } - public void create(int agentId) throws ObjectAlreadyExistsException, ObjectCannotBeUpdated { - Gateway.getLookup().createRole(name, jobList); + public void create(int agentId) throws ObjectAlreadyExistsException, ObjectCannotBeUpdated, CannotManageException { + Gateway.getLookupManager().createRole(name, jobList); } } diff --git a/src/main/java/com/c2kernel/entity/proxy/ProxyManager.java b/src/main/java/com/c2kernel/entity/proxy/ProxyManager.java index ae02fc5..f65d26e 100644 --- a/src/main/java/com/c2kernel/entity/proxy/ProxyManager.java +++ b/src/main/java/com/c2kernel/entity/proxy/ProxyManager.java @@ -40,10 +40,11 @@ public class ProxyManager { Logger.msg(5, "ProxyManager - Starting....."); - Iterator servers = Gateway.getLookup().search(new DomainPath("/servers")); + Iterator servers = Gateway.getLookup().search(new DomainPath("/servers"), new Property("Type", "Server")); while(servers.hasNext()) { Path thisServerPath = servers.next(); try { + Logger.msg(thisServerPath.dump()); int syskey = thisServerPath.getSysKey(); String remoteServer = ((Property)Gateway.getStorage().get(syskey, ClusterStorage.PROPERTY+"/Name", null)).getValue(); String portStr = ((Property)Gateway.getStorage().get(syskey, ClusterStorage.PROPERTY+"/ProxyPort", null)).getValue(); diff --git a/src/main/java/com/c2kernel/entity/transfer/TransferItem.java b/src/main/java/com/c2kernel/entity/transfer/TransferItem.java index 9a4cfc5..9852555 100644 --- a/src/main/java/com/c2kernel/entity/transfer/TransferItem.java +++ b/src/main/java/com/c2kernel/entity/transfer/TransferItem.java @@ -91,7 +91,7 @@ public class TransferItem { // create item ItemPath entityPath = new ItemPath(sysKey); TraceableEntity newItem = (TraceableEntity)Gateway.getCorbaServer().createEntity(entityPath); - Gateway.getLookup().add(entityPath); + Gateway.getLookupManager().add(entityPath); PropertyArrayList props = new PropertyArrayList(); Workflow wf = null; @@ -121,7 +121,7 @@ public class TransferItem { // add domPaths for (String element : domainPaths) { DomainPath newPath = new DomainPath(element, entityPath); - Gateway.getLookup().add(newPath); + Gateway.getLookupManager().add(newPath); } } 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 3da17e9..4c02cbb 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddDomainPath.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddDomainPath.java @@ -15,7 +15,7 @@ import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.DomainPath; import com.c2kernel.lookup.InvalidItemPathException; import com.c2kernel.lookup.ItemPath; -import com.c2kernel.lookup.Lookup; +import com.c2kernel.lookup.LookupManager; import com.c2kernel.process.Gateway; import com.c2kernel.utils.Logger; @@ -31,14 +31,11 @@ public class AddDomainPath extends PredefinedStep protected String runActivityLogic(AgentPath agent, int itemSysKey, int transitionID, String requestData) throws InvalidDataException { - Logger.msg(8,"AddAlias::request()"); - Lookup lookupManager = Gateway.getLookup(); - Logger.msg(1,"AddAlias::request() - Starting."); - try { + LookupManager lookupManager = Gateway.getLookupManager(); DomainPath domainPath = new DomainPath(getDataList(requestData)[0], new ItemPath(itemSysKey)); lookupManager.add(domainPath); Logger.msg(8,"AddDomainPath::request() - systemKey:" + itemSysKey + 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 1ee5e8c..df1c44e 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java @@ -11,11 +11,10 @@ package com.c2kernel.lifecycle.instance.predefined; import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectCannotBeUpdated; import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.DomainPath; -import com.c2kernel.lookup.Lookup; +import com.c2kernel.lookup.LookupManager; import com.c2kernel.process.Gateway; import com.c2kernel.utils.Logger; @@ -32,7 +31,7 @@ public class RemoveDomainPath extends PredefinedStep int transitionID, String requestData) throws InvalidDataException { Logger.msg(8,"RemoveDomainPath::request()"); - Lookup lookupManager = Gateway.getLookup(); + Logger.msg(1,"RemoveDomainPath::request() - Starting."); @@ -49,10 +48,11 @@ public class RemoveDomainPath extends PredefinedStep throw new InvalidDataException("Domain path "+domainPath.toString()+" is a context.", ""); } try { + LookupManager lookupManager = Gateway.getLookupManager(); lookupManager.delete(domainPath); Logger.msg(8,"AddAlias::request() - context:" + domainPath.toString() + " DONE."); return requestData; - } catch (ObjectCannotBeUpdated ex) { + } catch (Exception ex) { Logger.error(ex); throw new InvalidDataException("Problem updating directory", ""); } 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 78ef5a9..f311dc1 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 @@ -68,7 +68,7 @@ public class CreateAgentFromDescription extends CreateItemFromDescription CorbaServer factory = Gateway.getCorbaServer(); if (factory == null) throw new AccessRightsException("This process cannot create new Items", ""); ActiveEntity newAgent = (ActiveEntity)factory.createEntity(newAgentPath); - Gateway.getLookup().add(newAgentPath); + Gateway.getLookupManager().add(newAgentPath); // initialise it with its properties and workflow @@ -85,7 +85,7 @@ public class CreateAgentFromDescription extends CreateItemFromDescription // add its domain path Logger.msg(3, "CreateItemFromDescription - Creating "+context); context.setEntity(newAgentPath); - Gateway.getLookup().add(context); + Gateway.getLookupManager().add(context); return requestData; } catch (Exception e) { Logger.error(e); 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 80281cc..0630f6c 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 @@ -1,5 +1,6 @@ package com.c2kernel.lifecycle.instance.predefined.agent; +import com.c2kernel.common.CannotManageException; import com.c2kernel.common.InvalidDataException; import com.c2kernel.common.ObjectCannotBeUpdated; import com.c2kernel.common.ObjectNotFoundException; @@ -41,6 +42,8 @@ public class RemoveAgent extends PredefinedStep { } catch (ObjectNotFoundException e) { Logger.error(e); throw new InvalidDataException("Tried to remove "+agentName+" from Role "+role.getName()+" that doesn't exist.", ""); + } catch (CannotManageException e) { + throw new InvalidDataException("Tried to alter roles in a non-server process.", ""); } } @@ -54,8 +57,8 @@ public class RemoveAgent extends PredefinedStep { //remove entity path try { - Gateway.getLookup().delete(targetAgent); - } catch (ObjectCannotBeUpdated e) { + Gateway.getLookupManager().delete(targetAgent); + } catch (Exception e) { throw new InvalidDataException("Error deleting AgentPath for "+agentName, ""); } return requestData; 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 102e8e2..09fdefe 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 @@ -2,6 +2,7 @@ package com.c2kernel.lifecycle.instance.predefined.agent; import java.security.NoSuchAlgorithmException; +import com.c2kernel.common.CannotManageException; import com.c2kernel.common.InvalidDataException; import com.c2kernel.common.ObjectCannotBeUpdated; import com.c2kernel.common.ObjectNotFoundException; @@ -36,7 +37,7 @@ public class SetAgentPassword extends PredefinedStep { throw new InvalidDataException("Requires 1 param: new password", ""); try { - Gateway.getLookup().setAgentPassword(targetAgent, params[0]); + Gateway.getLookupManager().setAgentPassword(targetAgent, params[0]); } catch (ObjectNotFoundException e) { Logger.error(e); throw new InvalidDataException("Agent "+agentName+" not found.", ""); @@ -46,6 +47,8 @@ public class SetAgentPassword extends PredefinedStep { } catch (NoSuchAlgorithmException e) { Logger.error(e); throw new InvalidDataException("Cryptographic libraries for password hashing not found.", ""); + } catch (CannotManageException e) { + throw new InvalidDataException("Cannot set agent password in a non-server process.", ""); } params[1] = "REDACTED"; // censor user's password from outcome diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java index 5d6c0b9..f63c188 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java @@ -89,7 +89,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.getLookup().add(entityPath); + Gateway.getLookupManager().add(entityPath); // initialise it with its properties and workflow @@ -106,7 +106,7 @@ public class CreateItemFromDescription extends PredefinedStep // add its domain path Logger.msg(3, "CreateItemFromDescription - Creating "+context); context.setEntity(entityPath); - Gateway.getLookup().add(context); + Gateway.getLookupManager().add(context); return requestData; } catch (Exception e) { Logger.error(e); diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/Erase.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/Erase.java index 2e868c4..81eb329 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/Erase.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/Erase.java @@ -53,14 +53,14 @@ public class Erase extends PredefinedStep DomainPath path = (DomainPath)domPaths.next(); // delete them if (path.getSysKey() == itemSysKey) - Gateway.getLookup().delete(path); + Gateway.getLookupManager().delete(path); } //clear out all storages Gateway.getStorage().removeCluster(itemSysKey, "", null); //remove entity path - Gateway.getLookup().delete(new ItemPath(itemSysKey)); + Gateway.getLookupManager().delete(new ItemPath(itemSysKey)); } catch( Exception ex ) { diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/AddDomainContext.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/AddDomainContext.java index a931143..585f96f 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/AddDomainContext.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/AddDomainContext.java @@ -2,6 +2,7 @@ package com.c2kernel.lifecycle.instance.predefined.server; import java.util.Stack; +import com.c2kernel.common.CannotManageException; import com.c2kernel.common.InvalidDataException; import com.c2kernel.common.ObjectAlreadyExistsException; import com.c2kernel.common.ObjectCannotBeUpdated; @@ -35,12 +36,14 @@ public class AddDomainContext extends PredefinedStep { while(!pathsToAdd.empty()) { pathToAdd = pathsToAdd.pop(); try { - Gateway.getLookup().add(pathToAdd); + Gateway.getLookupManager().add(pathToAdd); } catch (ObjectAlreadyExistsException e) { Logger.error("Context "+pathToAdd+" inconsistently exists."); } catch (ObjectCannotBeUpdated e) { Logger.error(e); throw new InvalidDataException("Exception adding path "+pathToAdd+": "+e.getMessage(), ""); + } catch (CannotManageException e) { + throw new InvalidDataException("Cannot alter directory in a non-server process", ""); } } return requestData; diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveDomainContext.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveDomainContext.java index a55f7dd..956166a 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveDomainContext.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveDomainContext.java @@ -1,5 +1,6 @@ package com.c2kernel.lifecycle.instance.predefined.server; +import com.c2kernel.common.CannotManageException; import com.c2kernel.common.InvalidDataException; import com.c2kernel.common.ObjectCannotBeUpdated; import com.c2kernel.common.ObjectNotFoundException; @@ -31,10 +32,12 @@ public class RemoveDomainContext extends PredefinedStep { throw new InvalidDataException("Context "+pathToDelete+" is not empty. Cannot delete.", ""); try { - Gateway.getLookup().delete(pathToDelete); + Gateway.getLookupManager().delete(pathToDelete); } catch (ObjectCannotBeUpdated e) { Logger.error(e); throw new InvalidDataException("Exception deleting path"+pathToDelete+": "+e.getMessage(), ""); + } catch (CannotManageException e) { + throw new InvalidDataException("Cannot alter directory in a non-server process", ""); } return requestData; } diff --git a/src/main/java/com/c2kernel/lookup/Lookup.java b/src/main/java/com/c2kernel/lookup/Lookup.java index 039c368..5384e7c 100644 --- a/src/main/java/com/c2kernel/lookup/Lookup.java +++ b/src/main/java/com/c2kernel/lookup/Lookup.java @@ -1,10 +1,7 @@ package com.c2kernel.lookup; -import java.security.NoSuchAlgorithmException; import java.util.Iterator; -import com.c2kernel.common.ObjectAlreadyExistsException; -import com.c2kernel.common.ObjectCannotBeUpdated; import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.process.auth.Authenticator; import com.c2kernel.property.Property; @@ -16,13 +13,6 @@ import com.c2kernel.property.PropertyDescriptionList; */ public interface Lookup { - /** - * Called when a server starts up. The Lookup implementation should ensure that the initial structure of its directory is valid, and create it on first boot. - * - * @throws ObjectNotFoundException When initialization data is not found - */ - public void initializeDirectory() throws ObjectNotFoundException; - /** * Connect to the directory using the credentials supplied in the Authenticator. * @@ -66,24 +56,6 @@ public interface Lookup { */ public org.omg.CORBA.Object resolve(Path path) throws ObjectNotFoundException; - // Path management - - /** - * Register a new a Path in the directory. - * - * @param newPath The path to add - * @throws ObjectCannotBeUpdated When there is an error writing to the directory - * @throws ObjectAlreadyExistsException When the Path has already been registered - */ - public void add(Path newPath) throws ObjectCannotBeUpdated, ObjectAlreadyExistsException; - - /** - * Remove a Path from the directory - * @param path The path to remove - * @throws ObjectCannotBeUpdated When an error occurs writing to the directory - */ - public void delete(Path path) throws ObjectCannotBeUpdated; - // Path finding and searching /** @@ -150,23 +122,6 @@ public interface Lookup { */ public RolePath getRolePath(String roleName) throws ObjectNotFoundException; - /** - * @param role - * @param hasJobList - * @return - * @throws ObjectAlreadyExistsException - * @throws ObjectCannotBeUpdated - */ - public RolePath createRole(String role, boolean hasJobList) throws ObjectAlreadyExistsException, ObjectCannotBeUpdated; - - /** - * @param agent - * @param rolePath - * @throws ObjectCannotBeUpdated - * @throws ObjectNotFoundException - */ - public void addRole(AgentPath agent, RolePath rolePath) throws ObjectCannotBeUpdated, ObjectNotFoundException; - /** * @param rolePath * @return @@ -187,14 +142,6 @@ public interface Lookup { */ public boolean hasRole(AgentPath agentPath, RolePath role); - /** - * @param agent - * @param role - * @throws ObjectCannotBeUpdated - * @throws ObjectNotFoundException - */ - public void removeRole(AgentPath agent, RolePath role) throws ObjectCannotBeUpdated, ObjectNotFoundException; - /** * @param agentPath * @return @@ -202,22 +149,4 @@ public interface Lookup { */ public String getAgentName(AgentPath agentPath) throws ObjectNotFoundException; - /** - * @param agent - * @param newPassword - * @throws ObjectNotFoundException - * @throws ObjectCannotBeUpdated - * @throws NoSuchAlgorithmException - */ - public void setAgentPassword(AgentPath agent, String newPassword) throws ObjectNotFoundException, ObjectCannotBeUpdated, NoSuchAlgorithmException; - - /** - * @param role - * @param hasJobList - * @throws ObjectNotFoundException - * @throws ObjectCannotBeUpdated - */ - public void setHasJobList(RolePath role, boolean hasJobList) throws ObjectNotFoundException, ObjectCannotBeUpdated; - - } diff --git a/src/main/java/com/c2kernel/lookup/LookupManager.java b/src/main/java/com/c2kernel/lookup/LookupManager.java new file mode 100644 index 0000000..ce1268e --- /dev/null +++ b/src/main/java/com/c2kernel/lookup/LookupManager.java @@ -0,0 +1,85 @@ +package com.c2kernel.lookup; + +import java.security.NoSuchAlgorithmException; + +import com.c2kernel.common.ObjectAlreadyExistsException; +import com.c2kernel.common.ObjectCannotBeUpdated; +import com.c2kernel.common.ObjectNotFoundException; + +/** + * @author abranson + * + */ +public interface LookupManager extends Lookup { + + /** + * Called when a server starts up. The Lookup implementation should ensure that the initial structure of its directory is valid, and create it on first boot. + * + * @throws ObjectNotFoundException When initialization data is not found + */ + public void initializeDirectory() throws ObjectNotFoundException; + + // Path management + + /** + * Register a new a Path in the directory. + * + * @param newPath The path to add + * @throws ObjectCannotBeUpdated When there is an error writing to the directory + * @throws ObjectAlreadyExistsException When the Path has already been registered + */ + public void add(Path newPath) throws ObjectCannotBeUpdated, ObjectAlreadyExistsException; + + /** + * Remove a Path from the directory + * @param path The path to remove + * @throws ObjectCannotBeUpdated When an error occurs writing to the directory + */ + public void delete(Path path) throws ObjectCannotBeUpdated; + + // Role and agent management + + /** + * @param role + * @param hasJobList + * @return + * @throws ObjectAlreadyExistsException + * @throws ObjectCannotBeUpdated + */ + public RolePath createRole(String role, boolean hasJobList) throws ObjectAlreadyExistsException, ObjectCannotBeUpdated; + + /** + * @param agent + * @param rolePath + * @throws ObjectCannotBeUpdated + * @throws ObjectNotFoundException + */ + public void addRole(AgentPath agent, RolePath rolePath) throws ObjectCannotBeUpdated, ObjectNotFoundException; + + /** + * @param agent + * @param role + * @throws ObjectCannotBeUpdated + * @throws ObjectNotFoundException + */ + public void removeRole(AgentPath agent, RolePath role) throws ObjectCannotBeUpdated, ObjectNotFoundException; + + /** + * @param agent + * @param newPassword + * @throws ObjectNotFoundException + * @throws ObjectCannotBeUpdated + * @throws NoSuchAlgorithmException + */ + public void setAgentPassword(AgentPath agent, String newPassword) throws ObjectNotFoundException, ObjectCannotBeUpdated, NoSuchAlgorithmException; + + /** + * @param role + * @param hasJobList + * @throws ObjectNotFoundException + * @throws ObjectCannotBeUpdated + */ + public void setHasJobList(RolePath role, boolean hasJobList) throws ObjectNotFoundException, ObjectCannotBeUpdated; + + +} diff --git a/src/main/java/com/c2kernel/lookup/RolePath.java b/src/main/java/com/c2kernel/lookup/RolePath.java index bd23991..fa37fb3 100644 --- a/src/main/java/com/c2kernel/lookup/RolePath.java +++ b/src/main/java/com/c2kernel/lookup/RolePath.java @@ -13,6 +13,7 @@ package com.c2kernel.lookup; import java.util.ArrayList; import java.util.Iterator; +import com.c2kernel.common.CannotManageException; import com.c2kernel.common.ObjectCannotBeUpdated; import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.process.Gateway; @@ -51,10 +52,11 @@ public class RolePath extends DomainPath * @param hasJobList The hasJobList to set. * @throws ObjectCannotBeUpdated * @throws ObjectNotFoundException + * @throws CannotManageException */ - public void setHasJobList(boolean hasJobList) throws ObjectNotFoundException, ObjectCannotBeUpdated { + public void setHasJobList(boolean hasJobList) throws ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException { this.hasJobList = hasJobList; - Gateway.getLookup().setHasJobList(this, hasJobList); + Gateway.getLookupManager().setHasJobList(this, hasJobList); } @@ -80,12 +82,12 @@ public class RolePath extends DomainPath } } - public void addAgent(AgentPath agent) throws ObjectCannotBeUpdated, ObjectNotFoundException { - Gateway.getLookup().addRole(agent, this); + public void addAgent(AgentPath agent) throws ObjectCannotBeUpdated, CannotManageException, ObjectNotFoundException { + Gateway.getLookupManager().addRole(agent, this); } - public void removeAgent(AgentPath agent) throws ObjectCannotBeUpdated, ObjectNotFoundException { - Gateway.getLookup().removeRole(agent, this); + public void removeAgent(AgentPath agent) throws ObjectCannotBeUpdated, CannotManageException, ObjectNotFoundException { + Gateway.getLookupManager().removeRole(agent, this); } @Override diff --git a/src/main/java/com/c2kernel/process/Bootstrap.java b/src/main/java/com/c2kernel/process/Bootstrap.java index f32764c..bc93676 100644 --- a/src/main/java/com/c2kernel/process/Bootstrap.java +++ b/src/main/java/com/c2kernel/process/Bootstrap.java @@ -23,7 +23,7 @@ import com.c2kernel.lifecycle.instance.stateMachine.Transition; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.DomainPath; import com.c2kernel.lookup.ItemPath; -import com.c2kernel.lookup.Lookup; +import com.c2kernel.lookup.LookupManager; import com.c2kernel.lookup.Path; import com.c2kernel.lookup.RolePath; import com.c2kernel.persistency.ClusterStorage; @@ -117,6 +117,7 @@ public class Bootstrap public static DomainPath verifyResource(String ns, String itemName, Integer version, String itemType, String dataLocation, int layer, boolean reset) throws Exception { if (version == null) version = 0; + LookupManager lookupManager = Gateway.getLookupManager(); ResourceImportHandler typeImpHandler = getHandler(itemType); Logger.msg(1, "Bootstrap.verifyResource() - Verifying version "+version+" of "+typeImpHandler.getName()+" "+itemName); @@ -163,8 +164,8 @@ public class Bootstrap Logger.msg("Module item "+itemName+" found with path "+path.toString()+". Moving to "+modDomPath.toString()); modDomPath.setEntity(new ItemPath(thisProxy.getSystemKey())); if (!modDomPath.exists()) - Gateway.getLookup().add(modDomPath); - Gateway.getLookup().delete(path); + lookupManager.add(modDomPath); + lookupManager.delete(path); } } @@ -252,6 +253,8 @@ public class Bootstrap // create props PropertyDescriptionList pdList = impHandler.getPropDesc(); PropertyArrayList props = new PropertyArrayList(); + LookupManager lookupManager = Gateway.getLookupManager(); + for (int i = 0; i < pdList.list.size(); i++) { PropertyDescription pd = pdList.list.get(i); String propName = pd.getName(); @@ -275,10 +278,10 @@ public class Bootstrap ItemPath entityPath = Gateway.getNextKeyManager().generateNextEntityKey(); Gateway.getCorbaServer().createEntity(entityPath); - Gateway.getLookup().add(entityPath); + lookupManager.add(entityPath); DomainPath newDomPath = impHandler.getPath(itemName, ns); newDomPath.setEntity(entityPath); - Gateway.getLookup().add(newDomPath); + lookupManager.add(newDomPath); ItemProxy newItemProxy = Gateway.getProxyManager().getProxy(entityPath); newItemProxy.initialise( 1, props, ca, null); return newItemProxy; @@ -289,12 +292,14 @@ 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."); - Lookup lookup = Gateway.getLookup(); + LookupManager lookup = Gateway.getLookupManager(); + try { systemAgents.put(name, Gateway.getProxyManager().getAgentProxy(lookup.getAgentPath(name))); Logger.msg(3, "Bootstrap.checkAgent() - User '"+name+"' found."); return; } catch (ObjectNotFoundException ex) { } + Logger.msg("Bootstrap.checkAgent() - User '"+name+"' not found. Creating."); RolePath rolePath; @@ -309,7 +314,7 @@ public class Bootstrap AgentPath agentPath = new AgentPath(entityPath.getSysKey(), name); agentPath.setPassword(pass); Gateway.getCorbaServer().createEntity(agentPath); - Gateway.getLookup().add(agentPath); + lookup.add(agentPath); // assign admin role Logger.msg("Bootstrap.checkAgent() - Assigning role '"+role+"'"); @@ -341,6 +346,7 @@ public class Bootstrap } public static void createServerItem() throws Exception { + LookupManager lookupManager = Gateway.getLookupManager(); String serverName = Gateway.getProperties().getProperty("ItemServer.name"); thisServerPath = new DomainPath("/servers/"+serverName); ItemPath serverEntity; @@ -350,9 +356,9 @@ public class Bootstrap Logger.msg("Creating server item "+thisServerPath); serverEntity = Gateway.getNextKeyManager().generateNextEntityKey(); Gateway.getCorbaServer().createEntity(serverEntity); - Gateway.getLookup().add(serverEntity); + lookupManager.add(serverEntity); thisServerPath.setEntity(serverEntity); - Gateway.getLookup().add(thisServerPath); + lookupManager.add(thisServerPath); } Gateway.getStorage().put(serverEntity.getSysKey(), new Property("Name", serverName, false), null); Gateway.getStorage().put(serverEntity.getSysKey(), new Property("Type", "Server", false), null); diff --git a/src/main/java/com/c2kernel/process/Gateway.java b/src/main/java/com/c2kernel/process/Gateway.java index 2499bf7..09700d6 100644 --- a/src/main/java/com/c2kernel/process/Gateway.java +++ b/src/main/java/com/c2kernel/process/Gateway.java @@ -9,6 +9,7 @@ import java.net.MalformedURLException; import java.util.Enumeration; import java.util.Properties; +import com.c2kernel.common.CannotManageException; import com.c2kernel.common.InvalidDataException; import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.entity.CorbaServer; @@ -17,6 +18,7 @@ import com.c2kernel.entity.proxy.ProxyManager; import com.c2kernel.entity.proxy.ProxyServer; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.Lookup; +import com.c2kernel.lookup.LookupManager; import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.persistency.NextKeyManager; import com.c2kernel.persistency.TransactionManager; @@ -58,6 +60,7 @@ public class Gateway static private org.omg.CORBA.ORB mORB; static private boolean orbDestroyed = false; static private Lookup mLookup; + static private LookupManager mLookupManager = null; static private NextKeyManager mNextKeyManager; static private TransactionManager mStorage; static private ProxyManager mProxyManager; @@ -145,10 +148,16 @@ public class Gateway * * @throws InvalidDataException - error initialising */ - static public void startServer(Authenticator auth) throws InvalidDataException { + static public void startServer(Authenticator auth) throws InvalidDataException, CannotManageException { try { // check top level directory contexts - mLookup.initializeDirectory(); + if (mLookup instanceof LookupManager) { + mLookupManager = (LookupManager)mLookup; + mLookupManager.initializeDirectory(); + } + else { + throw new CannotManageException("Lookup implementation is not a LookupManager. Cannot write to directory"); + } // init next key manager mNextKeyManager = (NextKeyManager)mC2KProps.getInstance("NextKeyManager"); @@ -322,6 +331,14 @@ public class Gateway return mLookup; } + static public LookupManager getLookupManager() throws CannotManageException + { + if (mLookupManager == null) + throw new CannotManageException("No Lookup Manager created. Not a server process.", ""); + else + return mLookupManager; + } + static public CorbaServer getCorbaServer() { return mCorbaServer; diff --git a/src/main/java/com/c2kernel/property/Property.java b/src/main/java/com/c2kernel/property/Property.java index 6b7c4ee..3240b07 100644 --- a/src/main/java/com/c2kernel/property/Property.java +++ b/src/main/java/com/c2kernel/property/Property.java @@ -37,6 +37,12 @@ public class Property implements C2KLocalObject setValue( value ); setMutable( mutable ); } + + public Property( String name, String value) + { + setName( name ); + setValue( value ); + } /************************************************************************** * -- cgit v1.2.3