summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/entity/proxy
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2014-06-05 15:02:07 +0200
committerAndrew Branson <andrew.branson@cern.ch>2014-06-05 15:02:07 +0200
commitd4fa3bd9dd48f4d5e26850a23f5ba48a9c10ad64 (patch)
tree5ad7bfbce8ba9df9aad53ef33a8b908ca0680fc4 /src/main/java/com/c2kernel/entity/proxy
parent8bb86312d4f07dcb343ca2d212f4020906dbdb52 (diff)
LDAP refactored behind interfaces. All functions of LDAP now hidden
behind interfaces: Authenticator, Lookup and NextKeyManager (LDAP property storage was already a ClusterStorage). Gateway holds additional objects, and Fixes #26 #191. Refs #27 (needs additional work for read perms and auth tokens)
Diffstat (limited to 'src/main/java/com/c2kernel/entity/proxy')
-rw-r--r--src/main/java/com/c2kernel/entity/proxy/AgentProxy.java22
-rw-r--r--src/main/java/com/c2kernel/entity/proxy/ProxyManager.java31
2 files changed, 34 insertions, 19 deletions
diff --git a/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java b/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java
index b6566a8..e5a52f0 100644
--- a/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java
+++ b/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java
@@ -11,7 +11,7 @@
package com.c2kernel.entity.proxy;
import java.util.Date;
-import java.util.Enumeration;
+import java.util.Iterator;
import com.c2kernel.common.AccessRightsException;
import com.c2kernel.common.InvalidDataException;
@@ -32,6 +32,7 @@ import com.c2kernel.lookup.Path;
import com.c2kernel.persistency.outcome.OutcomeValidator;
import com.c2kernel.persistency.outcome.Schema;
import com.c2kernel.process.Gateway;
+import com.c2kernel.process.auth.Authenticator;
import com.c2kernel.scripting.ErrorInfo;
import com.c2kernel.scripting.Script;
import com.c2kernel.scripting.ScriptErrorException;
@@ -50,6 +51,7 @@ public class AgentProxy extends ItemProxy
{
AgentPath agentPath;
+ Authenticator auth;
/**************************************************************************
* Creates an AgentProxy without cache and change notification
**************************************************************************/
@@ -66,7 +68,15 @@ public class AgentProxy extends ItemProxy
}
}
- @Override
+ public Authenticator getAuthObj() {
+ return auth;
+ }
+
+ public void setAuthObj(Authenticator auth) {
+ this.auth = auth;
+ }
+
+ @Override
public Agent narrow() throws ObjectNotFoundException
{
try {
@@ -237,14 +247,14 @@ public class AgentProxy extends ItemProxy
/** Let scripts resolve items */
public ItemProxy searchItem(String name) throws ObjectNotFoundException {
- Enumeration<Path> results = Gateway.getLDAPLookup().search(new DomainPath(""),name);
+ Iterator<Path> results = Gateway.getLookup().search(new DomainPath(""),name);
Path returnPath = null;
- if (!results.hasMoreElements())
+ if (!results.hasNext())
throw new ObjectNotFoundException(name, "");
- while(results.hasMoreElements()) {
- Path nextMatch = results.nextElement();
+ while(results.hasNext()) {
+ Path nextMatch = results.next();
if (returnPath != null && nextMatch.getSysKey() != -1 && returnPath.getSysKey() != nextMatch.getSysKey())
throw new ObjectNotFoundException("Too many items with that name");
returnPath = nextMatch;
diff --git a/src/main/java/com/c2kernel/entity/proxy/ProxyManager.java b/src/main/java/com/c2kernel/entity/proxy/ProxyManager.java
index b217f3e..2b2e0e9 100644
--- a/src/main/java/com/c2kernel/entity/proxy/ProxyManager.java
+++ b/src/main/java/com/c2kernel/entity/proxy/ProxyManager.java
@@ -12,7 +12,6 @@ package com.c2kernel.entity.proxy;
import java.util.ArrayList;
import java.util.ConcurrentModificationException;
-import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
@@ -41,9 +40,9 @@ public class ProxyManager
{
Logger.msg(5, "ProxyManager - Starting.....");
- Enumeration<Path> servers = Gateway.getLDAPLookup().searchEntities(new DomainPath("/servers"));
- while(servers.hasMoreElements()) {
- Path thisServerPath = servers.nextElement();
+ Iterator<Path> servers = Gateway.getLookup().searchEntities(new DomainPath("/servers"));
+ while(servers.hasNext()) {
+ Path thisServerPath = servers.next();
try {
int syskey = thisServerPath.getSysKey();
String remoteServer = ((Property)Gateway.getStorage().get(syskey, ClusterStorage.PROPERTY+"/Name", null)).getValue();
@@ -157,7 +156,7 @@ public class ProxyManager
**************************************************************************/
private ItemProxy createProxy( org.omg.CORBA.Object ior,
int systemKey,
- boolean isItem )
+ boolean isAgent )
throws ObjectNotFoundException
{
@@ -165,13 +164,13 @@ public class ProxyManager
Logger.msg(5, "ProxyManager::creating proxy on Item " + systemKey);
- if( isItem )
+ if( isAgent )
{
- newProxy = new ItemProxy(ior, systemKey);
+ newProxy = new AgentProxy(ior, systemKey);
}
else
{
- newProxy = new AgentProxy(ior, systemKey);
+ newProxy = new ItemProxy(ior, systemKey);
}
// subscribe to changes from server
@@ -195,7 +194,7 @@ public class ProxyManager
**************************************************************************/
private ItemProxy getProxy( org.omg.CORBA.Object ior,
int systemKey,
- boolean isItem )
+ boolean isAgent )
throws ObjectNotFoundException
{
Integer key = new Integer(systemKey);
@@ -206,7 +205,7 @@ public class ProxyManager
newProxy = proxyPool.get(key);
if (newProxy == null) {
// create a new one
- newProxy = createProxy(ior, systemKey, isItem );
+ newProxy = createProxy(ior, systemKey, isAgent );
proxyPool.put(key, newProxy);
}
return newProxy;
@@ -225,12 +224,18 @@ public class ProxyManager
//convert namePath to dn format
Logger.msg(8,"ProxyManager::getProxy(" + path.toString() + ")");
- boolean isItem = !(path.getEntity() instanceof AgentPath);
- return getProxy( Gateway.getLDAPLookup().getIOR(path),
+ boolean isAgent = (path.getEntity() instanceof AgentPath);
+ return getProxy( Gateway.getLookup().resolve(path),
path.getSysKey(),
- isItem );
+ isAgent );
}
+
+ public AgentProxy getAgentProxy( AgentPath path )
+ throws ObjectNotFoundException
+ {
+ return (AgentProxy) getProxy(path);
+ }
/**************************************************************************
* void reportCurrentProxies()