From a1f0ecbb6a2bea6aa214322c412af2f3c5ce124b Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Wed, 7 May 2014 17:33:13 +0200 Subject: Agent now extends Item, so they can have workflows. All traces of the old 'Entity' superclasses should be removed, including proxies and paths. Very large change, breaks API compatibility with CRISTAL 2.x. Fixes #135 --- src/main/java/com/c2kernel/lookup/AgentPath.java | 10 +- src/main/java/com/c2kernel/lookup/DomainPath.java | 10 +- src/main/java/com/c2kernel/lookup/EntityPath.java | 175 --------------------- .../c2kernel/lookup/InvalidAgentPathException.java | 2 +- .../lookup/InvalidEntityPathException.java | 13 -- .../c2kernel/lookup/InvalidItemPathException.java | 13 ++ src/main/java/com/c2kernel/lookup/ItemPath.java | 175 +++++++++++++++++++++ src/main/java/com/c2kernel/lookup/LDAPLookup.java | 36 ++--- .../com/c2kernel/lookup/LDAPPropertyManager.java | 10 +- .../java/com/c2kernel/lookup/LDAPRoleManager.java | 2 +- .../java/com/c2kernel/lookup/NextKeyManager.java | 14 +- src/main/java/com/c2kernel/lookup/Path.java | 2 +- 12 files changed, 231 insertions(+), 231 deletions(-) delete mode 100644 src/main/java/com/c2kernel/lookup/EntityPath.java delete mode 100644 src/main/java/com/c2kernel/lookup/InvalidEntityPathException.java create mode 100644 src/main/java/com/c2kernel/lookup/InvalidItemPathException.java create mode 100644 src/main/java/com/c2kernel/lookup/ItemPath.java (limited to 'src/main/java/com/c2kernel/lookup') diff --git a/src/main/java/com/c2kernel/lookup/AgentPath.java b/src/main/java/com/c2kernel/lookup/AgentPath.java index 5ff6988..a560795 100644 --- a/src/main/java/com/c2kernel/lookup/AgentPath.java +++ b/src/main/java/com/c2kernel/lookup/AgentPath.java @@ -29,14 +29,14 @@ import com.novell.ldap.LDAPEntry; * @version $Revision: 1.12 $ $Date: 2005/10/13 08:15:00 $ * @author $Author: abranson $ **/ -public class AgentPath extends EntityPath +public class AgentPath extends ItemPath { private String mAgentName=null; private String mPassword=null; public AgentPath(int syskey, String agentName) - throws InvalidAgentPathException,InvalidEntityPathException + throws InvalidAgentPathException,InvalidItemPathException { super(syskey); if (agentName!=null && agentName.length()>0) @@ -46,16 +46,16 @@ public class AgentPath extends EntityPath } public AgentPath(int syskey) - throws InvalidEntityPathException + throws InvalidItemPathException { super(syskey); } - public AgentPath(EntityPath entity) { + public AgentPath(ItemPath entity) { super(); try { setSysKey(entity.getSysKey()); - } catch (InvalidEntityPathException ex) { + } catch (InvalidItemPathException ex) { //won't happen as the entity path was valid } } diff --git a/src/main/java/com/c2kernel/lookup/DomainPath.java b/src/main/java/com/c2kernel/lookup/DomainPath.java index ce849ce..b0784f9 100644 --- a/src/main/java/com/c2kernel/lookup/DomainPath.java +++ b/src/main/java/com/c2kernel/lookup/DomainPath.java @@ -23,7 +23,7 @@ import com.novell.ldap.LDAPAttributeSet; **/ public class DomainPath extends Path { - private EntityPath target = null; + private ItemPath target = null; protected static String mTypeRoot; /* Very simple extension to Path. Only copies constructors and defines root */ @@ -49,7 +49,7 @@ public class DomainPath extends Path super(path, Path.UNKNOWN); } - public DomainPath(String path, EntityPath entity) throws InvalidEntityPathException + public DomainPath(String path, ItemPath entity) throws InvalidItemPathException { super(path, Path.UNKNOWN); setEntity(entity); @@ -76,7 +76,7 @@ public class DomainPath extends Path return new DomainPath(parentPath); } - public void setEntity(EntityPath newTarget) { + public void setEntity(ItemPath newTarget) { if (newTarget == null) { // clear target = null; mType = Path.CONTEXT; @@ -88,7 +88,7 @@ public class DomainPath extends Path } @Override - public EntityPath getEntity() throws ObjectNotFoundException { + public ItemPath getEntity() throws ObjectNotFoundException { if (mType == UNKNOWN) { // must decide checkType(); } @@ -109,7 +109,7 @@ public class DomainPath extends Path public void checkType() { try { setEntity(Gateway.getLDAPLookup().resolvePath(this)); - } catch (InvalidEntityPathException ex) { + } catch (InvalidItemPathException ex) { Logger.error(ex); mType = CONTEXT; } catch (ObjectNotFoundException ex) { diff --git a/src/main/java/com/c2kernel/lookup/EntityPath.java b/src/main/java/com/c2kernel/lookup/EntityPath.java deleted file mode 100644 index 4f9b771..0000000 --- a/src/main/java/com/c2kernel/lookup/EntityPath.java +++ /dev/null @@ -1,175 +0,0 @@ -/************************************************************************** - * EntityPath.java - * - * $Revision: 1.14 $ - * $Date: 2006/03/03 13:52:21 $ - * - * Copyright (C) 2001 CERN - European Organization for Nuclear Research - * All rights reserved. - **************************************************************************/ - -package com.c2kernel.lookup; - -import java.util.ArrayList; - -import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFoundException; -import com.c2kernel.process.Gateway; -import com.novell.ldap.LDAPAttribute; -import com.novell.ldap.LDAPAttributeSet; - - -/** -* Extends Path to enforce SystemKey structure and support int form -* -* @version $Revision: 1.14 $ $Date: 2006/03/03 13:52:21 $ -* @author $Author: abranson $ -**/ -public class EntityPath extends Path -{ - // no of components in a syskey - public static final int elementNo = 3; - // no of digits in a syskey component - public static final int elementLen = 3; - // maximum possible int syskey - public static final int maxSysKey = (int)Math.pow(10, elementNo*elementLen)-1; - protected static String mTypeRoot; - /* - * From syskey int - * Note no EntityPath constructors allow setting of CONTEXT or ENTITY: - * The object decides that for itself from the number of components - */ - - public EntityPath(int syskey) throws InvalidEntityPathException { - super(); - setSysKey(syskey); - } - - /* - */ - public EntityPath() - { - super(); - } - - - /* - */ - public EntityPath(String[] path) throws InvalidEntityPathException - { - super(path, Path.CONTEXT); // dummy - it will get replaced in checkSysPath() - checkSysPath(); - } - - /* - */ - public EntityPath(String path) throws InvalidEntityPathException - { - super(path, Path.CONTEXT); - checkSysPath(); - } - - /* - */ - public EntityPath(EntityPath parent, String child) throws InvalidEntityPathException { - super(parent, child); - checkSysPath(); - } - - // EntityPaths root in /entity - @Override - public String getRoot() { - return "entity"; - } - - @Override - public EntityPath getEntity() throws ObjectNotFoundException { - return this; - } - - public byte[] getOID() { - if (mSysKey == Path.INVALID) return null; - return String.valueOf(mSysKey).getBytes(); - } - - /*************************************************************************/ - - /** Returns int form of syskey (if possible) - */ - @Override - public int getSysKey() { - if (mSysKey == Path.INVALID && mType == Path.ENTITY) - try { - if (mPath.length != elementNo) - throw new InvalidEntityPathException("Incorrect number of components for a system key"); - mSysKey = 0; - for (String keypart : mPath) { - if (keypart.length()!=elementLen+1) - throw new InvalidEntityPathException("Component '"+keypart+"' is not the correct size for a system key"); - for(int j=1; j= '0') && (c <='9')) - mSysKey = mSysKey*10 + c - '0'; - else - throw new InvalidEntityPathException("Component '"+keypart+"' contained a non-numeric char (excluding first char 'd')."); - - } - } - } catch (InvalidEntityPathException ex) { - mSysKey = Path.INVALID; - } - return mSysKey; - } - - /** Sets path from int syskey - */ - public void setSysKey(int sysKey) throws InvalidEntityPathException - { - if (sysKey < 0 || sysKey > maxSysKey) - throw new InvalidEntityPathException("System key "+sysKey+" out of range"); - String stringPath = Integer.toString(sysKey); - ArrayList newKey = new ArrayList(); - for (int i=0; i elementNo) - throw new InvalidEntityPathException("EntityPath cannot have more than "+elementNo+" components: "+toString()); - if (mPath.length == elementNo) - mType = Path.ENTITY; - else - mType = Path.CONTEXT; - } - - @Override - public LDAPAttributeSet createAttributeSet() throws ObjectCannotBeUpdated { - LDAPAttributeSet attrs = new LDAPAttributeSet(); - attrs.add(new LDAPAttribute("objectclass","cristalentity")); - attrs.add(new LDAPAttribute("intsyskey",Integer.toString(mSysKey))); - attrs.add(new LDAPAttribute("cn", getPath()[getPath().length-1])); - if (mIOR != null) - attrs.add(new LDAPAttribute("ior", Gateway.getORB().object_to_string(mIOR))); - return attrs; - } -} - diff --git a/src/main/java/com/c2kernel/lookup/InvalidAgentPathException.java b/src/main/java/com/c2kernel/lookup/InvalidAgentPathException.java index be4d952..a74e1ee 100644 --- a/src/main/java/com/c2kernel/lookup/InvalidAgentPathException.java +++ b/src/main/java/com/c2kernel/lookup/InvalidAgentPathException.java @@ -1,6 +1,6 @@ package com.c2kernel.lookup; -public class InvalidAgentPathException extends InvalidEntityPathException { +public class InvalidAgentPathException extends InvalidItemPathException { public InvalidAgentPathException() { super(); diff --git a/src/main/java/com/c2kernel/lookup/InvalidEntityPathException.java b/src/main/java/com/c2kernel/lookup/InvalidEntityPathException.java deleted file mode 100644 index 27c754d..0000000 --- a/src/main/java/com/c2kernel/lookup/InvalidEntityPathException.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.c2kernel.lookup; - -public class InvalidEntityPathException extends Exception { - - public InvalidEntityPathException() { - super(); - } - - public InvalidEntityPathException(String msg) { - super(msg); - } - -} diff --git a/src/main/java/com/c2kernel/lookup/InvalidItemPathException.java b/src/main/java/com/c2kernel/lookup/InvalidItemPathException.java new file mode 100644 index 0000000..5b37cd7 --- /dev/null +++ b/src/main/java/com/c2kernel/lookup/InvalidItemPathException.java @@ -0,0 +1,13 @@ +package com.c2kernel.lookup; + +public class InvalidItemPathException extends Exception { + + public InvalidItemPathException() { + super(); + } + + public InvalidItemPathException(String msg) { + super(msg); + } + +} diff --git a/src/main/java/com/c2kernel/lookup/ItemPath.java b/src/main/java/com/c2kernel/lookup/ItemPath.java new file mode 100644 index 0000000..89fe5ee --- /dev/null +++ b/src/main/java/com/c2kernel/lookup/ItemPath.java @@ -0,0 +1,175 @@ +/************************************************************************** + * EntityPath.java + * + * $Revision: 1.14 $ + * $Date: 2006/03/03 13:52:21 $ + * + * Copyright (C) 2001 CERN - European Organization for Nuclear Research + * All rights reserved. + **************************************************************************/ + +package com.c2kernel.lookup; + +import java.util.ArrayList; + +import com.c2kernel.common.ObjectCannotBeUpdated; +import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.process.Gateway; +import com.novell.ldap.LDAPAttribute; +import com.novell.ldap.LDAPAttributeSet; + + +/** +* Extends Path to enforce SystemKey structure and support int form +* +* @version $Revision: 1.14 $ $Date: 2006/03/03 13:52:21 $ +* @author $Author: abranson $ +**/ +public class ItemPath extends Path +{ + // no of components in a syskey + public static final int elementNo = 3; + // no of digits in a syskey component + public static final int elementLen = 3; + // maximum possible int syskey + public static final int maxSysKey = (int)Math.pow(10, elementNo*elementLen)-1; + protected static String mTypeRoot; + /* + * From syskey int + * Note no EntityPath constructors allow setting of CONTEXT or ENTITY: + * The object decides that for itself from the number of components + */ + + public ItemPath(int syskey) throws InvalidItemPathException { + super(); + setSysKey(syskey); + } + + /* + */ + public ItemPath() + { + super(); + } + + + /* + */ + public ItemPath(String[] path) throws InvalidItemPathException + { + super(path, Path.CONTEXT); // dummy - it will get replaced in checkSysPath() + checkSysPath(); + } + + /* + */ + public ItemPath(String path) throws InvalidItemPathException + { + super(path, Path.CONTEXT); + checkSysPath(); + } + + /* + */ + public ItemPath(ItemPath parent, String child) throws InvalidItemPathException { + super(parent, child); + checkSysPath(); + } + + // EntityPaths root in /entity + @Override + public String getRoot() { + return "entity"; + } + + @Override + public ItemPath getEntity() throws ObjectNotFoundException { + return this; + } + + public byte[] getOID() { + if (mSysKey == Path.INVALID) return null; + return String.valueOf(mSysKey).getBytes(); + } + + /*************************************************************************/ + + /** Returns int form of syskey (if possible) + */ + @Override + public int getSysKey() { + if (mSysKey == Path.INVALID && mType == Path.ENTITY) + try { + if (mPath.length != elementNo) + throw new InvalidItemPathException("Incorrect number of components for a system key"); + mSysKey = 0; + for (String keypart : mPath) { + if (keypart.length()!=elementLen+1) + throw new InvalidItemPathException("Component '"+keypart+"' is not the correct size for a system key"); + for(int j=1; j= '0') && (c <='9')) + mSysKey = mSysKey*10 + c - '0'; + else + throw new InvalidItemPathException("Component '"+keypart+"' contained a non-numeric char (excluding first char 'd')."); + + } + } + } catch (InvalidItemPathException ex) { + mSysKey = Path.INVALID; + } + return mSysKey; + } + + /** Sets path from int syskey + */ + public void setSysKey(int sysKey) throws InvalidItemPathException + { + if (sysKey < 0 || sysKey > maxSysKey) + throw new InvalidItemPathException("System key "+sysKey+" out of range"); + String stringPath = Integer.toString(sysKey); + ArrayList newKey = new ArrayList(); + for (int i=0; i elementNo) + throw new InvalidItemPathException("EntityPath cannot have more than "+elementNo+" components: "+toString()); + if (mPath.length == elementNo) + mType = Path.ENTITY; + else + mType = Path.CONTEXT; + } + + @Override + public LDAPAttributeSet createAttributeSet() throws ObjectCannotBeUpdated { + LDAPAttributeSet attrs = new LDAPAttributeSet(); + attrs.add(new LDAPAttribute("objectclass","cristalentity")); + attrs.add(new LDAPAttribute("intsyskey",Integer.toString(mSysKey))); + attrs.add(new LDAPAttribute("cn", getPath()[getPath().length-1])); + if (mIOR != null) + attrs.add(new LDAPAttribute("ior", Gateway.getORB().object_to_string(mIOR))); + return attrs; + } +} + diff --git a/src/main/java/com/c2kernel/lookup/LDAPLookup.java b/src/main/java/com/c2kernel/lookup/LDAPLookup.java index 4ea6e68..116362e 100644 --- a/src/main/java/com/c2kernel/lookup/LDAPLookup.java +++ b/src/main/java/com/c2kernel/lookup/LDAPLookup.java @@ -12,7 +12,7 @@ import com.c2kernel.common.ObjectCannotBeUpdated; import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.entity.TraceableEntity; import com.c2kernel.entity.agent.ActiveEntity; -import com.c2kernel.entity.proxy.EntityProxyManager; +import com.c2kernel.entity.proxy.ProxyManager; import com.c2kernel.entity.proxy.ProxyMessage; import com.c2kernel.process.Gateway; import com.c2kernel.property.PropertyDescription; @@ -67,13 +67,13 @@ public class LDAPLookup Path.mRootPath=props.mRootPath; Path.mLocalPath=props.mLocalPath; - EntityPath.mTypeRoot = "cn=entity,"+props.mLocalPath; + ItemPath.mTypeRoot = "cn=entity,"+props.mLocalPath; DomainPath.mTypeRoot = "cn=domain,"+props.mLocalPath; - mNextKeyManager = new NextKeyManager(this, "cn=last,"+EntityPath.mTypeRoot); + mNextKeyManager = new NextKeyManager(this, "cn=last,"+ItemPath.mTypeRoot); Logger.msg(7, "LDAP.useOldProps="+Gateway.getProperties().getBoolean("LDAP.useOldProps", false)); mPropManager = new LDAPPropertyManager(this); - mRoleManager = new LDAPRoleManager(this, "cn=agent,"+DomainPath.mTypeRoot, EntityPath.mTypeRoot); + mRoleManager = new LDAPRoleManager(this, "cn=agent,"+DomainPath.mTypeRoot, ItemPath.mTypeRoot); } @@ -199,12 +199,12 @@ public class LDAPLookup * * @param domPath * @return - * @throws InvalidEntityPathException + * @throws InvalidItemPathException * @throws ObjectNotFoundException */ - protected EntityPath resolvePath(DomainPath domPath) - throws InvalidEntityPathException, ObjectNotFoundException { - EntityPath referencedPath = null; + protected ItemPath resolvePath(DomainPath domPath) + throws InvalidItemPathException, ObjectNotFoundException { + ItemPath referencedPath = null; LDAPEntry domEntry = LDAPLookupUtils.getEntry(getConnection(), domPath .getFullDN(), LDAPSearchConstraints.DEREF_ALWAYS); String entityKey = LDAPLookupUtils.getFirstAttributeValue(domEntry, @@ -216,7 +216,7 @@ public class LDAPLookup if (objClass.equals("cristalagent")) referencedPath = new AgentPath(Integer.parseInt(entityKey)); else - referencedPath = new EntityPath(Integer.parseInt(entityKey)); + referencedPath = new ItemPath(Integer.parseInt(entityKey)); return referencedPath; } @@ -231,7 +231,7 @@ public class LDAPLookup LDAPEntry newEntry = new LDAPEntry(path.getFullDN(),attrSet); LDAPLookupUtils.addEntry(getConnection(),newEntry); if (path instanceof DomainPath) - EntityProxyManager.sendProxyEvent(new ProxyMessage(ProxyMessage.NA, path.toString(), ProxyMessage.ADDED)); + ProxyManager.sendProxyEvent(new ProxyMessage(ProxyMessage.NA, path.toString(), ProxyMessage.ADDED)); return newEntry; } catch (LDAPException ex) { if (ex.getResultCode() == LDAPException.ENTRY_ALREADY_EXISTS) @@ -251,7 +251,7 @@ public class LDAPLookup throw new ObjectCannotBeUpdated(ex.getLDAPErrorMessage(), ""); } if (path instanceof DomainPath) { - EntityProxyManager.sendProxyEvent(new ProxyMessage(ProxyMessage.NA, path.toString(), ProxyMessage.DELETED)); + ProxyManager.sendProxyEvent(new ProxyMessage(ProxyMessage.NA, path.toString(), ProxyMessage.DELETED)); } } @@ -393,7 +393,7 @@ public class LDAPLookup return search(start.getFullDN(), LDAPConnection.SCOPE_SUB, "objectClass=aliasObject", searchCons); } - public LDAPPathSet searchAliases(EntityPath entity) { + public LDAPPathSet searchAliases(ItemPath entity) { LDAPSearchConstraints searchCons = new LDAPSearchConstraints(); searchCons.setBatchSize(0); searchCons.setDereference(LDAPSearchConstraints.DEREF_NEVER); @@ -431,7 +431,7 @@ public class LDAPLookup * @throws ObjectNotFoundException * @throws ObjectNotFoundException */ - protected Path nodeToPath(LDAPEntry entry) throws InvalidEntityPathException, ObjectNotFoundException + protected Path nodeToPath(LDAPEntry entry) throws InvalidItemPathException, ObjectNotFoundException { String dn = entry.getDN(); @@ -470,14 +470,14 @@ public class LDAPLookup thisPath = domainPath; } else if (LDAPLookupUtils.existsAttributeValue(entry,"objectclass","cristalentity") || - (LDAPLookupUtils.existsAttributeValue(entry,"objectclass","cristalcontext") && dn.endsWith(EntityPath.mTypeRoot))) + (LDAPLookupUtils.existsAttributeValue(entry,"objectclass","cristalcontext") && dn.endsWith(ItemPath.mTypeRoot))) { - if(dn.endsWith(EntityPath.mTypeRoot)) { - EntityPath entityPath; + if(dn.endsWith(ItemPath.mTypeRoot)) { + ItemPath entityPath; if (entityKey != -1) - entityPath = new EntityPath(entityKey); + entityPath = new ItemPath(entityKey); else { - entityPath = new EntityPath(); + entityPath = new ItemPath(); entityPath.setDN(dn); } thisPath = entityPath; diff --git a/src/main/java/com/c2kernel/lookup/LDAPPropertyManager.java b/src/main/java/com/c2kernel/lookup/LDAPPropertyManager.java index fcf1ef8..51b9ded 100644 --- a/src/main/java/com/c2kernel/lookup/LDAPPropertyManager.java +++ b/src/main/java/com/c2kernel/lookup/LDAPPropertyManager.java @@ -35,7 +35,7 @@ public class LDAPPropertyManager { * @return * @throws ObjectNotFoundException */ - public boolean hasProperties(EntityPath thisEntity) throws ObjectNotFoundException { + public boolean hasProperties(ItemPath thisEntity) throws ObjectNotFoundException { LDAPEntry entityEntry = LDAPLookupUtils.getEntry(ldap.getConnection(), thisEntity.getFullDN()); return entityEntry.getAttribute("cristalprop") != null; } @@ -45,7 +45,7 @@ public class LDAPPropertyManager { * @return array of Property * @throws ObjectNotFoundException */ - public String[] getPropertyNames(EntityPath thisEntity) throws ObjectNotFoundException { + public String[] getPropertyNames(ItemPath thisEntity) throws ObjectNotFoundException { LDAPEntry entityEntry = LDAPLookupUtils.getEntry(ldap.getConnection(), thisEntity.getFullDN()); ArrayList propbag = new ArrayList(); LDAPAttribute props = entityEntry.getAttribute("cristalprop"); @@ -66,7 +66,7 @@ public class LDAPPropertyManager { * @return The Property object * @throws ObjectNotFoundException */ - public Property getProperty(EntityPath thisEntity, String name) throws ObjectNotFoundException { + public Property getProperty(ItemPath thisEntity, String name) throws ObjectNotFoundException { LDAPEntry entityEntry = LDAPLookupUtils.getEntry(ldap.getConnection(), thisEntity.getFullDN()); return getProperty(entityEntry, name); } @@ -77,7 +77,7 @@ public class LDAPPropertyManager { * @throws ObjectNotFoundException * @throws ObjectCannotBeUpdated */ - public void deleteProperty(EntityPath thisEntity, String name) throws ObjectNotFoundException, ObjectCannotBeUpdated { + public void deleteProperty(ItemPath thisEntity, String name) throws ObjectNotFoundException, ObjectCannotBeUpdated { LDAPEntry entityEntry = LDAPLookupUtils.getEntry(ldap.getConnection(), thisEntity.getFullDN()); Property prop = getProperty(entityEntry, name); Logger.msg(6, "LDAPLookupUtils.deleteProperty("+name+") - Deleting property"); @@ -94,7 +94,7 @@ public class LDAPPropertyManager { * @throws ObjectNotFoundException * @throws ObjectCannotBeUpdated */ - public void setProperty(EntityPath thisEntity, Property prop) throws ObjectNotFoundException, ObjectCannotBeUpdated { + public void setProperty(ItemPath thisEntity, Property prop) throws ObjectNotFoundException, ObjectCannotBeUpdated { LDAPEntry entityEntry = LDAPLookupUtils.getEntry(ldap.getConnection(), thisEntity.getFullDN()); try { Property oldProp = getProperty(entityEntry, prop.getName()); diff --git a/src/main/java/com/c2kernel/lookup/LDAPRoleManager.java b/src/main/java/com/c2kernel/lookup/LDAPRoleManager.java index f40cd53..091f6d7 100644 --- a/src/main/java/com/c2kernel/lookup/LDAPRoleManager.java +++ b/src/main/java/com/c2kernel/lookup/LDAPRoleManager.java @@ -124,7 +124,7 @@ public class LDAPRoleManager { agents.add(path); } catch (ObjectNotFoundException ex) { Logger.error("Agent "+userDN+" does not exist"); - } catch (InvalidEntityPathException ex) { + } catch (InvalidItemPathException ex) { Logger.error("Agent "+userDN+" is not a valid entity"); } } diff --git a/src/main/java/com/c2kernel/lookup/NextKeyManager.java b/src/main/java/com/c2kernel/lookup/NextKeyManager.java index a4ead4b..9aea50d 100644 --- a/src/main/java/com/c2kernel/lookup/NextKeyManager.java +++ b/src/main/java/com/c2kernel/lookup/NextKeyManager.java @@ -28,14 +28,14 @@ public class NextKeyManager { this.lastKeyPath = lastKeyPath; } - public synchronized EntityPath generateNextEntityKey() + public synchronized ItemPath generateNextEntityKey() throws ObjectCannotBeUpdated, ObjectNotFoundException { - EntityPath lastKey = getLastEntityPath(); + ItemPath lastKey = getLastEntityPath(); try { lastKey.setSysKey(lastKey.getSysKey()+1); - } catch (InvalidEntityPathException ex) { + } catch (InvalidItemPathException ex) { throw new ObjectCannotBeUpdated("Invalid syskey "+(lastKey.getSysKey()+1)+". Maybe centre is full."); } //test that storage is empty for that key @@ -56,7 +56,7 @@ public class NextKeyManager { public synchronized AgentPath generateNextAgentKey() throws ObjectCannotBeUpdated, ObjectNotFoundException { - EntityPath newEntity = generateNextEntityKey(); + ItemPath newEntity = generateNextEntityKey(); return new AgentPath(newEntity); } @@ -65,15 +65,15 @@ public class NextKeyManager { LDAPLookupUtils.setAttributeValue(ldap.getConnection(), lastKeyEntry,"intsyskey",Integer.toString(sysKey)); } - public EntityPath getLastEntityPath() throws ObjectNotFoundException + public ItemPath getLastEntityPath() throws ObjectNotFoundException { LDAPEntry lastKeyEntry = LDAPLookupUtils.getEntry(ldap.getConnection(),lastKeyPath); String lastKey = LDAPLookupUtils.getFirstAttributeValue(lastKeyEntry,"intsyskey"); try { int sysKey = Integer.parseInt(lastKey); - EntityPath sysPath = new EntityPath(sysKey); + ItemPath sysPath = new ItemPath(sysKey); return sysPath; - } catch (InvalidEntityPathException ex) { + } catch (InvalidItemPathException ex) { throw new ObjectNotFoundException("Invalid syskey. Maybe centre is full."); } catch (NumberFormatException ex) { throw new ObjectNotFoundException("Invalid syskey in lastkey."); diff --git a/src/main/java/com/c2kernel/lookup/Path.java b/src/main/java/com/c2kernel/lookup/Path.java index 4bec43a..16f3e5d 100644 --- a/src/main/java/com/c2kernel/lookup/Path.java +++ b/src/main/java/com/c2kernel/lookup/Path.java @@ -279,7 +279,7 @@ public abstract class Path implements Serializable throw new ObjectNotFoundException("No match for "+name, ""); } - public abstract EntityPath getEntity() throws ObjectNotFoundException; + public abstract ItemPath getEntity() throws ObjectNotFoundException; public abstract LDAPAttributeSet createAttributeSet() throws ObjectCannotBeUpdated; -- cgit v1.2.3