From a1f0ecbb6a2bea6aa214322c412af2f3c5ce124b Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Wed, 7 May 2014 17:33:13 +0200 Subject: Agent now extends Item, so they can have workflows. All traces of the old 'Entity' superclasses should be removed, including proxies and paths. Very large change, breaks API compatibility with CRISTAL 2.x. Fixes #135 --- src/main/java/com/c2kernel/persistency/XMLClusterStorage.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/main/java/com/c2kernel/persistency/XMLClusterStorage.java') diff --git a/src/main/java/com/c2kernel/persistency/XMLClusterStorage.java b/src/main/java/com/c2kernel/persistency/XMLClusterStorage.java index f63dac6..50c76f0 100644 --- a/src/main/java/com/c2kernel/persistency/XMLClusterStorage.java +++ b/src/main/java/com/c2kernel/persistency/XMLClusterStorage.java @@ -3,8 +3,8 @@ import java.io.File; import java.util.ArrayList; import com.c2kernel.entity.C2KLocalObject; -import com.c2kernel.lookup.EntityPath; -import com.c2kernel.lookup.InvalidEntityPathException; +import com.c2kernel.lookup.ItemPath; +import com.c2kernel.lookup.InvalidItemPathException; import com.c2kernel.persistency.outcome.Outcome; import com.c2kernel.process.Gateway; import com.c2kernel.utils.FileStringUtility; @@ -145,8 +145,8 @@ public class XMLClusterStorage extends ClusterStorage { } } - protected String getFilePath(Integer sysKey, String path) throws InvalidEntityPathException { - EntityPath thisEntity = new EntityPath(sysKey.intValue()); + protected String getFilePath(Integer sysKey, String path) throws InvalidItemPathException { + ItemPath thisEntity = new ItemPath(sysKey.intValue()); if (path.length() == 0 || path.charAt(0) != '/') path = "/"+path; String filePath = rootDir+thisEntity.toString()+path; Logger.msg(8, "XMLClusterStorage.getFilePath() - "+filePath); -- cgit v1.2.3 From 49fe139f52afcb444478400d10db41263ef1162d Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Thu, 5 Jun 2014 15:28:46 +0200 Subject: Add Authenticator to the open() method params of ClusterStorage. Passed in through the TransactionManager. This allows user-login to storages. Fixes #192 --- src/main/java/com/c2kernel/persistency/ClusterStorage.java | 3 ++- src/main/java/com/c2kernel/persistency/ClusterStorageManager.java | 5 +++-- src/main/java/com/c2kernel/persistency/LDAPClusterStorage.java | 3 ++- src/main/java/com/c2kernel/persistency/MemoryOnlyClusterStorage.java | 3 ++- src/main/java/com/c2kernel/persistency/ProxyLoader.java | 3 ++- src/main/java/com/c2kernel/persistency/TransactionManager.java | 5 +++-- src/main/java/com/c2kernel/persistency/XMLClusterStorage.java | 5 +++-- src/main/java/com/c2kernel/process/Gateway.java | 4 ++-- 8 files changed, 19 insertions(+), 12 deletions(-) (limited to 'src/main/java/com/c2kernel/persistency/XMLClusterStorage.java') diff --git a/src/main/java/com/c2kernel/persistency/ClusterStorage.java b/src/main/java/com/c2kernel/persistency/ClusterStorage.java index 9c18bb4..76aaf1e 100644 --- a/src/main/java/com/c2kernel/persistency/ClusterStorage.java +++ b/src/main/java/com/c2kernel/persistency/ClusterStorage.java @@ -3,6 +3,7 @@ package com.c2kernel.persistency; import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.persistency.outcome.Outcome; import com.c2kernel.persistency.outcome.Viewpoint; +import com.c2kernel.process.auth.Authenticator; import com.c2kernel.utils.Logger; /** Interface for persistency managers of entities. It allows different kernel objects to be stored in different backend. For instance, @@ -85,7 +86,7 @@ public abstract class ClusterStorage { public static final String[] allClusterTypes = { PROPERTY, COLLECTION, LIFECYCLE, OUTCOME, HISTORY, VIEWPOINT, JOB }; // connection maintenance - public abstract void open() + public abstract void open(Authenticator auth) throws ClusterStorageException; public abstract void close() throws ClusterStorageException; diff --git a/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java b/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java index 20857c6..c9ede04 100644 --- a/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java +++ b/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java @@ -15,6 +15,7 @@ import com.c2kernel.events.History; import com.c2kernel.persistency.outcome.Outcome; import com.c2kernel.persistency.outcome.Viewpoint; import com.c2kernel.process.Gateway; +import com.c2kernel.process.auth.Authenticator; import com.c2kernel.utils.Logger; import com.c2kernel.utils.SoftCache; import com.c2kernel.utils.WeakCache; @@ -38,7 +39,7 @@ public class ClusterStorageManager { * Initialises all ClusterStorage handlers listed by class name in the property "ClusterStorages" * This property is usually process specific, and so should be in the server/client.conf and not the connect file. */ - public ClusterStorageManager() throws ClusterStorageException { + public ClusterStorageManager(Authenticator auth) throws ClusterStorageException { Object clusterStorageProp = Gateway.getProperties().getObject("ClusterStorage"); if (clusterStorageProp == null || clusterStorageProp.equals("")) { throw new ClusterStorageException("ClusterStorageManager.init() - no ClusterStorages defined. No persistency!"); @@ -64,7 +65,7 @@ public class ClusterStorageManager { int clusterNo = 0; for (ClusterStorage newStorage : rootStores) { try { - newStorage.open(); + newStorage.open(auth); } catch (ClusterStorageException ex) { Logger.error(ex); throw new ClusterStorageException("ClusterStorageManager.init() - Error initialising storage handler " + newStorage.getClass().getName() + diff --git a/src/main/java/com/c2kernel/persistency/LDAPClusterStorage.java b/src/main/java/com/c2kernel/persistency/LDAPClusterStorage.java index cc65805..4762a33 100644 --- a/src/main/java/com/c2kernel/persistency/LDAPClusterStorage.java +++ b/src/main/java/com/c2kernel/persistency/LDAPClusterStorage.java @@ -10,6 +10,7 @@ import com.c2kernel.lookup.Lookup; import com.c2kernel.lookup.ldap.LDAPLookup; import com.c2kernel.lookup.ldap.LDAPPropertyManager; import com.c2kernel.process.Gateway; +import com.c2kernel.process.auth.Authenticator; import com.c2kernel.property.Property; import com.c2kernel.utils.Logger; @@ -17,7 +18,7 @@ public class LDAPClusterStorage extends ClusterStorage { LDAPPropertyManager ldapStore; @Override - public void open() throws ClusterStorageException { + public void open(Authenticator auth) throws ClusterStorageException { Lookup lookup = Gateway.getLookup(); if (lookup instanceof LDAPLookup) ldapStore = ((LDAPLookup)lookup).getPropManager(); diff --git a/src/main/java/com/c2kernel/persistency/MemoryOnlyClusterStorage.java b/src/main/java/com/c2kernel/persistency/MemoryOnlyClusterStorage.java index 4766d82..cd5d122 100644 --- a/src/main/java/com/c2kernel/persistency/MemoryOnlyClusterStorage.java +++ b/src/main/java/com/c2kernel/persistency/MemoryOnlyClusterStorage.java @@ -6,6 +6,7 @@ import java.util.HashMap; import java.util.Map; import com.c2kernel.entity.C2KLocalObject; +import com.c2kernel.process.auth.Authenticator; import com.c2kernel.utils.Logger; public class MemoryOnlyClusterStorage extends ClusterStorage { @@ -19,7 +20,7 @@ public class MemoryOnlyClusterStorage extends ClusterStorage { } @Override - public void open() throws ClusterStorageException { + public void open(Authenticator auth) throws ClusterStorageException { } diff --git a/src/main/java/com/c2kernel/persistency/ProxyLoader.java b/src/main/java/com/c2kernel/persistency/ProxyLoader.java index fe48966..57b91af 100644 --- a/src/main/java/com/c2kernel/persistency/ProxyLoader.java +++ b/src/main/java/com/c2kernel/persistency/ProxyLoader.java @@ -11,6 +11,7 @@ import com.c2kernel.lookup.ItemPath; import com.c2kernel.lookup.Lookup; import com.c2kernel.persistency.outcome.Outcome; import com.c2kernel.process.Gateway; +import com.c2kernel.process.auth.Authenticator; import com.c2kernel.utils.Logger; /** Used by proxies to load clusters by queryData from the Entity. @@ -22,7 +23,7 @@ public class ProxyLoader extends ClusterStorage { Lookup lookup; @Override - public void open() throws ClusterStorageException { + public void open(Authenticator auth) throws ClusterStorageException { lookup = Gateway.getLookup(); } diff --git a/src/main/java/com/c2kernel/persistency/TransactionManager.java b/src/main/java/com/c2kernel/persistency/TransactionManager.java index d966eec..94b8123 100644 --- a/src/main/java/com/c2kernel/persistency/TransactionManager.java +++ b/src/main/java/com/c2kernel/persistency/TransactionManager.java @@ -7,6 +7,7 @@ import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.entity.agent.JobList; import com.c2kernel.events.History; +import com.c2kernel.process.auth.Authenticator; import com.c2kernel.utils.Logger; public class TransactionManager { @@ -15,8 +16,8 @@ public class TransactionManager { HashMap> pendingTransactions; ClusterStorageManager storage; - public TransactionManager() throws ClusterStorageException { - storage = new ClusterStorageManager(); + public TransactionManager(Authenticator auth) throws ClusterStorageException { + storage = new ClusterStorageManager(auth); locks = new HashMap(); pendingTransactions = new HashMap>(); } diff --git a/src/main/java/com/c2kernel/persistency/XMLClusterStorage.java b/src/main/java/com/c2kernel/persistency/XMLClusterStorage.java index 50c76f0..e6c6e9f 100644 --- a/src/main/java/com/c2kernel/persistency/XMLClusterStorage.java +++ b/src/main/java/com/c2kernel/persistency/XMLClusterStorage.java @@ -3,10 +3,11 @@ import java.io.File; import java.util.ArrayList; import com.c2kernel.entity.C2KLocalObject; -import com.c2kernel.lookup.ItemPath; import com.c2kernel.lookup.InvalidItemPathException; +import com.c2kernel.lookup.ItemPath; import com.c2kernel.persistency.outcome.Outcome; import com.c2kernel.process.Gateway; +import com.c2kernel.process.auth.Authenticator; import com.c2kernel.utils.FileStringUtility; import com.c2kernel.utils.Logger; @@ -17,7 +18,7 @@ public class XMLClusterStorage extends ClusterStorage { } @Override - public void open() throws ClusterStorageException { + public void open(Authenticator auth) throws ClusterStorageException { String rootProp = Gateway.getProperties().getProperty("XMLStorage.root"); if (rootProp == null) throw new ClusterStorageException("XMLClusterStorage.open() - Root path not given in config file."); diff --git a/src/main/java/com/c2kernel/process/Gateway.java b/src/main/java/com/c2kernel/process/Gateway.java index 836b34b..2db7aa1 100644 --- a/src/main/java/com/c2kernel/process/Gateway.java +++ b/src/main/java/com/c2kernel/process/Gateway.java @@ -207,7 +207,7 @@ public class Gateway mLookup = (Lookup)mC2KProps.getInstance("Lookup"); mLookup.open(auth); - mStorage = new TransactionManager(); + mStorage = new TransactionManager(auth); mProxyManager = new ProxyManager(); } catch (Exception ex) { @@ -240,7 +240,7 @@ public class Gateway mLookup = (Lookup)mC2KProps.getInstance("Lookup"); mLookup.open(auth); - mStorage = new TransactionManager(); + mStorage = new TransactionManager(auth); mProxyManager = new ProxyManager(); // find agent proxy -- cgit v1.2.3