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. --- .../java/com/c2kernel/lookup/ldap/LDAPLookup.java | 102 ++++++++++----------- 1 file changed, 51 insertions(+), 51 deletions(-) (limited to 'src/main/java/com/c2kernel/lookup/ldap/LDAPLookup.java') 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"); } -- cgit v1.2.3