diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2014-06-02 11:31:08 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2014-06-02 11:31:08 +0200 |
| commit | b96dd998d6c442be19c342399839896d00d4b6f5 (patch) | |
| tree | 51a0a07647e1d439d0adefdb57e6818a15d179ec /src/main/java/com/c2kernel/lookup/Path.java | |
| parent | 42adf60503b73c5106b30ba57fdeba13b3091169 (diff) | |
Initial commit
Diffstat (limited to 'src/main/java/com/c2kernel/lookup/Path.java')
| -rw-r--r-- | src/main/java/com/c2kernel/lookup/Path.java | 87 |
1 files changed, 9 insertions, 78 deletions
diff --git a/src/main/java/com/c2kernel/lookup/Path.java b/src/main/java/com/c2kernel/lookup/Path.java index 16f3e5d..f9fd15d 100644 --- a/src/main/java/com/c2kernel/lookup/Path.java +++ b/src/main/java/com/c2kernel/lookup/Path.java @@ -12,15 +12,11 @@ package com.c2kernel.lookup; import java.io.Serializable;
import java.util.ArrayList;
-import java.util.Enumeration;
+import java.util.Iterator;
import java.util.StringTokenizer;
-import com.c2kernel.common.ObjectCannotBeUpdated;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.process.Gateway;
-import com.novell.ldap.LDAPAttributeSet;
-import com.novell.ldap.LDAPConnection;
-import com.novell.ldap.LDAPSearchConstraints;
/**
@@ -45,19 +41,11 @@ public abstract class Path implements Serializable protected String mStringPath = null;
// entity or context
protected short mType = CONTEXT;
- // LDAP dn
- protected String mDN = null;
// int syskey (only valid for entity SystemPaths)
protected int mSysKey = INVALID;
// ior is stored in here when it is resolved
protected org.omg.CORBA.Object mIOR = null;
- //
- // needed for unusual subclass constructors
-
- protected static String mGlobalPath; //cern.ch
- protected static String mRootPath; //cristal2
- protected static String mLocalPath; //lab27
public Path() {
}
@@ -114,7 +102,6 @@ public abstract class Path implements Serializable public void setPath(String[] path)
{
mStringPath = null;
- mDN = null;
mPath = path.clone();
mSysKey = INVALID;
}
@@ -136,7 +123,6 @@ public abstract class Path implements Serializable mPath = (newPath.toArray(mPath));
mStringPath = null;
- mDN = null;
mSysKey = INVALID;
}
@@ -152,40 +138,10 @@ public abstract class Path implements Serializable public void setPath(Path path)
{
mStringPath = null;
- mDN = null;
mPath = (path.getPath().clone());
mSysKey = INVALID;
}
- /* LDAP dn e.g. cn=6L,cn=Barrel,cn=Crystal,cn=Product,cn=domain,
- * system/domain node PRESENT
- * trailing comma
- */
- public void setDN(String dn)
- {
- // strip off root path components
- String root = "cn="+getRoot()+",";
- if (dn.endsWith(mLocalPath))
- dn = dn.substring(0, dn.lastIndexOf(mLocalPath));
-
- if (dn.endsWith(root))
- dn = dn.substring(0, dn.lastIndexOf(root));
-
- ArrayList<String> newPath = new ArrayList<String>();
- StringTokenizer tok = new StringTokenizer(dn, ",");
- while (tok.hasMoreTokens()) {
- String nextPath = tok.nextToken();
- if (nextPath.indexOf("cn=") == 0)
- newPath.add(0, LDAPLookupUtils.unescapeDN(nextPath.substring(3)));
- else
- break;
- }
- mPath = (newPath.toArray(mPath));
- mSysKey = INVALID;
- mStringPath = null;
- mDN = dn+root;
- }
-
/*************************************************************************/
@@ -212,23 +168,8 @@ public abstract class Path implements Serializable return mStringPath;
}
- public String getDN() {
- if (mDN == null) {
- StringBuffer dnBuffer = new StringBuffer();
- for (int i=mPath.length-1; i>=0; i--)
- dnBuffer.append("cn=").append(LDAPLookupUtils.escapeDN(mPath[i])).append(",");
- dnBuffer.append("cn="+getRoot()+",");
- mDN = dnBuffer.toString();
- }
- return mDN;
- }
-
- public String getFullDN() {
- return getDN()+mLocalPath;
- }
-
public boolean exists() {
- return Gateway.getLDAPLookup().exists(this);
+ return Gateway.getLookup().exists(this);
}
/** Queries the lookup for the IOR
@@ -237,9 +178,9 @@ public abstract class Path implements Serializable public org.omg.CORBA.Object getIOR() {
org.omg.CORBA.Object newIOR = null;
if (mIOR==null) { // if not cached try to resolve
- LDAPLookup myLookup = Gateway.getLDAPLookup();
+ Lookup myLookup = Gateway.getLookup();
try {
- newIOR = myLookup.getIOR(this);
+ newIOR = myLookup.resolve(this);
} catch (ObjectNotFoundException ex) {
}
setIOR(newIOR);
@@ -260,19 +201,11 @@ public abstract class Path implements Serializable return mSysKey;
}
- public Enumeration<? extends Path> getChildren() {
- String filter = "objectclass=*";
- LDAPSearchConstraints searchCons = new LDAPSearchConstraints();
- searchCons.setBatchSize(10);
- searchCons.setDereference(LDAPSearchConstraints.DEREF_FINDING );
- return Gateway.getLDAPLookup().search(getFullDN(), LDAPConnection.SCOPE_ONE,filter,searchCons);
- }
-
public Path find(String name) throws ObjectNotFoundException {
- Enumeration<Path> e = Gateway.getLDAPLookup().search(this, name);
- if (e.hasMoreElements()) {
- Path thisPath = e.nextElement();
- if (e.hasMoreElements())
+ Iterator<Path> e = Gateway.getLookup().search(this, name);
+ if (e.hasNext()) {
+ Path thisPath = e.next();
+ if (e.hasNext())
throw new ObjectNotFoundException("More than one match for "+name, "");
return thisPath;
}
@@ -281,8 +214,6 @@ public abstract class Path implements Serializable public abstract ItemPath getEntity() throws ObjectNotFoundException;
- public abstract LDAPAttributeSet createAttributeSet() throws ObjectCannotBeUpdated;
-
@Override
public boolean equals( Object path )
{
@@ -298,7 +229,7 @@ public abstract class Path implements Serializable StringBuffer comp = new StringBuffer("Components: { ");
for (String element : mPath)
comp.append("'").append(element).append("' ");
- return "Path - dump(): "+comp.toString()+"}\n dn="+getDN()+"\n string="+toString()+"\n int="+getSysKey()+"\n type="+mType;
+ return "Path - dump(): "+comp.toString()+"}\n string="+toString()+"\n int="+getSysKey()+"\n type="+mType;
}
}
|
