diff options
6 files changed, 124 insertions, 125 deletions
diff --git a/src/main/java/com/c2kernel/lookup/ldap/LDAPAuthManager.java b/src/main/java/com/c2kernel/lookup/ldap/LDAPAuthManager.java index 1ddb452..d97fa1f 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.InvalidDataException;
-import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.InvalidData;
+import com.c2kernel.common.ObjectNotFound;
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 InvalidDataException, ObjectNotFoundException {
+ String password, String resource) throws InvalidData, ObjectNotFound {
ldapProps = new LDAPProperties(Gateway.getProperties());
@@ -42,18 +42,18 @@ public class LDAPAuthManager implements Authenticator { }
else
{
- throw new InvalidDataException("Cannot log in. Some connection properties are not set.", "");
+ throw new InvalidData("Cannot log in. Some connection properties are not set.");
}
}
@Override
- public boolean authenticate(String resource) throws InvalidDataException, ObjectNotFoundException {
+ public boolean authenticate(String resource) throws InvalidData, ObjectNotFound {
ldapProps = new LDAPProperties(Gateway.getProperties());
if (ldapProps.mUser == null || ldapProps.mUser.length()==0 ||
ldapProps.mPassword == null || ldapProps.mPassword.length()==0)
- throw new InvalidDataException("LDAP root user properties not found in config.");
+ throw new InvalidData("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/LDAPClientReader.java b/src/main/java/com/c2kernel/lookup/ldap/LDAPClientReader.java index 1d41ed7..70bf126 100644 --- a/src/main/java/com/c2kernel/lookup/ldap/LDAPClientReader.java +++ b/src/main/java/com/c2kernel/lookup/ldap/LDAPClientReader.java @@ -1,8 +1,8 @@ package com.c2kernel.lookup.ldap;
+import com.c2kernel.common.PersistencyException;
import com.c2kernel.entity.C2KLocalObject;
import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.persistency.ClusterStorageException;
/** Allows clients to directly load properties and collections from the LDAP
* so no CORBA calls need to be made during normal browsing
@@ -21,8 +21,8 @@ public class LDAPClientReader extends LDAPClusterStorage { */
@Override
public void delete(ItemPath itemPath, String path)
- throws ClusterStorageException {
- throw new ClusterStorageException("Writing not supported in ClientReader");
+ throws PersistencyException {
+ throw new PersistencyException("Writing not supported in ClientReader");
}
/**
@@ -38,8 +38,8 @@ public class LDAPClientReader extends LDAPClusterStorage { */
public void put(ItemPath itemPath, String path, C2KLocalObject obj)
- throws ClusterStorageException {
- throw new ClusterStorageException("Writing not supported in ClientReader");
+ throws PersistencyException {
+ throw new PersistencyException("Writing not supported in ClientReader");
}
}
diff --git a/src/main/java/com/c2kernel/lookup/ldap/LDAPClusterStorage.java b/src/main/java/com/c2kernel/lookup/ldap/LDAPClusterStorage.java index 3de9aad..ac91c29 100644 --- a/src/main/java/com/c2kernel/lookup/ldap/LDAPClusterStorage.java +++ b/src/main/java/com/c2kernel/lookup/ldap/LDAPClusterStorage.java @@ -2,13 +2,12 @@ package com.c2kernel.lookup.ldap; import java.util.ArrayList;
import java.util.StringTokenizer;
-import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.ObjectNotFound;
+import com.c2kernel.common.PersistencyException;
import com.c2kernel.entity.C2KLocalObject;
-import com.c2kernel.lookup.InvalidItemPathException;
import com.c2kernel.lookup.ItemPath;
import com.c2kernel.lookup.Lookup;
import com.c2kernel.persistency.ClusterStorage;
-import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.process.Gateway;
import com.c2kernel.process.auth.Authenticator;
import com.c2kernel.property.Property;
@@ -18,17 +17,17 @@ public class LDAPClusterStorage extends ClusterStorage { LDAPPropertyManager ldapStore;
@Override
- public void open(Authenticator auth) throws ClusterStorageException {
+ public void open(Authenticator auth) throws PersistencyException {
Lookup lookup = Gateway.getLookup();
if (lookup instanceof LDAPLookup)
ldapStore = ((LDAPLookup)lookup).getPropManager();
else
- throw new ClusterStorageException("Cannot use LDAP cluster storage without LDAP Lookup");
+ throw new PersistencyException("Cannot use LDAP cluster storage without LDAP Lookup");
}
@Override
- public void close() throws ClusterStorageException {
+ public void close() throws PersistencyException {
}
// introspection
@@ -52,12 +51,12 @@ public class LDAPClusterStorage extends ClusterStorage { // retrieve object by path
@Override
- public C2KLocalObject get(ItemPath thisItem, String path) throws ClusterStorageException {
+ public C2KLocalObject get(ItemPath thisItem, String path) throws PersistencyException {
Logger.msg(6, "LDAPClusterStorage.get() - "+thisItem+"/"+path);
StringTokenizer tok = new StringTokenizer(path, "/");
int pathLength = tok.countTokens();
if (pathLength != 2)
- throw new ClusterStorageException("Path length was invalid: "+path);
+ throw new PersistencyException("Path length was invalid: "+path);
String type = tok.nextToken();
String objName = tok.nextToken();
@@ -67,19 +66,19 @@ public class LDAPClusterStorage extends ClusterStorage { try {
Property newProperty = ldapStore.getProperty(thisItem, objName);
newObj = newProperty;
- } catch (ObjectNotFoundException ex) {
- throw new ClusterStorageException("Property "+objName+" not found in "+thisItem);
+ } catch (ObjectNotFound ex) {
+ throw new PersistencyException("Property "+objName+" not found in "+thisItem);
}
}
else
- throw new ClusterStorageException("Cluster type "+type+" not supported.");
+ throw new PersistencyException("Cluster type "+type+" not supported.");
return newObj;
}
// store object by path
@Override
- public void put(ItemPath thisItem, C2KLocalObject obj) throws ClusterStorageException {
+ public void put(ItemPath thisItem, C2KLocalObject obj) throws PersistencyException {
Logger.msg(6, "LDAPClusterStorage.put() - "+thisItem+"/"+ClusterStorage.getPath(obj));
String type = obj.getClusterType();
@@ -89,20 +88,20 @@ public class LDAPClusterStorage extends ClusterStorage { ldapStore.setProperty(thisItem, (Property)obj);
} catch (Exception e1) {
Logger.error(e1);
- throw new ClusterStorageException("LDAPClusterStorage - could not write property");
+ throw new PersistencyException("LDAPClusterStorage - could not write property");
}
}
else
- throw new ClusterStorageException("Cluster type "+type+" not supported.");
+ throw new PersistencyException("Cluster type "+type+" not supported.");
}
// delete cluster
@Override
- public void delete(ItemPath thisItem, String path) throws ClusterStorageException {
+ public void delete(ItemPath thisItem, String path) throws PersistencyException {
StringTokenizer tok = new StringTokenizer(path, "/");
int pathLength = tok.countTokens();
if (pathLength != 2)
- throw new ClusterStorageException("Path length was invalid: "+path);
+ throw new PersistencyException("Path length was invalid: "+path);
String type = tok.nextToken();
if (type.equals(PROPERTY)) {
@@ -110,11 +109,11 @@ public class LDAPClusterStorage extends ClusterStorage { ldapStore.deleteProperty(thisItem, tok.nextToken());
} catch (Exception e1) {
Logger.error(e1);
- throw new ClusterStorageException("LDAPClusterStorage - could not delete property");
+ throw new PersistencyException("LDAPClusterStorage - could not delete property");
}
}
else
- throw new ClusterStorageException("Cluster type "+type+" not supported.");
+ throw new PersistencyException("Cluster type "+type+" not supported.");
}
@@ -122,7 +121,7 @@ public class LDAPClusterStorage extends ClusterStorage { // directory listing
@Override
- public String[] getClusterContents(ItemPath thisItem, String path) throws ClusterStorageException {
+ public String[] getClusterContents(ItemPath thisItem, String path) throws PersistencyException {
Logger.msg(6, "LDAPClusterStorage.getClusterContents() - "+thisItem+"/"+path);
StringTokenizer tok = new StringTokenizer(path, "/");
int pathLength = tok.countTokens();
@@ -144,9 +143,9 @@ public class LDAPClusterStorage extends ClusterStorage { return allClusters;
}
else
- throw new ClusterStorageException("Cluster type "+type+" not supported.");
- } catch (ObjectNotFoundException e) {
- throw new ClusterStorageException("Item "+thisItem+" does not exist");
+ throw new PersistencyException("Cluster type "+type+" not supported.");
+ } catch (ObjectNotFound 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 7d4c53f..a9fcd6d 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.ObjectAlreadyExistsException;
+import com.c2kernel.common.ObjectAlreadyExists;
import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.ObjectNotFound;
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 ObjectNotFoundException When the path does not exist
+ * @throws ObjectNotFound When the path does not exist
*/
public org.omg.CORBA.Object getIOR(Path path)
- throws ObjectNotFoundException
+ throws ObjectNotFound
{
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 ObjectNotFoundException when the dn or aliased dn does not exist
+ * @throws ObjectNotFound when the dn or aliased dn does not exist
*/
private org.omg.CORBA.Object resolveObject(String dn)
- throws ObjectNotFoundException
+ throws ObjectNotFound
{
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 ObjectNotFoundException("LDAPLookup.resolveObject() - " + dn + " has no IOR", "");
- } catch (ObjectNotFoundException ex) {
+ throw new ObjectNotFound("LDAPLookup.resolveObject() - " + dn + " has no IOR");
+ } catch (ObjectNotFound ex) {
return resolveObject(LDAPLookupUtils.getFirstAttributeValue(anEntry,"aliasedObjectName"));
}
}
else
- throw new ObjectNotFoundException("LDAPLookup.resolveObject() LDAP node " + dn + " is not in LDAP or has no IOR.", "");
+ throw new ObjectNotFound("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 ObjectNotFoundException
+ * @throws ObjectNotFound
*/
@Override
public ItemPath resolvePath(DomainPath domPath)
- throws InvalidItemPathException, ObjectNotFoundException {
+ throws InvalidItemPathException, ObjectNotFound {
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, ObjectAlreadyExistsException
+ throws ObjectCannotBeUpdated, ObjectAlreadyExists
{
try {
checkLDAPContext(path);
@@ -197,9 +197,9 @@ 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 ObjectAlreadyExistsException(ex.getLDAPErrorMessage(), "");
+ throw new ObjectAlreadyExists(ex.getLDAPErrorMessage());
else
- throw new ObjectCannotBeUpdated(ex.getLDAPErrorMessage(), "");
+ throw new ObjectCannotBeUpdated(ex.getLDAPErrorMessage());
}
}
@@ -211,7 +211,7 @@ public class LDAPLookup implements LookupManager{ try {
LDAPLookupUtils.delete(mLDAPAuth.getAuthObject(),getDN(path)+mLocalPath);
} catch (LDAPException ex) {
- throw new ObjectCannotBeUpdated(ex.getLDAPErrorMessage(), "");
+ throw new ObjectCannotBeUpdated(ex.getLDAPErrorMessage());
}
if (path instanceof DomainPath) {
Gateway.getProxyServer().sendProxyEvent(new ProxyMessage(null, path.toString(), ProxyMessage.DELETED));
@@ -260,7 +260,7 @@ public class LDAPLookup implements LookupManager{ }
@Override
- public void initializeDirectory() throws ObjectNotFoundException
+ public void initializeDirectory() throws ObjectNotFound
{
createBootTree();
initTree( Gateway.getResource().getTextResource("ldap", "LDAPboot.txt"));
@@ -364,7 +364,7 @@ public class LDAPLookup implements LookupManager{ }
@Override
- public ItemPath getItemPath(String uuid) throws ObjectNotFoundException, InvalidItemPathException {
+ public ItemPath getItemPath(String uuid) throws ObjectNotFound, 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 ObjectNotFoundException("Not an entity", "");
+ throw new ObjectNotFound("Not an entity");
} catch (LDAPException ex) {
if (ex.getResultCode() == LDAPException.NO_SUCH_OBJECT)
- throw new ObjectNotFoundException("Entity does not exist", "");
+ throw new ObjectNotFound("Entity does not exist");
Logger.error(ex);
- throw new ObjectNotFoundException("Error getting entity class", "");
+ throw new ObjectNotFound("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 ObjectNotFoundException
- * @throws ObjectNotFoundException
+ * @throws ObjectNotFound
+ * @throws ObjectNotFound
* @throws
*/
- protected Path nodeToPath(LDAPEntry entry) throws InvalidItemPathException, ObjectNotFoundException
+ protected Path nodeToPath(LDAPEntry entry) throws InvalidItemPathException, ObjectNotFound
{
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 (ObjectNotFoundException ex) {
+ } catch (ObjectNotFound 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 (ObjectNotFoundException ex) {
+ } catch (ObjectNotFound ex) {
ior = null;
}
@@ -443,11 +443,11 @@ public class LDAPLookup implements LookupManager{ thisPath = entityKey;
}
else
- throw new ObjectNotFoundException("Entity found outside entity tree", "");
+ throw new ObjectNotFound("Entity found outside entity tree");
}
else
{
- throw new ObjectNotFoundException("Unrecognised LDAP entry. Not a cristal entry", "");
+ throw new ObjectNotFound("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 ObjectNotFoundException {
+ public Object resolve(Path path) throws ObjectNotFound {
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 (ObjectNotFoundException e) { // no entity - is a context
+ } catch (ObjectNotFound e) { // no entity - is a context
attrs.add(new LDAPAttribute("objectclass","cristalcontext"));
}
}
@@ -532,17 +532,17 @@ public class LDAPLookup implements LookupManager{ if (agentName != null && agentName.length() > 0)
attrs.add(new LDAPAttribute("uid", agentName));
else
- throw new ObjectCannotBeUpdated("Cannot create agent. No userId specified", "");
+ throw new ObjectCannotBeUpdated("Cannot create agent. No userId specified");
String agentPass = agentPath.getPassword();
if (agentPass != null && agentPass.length() > 0)
try {
attrs.add(new LDAPAttribute("userPassword", AgentPath.generateUserPassword(agentPass, "SHA")));
} catch (NoSuchAlgorithmException ex) {
- throw new ObjectCannotBeUpdated("Cryptographic libraries for password hashing not found.", "");
+ throw new ObjectCannotBeUpdated("Cryptographic libraries for password hashing not found.");
}
else
- throw new ObjectCannotBeUpdated("Cannot create agent. No password given", "");
+ throw new ObjectCannotBeUpdated("Cannot create agent. No password given");
}
else {
attrs.add(new LDAPAttribute("objectclass","cristalentity"));
@@ -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 ObjectAlreadyExistsException, ObjectCannotBeUpdated
+ throws ObjectAlreadyExists, ObjectCannotBeUpdated
{
// create the role
@@ -566,21 +566,21 @@ public class LDAPLookup implements LookupManager{ try
{
roleNode = LDAPLookupUtils.getEntry(mLDAPAuth.getAuthObject(), getFullDN(rolePath));
- throw new ObjectAlreadyExistsException();
- } catch (ObjectNotFoundException ex) { }
+ throw new ObjectAlreadyExists();
+ } catch (ObjectNotFound ex) { }
//create CristalRole if it does not exist
roleNode = new LDAPEntry(roleDN, createAttributeSet(rolePath));
try {
LDAPLookupUtils.addEntry(mLDAPAuth.getAuthObject(),roleNode);
} catch (LDAPException e) {
- throw new ObjectCannotBeUpdated(e.getLDAPErrorMessage(), "");
+ throw new ObjectCannotBeUpdated(e.getLDAPErrorMessage());
}
return rolePath;
}
- public void deleteRole(RolePath role) throws ObjectNotFoundException, ObjectCannotBeUpdated {
+ public void deleteRole(RolePath role) throws ObjectNotFound, 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, ObjectNotFoundException
+ throws ObjectCannotBeUpdated, ObjectNotFound
{
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, ObjectNotFoundException
+ throws ObjectCannotBeUpdated, ObjectNotFound
{
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 ObjectNotFoundException
+ throws ObjectNotFound
{
//get the roleDN entry, and its uniqueMember entry pointing to
LDAPEntry roleEntry;
try {
roleEntry = LDAPLookupUtils.getEntry(mLDAPAuth.getAuthObject(), getFullDN(role));
- } catch (ObjectNotFoundException e) {
- throw new ObjectNotFoundException("Role does not exist", "");
+ } catch (ObjectNotFound e) {
+ throw new ObjectNotFound("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 (ObjectNotFoundException ex) {
+ } catch (ObjectNotFound 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 ObjectNotFoundException
+ * @throws ObjectNotFound
*/
@Override
- public AgentPath getAgentPath(String agentName) throws ObjectNotFoundException
+ public AgentPath getAgentPath(String agentName) throws ObjectNotFound
{
//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<Path> res = search(mItemTypeRoot,LDAPConnection.SCOPE_SUB,filter,searchCons);
if (!res.hasNext())
- throw new ObjectNotFoundException("Agent not found: "+agentName, "");
+ throw new ObjectNotFound("Agent not found: "+agentName);
Path result = res.next();
if (result instanceof AgentPath)
return (AgentPath)result;
else
- throw new ObjectNotFoundException("Entry was not an Agent");
+ throw new ObjectNotFound("Entry was not an Agent");
}
@Override
- public RolePath getRolePath(String roleName) throws ObjectNotFoundException
+ public RolePath getRolePath(String roleName) throws ObjectNotFound
{
LDAPSearchConstraints searchCons = new LDAPSearchConstraints();
searchCons.setBatchSize(0);
@@ -709,35 +709,35 @@ public class LDAPLookup implements LookupManager{ String filter = "(&(objectclass=cristalrole)(cn="+roleName+"))";
Iterator<Path> res = search(mRolePath,LDAPConnection.SCOPE_SUB,filter,searchCons);
if (!res.hasNext())
- throw new ObjectNotFoundException("Role not found");
+ throw new ObjectNotFound("Role not found");
Path result = res.next();
if (result instanceof RolePath)
return (RolePath)result;
else
- throw new ObjectNotFoundException("Entry was not a Role");
+ throw new ObjectNotFound("Entry was not a Role");
}
@Override
- public void setHasJobList(RolePath role, boolean hasJobList) throws ObjectNotFoundException, ObjectCannotBeUpdated {
+ public void setHasJobList(RolePath role, boolean hasJobList) throws ObjectNotFound, ObjectCannotBeUpdated {
// get entry
LDAPEntry roleEntry;
try {
roleEntry = LDAPLookupUtils.getEntry(mLDAPAuth.getAuthObject(), getFullDN(role));
- } catch (ObjectNotFoundException e) {
- throw new ObjectNotFoundException("Role does not exist", "");
+ } catch (ObjectNotFound e) {
+ throw new ObjectNotFound("Role does not exist");
}
// set attribute
LDAPLookupUtils.setAttributeValue(mLDAPAuth.getAuthObject(), roleEntry, "jobList", hasJobList?"TRUE":"FALSE");
}
@Override
- public void setAgentPassword(AgentPath agent, String newPassword) throws ObjectNotFoundException, ObjectCannotBeUpdated, NoSuchAlgorithmException {
+ public void setAgentPassword(AgentPath agent, String newPassword) throws ObjectNotFound, ObjectCannotBeUpdated, NoSuchAlgorithmException {
String encPasswd = AgentPath.generateUserPassword(newPassword, "SHA");
LDAPEntry agentEntry;
try {
agentEntry = LDAPLookupUtils.getEntry(mLDAPAuth.getAuthObject(), getFullDN(agent));
- } catch (ObjectNotFoundException e) {
- throw new ObjectNotFoundException("Agent "+agent.getAgentName()+" does not exist", "");
+ } catch (ObjectNotFound e) {
+ throw new ObjectNotFound("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 ObjectNotFoundException {
+ throws ObjectNotFound {
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 e1c8ac4..0aa0ca6 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.ObjectAlreadyExistsException;
+import com.c2kernel.common.ObjectAlreadyExists;
import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.ObjectNotFound;
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 ObjectNotFoundException
+ throws ObjectNotFound
{
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 ObjectNotFoundException("LDAP Exception for dn:"+dn+": \n"+ex.getMessage(), "");
+ throw new ObjectNotFound("LDAP Exception for dn:"+dn+": \n"+ex.getMessage());
}
- throw new ObjectNotFoundException(dn+" does not exist", "");
+ throw new ObjectNotFound(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 ObjectNotFoundException
+ throws ObjectNotFound
{
return getEntry(ld, dn, LDAPSearchConstraints.DEREF_NEVER);
}
- static public String getFirstAttributeValue(LDAPEntry anEntry, String attribute) throws ObjectNotFoundException
+ static public String getFirstAttributeValue(LDAPEntry anEntry, String attribute) throws ObjectNotFound
{
LDAPAttribute attr = anEntry.getAttribute(attribute);
if (attr==null)
- throw new ObjectNotFoundException("No attributes named '"+attribute+"'", "");
+ throw new ObjectNotFound("No attributes named '"+attribute+"'");
return (String)attr.getStringValues().nextElement();
}
- static public String[] getAllAttributeValues(LDAPEntry anEntry, String attribute) throws ObjectNotFoundException
+ static public String[] getAllAttributeValues(LDAPEntry anEntry, String attribute) throws ObjectNotFound
{
LDAPAttribute attr = anEntry.getAttribute(attribute);
if (attr!=null)
return attr.getStringValueArray();
- throw new ObjectNotFoundException("No attributes named '"+attribute+"'", "");
+ throw new ObjectNotFound("No attributes named '"+attribute+"'");
}
@@ -108,24 +108,24 @@ final public class LDAPLookupUtils }
return false;
}
- static public boolean hasOneAttributeValue(LDAPEntry anEntry, String attribute) throws ObjectNotFoundException
+ static public boolean hasOneAttributeValue(LDAPEntry anEntry, String attribute) throws ObjectNotFound
{
int j =0;
LDAPAttribute attr = anEntry.getAttribute(attribute);
if (attr==null)
- throw new ObjectNotFoundException("No attributes named '"+attribute+"'", "");
+ throw new ObjectNotFound("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 ObjectNotFoundException, ObjectCannotBeUpdated
+ throws ObjectNotFound, ObjectCannotBeUpdated
{
try {
if (!hasOneAttributeValue(anEntry, attribute))
- throw new ObjectCannotBeUpdated("Attribute "+attribute + " of entry " + anEntry.getDN()+" has more than one value", "");
- } catch (ObjectNotFoundException ex) {
+ throw new ObjectCannotBeUpdated("Attribute "+attribute + " of entry " + anEntry.getDN()+" has more than one value");
+ } catch (ObjectNotFound ex) {
addAttributeValue(ld, anEntry, attribute, newValue);
}
try
@@ -135,7 +135,7 @@ final public class LDAPLookupUtils catch (LDAPException ex)
{
Logger.error(ex);
- throw new ObjectCannotBeUpdated("Attribute " + attribute + " of entry " + anEntry.getDN() + " could not be modified", "");
+ throw new ObjectCannotBeUpdated("Attribute " + attribute + " of entry " + anEntry.getDN() + " could not be modified");
}
}
@@ -151,7 +151,7 @@ final public class LDAPLookupUtils catch (LDAPException ex)
{
Logger.error(ex);
- throw new ObjectCannotBeUpdated("Attribute " + attribute + " of entry " + anEntry.getDN() + " could not be added.", "");
+ throw new ObjectCannotBeUpdated("Attribute " + attribute + " of entry " + anEntry.getDN() + " could not be added.");
}
}
@@ -166,7 +166,7 @@ final public class LDAPLookupUtils catch (LDAPException ex)
{
Logger.error(ex);
- throw new ObjectCannotBeUpdated("Attribute " + attribute + " of entry " + anEntry.getDN() + " could not be deleted", "");
+ throw new ObjectCannotBeUpdated("Attribute " + attribute + " of entry " + anEntry.getDN() + " could not be deleted");
}
}
@@ -186,7 +186,7 @@ final public class LDAPLookupUtils }
static public void addEntry(LDAPConnection ld,LDAPEntry myEntry)
- throws ObjectAlreadyExistsException, LDAPException
+ throws ObjectAlreadyExists, LDAPException
{
try
{
@@ -194,7 +194,7 @@ final public class LDAPLookupUtils }
catch( LDAPException ex ) {
if (ex.getResultCode() == LDAPException.ENTRY_ALREADY_EXISTS)
- throw new ObjectAlreadyExistsException("Entry already present." + myEntry.getDN(), "");
+ throw new ObjectAlreadyExists("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 30bc9d7..633ae60 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.ObjectNotFoundException;
+import com.c2kernel.common.ObjectNotFound;
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 ObjectNotFoundException
+ * @throws ObjectNotFound
*/
- public boolean hasProperties(ItemPath thisItem) throws ObjectNotFoundException {
+ public boolean hasProperties(ItemPath thisItem) throws ObjectNotFound {
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 ObjectNotFoundException
+ * @throws ObjectNotFound
*/
- public String[] getPropertyNames(ItemPath thisItem) throws ObjectNotFoundException {
+ public String[] getPropertyNames(ItemPath thisItem) throws ObjectNotFound {
LDAPEntry entityEntry = LDAPLookupUtils.getEntry(auth.getAuthObject(), ldap.getFullDN(thisItem));
ArrayList<String> propbag = new ArrayList<String>();
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 ObjectNotFoundException
+ * @throws ObjectNotFound
*/
- public Property getProperty(ItemPath thisItem, String name) throws ObjectNotFoundException {
+ public Property getProperty(ItemPath thisItem, String name) throws ObjectNotFound {
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 ObjectNotFoundException
+ * @throws ObjectNotFound
* @throws ObjectCannotBeUpdated
*/
- public void deleteProperty(ItemPath thisItem, String name) throws ObjectNotFoundException, ObjectCannotBeUpdated {
+ public void deleteProperty(ItemPath thisItem, String name) throws ObjectNotFound, 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 ObjectNotFoundException
+ * @throws ObjectNotFound
* @throws ObjectCannotBeUpdated
*/
- public void setProperty(ItemPath thisItem, Property prop) throws ObjectNotFoundException, ObjectCannotBeUpdated {
+ public void setProperty(ItemPath thisItem, Property prop) throws ObjectNotFound, 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 (ObjectNotFoundException ex) {
+ } catch (ObjectNotFound 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 ObjectNotFoundException {
+ public static Property getProperty(LDAPEntry myEntry, String propName) throws ObjectNotFound {
// delete existing props
LDAPAttribute props = myEntry.getAttribute("cristalprop");
if (props == null)
- throw new ObjectNotFoundException("Property "+propName+" does not exist", "");
+ throw new ObjectNotFound("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 ObjectNotFoundException("Property "+propName+" does not exist", "");
+ throw new ObjectNotFound("Property "+propName+" does not exist");
Logger.msg(6, "Loaded "+(mutable?"":"Non-")+"Mutable Property: "+name+"="+val);
return new Property(name, val, mutable);
}
|
