From e7944d42d0e4e73c4fb4c6ce026bd624a5a71f1b Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Fri, 3 Oct 2014 23:19:25 +0200 Subject: Rolled back the renaming of existing exceptions. --- .../com/c2kernel/lookup/ldap/LDAPAuthManager.java | 12 +-- .../c2kernel/lookup/ldap/LDAPClusterStorage.java | 6 +- .../java/com/c2kernel/lookup/ldap/LDAPLookup.java | 102 ++++++++++----------- .../com/c2kernel/lookup/ldap/LDAPLookupUtils.java | 32 +++---- .../c2kernel/lookup/ldap/LDAPPropertyManager.java | 30 +++--- 5 files changed, 91 insertions(+), 91 deletions(-) diff --git a/src/main/java/com/c2kernel/lookup/ldap/LDAPAuthManager.java b/src/main/java/com/c2kernel/lookup/ldap/LDAPAuthManager.java index d97fa1f..5e6d5ad 100644 --- a/src/main/java/com/c2kernel/lookup/ldap/LDAPAuthManager.java +++ b/src/main/java/com/c2kernel/lookup/ldap/LDAPAuthManager.java @@ -1,7 +1,7 @@ package com.c2kernel.lookup.ldap; -import com.c2kernel.common.InvalidData; -import com.c2kernel.common.ObjectNotFound; +import com.c2kernel.common.InvalidDataException; +import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.process.Gateway; import com.c2kernel.process.auth.Authenticator; import com.c2kernel.utils.Logger; @@ -16,7 +16,7 @@ public class LDAPAuthManager implements Authenticator { @Override public boolean authenticate(String agentName, - String password, String resource) throws InvalidData, ObjectNotFound { + String password, String resource) throws InvalidDataException, ObjectNotFoundException { ldapProps = new LDAPProperties(Gateway.getProperties()); @@ -42,18 +42,18 @@ public class LDAPAuthManager implements Authenticator { } else { - throw new InvalidData("Cannot log in. Some connection properties are not set."); + throw new InvalidDataException("Cannot log in. Some connection properties are not set."); } } @Override - public boolean authenticate(String resource) throws InvalidData, ObjectNotFound { + public boolean authenticate(String resource) throws InvalidDataException, ObjectNotFoundException { ldapProps = new LDAPProperties(Gateway.getProperties()); if (ldapProps.mUser == null || ldapProps.mUser.length()==0 || ldapProps.mPassword == null || ldapProps.mPassword.length()==0) - throw new InvalidData("LDAP root user properties not found in config."); + throw new InvalidDataException("LDAP root user properties not found in config."); try { mLDAPConn = LDAPLookupUtils.createConnection(ldapProps); return true; diff --git a/src/main/java/com/c2kernel/lookup/ldap/LDAPClusterStorage.java b/src/main/java/com/c2kernel/lookup/ldap/LDAPClusterStorage.java index ac91c29..a264fcc 100644 --- a/src/main/java/com/c2kernel/lookup/ldap/LDAPClusterStorage.java +++ b/src/main/java/com/c2kernel/lookup/ldap/LDAPClusterStorage.java @@ -2,7 +2,7 @@ package com.c2kernel.lookup.ldap; import java.util.ArrayList; import java.util.StringTokenizer; -import com.c2kernel.common.ObjectNotFound; +import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.common.PersistencyException; import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.lookup.ItemPath; @@ -66,7 +66,7 @@ public class LDAPClusterStorage extends ClusterStorage { try { Property newProperty = ldapStore.getProperty(thisItem, objName); newObj = newProperty; - } catch (ObjectNotFound ex) { + } catch (ObjectNotFoundException ex) { throw new PersistencyException("Property "+objName+" not found in "+thisItem); } @@ -144,7 +144,7 @@ public class LDAPClusterStorage extends ClusterStorage { } else throw new PersistencyException("Cluster type "+type+" not supported."); - } catch (ObjectNotFound e) { + } catch (ObjectNotFoundException e) { throw new PersistencyException("Item "+thisItem+" does not exist"); } } diff --git a/src/main/java/com/c2kernel/lookup/ldap/LDAPLookup.java b/src/main/java/com/c2kernel/lookup/ldap/LDAPLookup.java index a9fcd6d..cb4395c 100644 --- a/src/main/java/com/c2kernel/lookup/ldap/LDAPLookup.java +++ b/src/main/java/com/c2kernel/lookup/ldap/LDAPLookup.java @@ -12,9 +12,9 @@ import java.util.StringTokenizer; import org.omg.CORBA.Object; -import com.c2kernel.common.ObjectAlreadyExists; +import com.c2kernel.common.ObjectAlreadyExistsException; import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFound; +import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.entity.proxy.ProxyMessage; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.DomainPath; @@ -121,10 +121,10 @@ public class LDAPLookup implements LookupManager{ * Attempts to resolve the CORBA object for a Path, either directly or through an alias. * @param path the path to resolve * @return the CORBA object - * @throws ObjectNotFound When the path does not exist + * @throws ObjectNotFoundException When the path does not exist */ public org.omg.CORBA.Object getIOR(Path path) - throws ObjectNotFound + throws ObjectNotFoundException { return resolveObject(getFullDN(path)); } @@ -132,10 +132,10 @@ public class LDAPLookup implements LookupManager{ /** * Attempts to resolve the CORBA object from the IOR attribute of a DN, either directly or through an alias * @param dn The String dn - * @throws ObjectNotFound when the dn or aliased dn does not exist + * @throws ObjectNotFoundException when the dn or aliased dn does not exist */ private org.omg.CORBA.Object resolveObject(String dn) - throws ObjectNotFound + throws ObjectNotFoundException { Logger.msg(8,"LDAPLookup.resolveObject("+dn+")"); LDAPEntry anEntry = LDAPLookupUtils.getEntry(mLDAPAuth.getAuthObject(),dn,LDAPSearchConstraints.DEREF_NEVER); @@ -148,13 +148,13 @@ public class LDAPLookup implements LookupManager{ if (ior!=null) return ior; else - throw new ObjectNotFound("LDAPLookup.resolveObject() - " + dn + " has no IOR"); - } catch (ObjectNotFound ex) { + throw new ObjectNotFoundException("LDAPLookup.resolveObject() - " + dn + " has no IOR"); + } catch (ObjectNotFoundException ex) { return resolveObject(LDAPLookupUtils.getFirstAttributeValue(anEntry,"aliasedObjectName")); } } else - throw new ObjectNotFound("LDAPLookup.resolveObject() LDAP node " + dn + " is not in LDAP or has no IOR."); + throw new ObjectNotFoundException("LDAPLookup.resolveObject() LDAP node " + dn + " is not in LDAP or has no IOR."); } /** @@ -162,11 +162,11 @@ public class LDAPLookup implements LookupManager{ * @param domPath * @return * @throws InvalidItemPathException - * @throws ObjectNotFound + * @throws ObjectNotFoundException */ @Override public ItemPath resolvePath(DomainPath domPath) - throws InvalidItemPathException, ObjectNotFound { + throws InvalidItemPathException, ObjectNotFoundException { LDAPEntry domEntry = LDAPLookupUtils.getEntry(mLDAPAuth.getAuthObject(), getFullDN(domPath), LDAPSearchConstraints.DEREF_ALWAYS); @@ -186,7 +186,7 @@ public class LDAPLookup implements LookupManager{ @Override public void add(Path path) - throws ObjectCannotBeUpdated, ObjectAlreadyExists + throws ObjectCannotBeUpdated, ObjectAlreadyExistsException { try { checkLDAPContext(path); @@ -197,7 +197,7 @@ public class LDAPLookup implements LookupManager{ Gateway.getProxyServer().sendProxyEvent(new ProxyMessage(null, path.toString(), ProxyMessage.ADDED)); } catch (LDAPException ex) { if (ex.getResultCode() == LDAPException.ENTRY_ALREADY_EXISTS) - throw new ObjectAlreadyExists(ex.getLDAPErrorMessage()); + throw new ObjectAlreadyExistsException(ex.getLDAPErrorMessage()); else throw new ObjectCannotBeUpdated(ex.getLDAPErrorMessage()); } @@ -260,7 +260,7 @@ public class LDAPLookup implements LookupManager{ } @Override - public void initializeDirectory() throws ObjectNotFound + public void initializeDirectory() throws ObjectNotFoundException { createBootTree(); initTree( Gateway.getResource().getTextResource("ldap", "LDAPboot.txt")); @@ -364,7 +364,7 @@ public class LDAPLookup implements LookupManager{ } @Override - public ItemPath getItemPath(String uuid) throws ObjectNotFound, InvalidItemPathException { + public ItemPath getItemPath(String uuid) throws ObjectNotFoundException, InvalidItemPathException { String[] attr = { LDAPConnection.ALL_USER_ATTRS }; try { ItemPath item = new ItemPath(uuid); @@ -375,24 +375,24 @@ public class LDAPLookup implements LookupManager{ else if (type.equals("cristalagent")) return new AgentPath(item); else - throw new ObjectNotFound("Not an entity"); + throw new ObjectNotFoundException("Not an entity"); } catch (LDAPException ex) { if (ex.getResultCode() == LDAPException.NO_SUCH_OBJECT) - throw new ObjectNotFound("Entity does not exist"); + throw new ObjectNotFoundException("Entity does not exist"); Logger.error(ex); - throw new ObjectNotFound("Error getting entity class"); + throw new ObjectNotFoundException("Error getting entity class"); } } /** converts an LDAPentry to a Path object * Note that the search producing the entry should have retrieved the attrs * 'ior' and 'uniquemember' - * @throws ObjectNotFound - * @throws ObjectNotFound + * @throws ObjectNotFoundException + * @throws ObjectNotFoundException * @throws */ - protected Path nodeToPath(LDAPEntry entry) throws InvalidItemPathException, ObjectNotFound + protected Path nodeToPath(LDAPEntry entry) throws InvalidItemPathException, ObjectNotFoundException { String dn = entry.getDN(); ItemPath entityKey; @@ -402,7 +402,7 @@ public class LDAPLookup implements LookupManager{ try { String entityKeyStr = LDAPLookupUtils.getFirstAttributeValue(entry, "cn"); entityKey = new ItemPath(entityKeyStr); - } catch (ObjectNotFound ex) { + } catch (ObjectNotFoundException ex) { entityKey = null; } catch (InvalidItemPathException ex) { entityKey = null; @@ -412,7 +412,7 @@ public class LDAPLookup implements LookupManager{ try { String stringIOR = LDAPLookupUtils.getFirstAttributeValue(entry,"ior"); ior = Gateway.getORB().string_to_object(stringIOR); - } catch (ObjectNotFound ex) { + } catch (ObjectNotFoundException ex) { ior = null; } @@ -443,11 +443,11 @@ public class LDAPLookup implements LookupManager{ thisPath = entityKey; } else - throw new ObjectNotFound("Entity found outside entity tree"); + throw new ObjectNotFoundException("Entity found outside entity tree"); } else { - throw new ObjectNotFound("Unrecognised LDAP entry. Not a cristal entry"); + throw new ObjectNotFoundException("Unrecognised LDAP entry. Not a cristal entry"); } //set IOR if we have one @@ -483,7 +483,7 @@ public class LDAPLookup implements LookupManager{ } @Override - public Object resolve(Path path) throws ObjectNotFound { + public Object resolve(Path path) throws ObjectNotFoundException { return resolveObject(getFullDN(path)); } @@ -513,7 +513,7 @@ public class LDAPLookup implements LookupManager{ attrs.add(new LDAPAttribute("aliasedObjectName",getFullDN(domPath.getItemPath()))); String objectclass_values[] = { "alias", "aliasObject" }; attrs.add(new LDAPAttribute("objectclass",objectclass_values)); - } catch (ObjectNotFound e) { // no entity - is a context + } catch (ObjectNotFoundException e) { // no entity - is a context attrs.add(new LDAPAttribute("objectclass","cristalcontext")); } } @@ -557,7 +557,7 @@ public class LDAPLookup implements LookupManager{ //CristalRole is-a specialized CristalContext which contains multi-valued uniqueMember attribute pointing to cristalagents @Override public RolePath createRole(RolePath rolePath) - throws ObjectAlreadyExists, ObjectCannotBeUpdated + throws ObjectAlreadyExistsException, ObjectCannotBeUpdated { // create the role @@ -566,8 +566,8 @@ public class LDAPLookup implements LookupManager{ try { roleNode = LDAPLookupUtils.getEntry(mLDAPAuth.getAuthObject(), getFullDN(rolePath)); - throw new ObjectAlreadyExists(); - } catch (ObjectNotFound ex) { } + throw new ObjectAlreadyExistsException(); + } catch (ObjectNotFoundException ex) { } //create CristalRole if it does not exist roleNode = new LDAPEntry(roleDN, createAttributeSet(rolePath)); @@ -580,7 +580,7 @@ public class LDAPLookup implements LookupManager{ } - public void deleteRole(RolePath role) throws ObjectNotFound, ObjectCannotBeUpdated { + public void deleteRole(RolePath role) throws ObjectNotFoundException, ObjectCannotBeUpdated { try { LDAPLookupUtils.delete(mLDAPAuth.getAuthObject(), getFullDN(role)); } catch (LDAPException ex) { @@ -590,7 +590,7 @@ public class LDAPLookup implements LookupManager{ @Override public void addRole(AgentPath agent, RolePath role) - throws ObjectCannotBeUpdated, ObjectNotFound + throws ObjectCannotBeUpdated, ObjectNotFoundException { LDAPEntry roleEntry = LDAPLookupUtils.getEntry(mLDAPAuth.getAuthObject(), getFullDN(role)); //add memberDN to uniqueMember if it is not yet a member @@ -602,7 +602,7 @@ public class LDAPLookup implements LookupManager{ @Override public void removeRole(AgentPath agent, RolePath role) - throws ObjectCannotBeUpdated, ObjectNotFound + throws ObjectCannotBeUpdated, ObjectNotFoundException { LDAPEntry roleEntry = LDAPLookupUtils.getEntry(mLDAPAuth.getAuthObject(), getFullDN(role)); if (LDAPLookupUtils.existsAttributeValue(roleEntry, "uniqueMember", getFullDN(agent))) @@ -622,14 +622,14 @@ public class LDAPLookup implements LookupManager{ @Override public AgentPath[] getAgents(RolePath role) - throws ObjectNotFound + throws ObjectNotFoundException { //get the roleDN entry, and its uniqueMember entry pointing to LDAPEntry roleEntry; try { roleEntry = LDAPLookupUtils.getEntry(mLDAPAuth.getAuthObject(), getFullDN(role)); - } catch (ObjectNotFound e) { - throw new ObjectNotFound("Role does not exist"); + } catch (ObjectNotFoundException e) { + throw new ObjectNotFoundException("Role does not exist"); } String[] res = LDAPLookupUtils.getAllAttributeValues(roleEntry,"uniqueMember"); @@ -639,7 +639,7 @@ public class LDAPLookup implements LookupManager{ LDAPEntry userEntry = LDAPLookupUtils.getEntry(mLDAPAuth.getAuthObject(), userDN); AgentPath path = (AgentPath)nodeToPath(userEntry); agents.add(path); - } catch (ObjectNotFound ex) { + } catch (ObjectNotFoundException ex) { Logger.error("Agent "+userDN+" does not exist"); } catch (InvalidItemPathException ex) { Logger.error("Agent "+userDN+" is not a valid entity"); @@ -680,10 +680,10 @@ public class LDAPLookup implements LookupManager{ * @param agentName * @param baseDN * @return - * @throws ObjectNotFound + * @throws ObjectNotFoundException */ @Override - public AgentPath getAgentPath(String agentName) throws ObjectNotFound + public AgentPath getAgentPath(String agentName) throws ObjectNotFoundException { //search to get the userDN equivalent of the userID LDAPSearchConstraints searchCons = new LDAPSearchConstraints(); @@ -692,16 +692,16 @@ public class LDAPLookup implements LookupManager{ String filter = "(&(objectclass=cristalagent)(uid="+agentName+"))"; Iterator res = search(mItemTypeRoot,LDAPConnection.SCOPE_SUB,filter,searchCons); if (!res.hasNext()) - throw new ObjectNotFound("Agent not found: "+agentName); + throw new ObjectNotFoundException("Agent not found: "+agentName); Path result = res.next(); if (result instanceof AgentPath) return (AgentPath)result; else - throw new ObjectNotFound("Entry was not an Agent"); + throw new ObjectNotFoundException("Entry was not an Agent"); } @Override - public RolePath getRolePath(String roleName) throws ObjectNotFound + public RolePath getRolePath(String roleName) throws ObjectNotFoundException { LDAPSearchConstraints searchCons = new LDAPSearchConstraints(); searchCons.setBatchSize(0); @@ -709,35 +709,35 @@ public class LDAPLookup implements LookupManager{ String filter = "(&(objectclass=cristalrole)(cn="+roleName+"))"; Iterator res = search(mRolePath,LDAPConnection.SCOPE_SUB,filter,searchCons); if (!res.hasNext()) - throw new ObjectNotFound("Role not found"); + throw new ObjectNotFoundException("Role not found"); Path result = res.next(); if (result instanceof RolePath) return (RolePath)result; else - throw new ObjectNotFound("Entry was not a Role"); + throw new ObjectNotFoundException("Entry was not a Role"); } @Override - public void setHasJobList(RolePath role, boolean hasJobList) throws ObjectNotFound, ObjectCannotBeUpdated { + public void setHasJobList(RolePath role, boolean hasJobList) throws ObjectNotFoundException, ObjectCannotBeUpdated { // get entry LDAPEntry roleEntry; try { roleEntry = LDAPLookupUtils.getEntry(mLDAPAuth.getAuthObject(), getFullDN(role)); - } catch (ObjectNotFound e) { - throw new ObjectNotFound("Role does not exist"); + } catch (ObjectNotFoundException e) { + throw new ObjectNotFoundException("Role does not exist"); } // set attribute LDAPLookupUtils.setAttributeValue(mLDAPAuth.getAuthObject(), roleEntry, "jobList", hasJobList?"TRUE":"FALSE"); } @Override - public void setAgentPassword(AgentPath agent, String newPassword) throws ObjectNotFound, ObjectCannotBeUpdated, NoSuchAlgorithmException { + public void setAgentPassword(AgentPath agent, String newPassword) throws ObjectNotFoundException, ObjectCannotBeUpdated, NoSuchAlgorithmException { String encPasswd = AgentPath.generateUserPassword(newPassword, "SHA"); LDAPEntry agentEntry; try { agentEntry = LDAPLookupUtils.getEntry(mLDAPAuth.getAuthObject(), getFullDN(agent)); - } catch (ObjectNotFound e) { - throw new ObjectNotFound("Agent "+agent.getAgentName()+" does not exist"); + } catch (ObjectNotFoundException e) { + throw new ObjectNotFoundException("Agent "+agent.getAgentName()+" does not exist"); } LDAPLookupUtils.setAttributeValue(mLDAPAuth.getAuthObject(), agentEntry, "userPassword", encPasswd); @@ -745,7 +745,7 @@ public class LDAPLookup implements LookupManager{ @Override public String getAgentName(AgentPath agentPath) - throws ObjectNotFound { + throws ObjectNotFoundException { LDAPEntry agentEntry = LDAPLookupUtils.getEntry(mLDAPAuth.getAuthObject(), getFullDN(agentPath)); return LDAPLookupUtils.getFirstAttributeValue(agentEntry,"uid"); } diff --git a/src/main/java/com/c2kernel/lookup/ldap/LDAPLookupUtils.java b/src/main/java/com/c2kernel/lookup/ldap/LDAPLookupUtils.java index 0aa0ca6..ad41e7a 100644 --- a/src/main/java/com/c2kernel/lookup/ldap/LDAPLookupUtils.java +++ b/src/main/java/com/c2kernel/lookup/ldap/LDAPLookupUtils.java @@ -6,9 +6,9 @@ package com.c2kernel.lookup.ldap; //import netscape.ldap.*; //import netscape.ldap.util.*; -import com.c2kernel.common.ObjectAlreadyExists; +import com.c2kernel.common.ObjectAlreadyExistsException; import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFound; +import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.utils.Logger; import com.novell.ldap.LDAPAttribute; import com.novell.ldap.LDAPAttributeSet; @@ -30,7 +30,7 @@ final public class LDAPLookupUtils static final char[] META_CHARS = {'+', '=', '"', ',', '<', '>', ';', '/'}; static final String[] META_ESCAPED = {"2B", "3D", "22", "2C", "3C", "3E", "3B", "2F"}; static public LDAPEntry getEntry(LDAPConnection ld, String dn,int dereference) - throws ObjectNotFound + throws ObjectNotFoundException { try { LDAPSearchConstraints searchCons = new LDAPSearchConstraints(); @@ -39,9 +39,9 @@ final public class LDAPLookupUtils LDAPEntry thisEntry = ld.read(dn,searchCons); if (thisEntry != null) return thisEntry; } catch (LDAPException ex) { - throw new ObjectNotFound("LDAP Exception for dn:"+dn+": \n"+ex.getMessage()); + throw new ObjectNotFoundException("LDAP Exception for dn:"+dn+": \n"+ex.getMessage()); } - throw new ObjectNotFound(dn+" does not exist"); + throw new ObjectNotFoundException(dn+" does not exist"); } @@ -72,26 +72,26 @@ final public class LDAPLookupUtils //Given a DN, return an LDAP Entry static public LDAPEntry getEntry(LDAPConnection ld, String dn) - throws ObjectNotFound + throws ObjectNotFoundException { return getEntry(ld, dn, LDAPSearchConstraints.DEREF_NEVER); } - static public String getFirstAttributeValue(LDAPEntry anEntry, String attribute) throws ObjectNotFound + static public String getFirstAttributeValue(LDAPEntry anEntry, String attribute) throws ObjectNotFoundException { LDAPAttribute attr = anEntry.getAttribute(attribute); if (attr==null) - throw new ObjectNotFound("No attributes named '"+attribute+"'"); + throw new ObjectNotFoundException("No attributes named '"+attribute+"'"); return (String)attr.getStringValues().nextElement(); } - static public String[] getAllAttributeValues(LDAPEntry anEntry, String attribute) throws ObjectNotFound + static public String[] getAllAttributeValues(LDAPEntry anEntry, String attribute) throws ObjectNotFoundException { LDAPAttribute attr = anEntry.getAttribute(attribute); if (attr!=null) return attr.getStringValueArray(); - throw new ObjectNotFound("No attributes named '"+attribute+"'"); + throw new ObjectNotFoundException("No attributes named '"+attribute+"'"); } @@ -108,24 +108,24 @@ final public class LDAPLookupUtils } return false; } - static public boolean hasOneAttributeValue(LDAPEntry anEntry, String attribute) throws ObjectNotFound + static public boolean hasOneAttributeValue(LDAPEntry anEntry, String attribute) throws ObjectNotFoundException { int j =0; LDAPAttribute attr = anEntry.getAttribute(attribute); if (attr==null) - throw new ObjectNotFound("No attributes named '"+attribute+"'"); + throw new ObjectNotFoundException("No attributes named '"+attribute+"'"); j=attr.size(); return j==1; } //this is for a single-valued attribute static public void setAttributeValue(LDAPConnection ld, LDAPEntry anEntry, String attribute, String newValue) - throws ObjectNotFound, ObjectCannotBeUpdated + throws ObjectNotFoundException, ObjectCannotBeUpdated { try { if (!hasOneAttributeValue(anEntry, attribute)) throw new ObjectCannotBeUpdated("Attribute "+attribute + " of entry " + anEntry.getDN()+" has more than one value"); - } catch (ObjectNotFound ex) { + } catch (ObjectNotFoundException ex) { addAttributeValue(ld, anEntry, attribute, newValue); } try @@ -186,7 +186,7 @@ final public class LDAPLookupUtils } static public void addEntry(LDAPConnection ld,LDAPEntry myEntry) - throws ObjectAlreadyExists, LDAPException + throws ObjectAlreadyExistsException, LDAPException { try { @@ -194,7 +194,7 @@ final public class LDAPLookupUtils } catch( LDAPException ex ) { if (ex.getResultCode() == LDAPException.ENTRY_ALREADY_EXISTS) - throw new ObjectAlreadyExists("Entry already present." + myEntry.getDN()); + throw new ObjectAlreadyExistsException("Entry already present." + myEntry.getDN()); throw ex; } } diff --git a/src/main/java/com/c2kernel/lookup/ldap/LDAPPropertyManager.java b/src/main/java/com/c2kernel/lookup/ldap/LDAPPropertyManager.java index 633ae60..48e0a8e 100644 --- a/src/main/java/com/c2kernel/lookup/ldap/LDAPPropertyManager.java +++ b/src/main/java/com/c2kernel/lookup/ldap/LDAPPropertyManager.java @@ -4,7 +4,7 @@ import java.util.ArrayList; import java.util.Enumeration; import com.c2kernel.common.ObjectCannotBeUpdated; -import com.c2kernel.common.ObjectNotFound; +import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.lookup.ItemPath; import com.c2kernel.property.Property; import com.c2kernel.utils.Logger; @@ -36,9 +36,9 @@ public class LDAPPropertyManager { /** * @param thisItem - EntityPath of the subject entity * @return - * @throws ObjectNotFound + * @throws ObjectNotFoundException */ - public boolean hasProperties(ItemPath thisItem) throws ObjectNotFound { + public boolean hasProperties(ItemPath thisItem) throws ObjectNotFoundException { LDAPEntry entityEntry = LDAPLookupUtils.getEntry(auth.getAuthObject(), ldap.getFullDN(thisItem)); return entityEntry.getAttribute("cristalprop") != null; } @@ -46,9 +46,9 @@ public class LDAPPropertyManager { /** * @param thisItem - EntityPath of the subject entity * @return array of Property - * @throws ObjectNotFound + * @throws ObjectNotFoundException */ - public String[] getPropertyNames(ItemPath thisItem) throws ObjectNotFound { + public String[] getPropertyNames(ItemPath thisItem) throws ObjectNotFoundException { LDAPEntry entityEntry = LDAPLookupUtils.getEntry(auth.getAuthObject(), ldap.getFullDN(thisItem)); ArrayList propbag = new ArrayList(); LDAPAttribute props = entityEntry.getAttribute("cristalprop"); @@ -67,9 +67,9 @@ public class LDAPPropertyManager { * @param thisItem - EntityPath of the subject entity * @param propName - the name of the property to retrieve * @return The Property object - * @throws ObjectNotFound + * @throws ObjectNotFoundException */ - public Property getProperty(ItemPath thisItem, String name) throws ObjectNotFound { + public Property getProperty(ItemPath thisItem, String name) throws ObjectNotFoundException { LDAPEntry entityEntry = LDAPLookupUtils.getEntry(auth.getAuthObject(), ldap.getFullDN(thisItem)); return getProperty(entityEntry, name); } @@ -77,10 +77,10 @@ public class LDAPPropertyManager { /** * @param thisItem - EntityPath of the subject entity * @param name - the property name to delete - * @throws ObjectNotFound + * @throws ObjectNotFoundException * @throws ObjectCannotBeUpdated */ - public void deleteProperty(ItemPath thisItem, String name) throws ObjectNotFound, ObjectCannotBeUpdated { + public void deleteProperty(ItemPath thisItem, String name) throws ObjectNotFoundException, ObjectCannotBeUpdated { LDAPEntry entityEntry = LDAPLookupUtils.getEntry(auth.getAuthObject(), ldap.getFullDN(thisItem)); Property prop = getProperty(entityEntry, name); Logger.msg(6, "LDAPLookupUtils.deleteProperty("+name+") - Deleting property"); @@ -94,27 +94,27 @@ public class LDAPPropertyManager { /** * @param thisItem - EntityPath of the subject entity * @param prop - the property to store - * @throws ObjectNotFound + * @throws ObjectNotFoundException * @throws ObjectCannotBeUpdated */ - public void setProperty(ItemPath thisItem, Property prop) throws ObjectNotFound, ObjectCannotBeUpdated { + public void setProperty(ItemPath thisItem, Property prop) throws ObjectNotFoundException, ObjectCannotBeUpdated { LDAPEntry entityEntry = LDAPLookupUtils.getEntry(auth.getAuthObject(), ldap.getFullDN(thisItem)); try { Property oldProp = getProperty(entityEntry, prop.getName()); Logger.msg(6, "LDAPLookupUtils.setProperty("+prop.getName()+") - Removing old value '"+oldProp.getValue()+"'"); LDAPLookupUtils.removeAttributeValue(auth.getAuthObject(), entityEntry, "cristalprop", getPropertyAttrValue(oldProp)); - } catch (ObjectNotFound ex) { + } catch (ObjectNotFoundException ex) { Logger.msg(6, "LDAPLookupUtils.setProperty("+prop.getName()+") - creating new property."); } Logger.msg(6, "LDAPLookupUtils.setProperty("+prop.getName()+") - setting to '"+prop.getValue()+"'"); LDAPLookupUtils.addAttributeValue(auth.getAuthObject(), entityEntry, "cristalprop", getPropertyAttrValue(prop)); } - public static Property getProperty(LDAPEntry myEntry, String propName) throws ObjectNotFound { + public static Property getProperty(LDAPEntry myEntry, String propName) throws ObjectNotFoundException { // delete existing props LDAPAttribute props = myEntry.getAttribute("cristalprop"); if (props == null) - throw new ObjectNotFound("Property "+propName+" does not exist"); + throw new ObjectNotFoundException("Property "+propName+" does not exist"); String propPrefix = propName+":"; String roPropPrefix = "!"+propPrefix; String val = null, name = null; boolean mutable = false; @@ -133,7 +133,7 @@ public class LDAPPropertyManager { } } if (name == null) - throw new ObjectNotFound("Property "+propName+" does not exist"); + throw new ObjectNotFoundException("Property "+propName+" does not exist"); Logger.msg(6, "Loaded "+(mutable?"":"Non-")+"Mutable Property: "+name+"="+val); return new Property(name, val, mutable); } -- cgit v1.2.3