summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/entity
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/c2kernel/entity')
-rw-r--r--src/main/java/com/c2kernel/entity/CorbaServer.java109
-rw-r--r--src/main/java/com/c2kernel/entity/ItemImplementation.java86
-rw-r--r--src/main/java/com/c2kernel/entity/TraceableEntity.java12
-rw-r--r--src/main/java/com/c2kernel/entity/TraceableLocator.java27
-rw-r--r--src/main/java/com/c2kernel/entity/agent/ActiveEntity.java17
-rw-r--r--src/main/java/com/c2kernel/entity/agent/ActiveLocator.java14
-rw-r--r--src/main/java/com/c2kernel/entity/agent/AgentImplementation.java (renamed from src/main/java/com/c2kernel/entity/AgentImplementation.java)33
-rw-r--r--src/main/java/com/c2kernel/entity/agent/Job.java74
-rw-r--r--src/main/java/com/c2kernel/entity/agent/JobList.java21
-rw-r--r--src/main/java/com/c2kernel/entity/imports/ImportAgent.java57
-rw-r--r--src/main/java/com/c2kernel/entity/imports/ImportAggregation.java21
-rw-r--r--src/main/java/com/c2kernel/entity/imports/ImportDependency.java16
-rw-r--r--src/main/java/com/c2kernel/entity/imports/ImportItem.java143
-rw-r--r--src/main/java/com/c2kernel/entity/imports/ImportRole.java14
-rw-r--r--src/main/java/com/c2kernel/entity/proxy/AgentProxy.java36
-rw-r--r--src/main/java/com/c2kernel/entity/proxy/ItemProxy.java95
-rw-r--r--src/main/java/com/c2kernel/entity/proxy/MemberSubscription.java2
-rw-r--r--src/main/java/com/c2kernel/entity/proxy/ProxyClientConnection.java31
-rw-r--r--src/main/java/com/c2kernel/entity/proxy/ProxyManager.java73
-rw-r--r--src/main/java/com/c2kernel/entity/proxy/ProxyMessage.java38
-rw-r--r--src/main/java/com/c2kernel/entity/transfer/TransferItem.java68
-rw-r--r--src/main/java/com/c2kernel/entity/transfer/TransferSet.java47
22 files changed, 588 insertions, 446 deletions
diff --git a/src/main/java/com/c2kernel/entity/CorbaServer.java b/src/main/java/com/c2kernel/entity/CorbaServer.java
index 60c10a8..324a7c1 100644
--- a/src/main/java/com/c2kernel/entity/CorbaServer.java
+++ b/src/main/java/com/c2kernel/entity/CorbaServer.java
@@ -14,7 +14,7 @@ import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.entity.agent.ActiveEntity;
import com.c2kernel.entity.agent.ActiveLocator;
import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.InvalidItemPathException;
+import com.c2kernel.lookup.InvalidAgentPathException;
import com.c2kernel.lookup.ItemPath;
import com.c2kernel.process.Gateway;
import com.c2kernel.utils.Logger;
@@ -31,14 +31,14 @@ import com.c2kernel.utils.SoftCache;
public class CorbaServer {
- private final Map<ItemPath, Servant> mEntityCache;
+ private final Map<ItemPath, Servant> mItemCache;
private POA mRootPOA;
private POA mItemPOA;
private POA mAgentPOA;
private POAManager mPOAManager;
public CorbaServer() throws InvalidDataException {
- mEntityCache = new SoftCache<ItemPath, Servant>(50);
+ mItemCache = new SoftCache<ItemPath, Servant>(50);
// init POA
try {
@@ -116,74 +116,67 @@ public class CorbaServer {
/**************************************************************************
* Returns a CORBA servant for a pre-existing entity
+ * @throws ObjectNotFoundException
**************************************************************************/
- private Servant getItem(int sysKey, org.omg.PortableServer.POA poa) throws ObjectNotFoundException {
- try {
- ItemPath itemPath = Gateway.getLookup().getItemPath(sysKey);
- Servant item = null;
- synchronized (mEntityCache) {
- item = mEntityCache.get(itemPath);
- if (item == null) {
- Logger.msg(7, "Creating new servant for "+sysKey);
-
- if (itemPath instanceof AgentPath) {
- if (poa == null) poa = mAgentPOA;
- item = new ActiveEntity(sysKey, poa);
- }
- else if (itemPath instanceof ItemPath) {
- if (poa == null) poa = mItemPOA;
- item = new TraceableEntity(sysKey, poa);
- }
-
- mEntityCache.put(itemPath, item);
- }
+ public TraceableEntity getItem(ItemPath itemPath) throws ObjectNotFoundException {
+ Servant item = null;
+ if (!itemPath.exists()) throw new ObjectNotFoundException(itemPath+" does not exist", "");
+ synchronized (mItemCache) {
+ item = mItemCache.get(itemPath);
+ if (item == null) {
+ Logger.msg(7, "Creating new servant for "+itemPath);
+ item = new TraceableEntity(itemPath, mItemPOA);
+ mItemCache.put(itemPath, item);
}
- return item;
-
- } catch (InvalidItemPathException ex) {
- throw new ObjectNotFoundException("Invalid Entity Key", "");
}
+ return (TraceableEntity)item;
}
/**************************************************************************
- * Wrapper for fetching Items
- **************************************************************************/
- public TraceableEntity getItem(int sysKey) throws ObjectNotFoundException {
- return (TraceableEntity)getItem(sysKey, mItemPOA);
- }
-
- /**************************************************************************
- * Wrapper for fetching Agents
+ * Returns a CORBA servant for a pre-existing entity
**************************************************************************/
- public ActiveEntity getAgent(int sysKey) throws ObjectNotFoundException {
- return (ActiveEntity)getItem(sysKey, mAgentPOA);
+ public ActiveEntity getAgent(AgentPath agentPath) throws InvalidAgentPathException, ObjectNotFoundException {
+ Servant agent = null;
+ if (!agentPath.exists()) throw new ObjectNotFoundException(agentPath+" does not exist", "");
+ synchronized (mItemCache) {
+ agent = mItemCache.get(agentPath);
+ if (agent == null) {
+ Logger.msg(7, "Creating new servant for "+agentPath);
+ agent = new ActiveEntity(agentPath, mAgentPOA);
+ mItemCache.put(agentPath, agent);
+ }
+ else if (!(agent instanceof ActiveEntity))
+ throw new InvalidAgentPathException("Item "+agentPath+" was not an agent");
+ }
+ return (ActiveEntity)agent;
}
/**
- * @param entityPath
+ * @param itemPath
* @return
*/
- public Servant createEntity(ItemPath entityPath) throws CannotManageException, ObjectAlreadyExistsException {
- try {
- if (entityPath == null)
- entityPath = Gateway.getNextKeyManager().generateNextEntityKey();
- } catch (Exception ex) {
- Logger.error(ex);
- throw new CannotManageException("Cannot generate next entity key");
+ public TraceableEntity createItem(ItemPath itemPath) throws CannotManageException, ObjectAlreadyExistsException {
+
+ if (itemPath.exists()) throw new ObjectAlreadyExistsException();
+ org.omg.CORBA.Object obj = mItemPOA.create_reference_with_id(itemPath.getOID(), ItemHelper.id());
+ itemPath.setIOR(obj);
+ TraceableEntity item = new TraceableEntity(itemPath, mItemPOA);
+ synchronized (mItemCache) {
+ mItemCache.put(itemPath, item);
}
- boolean isAgent = entityPath instanceof AgentPath;
- POA myPOA = isAgent?mAgentPOA:mItemPOA;
- org.omg.CORBA.Object obj = myPOA.create_reference_with_id(entityPath.getOID(), isAgent?AgentHelper.id():ItemHelper.id());
- entityPath.setIOR(obj);
- Servant entity;
- if (isAgent)
- entity = new ActiveEntity(entityPath.getSysKey(), myPOA);
- else
- entity = new TraceableEntity(entityPath.getSysKey(), myPOA);
- synchronized (mEntityCache) {
- mEntityCache.put(entityPath, entity);
+ return item;
+ }
+
+ public ActiveEntity createAgent(AgentPath agentPath) throws CannotManageException, ObjectAlreadyExistsException {
+ if (agentPath.exists()) throw new ObjectAlreadyExistsException();
+ org.omg.CORBA.Object obj = mAgentPOA.create_reference_with_id(agentPath.getOID(), AgentHelper.id());
+ agentPath.setIOR(obj);
+ ActiveEntity agent;
+ agent = new ActiveEntity(agentPath, mAgentPOA);
+ synchronized (mItemCache) {
+ mItemCache.put(agentPath, agent);
}
- return entity;
-
+ return agent;
+
}
}
diff --git a/src/main/java/com/c2kernel/entity/ItemImplementation.java b/src/main/java/com/c2kernel/entity/ItemImplementation.java
index 9aa4f9b..79b2c89 100644
--- a/src/main/java/com/c2kernel/entity/ItemImplementation.java
+++ b/src/main/java/com/c2kernel/entity/ItemImplementation.java
@@ -1,5 +1,7 @@
package com.c2kernel.entity;
+import java.util.UUID;
+
import com.c2kernel.collection.Collection;
import com.c2kernel.collection.CollectionArrayList;
import com.c2kernel.common.AccessRightsException;
@@ -8,6 +10,7 @@ import com.c2kernel.common.InvalidTransitionException;
import com.c2kernel.common.ObjectAlreadyExistsException;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.common.PersistencyException;
+import com.c2kernel.common.SystemKey;
import com.c2kernel.entity.agent.JobArrayList;
import com.c2kernel.lifecycle.instance.CompositeActivity;
import com.c2kernel.lifecycle.instance.Workflow;
@@ -15,6 +18,7 @@ import com.c2kernel.lifecycle.instance.predefined.PredefinedStepContainer;
import com.c2kernel.lifecycle.instance.predefined.item.ItemPredefinedStepContainer;
import com.c2kernel.lookup.AgentPath;
import com.c2kernel.lookup.InvalidItemPathException;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.persistency.TransactionManager;
@@ -26,27 +30,30 @@ import com.c2kernel.utils.Logger;
public class ItemImplementation implements ItemOperations {
protected final TransactionManager mStorage;
- protected final int mSystemKey;
+ protected final ItemPath mItemPath;
- protected ItemImplementation(int systemKey) {
+ protected ItemImplementation(ItemPath key) {
this.mStorage = Gateway.getStorage();
- this.mSystemKey = systemKey;
+ this.mItemPath = key;
}
@Override
- public int getSystemKey() {
- // TODO Auto-generated method stub
- return 0;
+ public SystemKey getSystemKey() {
+ return mItemPath.getSystemKey();
+ }
+
+ public UUID getUUID() {
+ return mItemPath.getUUID();
}
@Override
- public void initialise(int agentId, String propString, String initWfString,
+ public void initialise(SystemKey agentId, String propString, String initWfString,
String initCollsString) throws AccessRightsException,
InvalidDataException, PersistencyException
{
- Logger.msg(5, "Item::initialise("+mSystemKey+") - agent:"+agentId);
+ Logger.msg(5, "Item::initialise("+mItemPath+") - agent:"+agentId);
Object locker = new Object();
-
+
AgentPath agentPath;
try {
agentPath = new AgentPath(agentId);
@@ -64,9 +71,9 @@ public class ItemImplementation implements ItemOperations {
PropertyArrayList props = (PropertyArrayList) Gateway
.getMarshaller().unmarshall(propString);
for (Property thisProp : props.list)
- mStorage.put(mSystemKey, thisProp, locker);
+ mStorage.put(mItemPath, thisProp, locker);
} catch (Throwable ex) {
- Logger.msg(8, "TraceableEntity::initialise(" + mSystemKey
+ Logger.msg(8, "TraceableEntity::initialise(" + mItemPath
+ ") - Properties were invalid: " + propString);
Logger.error(ex);
mStorage.abort(locker);
@@ -81,10 +88,10 @@ public class ItemImplementation implements ItemOperations {
else
lc = new Workflow((CompositeActivity) Gateway
.getMarshaller().unmarshall(initWfString), getNewPredefStepContainer());
- lc.initialise(mSystemKey, agentPath);
- mStorage.put(mSystemKey, lc, locker);
+ lc.initialise(mItemPath, agentPath);
+ mStorage.put(mItemPath, lc, locker);
} catch (Throwable ex) {
- Logger.msg(8, "TraceableEntity::initialise(" + mSystemKey
+ Logger.msg(8, "TraceableEntity::initialise(" + mItemPath
+ ") - Workflow was invalid: " + initWfString);
Logger.error(ex);
mStorage.abort(locker);
@@ -97,10 +104,10 @@ public class ItemImplementation implements ItemOperations {
CollectionArrayList colls = (CollectionArrayList) Gateway
.getMarshaller().unmarshall(initCollsString);
for (Collection<?> thisColl : colls.list) {
- mStorage.put(mSystemKey, thisColl, locker);
+ mStorage.put(mItemPath, thisColl, locker);
}
} catch (Throwable ex) {
- Logger.msg(8, "TraceableEntity::initialise(" + mSystemKey
+ Logger.msg(8, "TraceableEntity::initialise(" + mItemPath
+ ") - Collections were invalid: "
+ initCollsString);
Logger.error(ex);
@@ -109,7 +116,7 @@ public class ItemImplementation implements ItemOperations {
}
}
mStorage.commit(locker);
- Logger.msg(3, "Initialisation of item " + mSystemKey
+ Logger.msg(3, "Initialisation of item " + mItemPath
+ " was successful");
}
@@ -120,7 +127,7 @@ public class ItemImplementation implements ItemOperations {
}
@Override
- public String requestAction(int agentId, String stepPath, int transitionID,
+ public String requestAction(SystemKey agentId, String stepPath, int transitionID,
String requestData) throws AccessRightsException,
InvalidTransitionException, ObjectNotFoundException,
InvalidDataException, PersistencyException,
@@ -128,20 +135,20 @@ public class ItemImplementation implements ItemOperations {
try {
- Logger.msg(1, "TraceableEntity::request(" + mSystemKey + ") - "
+ Logger.msg(1, "TraceableEntity::request(" + mItemPath + ") - "
+ transitionID + " " + stepPath + " by " + agentId);
AgentPath agent = new AgentPath(agentId);
- Workflow lifeCycle = (Workflow) mStorage.get(mSystemKey,
+ Workflow lifeCycle = (Workflow) mStorage.get(mItemPath,
ClusterStorage.LIFECYCLE + "/workflow", null);
- String finalOutcome = lifeCycle.requestAction(agent, stepPath, mSystemKey,
+ String finalOutcome = lifeCycle.requestAction(agent, stepPath, mItemPath,
transitionID, requestData);
// store the workflow if we've changed the state of the domain
// wf
if (!(stepPath.startsWith("workflow/predefined")))
- mStorage.put(mSystemKey, lifeCycle, null);
+ mStorage.put(mItemPath, lifeCycle, null);
return finalOutcome;
// Normal operation exceptions
@@ -173,7 +180,7 @@ public class ItemImplementation implements ItemOperations {
throw ex;
// non-CORBA exception hasn't been caught!
} catch (Throwable ex) {
- Logger.error("Unknown Error: requestAction on " + mSystemKey
+ Logger.error("Unknown Error: requestAction on " + mItemPath
+ " by " + agentId + " executing " + stepPath);
Logger.error(ex);
throw new InvalidDataException(
@@ -184,10 +191,10 @@ public class ItemImplementation implements ItemOperations {
}
@Override
- public String queryLifeCycle(int agentId, boolean filter)
+ public String queryLifeCycle(SystemKey agentId, boolean filter)
throws AccessRightsException, ObjectNotFoundException,
PersistencyException {
- Logger.msg(1, "TraceableEntity::queryLifeCycle(" + mSystemKey
+ Logger.msg(1, "TraceableEntity::queryLifeCycle(" + mItemPath
+ ") - agent: " + agentId);
try {
AgentPath agent;
@@ -199,21 +206,21 @@ public class ItemImplementation implements ItemOperations {
}
Workflow wf;
try {
- wf = (Workflow) mStorage.get(mSystemKey,
+ wf = (Workflow) mStorage.get(mItemPath,
ClusterStorage.LIFECYCLE + "/workflow", null);
} catch (ClusterStorageException e) {
Logger.error("TraceableEntity::queryLifeCycle("
- + mSystemKey + ") - Error loading workflow");
+ + mItemPath + ") - Error loading workflow");
Logger.error(e);
throw new PersistencyException("Error loading workflow");
}
JobArrayList jobBag = new JobArrayList();
CompositeActivity domainWf = (CompositeActivity) wf
.search("workflow/domain");
- jobBag.list = filter ? domainWf.calculateJobs(agent,
- mSystemKey, true) : domainWf.calculateAllJobs(agent,
- mSystemKey, true);
- Logger.msg(1, "TraceableEntity::queryLifeCycle(" + mSystemKey
+ jobBag.list = filter ?
+ domainWf.calculateJobs(agent, mItemPath, true) :
+ domainWf.calculateAllJobs(agent, mItemPath, true);
+ Logger.msg(1, "TraceableEntity::queryLifeCycle(" + mItemPath
+ ") - Returning " + jobBag.list.size() + " jobs.");
try {
return Gateway.getMarshaller().marshall(jobBag);
@@ -222,7 +229,7 @@ public class ItemImplementation implements ItemOperations {
throw new PersistencyException("Error marshalling job bag");
}
} catch (Throwable ex) {
- Logger.error("TraceableEntity::queryLifeCycle(" + mSystemKey
+ Logger.error("TraceableEntity::queryLifeCycle(" + mItemPath
+ ") - Unknown error");
Logger.error(ex);
throw new PersistencyException(
@@ -236,7 +243,7 @@ public class ItemImplementation implements ItemOperations {
String result = "";
- Logger.msg(1, "TraceableEntity::queryData(" + mSystemKey + ") - "
+ Logger.msg(1, "TraceableEntity::queryData(" + mItemPath + ") - "
+ path);
try { // check for cluster contents query
@@ -244,8 +251,7 @@ public class ItemImplementation implements ItemOperations {
if (path.endsWith("/all")) {
int allPos = path.lastIndexOf("all");
String query = path.substring(0, allPos);
- String[] ids = mStorage.getClusterContents(mSystemKey,
- query);
+ String[] ids = mStorage.getClusterContents(mItemPath, query);
for (int i = 0; i < ids.length; i++) {
result += ids[i];
@@ -256,7 +262,7 @@ public class ItemImplementation implements ItemOperations {
}
// ****************************************************************
else { // retrieve the object instead
- C2KLocalObject obj = mStorage.get(mSystemKey, path, null);
+ C2KLocalObject obj = mStorage.get(mItemPath, path, null);
// marshall it, or in the case of an outcome get the data.
result = Gateway.getMarshaller().marshall(obj);
@@ -264,14 +270,14 @@ public class ItemImplementation implements ItemOperations {
} catch (ObjectNotFoundException ex) {
throw ex;
} catch (Throwable ex) {
- Logger.warning("TraceableEntity::queryData(" + mSystemKey
+ Logger.warning("TraceableEntity::queryData(" + mItemPath
+ ") - " + path + " Failed: " + ex.getClass().getName());
throw new PersistencyException("Server exception: "
+ ex.getClass().getName(), "");
}
if (Logger.doLog(9))
- Logger.msg(9, "TraceableEntity::queryData(" + mSystemKey
+ Logger.msg(9, "TraceableEntity::queryData(" + mItemPath
+ ") - result:" + result);
return result;
@@ -282,8 +288,8 @@ public class ItemImplementation implements ItemOperations {
*/
@Override
protected void finalize() throws Throwable {
- Logger.msg(7, "Item "+mSystemKey+" reaped");
- Gateway.getStorage().clearCache(mSystemKey, null);
+ Logger.msg(7, "Item "+mItemPath+" reaped");
+ Gateway.getStorage().clearCache(mItemPath, null);
super.finalize();
}
}
diff --git a/src/main/java/com/c2kernel/entity/TraceableEntity.java b/src/main/java/com/c2kernel/entity/TraceableEntity.java
index a0980ee..5acf9c5 100644
--- a/src/main/java/com/c2kernel/entity/TraceableEntity.java
+++ b/src/main/java/com/c2kernel/entity/TraceableEntity.java
@@ -18,6 +18,8 @@ import com.c2kernel.common.InvalidTransitionException;
import com.c2kernel.common.ObjectAlreadyExistsException;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.common.PersistencyException;
+import com.c2kernel.common.SystemKey;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.utils.Logger;
/**************************************************************************
@@ -57,7 +59,7 @@ public class TraceableEntity extends ItemPOA
/**************************************************************************
* Constructor used by the Locator only
**************************************************************************/
- public TraceableEntity( int key,
+ public TraceableEntity( ItemPath key,
org.omg.PortableServer.POA poa )
{
Logger.msg(5,"TraceableEntity::constructor() - SystemKey:" + key );
@@ -83,7 +85,7 @@ public class TraceableEntity extends ItemPOA
*
**************************************************************************/
@Override
- public int getSystemKey()
+ public SystemKey getSystemKey()
{
return mItemImpl.getSystemKey();
}
@@ -92,7 +94,7 @@ public class TraceableEntity extends ItemPOA
*
**************************************************************************/
@Override
- public void initialise( int agentId,
+ public void initialise( SystemKey agentId,
String propString,
String initWfString,
String initCollsString
@@ -111,7 +113,7 @@ public class TraceableEntity extends ItemPOA
**************************************************************************/
//requestdata is xmlstring
@Override
- public String requestAction( int agentId,
+ public String requestAction( SystemKey agentId,
String stepPath,
int transitionID,
String requestData
@@ -132,7 +134,7 @@ public class TraceableEntity extends ItemPOA
*
**************************************************************************/
@Override
- public String queryLifeCycle( int agentId,
+ public String queryLifeCycle( SystemKey agentId,
boolean filter
)
throws AccessRightsException,
diff --git a/src/main/java/com/c2kernel/entity/TraceableLocator.java b/src/main/java/com/c2kernel/entity/TraceableLocator.java
index 387779b..e370ed6 100644
--- a/src/main/java/com/c2kernel/entity/TraceableLocator.java
+++ b/src/main/java/com/c2kernel/entity/TraceableLocator.java
@@ -12,9 +12,12 @@
package com.c2kernel.entity;
+import java.nio.ByteBuffer;
import java.sql.Timestamp;
+import java.util.UUID;
import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.process.Gateway;
import com.c2kernel.utils.Logger;
@@ -45,23 +48,21 @@ public class TraceableLocator extends org.omg.PortableServer.ServantLocatorPOA
String operation,
org.omg.PortableServer.ServantLocatorPackage.CookieHolder cookie )
{
- try
- {
+ ByteBuffer bb = ByteBuffer.wrap(oid);
+ long msb = bb.getLong();
+ long lsb = bb.getLong();
+ ItemPath syskey = new ItemPath(new UUID(msb, lsb));
- int syskey = Integer.parseInt(new String(oid));
+ Logger.msg(1,"===========================================================");
+ Logger.msg(1,"Item called at "+new Timestamp( System.currentTimeMillis()) +": " + operation +
+ "(" + syskey + ")." );
- Logger.msg(1,"===========================================================");
- Logger.msg(1,"Item called at "+new Timestamp( System.currentTimeMillis()) +": " + operation +
- "(" + syskey + ")." );
-
- return Gateway.getCorbaServer().getItem(syskey);
-
- }
- catch (ObjectNotFoundException ex)
- {
+ try {
+ return Gateway.getCorbaServer().getItem(syskey);
+ } catch (ObjectNotFoundException ex) {
Logger.error("ObjectNotFoundException::TraceableLocator::preinvoke() " + ex.toString());
throw new org.omg.CORBA.OBJECT_NOT_EXIST();
- }
+ }
}
diff --git a/src/main/java/com/c2kernel/entity/agent/ActiveEntity.java b/src/main/java/com/c2kernel/entity/agent/ActiveEntity.java
index a799b62..ca7431c 100644
--- a/src/main/java/com/c2kernel/entity/agent/ActiveEntity.java
+++ b/src/main/java/com/c2kernel/entity/agent/ActiveEntity.java
@@ -17,8 +17,9 @@ import com.c2kernel.common.InvalidTransitionException;
import com.c2kernel.common.ObjectAlreadyExistsException;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.common.PersistencyException;
-import com.c2kernel.entity.AgentImplementation;
+import com.c2kernel.common.SystemKey;
import com.c2kernel.entity.AgentPOA;
+import com.c2kernel.lookup.AgentPath;
import com.c2kernel.utils.Logger;
/**************************************************************************
@@ -33,8 +34,8 @@ public class ActiveEntity extends AgentPOA
private final org.omg.PortableServer.POA mPoa;
private final AgentImplementation mAgentImpl;
- public ActiveEntity( int key,
- org.omg.PortableServer.POA poa )
+ public ActiveEntity( AgentPath key,
+ org.omg.PortableServer.POA poa )
{
Logger.msg(5, "ActiveEntity::constructor() - SystemKey:" + key );
mPoa = poa;
@@ -61,7 +62,7 @@ public class ActiveEntity extends AgentPOA
*
**************************************************************************/
@Override
- public int getSystemKey()
+ public SystemKey getSystemKey()
{
return mAgentImpl.getSystemKey();
}
@@ -89,7 +90,7 @@ public class ActiveEntity extends AgentPOA
*/
@Override
- public void refreshJobList(int sysKey, String stepPath, String newJobs) {
+ public void refreshJobList(SystemKey sysKey, String stepPath, String newJobs) {
synchronized (this) {
mAgentImpl.refreshJobList(sysKey, stepPath, newJobs);
}
@@ -110,7 +111,7 @@ public class ActiveEntity extends AgentPOA
}
@Override
- public void initialise(int agentId, String propString, String initWfString,
+ public void initialise(SystemKey agentId, String propString, String initWfString,
String initCollsString) throws AccessRightsException,
InvalidDataException, PersistencyException, ObjectNotFoundException {
synchronized (this) {
@@ -120,7 +121,7 @@ public class ActiveEntity extends AgentPOA
}
@Override
- public String requestAction(int agentID, String stepPath, int transitionID,
+ public String requestAction(SystemKey agentID, String stepPath, int transitionID,
String requestData) throws AccessRightsException,
InvalidTransitionException, ObjectNotFoundException,
InvalidDataException, PersistencyException,
@@ -133,7 +134,7 @@ public class ActiveEntity extends AgentPOA
}
@Override
- public String queryLifeCycle(int agentId, boolean filter)
+ public String queryLifeCycle(SystemKey agentId, boolean filter)
throws AccessRightsException, ObjectNotFoundException,
PersistencyException {
synchronized (this) {
diff --git a/src/main/java/com/c2kernel/entity/agent/ActiveLocator.java b/src/main/java/com/c2kernel/entity/agent/ActiveLocator.java
index f3d4fb0..966b265 100644
--- a/src/main/java/com/c2kernel/entity/agent/ActiveLocator.java
+++ b/src/main/java/com/c2kernel/entity/agent/ActiveLocator.java
@@ -12,9 +12,13 @@
package com.c2kernel.entity.agent;
+import java.nio.ByteBuffer;
import java.sql.Timestamp;
+import java.util.UUID;
import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.InvalidAgentPathException;
import com.c2kernel.process.Gateway;
import com.c2kernel.utils.Logger;
@@ -48,7 +52,10 @@ public class ActiveLocator extends org.omg.PortableServer.ServantLocatorPOA
try
{
- int syskey = Integer.parseInt(new String(oid));
+ ByteBuffer bb = ByteBuffer.wrap(oid);
+ long msb = bb.getLong();
+ long lsb = bb.getLong();
+ AgentPath syskey = new AgentPath(new UUID(msb, lsb));
Logger.msg(1,"===========================================================");
Logger.msg(1,"Agent called at "+new Timestamp( System.currentTimeMillis()) +": " + operation +
@@ -61,7 +68,10 @@ public class ActiveLocator extends org.omg.PortableServer.ServantLocatorPOA
{
Logger.error("ObjectNotFoundException::ActiveLocator::preinvoke() "+ex.toString());
throw new org.omg.CORBA.OBJECT_NOT_EXIST();
- }
+ } catch (InvalidAgentPathException ex) {
+ Logger.error("InvalidAgentPathException::ActiveLocator::preinvoke() "+ex.toString());
+ throw new org.omg.CORBA.INV_OBJREF();
+ }
}
diff --git a/src/main/java/com/c2kernel/entity/AgentImplementation.java b/src/main/java/com/c2kernel/entity/agent/AgentImplementation.java
index 7f38f13..0406387 100644
--- a/src/main/java/com/c2kernel/entity/AgentImplementation.java
+++ b/src/main/java/com/c2kernel/entity/agent/AgentImplementation.java
@@ -1,15 +1,15 @@
-package com.c2kernel.entity;
+package com.c2kernel.entity.agent;
import com.c2kernel.common.CannotManageException;
import com.c2kernel.common.ObjectCannotBeUpdated;
import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.entity.agent.Job;
-import com.c2kernel.entity.agent.JobArrayList;
-import com.c2kernel.entity.agent.JobList;
+import com.c2kernel.common.SystemKey;
+import com.c2kernel.entity.AgentOperations;
+import com.c2kernel.entity.ItemImplementation;
import com.c2kernel.lifecycle.instance.predefined.PredefinedStepContainer;
import com.c2kernel.lifecycle.instance.predefined.agent.AgentPredefinedStepContainer;
import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.InvalidItemPathException;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.lookup.RolePath;
import com.c2kernel.process.Gateway;
import com.c2kernel.utils.Logger;
@@ -18,9 +18,11 @@ public class AgentImplementation extends ItemImplementation implements
AgentOperations {
private JobList currentJobs;
+ private final AgentPath mAgentPath;
- public AgentImplementation(int systemKey) {
- super(systemKey);
+ public AgentImplementation(AgentPath path) {
+ super(path);
+ mAgentPath = path;
}
/**
@@ -28,21 +30,22 @@ public class AgentImplementation extends ItemImplementation implements
*/
@Override
- public synchronized void refreshJobList(int sysKey, String stepPath, String newJobs) {
+ public synchronized void refreshJobList(SystemKey sysKey, String stepPath, String newJobs) {
try {
+ ItemPath itemPath = new ItemPath(sysKey);
JobArrayList newJobList = (JobArrayList)Gateway.getMarshaller().unmarshall(newJobs);
// get our joblist
if (currentJobs == null)
- currentJobs = new JobList( mSystemKey, null);
+ currentJobs = new JobList( itemPath, null);
// remove old jobs for this item
- currentJobs.removeJobsForStep( sysKey, stepPath );
+ currentJobs.removeJobsForStep( itemPath, stepPath );
// merge new jobs in
for (Object name : newJobList.list) {
Job newJob = (Job)name;
- Logger.msg(6, "Adding job for "+newJob.getItemSysKey()+"/"+newJob.getStepPath()+":"+newJob.getTransition().getId());
+ Logger.msg(6, "Adding job for "+newJob.getItemPath()+"/"+newJob.getStepPath()+":"+newJob.getTransition().getId());
currentJobs.addJob(newJob);
}
@@ -57,9 +60,7 @@ public class AgentImplementation extends ItemImplementation implements
public void addRole(String roleName) throws CannotManageException, ObjectNotFoundException {
RolePath newRole = Gateway.getLookup().getRolePath(roleName);
try {
- newRole.addAgent(new AgentPath(mSystemKey));
- } catch (InvalidItemPathException ex) {
- throw new CannotManageException("Invalid syskey for agent: "+mSystemKey, "");
+ newRole.addAgent(mAgentPath);
} catch (ObjectCannotBeUpdated ex) {
throw new CannotManageException("Could not update role");
}
@@ -69,9 +70,7 @@ public class AgentImplementation extends ItemImplementation implements
public void removeRole(String roleName) throws CannotManageException, ObjectNotFoundException {
RolePath rolePath = Gateway.getLookup().getRolePath(roleName);
try {
- rolePath.removeAgent(new AgentPath(mSystemKey));
- } catch (InvalidItemPathException e) {
- throw new CannotManageException("Invalid syskey for agent: "+mSystemKey, "");
+ rolePath.removeAgent(mAgentPath);
} catch (ObjectCannotBeUpdated ex) {
throw new CannotManageException("Could not update role");
}
diff --git a/src/main/java/com/c2kernel/entity/agent/Job.java b/src/main/java/com/c2kernel/entity/agent/Job.java
index cef35ef..fe2084d 100644
--- a/src/main/java/com/c2kernel/entity/agent/Job.java
+++ b/src/main/java/com/c2kernel/entity/agent/Job.java
@@ -1,6 +1,7 @@
package com.c2kernel.entity.agent;
import java.util.HashMap;
+import java.util.UUID;
import com.c2kernel.common.InvalidDataException;
import com.c2kernel.common.ObjectNotFoundException;
@@ -9,6 +10,7 @@ import com.c2kernel.entity.proxy.ItemProxy;
import com.c2kernel.lifecycle.instance.Activity;
import com.c2kernel.lifecycle.instance.stateMachine.Transition;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.InvalidAgentPathException;
import com.c2kernel.lookup.InvalidItemPathException;
import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.ClusterStorage;
@@ -34,7 +36,7 @@ public class Job implements C2KLocalObject
private int id;
- private int itemSysKey;
+ private ItemPath itemPath;
private String stepName;
@@ -48,8 +50,6 @@ public class Job implements C2KLocalObject
private String targetStateName;
- private int agentId = -1;
-
private String agentRole;
private CastorHashMap actProps = new CastorHashMap();
@@ -58,6 +58,8 @@ public class Job implements C2KLocalObject
private String name;
+ private AgentPath agentPath;
+
private String agentName;
private String outcomeData;
@@ -79,9 +81,9 @@ public class Job implements C2KLocalObject
{
}
- public Job(Activity act, int itemSysKey, Transition transition, AgentPath agent, String role) throws InvalidDataException, ObjectNotFoundException {
+ public Job(Activity act, ItemPath itemPath, Transition transition, AgentPath agent, String role) throws InvalidDataException, ObjectNotFoundException, InvalidAgentPathException {
- setItemSysKey(itemSysKey);
+ setItemPath(itemPath);
setStepPath(act.getPath());
setTransition(transition);
setOriginStateName(act.getStateMachine().getState(transition.getOriginStateId()).getName());
@@ -89,7 +91,7 @@ public class Job implements C2KLocalObject
setStepName(act.getName());
setActProps(act.getProperties());
setStepType(act.getType());
- setAgentName(agent.getAgentName());
+ if (agent != null) setAgentName(agent.getAgentName());
setAgentRole(role);
}
@@ -121,15 +123,24 @@ public class Job implements C2KLocalObject
name = String.valueOf(id);
}
- public int getItemSysKey() {
- return itemSysKey;
+ public ItemPath getItemPath() {
+ return itemPath;
}
- public void setItemSysKey(int sysKey) {
- itemSysKey = sysKey;
+ public void setItemPath(ItemPath path) {
+ itemPath = path;
item = null;
}
+ public void setItemUUID( String uuid )
+ {
+ setItemPath(new ItemPath(UUID.fromString(uuid)));
+ }
+
+ public String getItemUUID() {
+ return getItemPath().getUUID().toString();
+ }
+
public String getStepName() {
return stepName;
}
@@ -162,14 +173,34 @@ public class Job implements C2KLocalObject
this.transition = transition;
}
- public int getAgentId() throws ObjectNotFoundException {
- if (agentId == -1)
- agentId = Gateway.getLookup().getAgentPath(getAgentName()).getSysKey();
- return agentId;
+ public AgentPath getAgentPath() throws ObjectNotFoundException {
+ if (agentPath == null && getAgentName() != null) {
+ agentPath = Gateway.getLookup().getAgentPath(getAgentName());
+ }
+ return agentPath;
}
- public void setAgentId(int id) {
- agentId = id;
+ public void setAgentPath(AgentPath agentPath) {
+ this.agentPath = agentPath;
+ agentName = agentPath.getAgentName();
+ }
+
+ public void setAgentUUID( String uuid )
+ {
+ if (uuid != null)
+ try {
+ setAgentPath(new AgentPath(UUID.fromString(uuid)));
+ } catch (InvalidAgentPathException e) {
+ Logger.error("Invalid agent path in Job: "+uuid);
+ }
+ }
+
+ public String getAgentUUID() {
+ try {
+ if (getAgentPath() != null)
+ return getAgentPath().getUUID().toString();
+ } catch (ObjectNotFoundException e) { }
+ return null;
}
public String getAgentName()
@@ -179,9 +210,10 @@ public class Job implements C2KLocalObject
return agentName;
}
- public void setAgentName(String agentName)
+ public void setAgentName(String agentName) throws ObjectNotFoundException
{
this.agentName = agentName;
+ agentPath = Gateway.getLookup().getAgentPath(agentName);
}
public String getAgentRole() {
@@ -254,7 +286,7 @@ public class Job implements C2KLocalObject
public ItemProxy getItemProxy() throws ObjectNotFoundException, InvalidItemPathException {
if (item == null)
- item = Gateway.getProxyManager().getProxy(new ItemPath(itemSysKey));
+ item = Gateway.getProxyManager().getProxy(itemPath);
return item;
}
@@ -294,7 +326,7 @@ public class Job implements C2KLocalObject
}
try {
- Viewpoint view = (Viewpoint) Gateway.getStorage().get(getItemSysKey(),
+ Viewpoint view = (Viewpoint) Gateway.getStorage().get(itemPath,
ClusterStorage.VIEWPOINT + "/" + schemaName + "/" + viewName, null);
return view.getOutcome().getData();
} catch (ObjectNotFoundException ex) { // viewpoint doesn't exist yet
@@ -302,7 +334,7 @@ public class Job implements C2KLocalObject
} catch (ClusterStorageException e) {
Logger.error(e);
throw new InvalidDataException("ViewpointOutcomeInitiator: ClusterStorageException loading viewpoint "
- + ClusterStorage.VIEWPOINT + "/" + schemaName + "/" + viewName+" in syskey "+getItemSysKey());
+ + ClusterStorage.VIEWPOINT + "/" + schemaName + "/" + viewName+" in item "+itemPath.getUUID());
}
}
else
@@ -375,7 +407,7 @@ public class Job implements C2KLocalObject
public boolean equals(Job job)
{
- return (getItemSysKey() == job.getItemSysKey()) && this.stepPath.equals(job.stepPath) && transition.getId() == job.getTransition().getId();
+ return (itemPath.equals(job.getItemPath()) && this.stepPath.equals(job.stepPath) && transition.getId() == job.getTransition().getId());
}
private void setActProps(CastorHashMap actProps) {
diff --git a/src/main/java/com/c2kernel/entity/agent/JobList.java b/src/main/java/com/c2kernel/entity/agent/JobList.java
index 271decb..ac3b421 100644
--- a/src/main/java/com/c2kernel/entity/agent/JobList.java
+++ b/src/main/java/com/c2kernel/entity/agent/JobList.java
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import java.util.Vector;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.persistency.RemoteMap;
import com.c2kernel.utils.Logger;
@@ -20,9 +21,9 @@ public class JobList extends RemoteMap<Job>
/**************************************************************************
* Empty constructor for Castor
**************************************************************************/
- public JobList(int sysKey, Object locker)
+ public JobList(ItemPath itemPath, Object locker)
{
- super(sysKey, ClusterStorage.JOB, locker);
+ super(itemPath, ClusterStorage.JOB, locker);
}
@@ -55,7 +56,7 @@ public class JobList extends RemoteMap<Job>
/**
* @param job
*/
- public void removeJobsWithSysKey( int sysKey )
+ public void removeJobsForItem( ItemPath itemPath )
{
Iterator<Job> currentMembers = values().iterator();
Job j = null;
@@ -64,14 +65,14 @@ public class JobList extends RemoteMap<Job>
{
j = currentMembers.next();
- if( j.getItemSysKey() == sysKey )
+ if( j.getItemPath().equals(itemPath) )
remove( String.valueOf(j.getId()) );
}
- Logger.msg(5, "JobList::removeJobsWithSysKey() - " + sysKey + " DONE." );
+ Logger.msg(5, "JobList::removeJobsWithSysKey() - " + itemPath + " DONE." );
}
- public void removeJobsForStep( int sysKey, String stepPath )
+ public void removeJobsForStep( ItemPath itemPath, String stepPath )
{
ArrayList<String> staleJobs = new ArrayList<String>();
Iterator<String> jobIter = keySet().iterator();
@@ -79,7 +80,7 @@ public class JobList extends RemoteMap<Job>
{
String jid = jobIter.next();
Job j = get(jid);
- if( j.getItemSysKey() == sysKey && j.getStepPath().equals(stepPath))
+ if( j.getItemPath().equals(itemPath) && j.getStepPath().equals(stepPath))
staleJobs.add(jid);
}
@@ -88,14 +89,14 @@ public class JobList extends RemoteMap<Job>
for (String jid : staleJobs) {
remove(jid);
}
- Logger.msg(5, "JobList::removeJobsForStep() - " + sysKey + " DONE." );
+ Logger.msg(5, "JobList::removeJobsForStep() - " + itemPath + " DONE." );
}
/**
* @param itemKey
* @param string
* @return
*/
- public Vector<Job> getJobsOfSysKey(int sysKey)
+ public Vector<Job> getJobsOfItem( ItemPath itemPath )
{
Iterator<Job> currentMembers = values().iterator();
Job j = null;
@@ -105,7 +106,7 @@ public class JobList extends RemoteMap<Job>
{
j = currentMembers.next();
- if( j.getItemSysKey() == sysKey )
+ if( j.getItemPath().equals(itemPath) )
jobs.add(j);
}
diff --git a/src/main/java/com/c2kernel/entity/imports/ImportAgent.java b/src/main/java/com/c2kernel/entity/imports/ImportAgent.java
index 2aa6533..ac9911e 100644
--- a/src/main/java/com/c2kernel/entity/imports/ImportAgent.java
+++ b/src/main/java/com/c2kernel/entity/imports/ImportAgent.java
@@ -1,6 +1,5 @@
package com.c2kernel.entity.imports;
-import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
import com.c2kernel.common.CannotManageException;
@@ -9,6 +8,7 @@ import com.c2kernel.common.ObjectCannotBeUpdated;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.entity.agent.ActiveEntity;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.lookup.RolePath;
import com.c2kernel.process.Gateway;
import com.c2kernel.process.module.ModuleImport;
@@ -18,10 +18,9 @@ import com.c2kernel.utils.Logger;
public class ImportAgent extends ModuleImport implements java.io.Serializable {
- public String password;
-
- public ArrayList<String> roles = new ArrayList<String>();
- public ArrayList<Property> properties = new ArrayList<Property>();
+ private String password;
+ private ArrayList<Property> properties = new ArrayList<Property>();
+ private ArrayList<String> roles = new ArrayList<String>();
public ImportAgent() {
}
@@ -31,17 +30,17 @@ public class ImportAgent extends ModuleImport implements java.io.Serializable {
this.password = password;
}
- public void create(int agentId) throws ObjectNotFoundException, ObjectCannotBeUpdated, NoSuchAlgorithmException, CannotManageException, ObjectAlreadyExistsException {
- AgentPath newAgent = Gateway.getNextKeyManager().generateNextAgentKey();
- newAgent.setAgentName(name);
+ @Override
+ public void create(AgentPath agentPath, boolean reset) throws ObjectNotFoundException, ObjectCannotBeUpdated, CannotManageException, ObjectAlreadyExistsException {
+ AgentPath newAgent = new AgentPath(getItemPath(), name);
newAgent.setPassword(password);
- ActiveEntity newAgentEnt = (ActiveEntity)Gateway.getCorbaServer().createEntity(newAgent);
+ ActiveEntity newAgentEnt = Gateway.getCorbaServer().createAgent(newAgent);
Gateway.getLookupManager().add(newAgent);
// assemble properties
properties.add(new com.c2kernel.property.Property("Name", name, true));
properties.add(new com.c2kernel.property.Property("Type", "Agent", false));
try {
- newAgentEnt.initialise(agentId, Gateway.getMarshaller().marshall(new PropertyArrayList(properties)), null, null);
+ newAgentEnt.initialise(agentPath.getSystemKey(), Gateway.getMarshaller().marshall(new PropertyArrayList(properties)), null, null);
} catch (Exception ex) {
Logger.error(ex);
throw new CannotManageException("Error initialising new agent");
@@ -57,4 +56,42 @@ public class ImportAgent extends ModuleImport implements java.io.Serializable {
}
}
+
+ @Override
+ public ItemPath getItemPath() {
+ if (itemPath == null) { // try to find agent if it already exists
+ try {
+ AgentPath existAgent = Gateway.getLookup().getAgentPath(name);
+ itemPath = existAgent;
+ } catch (ObjectNotFoundException ex) {
+ itemPath = new AgentPath(name);
+ }
+ }
+ return itemPath;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public ArrayList<String> getRoles() {
+ return roles;
+ }
+
+ public void setRoles(ArrayList<String> roles) {
+ this.roles = roles;
+ }
+
+ public ArrayList<Property> getProperties() {
+ return properties;
+ }
+
+ public void setProperties(ArrayList<Property> properties) {
+ this.properties = properties;
+ }
+
}
diff --git a/src/main/java/com/c2kernel/entity/imports/ImportAggregation.java b/src/main/java/com/c2kernel/entity/imports/ImportAggregation.java
index 1c75990..2f19452 100644
--- a/src/main/java/com/c2kernel/entity/imports/ImportAggregation.java
+++ b/src/main/java/com/c2kernel/entity/imports/ImportAggregation.java
@@ -1,11 +1,13 @@
package com.c2kernel.entity.imports;
import java.util.ArrayList;
+import java.util.UUID;
import com.c2kernel.collection.MembershipException;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.graph.model.GraphPoint;
import com.c2kernel.lookup.DomainPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.property.PropertyDescription;
import com.c2kernel.property.PropertyDescriptionList;
import com.c2kernel.property.PropertyUtility;
@@ -32,7 +34,13 @@ public class ImportAggregation implements java.io.Serializable {
for (ImportAggregationMember thisMem : aggregationMemberList) {
StringBuffer classProps = new StringBuffer();
if (thisMem.itemDescriptionPath != null && thisMem.itemDescriptionPath.length()>0) {
- PropertyDescriptionList propList = PropertyUtility.getPropertyDescriptionOutcome(new DomainPath(thisMem.itemDescriptionPath).getSysKey());
+ ItemPath itemPath;
+ try {
+ itemPath = new ItemPath(UUID.fromString(thisMem.itemDescriptionPath));
+ } catch (IllegalArgumentException ex) {
+ itemPath = new DomainPath(thisMem.itemDescriptionPath).getItemPath();
+ }
+ PropertyDescriptionList propList = PropertyUtility.getPropertyDescriptionOutcome(itemPath);
for (PropertyDescription pd : propList.list) {
thisMem.props.put(pd.getName(), pd.getDefaultValue());
if (pd.getIsClassIdentifier())
@@ -40,10 +48,15 @@ public class ImportAggregation implements java.io.Serializable {
}
}
if (thisMem.itemPath != null && thisMem.itemPath.length()>0) {
- int syskey = new DomainPath(thisMem.itemPath).getSysKey();
- if (syskey == -1)
+ ItemPath itemPath;
+ try {
+ itemPath = new ItemPath(UUID.fromString(thisMem.itemPath));
+ } catch (IllegalArgumentException ex) {
+ itemPath = new DomainPath(thisMem.itemPath).getItemPath();
+ }
+ if (itemPath == null)
throw new MembershipException("Cannot find "+thisMem.itemPath+" specified for collection.");
- newAgg.addMember(syskey, thisMem.props, classProps.toString(), new GraphPoint(thisMem.geometry.x, thisMem.geometry.y), thisMem.geometry.width, thisMem.geometry.height);
+ newAgg.addMember(itemPath, thisMem.props, classProps.toString(), new GraphPoint(thisMem.geometry.x, thisMem.geometry.y), thisMem.geometry.width, thisMem.geometry.height);
}
}
return newAgg;
diff --git a/src/main/java/com/c2kernel/entity/imports/ImportDependency.java b/src/main/java/com/c2kernel/entity/imports/ImportDependency.java
index e6ce909..a43f6e3 100644
--- a/src/main/java/com/c2kernel/entity/imports/ImportDependency.java
+++ b/src/main/java/com/c2kernel/entity/imports/ImportDependency.java
@@ -1,10 +1,12 @@
package com.c2kernel.entity.imports;
import java.util.ArrayList;
+import java.util.UUID;
import com.c2kernel.collection.MembershipException;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.lookup.DomainPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.property.PropertyDescription;
import com.c2kernel.property.PropertyDescriptionList;
import com.c2kernel.property.PropertyUtility;
@@ -42,7 +44,7 @@ public class ImportDependency implements java.io.Serializable {
public com.c2kernel.collection.Dependency create() throws MembershipException, ObjectNotFoundException {
com.c2kernel.collection.Dependency newDep = isDescription?new com.c2kernel.collection.DependencyDescription(name):new com.c2kernel.collection.Dependency(name);
if (itemDescriptionPath != null && itemDescriptionPath.length()>0) {
- PropertyDescriptionList propList = PropertyUtility.getPropertyDescriptionOutcome(new DomainPath(itemDescriptionPath).getSysKey());
+ PropertyDescriptionList propList = PropertyUtility.getPropertyDescriptionOutcome(new DomainPath(itemDescriptionPath).getItemPath());
StringBuffer classProps = new StringBuffer();
for (PropertyDescription pd : propList.list) {
props.put(pd.getName(), pd.getDefaultValue());
@@ -54,10 +56,16 @@ public class ImportDependency implements java.io.Serializable {
}
for (ImportDependencyMember thisMem : dependencyMemberList) {
- int syskey = new DomainPath(thisMem.itemPath).getSysKey();
- if (syskey == -1)
+ ItemPath itemPath;
+ try {
+ itemPath = new ItemPath(UUID.fromString(thisMem.itemPath));
+ } catch (IllegalArgumentException ex) {
+ itemPath = new DomainPath(thisMem.itemPath).getItemPath();
+ }
+
+ if (itemPath == null)
throw new MembershipException("Cannot find "+thisMem.itemPath+" specified for collection.");
- com.c2kernel.collection.DependencyMember newDepMem = newDep.addMember(syskey);
+ com.c2kernel.collection.DependencyMember newDepMem = newDep.addMember(itemPath);
newDepMem.getProperties().putAll(thisMem.props);
}
return newDep;
diff --git a/src/main/java/com/c2kernel/entity/imports/ImportItem.java b/src/main/java/com/c2kernel/entity/imports/ImportItem.java
index 3847fbf..c1562b2 100644
--- a/src/main/java/com/c2kernel/entity/imports/ImportItem.java
+++ b/src/main/java/com/c2kernel/entity/imports/ImportItem.java
@@ -18,6 +18,7 @@ import com.c2kernel.events.Event;
import com.c2kernel.events.History;
import com.c2kernel.lifecycle.CompositeActivityDef;
import com.c2kernel.lifecycle.instance.stateMachine.Transition;
+import com.c2kernel.lookup.AgentPath;
import com.c2kernel.lookup.DomainPath;
import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.ClusterStorage;
@@ -38,48 +39,64 @@ import com.c2kernel.utils.Logger;
public class ImportItem extends ModuleImport {
- public String initialPath;
- public String workflow;
- public Integer workflowVer;
- public ArrayList<Property> properties = new ArrayList<Property>();
- public ArrayList<ImportAggregation> aggregationList = new ArrayList<ImportAggregation>();
- public ArrayList<ImportDependency> dependencyList = new ArrayList<ImportDependency>();
- public ArrayList<ImportOutcome> outcomes = new ArrayList<ImportOutcome>();
- private String ns;
+ protected String initialPath;
+ protected String workflow;
+ protected Integer workflowVer;
+ protected ArrayList<Property> properties = new ArrayList<Property>();
+ protected ArrayList<ImportAggregation> aggregationList = new ArrayList<ImportAggregation>();
+ protected ArrayList<ImportDependency> dependencyList = new ArrayList<ImportDependency>();
+ protected ArrayList<ImportOutcome> outcomes = new ArrayList<ImportOutcome>();
public ImportItem() {
}
- public ImportItem(String name, String initialPath, String wf, int wfVer) {
+ public ImportItem(String ns, String name, String initialPath, ItemPath itemPath, String wf, int wfVer) {
this();
- this.name = name;
- this.initialPath = initialPath;
- this.workflow = wf;
- this.workflowVer = wfVer;
+ setNamespace(ns);
+ setName(name);
+ setInitialPath(initialPath);
+ setWorkflow(wf);
+ setWorkflowVer(wfVer);
+ }
+
+ @Override
+ public ItemPath getItemPath() {
+ if (itemPath == null) { // try to find item if it already exists
+ DomainPath existingItem = new DomainPath(initialPath+"/"+name);
+ if (existingItem.exists()) {
+ try {
+ itemPath = existingItem.getItemPath();
+ } catch (ObjectNotFoundException ex) { }
+ }
+ }
+ if (itemPath == null) itemPath = new ItemPath();
+ return itemPath;
}
+ @Override
public void setNamespace(String ns) {
- this.ns = ns;
+ super.setNamespace(ns);
if (initialPath == null) initialPath = "/desc/"+ns;
+ itemPath = null;
}
-
- public String getNamespace() {
- return ns;
+
+ @Override
+ public void setName(String name) {
+ super.setName(name);
+ itemPath = null;
}
- public void create(int agentId, boolean reset) throws ObjectCannotBeUpdated, ObjectNotFoundException, CannotManageException, ObjectAlreadyExistsException {
+ @Override
+ public void create(AgentPath agentPath, boolean reset) throws ObjectCannotBeUpdated, ObjectNotFoundException, CannotManageException, ObjectAlreadyExistsException {
DomainPath domPath = new DomainPath(new DomainPath(initialPath), name);
- ItemPath entPath; TraceableEntity newItem;
- if (domPath.exists()) {
- entPath = domPath.getEntity();
- newItem = Gateway.getCorbaServer().getItem(entPath.getSysKey());
+ TraceableEntity newItem;
+ if (getItemPath().exists()) {
+ newItem = Gateway.getCorbaServer().getItem(getItemPath());
}
else {
- // create item
- entPath = Gateway.getNextKeyManager().generateNextEntityKey();
- newItem = (TraceableEntity)Gateway.getCorbaServer().createEntity(entPath);
- Gateway.getLookupManager().add(entPath);
+ newItem = Gateway.getCorbaServer().createItem(getItemPath());
+ Gateway.getLookupManager().add(getItemPath());
}
// set the name property
@@ -124,7 +141,7 @@ public class ImportItem extends ModuleImport {
// (re)initialise the new item with properties, workflow and collections
try {
newItem.initialise(
- agentId,
+ agentPath.getSystemKey(),
Gateway.getMarshaller().marshall(new PropertyArrayList(properties)),
Gateway.getMarshaller().marshall(compact.instantiate()),
Gateway.getMarshaller().marshall(colls));
@@ -137,12 +154,12 @@ public class ImportItem extends ModuleImport {
// import outcomes
XMLUnit.setIgnoreWhitespace(true);
XMLUnit.setIgnoreComments(true);
- History hist = new History(entPath.getSysKey(), null);
+ History hist = new History(getItemPath(), null);
for (ImportOutcome thisOutcome : outcomes) {
com.c2kernel.persistency.outcome.Outcome newOutcome = new com.c2kernel.persistency.outcome.Outcome(-1, thisOutcome.getData(ns), thisOutcome.schema, thisOutcome.version);
Viewpoint impView;
try {
- impView = (Viewpoint)Gateway.getStorage().get(entPath.getSysKey(), ClusterStorage.VIEWPOINT+"/"+thisOutcome.schema+"/"+thisOutcome.viewname, null);
+ impView = (Viewpoint)Gateway.getStorage().get(getItemPath(), ClusterStorage.VIEWPOINT+"/"+thisOutcome.schema+"/"+thisOutcome.viewname, null);
Diff xmlDiff = new Diff(newOutcome.getDOM(), impView.getOutcome().getDOM());
if (xmlDiff.identical()) {
@@ -158,7 +175,7 @@ public class ImportItem extends ModuleImport {
}
} catch (ObjectNotFoundException ex) {
Logger.msg(3, "View "+thisOutcome.schema+"/"+thisOutcome.viewname+" not found in "+name+". Creating.");
- impView = new Viewpoint(entPath.getSysKey(), thisOutcome.schema, thisOutcome.viewname, thisOutcome.version, -1);
+ impView = new Viewpoint(getItemPath(), thisOutcome.schema, thisOutcome.viewname, thisOutcome.version, -1);
} catch (ClusterStorageException e) {
throw new ObjectCannotBeUpdated("Could not check data for view "+thisOutcome.schema+"/"+thisOutcome.viewname+" in "+name);
} catch (InvalidDataException e) {
@@ -167,12 +184,12 @@ public class ImportItem extends ModuleImport {
// write new view/outcome/event
Transition predefDone = new Transition(0, "Done", 0, 0);
- Event newEvent = hist.addEvent("system", "Admin", "Import", "Import", "Import", thisOutcome.schema, thisOutcome.version, "PredefinedStep", 0, predefDone, thisOutcome.viewname);
+ Event newEvent = hist.addEvent(agentPath, "Admin", "Import", "Import", "Import", thisOutcome.schema, thisOutcome.version, "PredefinedStep", 0, predefDone, thisOutcome.viewname);
newOutcome.setID(newEvent.getID());
impView.setEventId(newEvent.getID());
try {
- Gateway.getStorage().put(entPath.getSysKey(), newOutcome, null);
- Gateway.getStorage().put(entPath.getSysKey(), impView, null);
+ Gateway.getStorage().put(getItemPath(), newOutcome, null);
+ Gateway.getStorage().put(getItemPath(), impView, null);
} catch (ClusterStorageException e) {
throw new ObjectCannotBeUpdated("Could not store data for view "+thisOutcome.schema+"/"+thisOutcome.viewname+" in "+name);
}
@@ -180,8 +197,66 @@ public class ImportItem extends ModuleImport {
// register domain path (before collections in case of recursive collections)
if (!domPath.exists()) {
- domPath.setEntity(entPath);
+ domPath.setEntity(getItemPath());
Gateway.getLookupManager().add(domPath);
}
}
+
+ public String getInitialPath() {
+ return initialPath;
+ }
+
+ public void setInitialPath(String initialPath) {
+ this.initialPath = initialPath;
+ itemPath = null;
+ }
+
+ public String getWorkflow() {
+ return workflow;
+ }
+
+ public void setWorkflow(String workflow) {
+ this.workflow = workflow;
+ }
+
+ public Integer getWorkflowVer() {
+ return workflowVer;
+ }
+
+ public void setWorkflowVer(Integer workflowVer) {
+ this.workflowVer = workflowVer;
+ }
+
+ public ArrayList<Property> getProperties() {
+ return properties;
+ }
+
+ public void setProperties(ArrayList<Property> properties) {
+ this.properties = properties;
+ }
+
+ public ArrayList<ImportAggregation> getAggregationList() {
+ return aggregationList;
+ }
+
+ public void setAggregationList(ArrayList<ImportAggregation> aggregationList) {
+ this.aggregationList = aggregationList;
+ }
+
+ public ArrayList<ImportDependency> getDependencyList() {
+ return dependencyList;
+ }
+
+ public void setDependencyList(ArrayList<ImportDependency> dependencyList) {
+ this.dependencyList = dependencyList;
+ }
+
+ public ArrayList<ImportOutcome> getOutcomes() {
+ return outcomes;
+ }
+
+ public void setOutcomes(ArrayList<ImportOutcome> outcomes) {
+ this.outcomes = outcomes;
+ }
+
}
diff --git a/src/main/java/com/c2kernel/entity/imports/ImportRole.java b/src/main/java/com/c2kernel/entity/imports/ImportRole.java
index 5749b06..dc8f351 100644
--- a/src/main/java/com/c2kernel/entity/imports/ImportRole.java
+++ b/src/main/java/com/c2kernel/entity/imports/ImportRole.java
@@ -3,18 +3,28 @@ package com.c2kernel.entity.imports;
import com.c2kernel.common.CannotManageException;
import com.c2kernel.common.ObjectAlreadyExistsException;
import com.c2kernel.common.ObjectCannotBeUpdated;
+import com.c2kernel.lookup.AgentPath;
import com.c2kernel.process.Gateway;
import com.c2kernel.process.module.ModuleImport;
public class ImportRole extends ModuleImport {
- public boolean jobList;
+ private boolean jobList;
public ImportRole() {
}
- public void create(int agentId) throws ObjectAlreadyExistsException, ObjectCannotBeUpdated, CannotManageException {
+ @Override
+ public void create(AgentPath agentPath, boolean reset) throws ObjectAlreadyExistsException, ObjectCannotBeUpdated, CannotManageException {
Gateway.getLookupManager().createRole(name, jobList);
}
+ public boolean hasJobList() {
+ return jobList;
+ }
+
+ public void setJobList(boolean jobList) {
+ this.jobList = jobList;
+ }
+
}
diff --git a/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java b/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java
index 173f239..1f24229 100644
--- a/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java
+++ b/src/main/java/com/c2kernel/entity/proxy/AgentProxy.java
@@ -50,22 +50,18 @@ import com.c2kernel.utils.Logger;
public class AgentProxy extends ItemProxy
{
- AgentPath agentPath;
+ AgentPath mAgentPath;
+ String mAgentName;
Authenticator auth;
/**************************************************************************
* Creates an AgentProxy without cache and change notification
**************************************************************************/
protected AgentProxy( org.omg.CORBA.Object ior,
- int systemKey)
+ AgentPath agentPath)
throws ObjectNotFoundException
{
- super(ior, systemKey);
- try {
- agentPath = new AgentPath(systemKey);
- mPath = agentPath;
- } catch (InvalidItemPathException e) {
- throw new ObjectNotFoundException();
- }
+ super(ior, agentPath);
+ mAgentPath = agentPath;
}
public Authenticator getAuthObj() {
@@ -103,7 +99,7 @@ public class AgentProxy extends ItemProxy
{
OutcomeValidator validator = null;
Date startTime = new Date();
- Logger.msg(3, "AgentProxy - executing "+job.getStepPath()+" for "+agentPath.getAgentName());
+ Logger.msg(3, "AgentProxy - executing "+job.getStepPath()+" for "+mAgentPath.getAgentName());
// get the outcome validator if present
if (job.hasOutcome())
{
@@ -160,7 +156,7 @@ public class AgentProxy extends ItemProxy
throw new InvalidDataException(error, "");
}
- job.setAgentId(getSystemKey());
+ job.setAgentPath(mAgentPath);
Logger.msg(3, "AgentProxy - submitting job to item proxy");
String result = item.requestAction(job);
if (Logger.doLog(3)) {
@@ -199,12 +195,8 @@ public class AgentProxy extends ItemProxy
ObjectAlreadyExistsException,
ScriptErrorException
{
- try {
- ItemProxy targetItem = Gateway.getProxyManager().getProxy(new ItemPath(job.getItemSysKey()));
- return execute(targetItem, job);
- } catch (InvalidItemPathException e) {
- throw new ObjectNotFoundException("Job contained invalid item sysKey: "+job.getItemSysKey(), "");
- }
+ ItemProxy targetItem = Gateway.getProxyManager().getProxy(job.getItemPath());
+ return execute(targetItem, job);
}
public String execute(ItemProxy item, String predefStep, C2KLocalObject obj)
@@ -233,7 +225,7 @@ public class AgentProxy extends ItemProxy
PersistencyException,
ObjectAlreadyExistsException
{
- return item.getItem().requestAction(getSystemKey(), "workflow/predefined/"+predefStep, PredefinedStep.DONE, PredefinedStep.bundleData(params));
+ return item.getItem().requestAction(mAgentPath.getSystemKey(), "workflow/predefined/"+predefStep, PredefinedStep.DONE, PredefinedStep.bundleData(params));
}
/** Wrappers for scripts */
@@ -255,7 +247,7 @@ public class AgentProxy extends ItemProxy
while(results.hasNext()) {
Path nextMatch = results.next();
- if (returnPath != null && nextMatch.getSysKey() != -1 && returnPath.getSysKey() != nextMatch.getSysKey())
+ if (returnPath != null && nextMatch.getUUID() != null && !returnPath.getUUID().equals(nextMatch.getUUID()))
throw new ObjectNotFoundException("Too many items with that name");
returnPath = nextMatch;
}
@@ -269,14 +261,14 @@ public class AgentProxy extends ItemProxy
@Override
public AgentPath getPath() {
- return agentPath;
+ return mAgentPath;
}
public ItemProxy getItem(Path itemPath) throws ObjectNotFoundException {
return Gateway.getProxyManager().getProxy(itemPath);
}
- public ItemProxy getItemBySysKey(int sysKey) throws ObjectNotFoundException, InvalidItemPathException {
- return Gateway.getProxyManager().getProxy(new ItemPath(sysKey));
+ public ItemProxy getItemByUUID(String uuid) throws ObjectNotFoundException, InvalidItemPathException {
+ return Gateway.getProxyManager().getProxy(new ItemPath(uuid));
}
}
diff --git a/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java b/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java
index 454da6d..987873f 100644
--- a/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java
+++ b/src/main/java/com/c2kernel/entity/proxy/ItemProxy.java
@@ -34,9 +34,8 @@ import com.c2kernel.entity.agent.Job;
import com.c2kernel.entity.agent.JobArrayList;
import com.c2kernel.lifecycle.instance.CompositeActivity;
import com.c2kernel.lifecycle.instance.Workflow;
-import com.c2kernel.lookup.InvalidItemPathException;
+import com.c2kernel.lookup.AgentPath;
import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.lookup.Path;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.persistency.outcome.Viewpoint;
@@ -57,9 +56,8 @@ public class ItemProxy
{
protected Item mItem = null;
+ protected ItemPath mItemPath;
protected org.omg.CORBA.Object mIOR;
- protected int mSystemKey;
- protected Path mPath;
private final HashMap<MemberSubscription<?>, ProxyObserver<?>>
mSubscriptions;
@@ -67,29 +65,18 @@ public class ItemProxy
*
**************************************************************************/
protected ItemProxy( org.omg.CORBA.Object ior,
- int systemKey)
- throws ObjectNotFoundException
+ ItemPath itemPath)
{
- Logger.msg(8, "ItemProxy::initialise() - Initialising entity " +systemKey);
+ Logger.msg(8, "ItemProxy::initialise() - Initialising item proxy " +itemPath);
mIOR = ior;
- mSystemKey = systemKey;
+ mItemPath = itemPath;
mSubscriptions = new HashMap<MemberSubscription<?>, ProxyObserver<?>>();
- try {
- mPath = new ItemPath(systemKey);
- } catch (InvalidItemPathException e) {
- throw new ObjectNotFoundException();
- }
}
-
- public int getSystemKey()
- {
- return mSystemKey;
- }
- public Path getPath() {
- return mPath;
+ public ItemPath getPath() {
+ return mItemPath;
}
protected Item getItem() throws ObjectNotFoundException {
@@ -105,23 +92,13 @@ public class ItemProxy
} catch (org.omg.CORBA.BAD_PARAM ex) { }
throw new ObjectNotFoundException("CORBA Object was not an Item, or the server is down.");
}
- /**
- * @throws MappingException
- * @throws IOException
- * @throws ValidationException
- * @throws MarshalException ************************************************************************
- *
- *
- **************************************************************************/
- public void initialise( int agentId,
+
+ public void initialise( AgentPath agentId,
PropertyArrayList itemProps,
CompositeActivity workflow,
CollectionArrayList colls
)
- throws AccessRightsException,
- InvalidDataException,
- PersistencyException,
- ObjectNotFoundException, MarshalException, ValidationException, IOException, MappingException
+ throws AccessRightsException, InvalidDataException, PersistencyException, ObjectNotFoundException, MarshalException, ValidationException, IOException, MappingException
{
Logger.msg(7, "ItemProxy::initialise - started");
CastorXMLUtility xml = Gateway.getMarshaller();
@@ -132,7 +109,7 @@ public class ItemProxy
String collString = "";
if (colls != null) collString = xml.marshall(colls);
- getItem().initialise( agentId, propString, wfString, collString);
+ getItem().initialise( agentId.getSystemKey(), propString, wfString, collString);
}
public void setProperty(AgentProxy agent, String name, String value)
@@ -174,25 +151,25 @@ public class ItemProxy
else
outcome="";
- if (thisJob.getAgentId() == -1)
+ if (thisJob.getAgentPath() == null)
throw new InvalidDataException("No Agent specified.", "");
Logger.msg(7, "ItemProxy - executing "+thisJob.getStepPath()+" for "+thisJob.getAgentName());
- return getItem().requestAction (thisJob.getAgentId(), thisJob.getStepPath(),
+ return getItem().requestAction (thisJob.getAgentPath().getSystemKey(), thisJob.getStepPath(),
thisJob.getTransition().getId(), outcome);
}
/**************************************************************************
*
**************************************************************************/
- private ArrayList<Job> getJobList(int agentId, boolean filter)
+ private ArrayList<Job> getJobList(AgentPath agentPath, boolean filter)
throws AccessRightsException,
ObjectNotFoundException,
PersistencyException
{
JobArrayList thisJobList;
try {
- String jobs = getItem().queryLifeCycle(agentId, filter);
+ String jobs = getItem().queryLifeCycle(agentPath.getSystemKey(), filter);
thisJobList = (JobArrayList)Gateway.getMarshaller().unmarshall(jobs);
}
catch (Exception e) {
@@ -207,23 +184,15 @@ public class ItemProxy
ObjectNotFoundException,
PersistencyException
{
- return getJobList(agent.getSystemKey());
- }
-
- private ArrayList<Job> getJobList(int agentId)
- throws AccessRightsException,
- ObjectNotFoundException,
- PersistencyException
- {
- return getJobList(agentId, true);
+ return getJobList(agent.getPath(), true);
}
- private Job getJobByName(String actName, int agentId)
+ private Job getJobByName(String actName, AgentPath agent)
throws AccessRightsException,
ObjectNotFoundException,
PersistencyException {
- ArrayList<Job> jobList = getJobList(agentId);
+ ArrayList<Job> jobList = getJobList(agent, true);
for (Job job : jobList) {
if (job.getStepName().equals(actName) && job.hasOutcome())
return job;
@@ -248,7 +217,7 @@ public class ItemProxy
throws AccessRightsException,
ObjectNotFoundException,
PersistencyException {
- return getJobByName(actName, agent.getSystemKey());
+ return getJobByName(actName, agent.getPath());
}
/**
@@ -256,9 +225,9 @@ public class ItemProxy
*/
@Override
protected void finalize() throws Throwable {
- Logger.msg(7, "Proxy "+mSystemKey+" reaped");
- Gateway.getStorage().clearCache(mSystemKey, null);
- Gateway.getProxyManager().removeProxy(mSystemKey);
+ Logger.msg(7, "Proxy "+mItemPath+" reaped");
+ Gateway.getStorage().clearCache(mItemPath, null);
+ Gateway.getProxyManager().removeProxy(mItemPath);
super.finalize();
}
@@ -270,10 +239,10 @@ public class ItemProxy
{
try {
- Logger.msg(7, "EntityProxy.queryData() - "+mSystemKey+"/"+path);
+ Logger.msg(7, "EntityProxy.queryData() - "+mItemPath+"/"+path);
if (path.endsWith("all")) {
Logger.msg(7, "EntityProxy.queryData() - listing contents");
- String[] result = Gateway.getStorage().getClusterContents(mSystemKey, path.substring(0, path.length()-3));
+ String[] result = Gateway.getStorage().getClusterContents(mItemPath, path.substring(0, path.length()-3));
StringBuffer retString = new StringBuffer();
for (int i = 0; i < result.length; i++) {
retString.append(result[i]);
@@ -282,7 +251,7 @@ public class ItemProxy
Logger.msg(7, "EntityProxy.queryData() - "+retString.toString());
return retString.toString();
}
- C2KLocalObject target = Gateway.getStorage().get(mSystemKey, path, null);
+ C2KLocalObject target = Gateway.getStorage().get(mItemPath, path, null);
return Gateway.getMarshaller().marshall(target);
} catch (ObjectNotFoundException e) {
throw e;
@@ -294,7 +263,7 @@ public class ItemProxy
public String[] getContents( String path ) throws ObjectNotFoundException {
try {
- return Gateway.getStorage().getClusterContents(mSystemKey, path.substring(0, path.length()));
+ return Gateway.getStorage().getClusterContents(mItemPath, path.substring(0, path.length()));
} catch (ClusterStorageException e) {
throw new ObjectNotFoundException(e.toString());
}
@@ -310,11 +279,11 @@ public class ItemProxy
// load from storage, falling back to proxy loader if not found in others
try
{
- return Gateway.getStorage().get( mSystemKey, xpath , null);
+ return Gateway.getStorage().get( mItemPath, xpath , null);
}
catch( ClusterStorageException ex )
{
- Logger.msg(4, "Exception loading object :"+mSystemKey+"/"+xpath);
+ Logger.msg(4, "Exception loading object :"+mItemPath+"/"+xpath);
throw new ObjectNotFoundException( ex.toString() );
}
}
@@ -324,7 +293,7 @@ public class ItemProxy
public String getProperty( String name )
throws ObjectNotFoundException
{
- Logger.msg(5, "Get property "+name+" from syskey/"+mSystemKey);
+ Logger.msg(5, "Get property "+name+" from item "+mItemPath);
Property prop = (Property)getObject("Property/"+name);
try
{
@@ -377,7 +346,7 @@ public class ItemProxy
public void dumpSubscriptions(int logLevel) {
if (mSubscriptions.size() == 0) return;
- Logger.msg(logLevel, "Subscriptions to proxy "+mSystemKey+":");
+ Logger.msg(logLevel, "Subscriptions to proxy "+mItemPath+":");
synchronized(this) {
for (MemberSubscription<?> element : mSubscriptions.keySet()) {
ProxyObserver<?> obs = element.getObserver();
@@ -390,10 +359,10 @@ public class ItemProxy
}
public void notify(ProxyMessage message) {
- Logger.msg(4, "EntityProxy.notify() - Received change notification for "+message.getPath()+" on "+mSystemKey);
+ Logger.msg(4, "EntityProxy.notify() - Received change notification for "+message.getPath()+" on "+mItemPath);
synchronized (this){
if (Gateway.getProxyServer()== null || !message.getServer().equals(Gateway.getProxyServer().getServerName()))
- Gateway.getStorage().clearCache(mSystemKey, message.getPath());
+ Gateway.getStorage().clearCache(mItemPath, message.getPath());
for (Iterator<MemberSubscription<?>> e = mSubscriptions.keySet().iterator(); e.hasNext();) {
MemberSubscription<?> newSub = e.next();
if (newSub.getObserver() == null) { // phantom
diff --git a/src/main/java/com/c2kernel/entity/proxy/MemberSubscription.java b/src/main/java/com/c2kernel/entity/proxy/MemberSubscription.java
index 01994e4..5fed443 100644
--- a/src/main/java/com/c2kernel/entity/proxy/MemberSubscription.java
+++ b/src/main/java/com/c2kernel/entity/proxy/MemberSubscription.java
@@ -27,7 +27,7 @@ public class MemberSubscription<C extends C2KLocalObject> implements Runnable {
@Override
public void run() {
- Thread.currentThread().setName("Member Subscription: "+subject.getSystemKey()+":"+interest);
+ Thread.currentThread().setName("Member Subscription: "+subject.getPath()+":"+interest);
if (preLoad) loadChildren();
}
diff --git a/src/main/java/com/c2kernel/entity/proxy/ProxyClientConnection.java b/src/main/java/com/c2kernel/entity/proxy/ProxyClientConnection.java
index 3a7e129..95104cf 100644
--- a/src/main/java/com/c2kernel/entity/proxy/ProxyClientConnection.java
+++ b/src/main/java/com/c2kernel/entity/proxy/ProxyClientConnection.java
@@ -11,6 +11,7 @@ import java.util.ArrayList;
import java.util.Iterator;
import com.c2kernel.common.InvalidDataException;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.process.Gateway;
import com.c2kernel.utils.Logger;
import com.c2kernel.utils.server.SocketHandler;
@@ -29,7 +30,7 @@ public class ProxyClientConnection implements SocketHandler {
Socket clientSocket = null;
static int clientId = -1;
int thisClientId;
- ArrayList<Integer> sysKeys;
+ ArrayList<ItemPath> subscribedItems;
PrintWriter response;
BufferedReader request;
boolean closing = false;
@@ -59,7 +60,7 @@ public class ProxyClientConnection implements SocketHandler {
newSocket.setSoTimeout(500);
clientSocket = newSocket;
response = new PrintWriter(clientSocket.getOutputStream(), true);
- sysKeys = new ArrayList<Integer>();
+ subscribedItems = new ArrayList<ItemPath>();
} catch (SocketException ex) {
Logger.msg("Could not set socket timeout:");
Logger.error(ex);
@@ -116,18 +117,18 @@ public class ProxyClientConnection implements SocketHandler {
// new subscription to entity changes
else if (message.getPath().equals(ProxyMessage.ADDPATH)) {
- Logger.msg(7, "ProxyClientConnection "+thisClientId+" subscribed to "+message.getSysKey());
- synchronized (sysKeys) {
- sysKeys.add(new Integer(message.getSysKey()));
+ Logger.msg(7, "ProxyClientConnection "+thisClientId+" subscribed to "+message.getItemPath());
+ synchronized (subscribedItems) {
+ subscribedItems.add(message.getItemPath());
}
}
// remove of subscription to entity changes
else if (message.getPath().equals(ProxyMessage.DELPATH)) {
- synchronized (sysKeys) {
- sysKeys.remove(new Integer(message.getSysKey()));
+ synchronized (subscribedItems) {
+ subscribedItems.remove(message.getItemPath());
}
- Logger.msg(7, "ProxyClientConnection "+thisClientId+" unsubscribed from "+message.getSysKey());
+ Logger.msg(7, "ProxyClientConnection "+thisClientId+" unsubscribed from "+message.getItemPath());
}
else // unknown message
@@ -137,11 +138,11 @@ public class ProxyClientConnection implements SocketHandler {
public synchronized void sendMessage(ProxyMessage message) {
if (clientSocket==null) return; // idle
- boolean relevant = message.getSysKey() == ProxyMessage.NA;
- synchronized (sysKeys) {
- for (Iterator<Integer> iter = sysKeys.iterator(); iter.hasNext() && !relevant;) {
- Integer thisKey = iter.next();
- if (thisKey.intValue() == message.getSysKey())
+ boolean relevant = message.getItemPath() == null;
+ synchronized (subscribedItems) {
+ for (Iterator<ItemPath> iter = subscribedItems.iterator(); iter.hasNext() && !relevant;) {
+ ItemPath thisKey = iter.next();
+ if (thisKey.equals(message.getItemPath()))
relevant = true;
}
}
@@ -175,8 +176,8 @@ public class ProxyClientConnection implements SocketHandler {
Logger.error("ProxyClientConnection "+thisClientId+" - Could not close socket.");
Logger.error(e);
}
- synchronized (sysKeys) {
- sysKeys = null;
+ synchronized (subscribedItems) {
+ subscribedItems = null;
}
clientSocket = null;
diff --git a/src/main/java/com/c2kernel/entity/proxy/ProxyManager.java b/src/main/java/com/c2kernel/entity/proxy/ProxyManager.java
index 6a35c88..d95c86e 100644
--- a/src/main/java/com/c2kernel/entity/proxy/ProxyManager.java
+++ b/src/main/java/com/c2kernel/entity/proxy/ProxyManager.java
@@ -19,6 +19,7 @@ import com.c2kernel.common.InvalidDataException;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.lookup.AgentPath;
import com.c2kernel.lookup.DomainPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.lookup.Path;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.process.Gateway;
@@ -29,7 +30,7 @@ import com.c2kernel.utils.SoftCache;
public class ProxyManager
{
- SoftCache<Integer, ItemProxy> proxyPool = new SoftCache<Integer, ItemProxy>(50);
+ SoftCache<ItemPath, ItemProxy> proxyPool = new SoftCache<ItemPath, ItemProxy>(50);
HashMap<DomainPathSubscriber, DomainPath> treeSubscribers = new HashMap<DomainPathSubscriber, DomainPath>();
HashMap<String, ProxyServerConnection> connections = new HashMap<String, ProxyServerConnection>();
@@ -42,17 +43,16 @@ public class ProxyManager
Iterator<Path> servers = Gateway.getLookup().search(new DomainPath("/servers"), new Property("Type", "Server", false));
while(servers.hasNext()) {
- Path thisServerPath = servers.next();
+ Path thisServerResult = servers.next();
try {
- Logger.msg(thisServerPath.dump());
- int syskey = thisServerPath.getSysKey();
- String remoteServer = ((Property)Gateway.getStorage().get(syskey, ClusterStorage.PROPERTY+"/Name", null)).getValue();
- String portStr = ((Property)Gateway.getStorage().get(syskey, ClusterStorage.PROPERTY+"/ProxyPort", null)).getValue();
+ ItemPath thisServerPath = thisServerResult.getItemPath();
+ String remoteServer = ((Property)Gateway.getStorage().get(thisServerPath, ClusterStorage.PROPERTY+"/Name", null)).getValue();
+ String portStr = ((Property)Gateway.getStorage().get(thisServerPath, ClusterStorage.PROPERTY+"/ProxyPort", null)).getValue();
int remotePort = Integer.parseInt(portStr);
connectToProxyServer(remoteServer, remotePort);
} catch (Exception ex) {
- Logger.error("Exception retrieving proxy server connection data for "+thisServerPath);
+ Logger.error("Exception retrieving proxy server connection data for "+thisServerResult);
Logger.error(ex);
}
}
@@ -68,8 +68,8 @@ public class ProxyManager
protected void resubscribe(ProxyServerConnection conn) {
synchronized (proxyPool) {
- for (Integer key : proxyPool.keySet()) {
- ProxyMessage sub = new ProxyMessage(key.intValue(), ProxyMessage.ADDPATH, false);
+ for (ItemPath key : proxyPool.keySet()) {
+ ProxyMessage sub = new ProxyMessage(key, ProxyMessage.ADDPATH, false);
Logger.msg(5, "Subscribing to item "+key);
conn.sendMessage(sub);
}
@@ -99,15 +99,14 @@ public class ProxyManager
if (thisMessage.getPath().equals(ProxyMessage.PINGPATH)) // ping response
return;
- if (thisMessage.getSysKey() == ProxyMessage.NA) // must be domain path info
+ if (thisMessage.getItemPath() == null) // must be domain path info
informTreeSubscribers(thisMessage.getState(), thisMessage.getPath());
else {
// proper proxy message
Logger.msg(5, "Received proxy message: "+thisMessage.toString());
- Integer key = new Integer(thisMessage.getSysKey());
- ItemProxy relevant = proxyPool.get(key);
+ ItemProxy relevant = proxyPool.get(thisMessage.getItemPath());
if (relevant == null)
- Logger.warning("Received proxy message for sysKey "+thisMessage.getSysKey()+" which we don't have a proxy for.");
+ Logger.warning("Received proxy message for sysKey "+thisMessage.getItemPath()+" which we don't have a proxy for.");
else
try {
relevant.notify(thisMessage);
@@ -156,35 +155,32 @@ public class ProxyManager
*
**************************************************************************/
private ItemProxy createProxy( org.omg.CORBA.Object ior,
- int systemKey,
- boolean isAgent )
+ ItemPath itemPath)
throws ObjectNotFoundException
{
ItemProxy newProxy = null;
- Logger.msg(5, "ProxyManager::creating proxy on Item " + systemKey);
+ Logger.msg(5, "ProxyManager::creating proxy on Item " + itemPath);
- if( isAgent )
- {
- newProxy = new AgentProxy(ior, systemKey);
+ if( itemPath instanceof AgentPath ) {
+ newProxy = new AgentProxy(ior, (AgentPath)itemPath);
}
- else
- {
- newProxy = new ItemProxy(ior, systemKey);
+ else {
+ newProxy = new ItemProxy(ior, itemPath);
}
// subscribe to changes from server
- ProxyMessage sub = new ProxyMessage(systemKey, ProxyMessage.ADDPATH, false);
+ ProxyMessage sub = new ProxyMessage(itemPath, ProxyMessage.ADDPATH, false);
sendMessage(sub);
reportCurrentProxies(9);
return ( newProxy );
}
- protected void removeProxy( int systemKey )
+ protected void removeProxy( ItemPath itemPath )
{
- ProxyMessage sub = new ProxyMessage(systemKey, ProxyMessage.DELPATH, true);
- Logger.msg(5,"ProxyManager.removeProxy() - Unsubscribing to proxy informer for "+systemKey);
+ ProxyMessage sub = new ProxyMessage(itemPath, ProxyMessage.DELPATH, true);
+ Logger.msg(5,"ProxyManager.removeProxy() - Unsubscribing to proxy informer for "+itemPath);
sendMessage(sub);
}
@@ -194,20 +190,18 @@ public class ProxyManager
* SystemKey
**************************************************************************/
private ItemProxy getProxy( org.omg.CORBA.Object ior,
- int systemKey,
- boolean isAgent )
+ ItemPath itemPath)
throws ObjectNotFoundException
{
- Integer key = new Integer(systemKey);
synchronized(proxyPool) {
ItemProxy newProxy;
// return it if it exists
- newProxy = proxyPool.get(key);
+ newProxy = proxyPool.get(itemPath);
if (newProxy == null) {
// create a new one
- newProxy = createProxy(ior, systemKey, isAgent );
- proxyPool.put(key, newProxy);
+ newProxy = createProxy(ior, itemPath);
+ proxyPool.put(itemPath, newProxy);
}
return newProxy;
@@ -222,13 +216,12 @@ public class ProxyManager
public ItemProxy getProxy( Path path )
throws ObjectNotFoundException
{
-
- //convert namePath to dn format
+ ItemPath itemPath;
+ if (path instanceof ItemPath) itemPath = (ItemPath)path;
+ else itemPath = path.getItemPath();
Logger.msg(8,"ProxyManager::getProxy(" + path.toString() + ")");
- boolean isAgent = (path.getEntity() instanceof AgentPath);
- return getProxy( Gateway.getLookup().resolve(path),
- path.getSysKey(),
- isAgent );
+ return getProxy( Gateway.getLookup().resolve(itemPath),
+ itemPath );
}
@@ -249,11 +242,11 @@ public class ProxyManager
Logger.msg(logLevel, "Current proxies: ");
try {
synchronized(proxyPool) {
- Iterator<Integer> i = proxyPool.keySet().iterator();
+ Iterator<ItemPath> i = proxyPool.keySet().iterator();
for( int count=0; i.hasNext(); count++ )
{
- Integer nextProxy = i.next();
+ ItemPath nextProxy = i.next();
ItemProxy thisProxy = proxyPool.get(nextProxy);
if (thisProxy != null)
Logger.msg(logLevel,
diff --git a/src/main/java/com/c2kernel/entity/proxy/ProxyMessage.java b/src/main/java/com/c2kernel/entity/proxy/ProxyMessage.java
index 62866eb..f90c976 100644
--- a/src/main/java/com/c2kernel/entity/proxy/ProxyMessage.java
+++ b/src/main/java/com/c2kernel/entity/proxy/ProxyMessage.java
@@ -2,9 +2,10 @@ package com.c2kernel.entity.proxy;
import java.io.IOException;
import java.net.DatagramPacket;
-import java.util.StringTokenizer;
import com.c2kernel.common.InvalidDataException;
+import com.c2kernel.lookup.InvalidItemPathException;
+import com.c2kernel.lookup.ItemPath;
/**************************************************************************
@@ -25,12 +26,11 @@ public class ProxyMessage {
public static final String PINGPATH = "ping";
public static final boolean ADDED = false;
public static final boolean DELETED = true;
- public static final int NA = -1;
- static ProxyMessage byeMessage = new ProxyMessage(NA, BYEPATH, ADDED);
- static ProxyMessage pingMessage = new ProxyMessage(NA, PINGPATH, ADDED);
+ static ProxyMessage byeMessage = new ProxyMessage(null, BYEPATH, ADDED);
+ static ProxyMessage pingMessage = new ProxyMessage(null, PINGPATH, ADDED);
- private int sysKey = NA;
+ private ItemPath itemPath = null;
private String path = "";
private String server = null;
private boolean state = ADDED;
@@ -38,9 +38,9 @@ public class ProxyMessage {
public ProxyMessage() {
super();
}
- public ProxyMessage(int sysKey, String path, boolean state) {
+ public ProxyMessage(ItemPath itemPath, String path, boolean state) {
this();
- setSysKey(sysKey);
+ setItemPath(itemPath);
setPath(path);
setState(state);
}
@@ -48,11 +48,17 @@ public class ProxyMessage {
public ProxyMessage(String line) throws InvalidDataException, IOException {
if (line == null)
throw new IOException("Null proxy message");
- StringTokenizer tok = new StringTokenizer(line,":");
- if (tok.countTokens()!=2)
+ String[] tok = line.split(":");
+ if (tok.length != 2)
throw new InvalidDataException("String '"+line+"' does not constitute a valid proxy message.", "");
- sysKey = Integer.parseInt(tok.nextToken());
- path = tok.nextToken();
+ if (tok[0].length() > 0 && !tok[0].equals("tree")) {
+ try {
+ itemPath = new ItemPath(tok[0]);
+ } catch (InvalidItemPathException e) {
+ throw new InvalidDataException("Item in proxy message "+line+" was not valid");
+ }
+ }
+ path = tok[1];
if (path.startsWith("-")) {
state = DELETED;
path = path.substring(1);
@@ -63,12 +69,12 @@ public class ProxyMessage {
this(new String(packet.getData()));
}
- public int getSysKey() {
- return sysKey;
+ public ItemPath getItemPath() {
+ return itemPath;
}
- public void setSysKey(int sysKey) {
- this.sysKey = sysKey;
+ public void setItemPath(ItemPath itemPath) {
+ this.itemPath = itemPath;
}
public String getPath() {
@@ -89,7 +95,7 @@ public class ProxyMessage {
@Override
public String toString() {
- return sysKey+":"+(state?"-":"")+path;
+ return (itemPath==null?"tree":itemPath.getUUID())+":"+(state?"-":"")+path;
}
public String getServer() {
diff --git a/src/main/java/com/c2kernel/entity/transfer/TransferItem.java b/src/main/java/com/c2kernel/entity/transfer/TransferItem.java
index 9852555..bcbbe65 100644
--- a/src/main/java/com/c2kernel/entity/transfer/TransferItem.java
+++ b/src/main/java/com/c2kernel/entity/transfer/TransferItem.java
@@ -3,11 +3,15 @@ package com.c2kernel.entity.transfer;
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.UUID;
+import com.c2kernel.collection.Collection;
+import com.c2kernel.collection.CollectionArrayList;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.entity.C2KLocalObject;
import com.c2kernel.entity.TraceableEntity;
import com.c2kernel.lifecycle.instance.Workflow;
+import com.c2kernel.lookup.AgentPath;
import com.c2kernel.lookup.DomainPath;
import com.c2kernel.lookup.ItemPath;
import com.c2kernel.lookup.Path;
@@ -20,33 +24,49 @@ import com.c2kernel.utils.FileStringUtility;
import com.c2kernel.utils.Logger;
public class TransferItem {
- public ArrayList<String> domainPaths;
- public int sysKey;
- static int importAgentId;
+ private ArrayList<String> domainPaths;
+ protected ItemPath itemPath;
+ static AgentPath importAgentId;
public TransferItem() throws Exception {
try {
- importAgentId = Gateway.getLookup().getAgentPath("system").getSysKey();
+ importAgentId = Gateway.getLookup().getAgentPath("system");
} catch (ObjectNotFoundException e) {
Logger.error("TransferItem - System user not found!");
throw e;
}
}
- public TransferItem(int sysKey) throws Exception {
- this.sysKey = sysKey;
+ public TransferItem(ItemPath itemPath) throws Exception {
+ this.itemPath = itemPath;
domainPaths = new ArrayList<String>();
- Property name = (Property)Gateway.getStorage().get(sysKey, ClusterStorage.PROPERTY + "/Name", null);
- Iterator<Path> paths = Gateway.getLookup().search(new DomainPath(), name.getValue());
+ Iterator<Path> paths = Gateway.getLookup().searchAliases(itemPath);
while (paths.hasNext()) {
DomainPath thisPath = (DomainPath)paths.next();
domainPaths.add(thisPath.toString());
}
}
-
+
+ public ArrayList<String> getDomainPaths() {
+ return domainPaths;
+ }
+
+ public void setDomainPaths(ArrayList<String> domainPaths) {
+ this.domainPaths = domainPaths;
+ }
+
+ public void setUUID( String uuid )
+ {
+ itemPath = new ItemPath(UUID.fromString(uuid));
+ }
+
+ public String getUUID() {
+ return itemPath.getUUID().toString();
+ }
+
public void exportItem(File dir, String path) throws Exception {
- Logger.msg("Path " + path + " in " + sysKey);
- String[] contents = Gateway.getStorage().getClusterContents(sysKey, path);
+ Logger.msg("Path " + path + " in " + itemPath);
+ String[] contents = Gateway.getStorage().getClusterContents(itemPath, path);
if (contents.length > 0) {
FileStringUtility.createNewDir(dir.getCanonicalPath());
for (String content : contents) {
@@ -54,8 +74,8 @@ public class TransferItem {
}
} else { //no children, try to dump object
try {
- C2KLocalObject obj = Gateway.getStorage().get(sysKey, path, null);
- Logger.msg("Dumping object " + path + " in " + sysKey);
+ C2KLocalObject obj = Gateway.getStorage().get(itemPath, path, null);
+ Logger.msg("Dumping object " + path + " in " + itemPath);
File dumpPath = new File(dir.getCanonicalPath() + ".xml");
FileStringUtility.string2File(dumpPath, Gateway.getMarshaller().marshall(obj));
return;
@@ -67,8 +87,8 @@ public class TransferItem {
public void importItem(File dir) throws Exception {
// check if already exists
try {
- Property name = (Property)Gateway.getStorage().get(sysKey, ClusterStorage.PROPERTY + "/Name", null);
- throw new Exception("Syskey " + sysKey + " already in use as " + name.getValue());
+ Property name = (Property)Gateway.getStorage().get(itemPath, ClusterStorage.PROPERTY + "/Name", null);
+ throw new Exception("Entity " + itemPath + " already in use as " + name.getValue());
} catch (Exception ex) {
}
@@ -89,38 +109,40 @@ public class TransferItem {
}
// create item
- ItemPath entityPath = new ItemPath(sysKey);
- TraceableEntity newItem = (TraceableEntity)Gateway.getCorbaServer().createEntity(entityPath);
- Gateway.getLookupManager().add(entityPath);
+ TraceableEntity newItem = Gateway.getCorbaServer().createItem(itemPath);
+ Gateway.getLookupManager().add(itemPath);
PropertyArrayList props = new PropertyArrayList();
+ CollectionArrayList colls = new CollectionArrayList();
Workflow wf = null;
// put objects
for (C2KLocalObject obj : objects) {
if (obj instanceof Property)
props.list.add((Property)obj);
+ else if (obj instanceof Collection)
+ colls.list.add((Collection<?>)obj);
else if (obj instanceof Workflow)
wf = (Workflow)obj;
}
if (wf == null)
- throw new Exception("No workflow found in import for "+sysKey);
+ throw new Exception("No workflow found in import for "+itemPath);
// init item
- newItem.initialise(importAgentId,
+ newItem.initialise(importAgentId.getSystemKey(),
Gateway.getMarshaller().marshall(props),
Gateway.getMarshaller().marshall(wf.search("workflow/domain")),
null);
// store objects
- importByType(ClusterStorage.COLLECTION, objects);
+ importByType(ClusterStorage.COLLECTION, objects); //TODO: move this to initialise
importByType(ClusterStorage.HISTORY, objects);
importByType(ClusterStorage.OUTCOME, objects);
importByType(ClusterStorage.VIEWPOINT, objects);
Gateway.getStorage().commit(this);
// add domPaths
for (String element : domainPaths) {
- DomainPath newPath = new DomainPath(element, entityPath);
+ DomainPath newPath = new DomainPath(element, itemPath);
Gateway.getLookupManager().add(newPath);
}
}
@@ -128,7 +150,7 @@ public class TransferItem {
private void importByType(String type, ArrayList<C2KLocalObject> objects) throws Exception {
for (C2KLocalObject element : objects) {
if (element.getClusterType().equals(type))
- Gateway.getStorage().put(sysKey, element, this);
+ Gateway.getStorage().put(itemPath, element, this);
}
}
diff --git a/src/main/java/com/c2kernel/entity/transfer/TransferSet.java b/src/main/java/com/c2kernel/entity/transfer/TransferSet.java
index 7a5833f..adc3d8c 100644
--- a/src/main/java/com/c2kernel/entity/transfer/TransferSet.java
+++ b/src/main/java/com/c2kernel/entity/transfer/TransferSet.java
@@ -4,7 +4,6 @@ import java.io.File;
import java.util.ArrayList;
import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.persistency.NextKeyManager;
import com.c2kernel.process.Gateway;
import com.c2kernel.utils.FileStringUtility;
import com.c2kernel.utils.Logger;
@@ -25,13 +24,13 @@ public class TransferSet {
public TransferSet() {
}
- public TransferSet(int[] sysKeys) {
+ public TransferSet(ItemPath[] itemPaths) {
items = new ArrayList<TransferItem>();
- for (int sysKey : sysKeys) {
+ for (ItemPath item : itemPaths) {
try {
- items.add(new TransferItem(sysKey));
+ items.add(new TransferItem(item));
} catch (Exception ex) {
- Logger.error("Could not add item "+sysKey);
+ Logger.error("Could not add item "+item);
Logger.error(ex);
}
}
@@ -43,9 +42,9 @@ public class TransferSet {
FileStringUtility.createNewDir(dir.getAbsolutePath());
for (TransferItem element : items) {
try {
- element.exportItem(new File(dir, String.valueOf(element.sysKey)), "/");
+ element.exportItem(new File(dir, element.itemPath.getUUID().toString()), "/");
} catch (Exception ex) {
- Logger.error("Error dumping item "+element.sysKey);
+ Logger.error("Error dumping item "+element.itemPath);
Logger.error(ex);
}
}
@@ -61,42 +60,14 @@ public class TransferSet {
public void importPackage(File rootDir) {
for (TransferItem element : items) {
- Logger.msg(5, "Importing "+element.sysKey);
+ Logger.msg(5, "Importing "+element.itemPath);
try {
- element.importItem(new File(rootDir, String.valueOf(element.sysKey)));
+ element.importItem(new File(rootDir, element.itemPath.getUUID().toString()));
} catch (Exception ex) {
- Logger.error("Import of item "+element.sysKey+" failed. Rolling back");
+ Logger.error("Import of item "+element.itemPath+" failed. Rolling back");
Logger.error(ex);
Gateway.getStorage().abort(element);
}
}
- checkLastKey();
- }
-
- private void checkLastKey()
- {
- // find highest key in out import set
- int packageLastKey = 0;
- for (TransferItem element : items) {
- if (element.sysKey > packageLastKey)
- packageLastKey = element.sysKey;
- }
-
- try
- { // find the current last key
- NextKeyManager nextKeyMan = Gateway.getNextKeyManager();
- ItemPath lastKey = nextKeyMan.getLastEntityPath();
- Logger.msg(1, "Last key imported was "+packageLastKey+". LDAP lastkey was "+lastKey.getSysKey());
-
-
- if (packageLastKey > lastKey.getSysKey()) { // set new last
- Logger.msg(1, "Updating lastKey to "+packageLastKey);
- nextKeyMan.writeLastEntityKey(packageLastKey);
- }
- }
- catch (Exception ex)
- {
- Logger.error("Exception::LoadKeys::processFile() " + ex);
- }
}
}