diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2014-09-09 12:13:21 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2014-09-09 12:13:21 +0200 |
| commit | da731d2bb81666b9c697d9099da632e7dfcdc0f7 (patch) | |
| tree | 567693c3c48f3d15ecbb2dac4f9db03bb6e58c72 /src/main | |
| parent | ae1e79e33fd30e3d8bcedbef8891a14a048276d7 (diff) | |
Replaced int sysKey Item identifier with UUID, which is now portable.
ItemPath objects are now used to identify Items throughout the kernel,
replacing ints and Integers.
Diffstat (limited to 'src/main')
109 files changed, 1897 insertions, 1598 deletions
diff --git a/src/main/idl/CommonTypes.idl b/src/main/idl/CommonTypes.idl index 93395eb..09b0767 100644 --- a/src/main/idl/CommonTypes.idl +++ b/src/main/idl/CommonTypes.idl @@ -34,7 +34,17 @@ module common long mSecond;
long mTimeOffset; //in seconds
};
-
+
+ /**************************************************************************
+ * Serialized UUID for Item identification
+ *
+ * @version 1.0
+ **************************************************************************/
+ struct SystemKey
+ {
+ unsigned long long msb;
+ unsigned long long lsb;
+ };
}; //end of module common
diff --git a/src/main/idl/Entity.idl b/src/main/idl/Entity.idl index 51884a3..24e5d9c 100644 --- a/src/main/idl/Entity.idl +++ b/src/main/idl/Entity.idl @@ -27,7 +27,7 @@ module entity /**
* System generated unique key of the Entity. It is unique in the domain tree of the local centre in which is is contained.
**/
- unsigned long getSystemKey();
+ common::SystemKey getSystemKey();
/** Initialises a new Item. Initial properties and the lifecycle are supplied. They should come from the Item's description.
*
@@ -38,7 +38,7 @@ module entity * @param collection The XML marshalled CollectionArrayList of the initial state of the Item's collections
* @exception ObjectNotFoundException
**/
- void initialise( in unsigned long agentId,
+ void initialise( in common::SystemKey agentId,
in string itemProps,
in string workflow,
in string collections )
@@ -101,7 +101,7 @@ module entity * @throws PersistencyException There was a problem committing the changes to storage.
* @throws ObjectAlreadyExistsException Not normally thrown, but reserved for PredefinedSteps to throw if they need to.
**/
- string requestAction( in unsigned long agentID,
+ string requestAction( in common::SystemKey agentID,
in string stepPath,
in unsigned long transitionID,
in string requestData
@@ -126,7 +126,7 @@ module entity * @throws ObjectNotFoundException - when the Item doesn't have a lifecycle
* @throws PersistencyException - when there was a storage or other unknown error
**/
- string queryLifeCycle( in unsigned long agentId,
+ string queryLifeCycle( in common::SystemKey agentId,
in boolean filter )
raises( common::AccessRightsException,
common::ObjectNotFoundException,
@@ -149,7 +149,9 @@ module entity * @param stepPath the activity within the lifecycle of the item which the jobs relate to
* @param newJobs an XML marshalled {@link com.c2kernel.entity.agent.JobArrayList JobArrayList} containing the new Jobs
**/
- void refreshJobList( in unsigned long sysKey, in string stepPath, in string newJobs );
+ void refreshJobList( in common::SystemKey sysKey,
+ in string stepPath,
+ in string newJobs );
/** Add this Agent to the given role
* @param roleName the new role to add
diff --git a/src/main/java/com/c2kernel/collection/Aggregation.java b/src/main/java/com/c2kernel/collection/Aggregation.java index f2ef710..2f01936 100644 --- a/src/main/java/com/c2kernel/collection/Aggregation.java +++ b/src/main/java/com/c2kernel/collection/Aggregation.java @@ -7,7 +7,6 @@ import com.c2kernel.graph.model.GraphModel; import com.c2kernel.graph.model.GraphPoint;
import com.c2kernel.graph.model.TypeNameAndConstructionInfo;
import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.lookup.InvalidItemPathException;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.process.Gateway;
import com.c2kernel.utils.CastorHashMap;
@@ -50,12 +49,12 @@ abstract public class Aggregation extends Parent2ChildCollection<AggregationMemb return mVertexTypeNameAndConstructionInfo;
}
- public boolean exists(int sysKey)
+ public boolean exists(ItemPath itemPath)
{
for (int i=0; i<size(); i++)
{
AggregationMember element = mMembers.list.get(i);
- if (element.getSystemKey() == sysKey)
+ if (element.getItemPath().equals(itemPath))
return true;
}
return false;
@@ -73,46 +72,47 @@ abstract public class Aggregation extends Parent2ChildCollection<AggregationMemb }
public AggregationMember addSlot(CastorHashMap props, String classProps, GraphPoint location, int w, int h)
- {
-
- // Default geometry if not present
- if (location == null) location = new GraphPoint(100,100*getCounter());
- if (w<0) w = 20;
- if (h<0) h = 20;
-
- // Create new member object
- AggregationMember aggMem = new AggregationMember();
- aggMem.setProperties(props);
- aggMem.setClassProps(classProps);
- // create vertex
- com.c2kernel.graph.model.Vertex vertex = new com.c2kernel.graph.model.Vertex();
- vertex.setHeight(h); vertex.setWidth(w);
- mLayout.addVertexAndCreateId(vertex,location);
- aggMem.setCollection(this);
- aggMem.setID(vertex.getID());
- aggMem.setIsLayoutable(true);
-
- mMembers.list.add(aggMem);
- Logger.msg(8, "AggregationDescription::addSlot new slot linked to vertexid " + vertex.getID());
- return aggMem;
- }
- public AggregationMember addMember(int sysKey, CastorHashMap props, String classProps, GraphPoint location, int w, int h)
+ {
+
+ // Default geometry if not present
+ if (location == null) location = new GraphPoint(100,100*getCounter());
+ if (w<0) w = 20;
+ if (h<0) h = 20;
+
+ // Create new member object
+ AggregationMember aggMem = new AggregationMember();
+ aggMem.setProperties(props);
+ aggMem.setClassProps(classProps);
+ // create vertex
+ com.c2kernel.graph.model.Vertex vertex = new com.c2kernel.graph.model.Vertex();
+ vertex.setHeight(h); vertex.setWidth(w);
+ mLayout.addVertexAndCreateId(vertex,location);
+ aggMem.setCollection(this);
+ aggMem.setID(vertex.getID());
+ aggMem.setIsLayoutable(true);
+
+ mMembers.list.add(aggMem);
+ Logger.msg(8, "AggregationDescription::addSlot new slot linked to vertexid " + vertex.getID());
+ return aggMem;
+ }
+
+ public AggregationMember addMember(ItemPath itemPath, CastorHashMap props, String classProps, GraphPoint location, int w, int h)
throws MembershipException
{
AggregationMember aggMem = addSlot(props, classProps, location, w, h);
- if (sysKey > -1) { // some clients use this method when not setting a member
- aggMem.assignItem(sysKey);
- aggMem.setIsComposite( getIsComposite(sysKey, getName()) );
+ if (itemPath != null) { // some clients use this method when not setting a member
+ aggMem.assignItem(itemPath);
+ aggMem.setIsComposite( getIsComposite(itemPath, getName()) );
}
- Logger.msg(8, "AggregationDescription::addMember(" + sysKey + ") assigned to new slot " + aggMem.getID());
+ Logger.msg(8, "AggregationDescription::addMember(" + itemPath + ") assigned to new slot " + aggMem.getID());
return aggMem;
}
@Override
- public AggregationMember addMember(int entityKey, CastorHashMap props, String classProps) throws MembershipException
+ public AggregationMember addMember(ItemPath itemPath, CastorHashMap props, String classProps) throws MembershipException
{
- return addMember(entityKey, props, classProps, null, -1, -1);
+ return addMember(itemPath, props, classProps, null, -1, -1);
}
public AggregationMember addSlot(CastorHashMap props, String classProps)
@@ -121,7 +121,7 @@ abstract public class Aggregation extends Parent2ChildCollection<AggregationMemb }
@Override
- public AggregationMember addMember(int entityKey) throws MembershipException {
+ public AggregationMember addMember(ItemPath itemPath) throws MembershipException {
throw new MembershipException("Aggregations cannot accept arbitrary members without type info");
}
@@ -138,16 +138,14 @@ abstract public class Aggregation extends Parent2ChildCollection<AggregationMemb throw new MembershipException("Member "+memberId+" not found");
}
- static public boolean getIsComposite(int entityKey, String name)
+ static public boolean getIsComposite(ItemPath itemPath, String name)
{
- if (entityKey == -1) return false;
+ if (itemPath == null) return false;
try {
- for(String collName: Gateway.getProxyManager().getProxy(new ItemPath(entityKey)).getContents(ClusterStorage.COLLECTION) )
+ for(String collName: Gateway.getProxyManager().getProxy(itemPath).getContents(ClusterStorage.COLLECTION) )
if (name == null || name.equals(collName)) return true;
} catch (ObjectNotFoundException e) {
return false;
- } catch (InvalidItemPathException e) {
- return false;
}
return false;
}
diff --git a/src/main/java/com/c2kernel/collection/AggregationDescription.java b/src/main/java/com/c2kernel/collection/AggregationDescription.java index 0587491..475ef53 100644 --- a/src/main/java/com/c2kernel/collection/AggregationDescription.java +++ b/src/main/java/com/c2kernel/collection/AggregationDescription.java @@ -35,20 +35,20 @@ public class AggregationDescription extends Aggregation implements CollectionDes {
AggregationMember mem = mMembers.list.get(i);
//get the propdesc of the member item
- PropertyDescriptionList pdList = PropertyUtility.getPropertyDescriptionOutcome(mem.getSystemKey());
+ PropertyDescriptionList pdList = PropertyUtility.getPropertyDescriptionOutcome(mem.getItemPath());
if (pdList!=null)
{
//create the new props of the member object
try {
Vertex v = getLayout().getVertexById(mem.getID());
- newInstance.addMember(-1, PropertyUtility.createProperty(pdList), pdList.getClassProps(),v.getCentrePoint(),v.getWidth(),v.getHeight());
+ newInstance.addMember(null, PropertyUtility.createProperty(pdList), pdList.getClassProps(),v.getCentrePoint(),v.getWidth(),v.getHeight());
} catch (MembershipException e) {
// won't happen as we're not assigning an entity
}
}
else
{
- Logger.error("AggregationDescription::newInstance() There is no PropertyDescription. Cannot instantiate. " + mem.getSystemKey());
+ Logger.error("AggregationDescription::newInstance() There is no PropertyDescription. Cannot instantiate. " + mem.getItemPath());
return null;
}
diff --git a/src/main/java/com/c2kernel/collection/AggregationInstance.java b/src/main/java/com/c2kernel/collection/AggregationInstance.java index 47e7c41..f46b691 100644 --- a/src/main/java/com/c2kernel/collection/AggregationInstance.java +++ b/src/main/java/com/c2kernel/collection/AggregationInstance.java @@ -6,6 +6,7 @@ package com.c2kernel.collection; */
import com.c2kernel.graph.model.GraphPoint;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.utils.CastorHashMap;
public class AggregationInstance extends Aggregation
@@ -23,23 +24,23 @@ public class AggregationInstance extends Aggregation @Override
- public AggregationMember addMember(int entityKey, CastorHashMap props, String classProps)
+ public AggregationMember addMember(ItemPath itemPath, CastorHashMap props, String classProps)
throws MembershipException
{
- if( entityKey!=-1 && exists(entityKey))
- throw new MembershipException(entityKey+" already exists in this collection.");
+ if( itemPath != null && exists(itemPath))
+ throw new MembershipException(itemPath+" already exists in this collection.");
else
- return super.addMember(entityKey, props, classProps);
+ return super.addMember(itemPath, props, classProps);
}
@Override
- public AggregationMember addMember(int entityKey, CastorHashMap props, String classProps, GraphPoint location, int w, int h)
+ public AggregationMember addMember(ItemPath itemPath, CastorHashMap props, String classProps, GraphPoint location, int w, int h)
throws MembershipException
{
- if( entityKey!=-1 && exists(entityKey))
- throw new MembershipException(entityKey+" already exists in this collection.");
+ if( itemPath != null && exists(itemPath))
+ throw new MembershipException(itemPath+" already exists in this collection.");
else
- return super.addMember(entityKey, props, classProps, location, w, h);
+ return super.addMember(itemPath, props, classProps, location, w, h);
}
}
diff --git a/src/main/java/com/c2kernel/collection/AggregationMember.java b/src/main/java/com/c2kernel/collection/AggregationMember.java index 67e92ad..cb8c355 100644 --- a/src/main/java/com/c2kernel/collection/AggregationMember.java +++ b/src/main/java/com/c2kernel/collection/AggregationMember.java @@ -1,12 +1,12 @@ package com.c2kernel.collection;
import java.util.StringTokenizer;
+import java.util.UUID;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.entity.proxy.ItemProxy;
import com.c2kernel.graph.model.GraphableVertex;
import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.lookup.InvalidItemPathException;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.process.Gateway;
import com.c2kernel.property.Property;
@@ -24,11 +24,11 @@ import com.c2kernel.utils.Logger; public class AggregationMember extends GraphableVertex implements CollectionMember
{
- private int mSystemKey = -1;
- private ItemProxy mItem = null;
- private Aggregation mCollection = null;
+ private ItemPath mItemPath = null;
+ private ItemProxy mItem = null;
+ private Aggregation mCollection = null;
private String mClassProps = null;
- String ItemName;
+ private String mItemName = null;
/**************************************************************************
@@ -37,14 +37,12 @@ public class AggregationMember extends GraphableVertex implements CollectionMemb public AggregationMember()
{
super();
- mSystemKey = -1;
- mCollection = null;
}
@Override
- public void setSystemKey(int sysKey) {
- mSystemKey = sysKey;
- ItemName = null;
+ public void setItemPath(ItemPath itemPath) {
+ mItemPath = itemPath;
+ mItemName = null;
}
public void setCollection(Aggregation aggregation)
@@ -59,9 +57,9 @@ public class AggregationMember extends GraphableVertex implements CollectionMemb }
@Override
- public int getSystemKey()
+ public ItemPath getItemPath()
{
- return mSystemKey;
+ return mItemPath;
}
public Aggregation getCollection()
@@ -76,9 +74,9 @@ public class AggregationMember extends GraphableVertex implements CollectionMemb }
@Override
- public void assignItem(int sysKey) throws MembershipException
+ public void assignItem(ItemPath itemPath) throws MembershipException
{
- if (sysKey > -1) {
+ if (itemPath != null) {
if (mClassProps == null || getProperties() == null)
throw new MembershipException("ClassProps not yet set. Cannot check membership validity.");
@@ -89,9 +87,9 @@ public class AggregationMember extends GraphableVertex implements CollectionMemb String aClassProp = sub.nextToken();
try {
String memberValue = (String)getProperties().get(aClassProp);
- Property ItemProperty = (Property)Gateway.getStorage().get(sysKey, ClusterStorage.PROPERTY+"/"+aClassProp, null);
+ Property ItemProperty = (Property)Gateway.getStorage().get(itemPath, ClusterStorage.PROPERTY+"/"+aClassProp, null);
if (ItemProperty == null)
- throw new MembershipException("Property "+aClassProp+ " does not exist for sysKey=" + sysKey );
+ throw new MembershipException("Property "+aClassProp+ " does not exist for item " + itemPath );
if (ItemProperty.getValue() == null || !ItemProperty.getValue().equalsIgnoreCase(memberValue))
throw new MembershipException("Value of mandatory prop "+aClassProp+" does not match: " + ItemProperty.getValue()+"!="+memberValue);
}
@@ -106,46 +104,54 @@ public class AggregationMember extends GraphableVertex implements CollectionMemb }
}
- mSystemKey = sysKey;
+ mItemPath = itemPath;
mItem = null;
- ItemName = null;
+ mItemName = null;
}
@Override
public void clearItem() {
- mSystemKey = -1;
+ mItemPath = null;
mItem = null;
+ mItemName = null;
}
@Override
public ItemProxy resolveItem() throws ObjectNotFoundException {
- if (mItem == null) {
- try {
- ItemPath path = new ItemPath(mSystemKey);
- mItem = Gateway.getProxyManager().getProxy(path);
- } catch (InvalidItemPathException ex) {
- throw new ObjectNotFoundException("No member defined", "");
- }
+ if (mItem == null && mItemPath != null) {
+ mItem = Gateway.getProxyManager().getProxy(mItemPath);
}
return mItem;
}
public String getItemName() {
- if (ItemName == null) {
- if (mSystemKey > -1) {
+ if (mItemName == null) {
+ if (mItemPath != null) {
try {
- ItemName = resolveItem().getName();
+ mItemName = resolveItem().getName();
} catch (ObjectNotFoundException ex) {
Logger.error(ex);
- ItemName = "Error ("+mSystemKey+")";
+ mItemName = "Error ("+mItemPath+")";
}
}
else
- ItemName = "Empty";
+ mItemName = "Empty";
}
- return ItemName;
+ return mItemName;
}
+ @Override
+ public void setChildUUID(String uuid) throws MembershipException {
+ setItemPath(new ItemPath(UUID.fromString(uuid)));
+ }
+
+
+ @Override
+ public String getChildUUID() {
+ if (getItemPath() == null) return null;
+ return getItemPath().getUUID().toString();
+ }
+
}
diff --git a/src/main/java/com/c2kernel/collection/Collection.java b/src/main/java/com/c2kernel/collection/Collection.java index b507593..0c28a3b 100644 --- a/src/main/java/com/c2kernel/collection/Collection.java +++ b/src/main/java/com/c2kernel/collection/Collection.java @@ -1,6 +1,7 @@ package com.c2kernel.collection;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.entity.C2KLocalObject;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.utils.CastorHashMap;
/**
@@ -21,9 +22,9 @@ public interface Collection<E extends CollectionMember> extends C2KLocalObject public CollectionMemberList<E> getMembers();
- public E addMember(int entityKey, CastorHashMap props, String classProps) throws MembershipException;
+ public E addMember(ItemPath itemPath, CastorHashMap props, String classProps) throws MembershipException;
- public E addMember(int entityKey) throws MembershipException;
+ public E addMember(ItemPath itemPath) throws MembershipException;
public void removeMember(int memberId) throws MembershipException;
diff --git a/src/main/java/com/c2kernel/collection/CollectionMember.java b/src/main/java/com/c2kernel/collection/CollectionMember.java index ff5d1cd..4fc7e3d 100644 --- a/src/main/java/com/c2kernel/collection/CollectionMember.java +++ b/src/main/java/com/c2kernel/collection/CollectionMember.java @@ -4,6 +4,7 @@ import java.io.Serializable; import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.entity.proxy.ItemProxy;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.utils.CastorHashMap;
/**************************************************************************
@@ -20,10 +21,13 @@ import com.c2kernel.utils.CastorHashMap; public interface CollectionMember extends Serializable {
- public void setSystemKey(int sysKey) throws MembershipException;
- public int getSystemKey();
+ public void setItemPath(ItemPath itemPath) throws MembershipException;
+ public ItemPath getItemPath();
+
+ public void setChildUUID(String uuid) throws MembershipException;
+ public String getChildUUID();
- public void assignItem(int ItemKey) throws MembershipException;
+ public void assignItem(ItemPath itemPath) throws MembershipException;
public void clearItem();
public ItemProxy resolveItem() throws ObjectNotFoundException;
diff --git a/src/main/java/com/c2kernel/collection/Dependency.java b/src/main/java/com/c2kernel/collection/Dependency.java index 4fb4f70..11ef16e 100644 --- a/src/main/java/com/c2kernel/collection/Dependency.java +++ b/src/main/java/com/c2kernel/collection/Dependency.java @@ -1,6 +1,7 @@ package com.c2kernel.collection;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.utils.CastorHashMap;
import com.c2kernel.utils.KeyValuePair;
import com.c2kernel.utils.Logger;
@@ -57,7 +58,7 @@ public class Dependency extends Parent2ChildCollection<DependencyMember> }
@Override
- public DependencyMember addMember(int sysKey) throws MembershipException {
+ public DependencyMember addMember(ItemPath itemPath) throws MembershipException {
// create member object
DependencyMember depMember = new DependencyMember();
depMember.setID(getCounter());
@@ -65,14 +66,14 @@ public class Dependency extends Parent2ChildCollection<DependencyMember> depMember.setClassProps(mClassProps);
// assign entity
- depMember.assignItem(sysKey);
+ depMember.assignItem(itemPath);
mMembers.list.add(depMember);
- Logger.msg(8, "Dependency::addMember(" + sysKey + ") added to children.");
+ Logger.msg(8, "Dependency::addMember(" + itemPath + ") added to children.");
return depMember;
}
@Override
- public DependencyMember addMember(int sysKey, CastorHashMap props, String classProps)
+ public DependencyMember addMember(ItemPath itemPath, CastorHashMap props, String classProps)
throws MembershipException
{
if (classProps != null && !classProps.equals(mClassProps))
@@ -97,9 +98,9 @@ public class Dependency extends Parent2ChildCollection<DependencyMember> depMember.setClassProps(mClassProps);
// assign entity
- depMember.assignItem(sysKey);
+ depMember.assignItem(itemPath);
mMembers.list.add(depMember);
- Logger.msg(8, "Dependency::addMember(" + sysKey + ") added to children.");
+ Logger.msg(8, "Dependency::addMember(" + itemPath + ") added to children.");
return depMember;
}
diff --git a/src/main/java/com/c2kernel/collection/DependencyDescription.java b/src/main/java/com/c2kernel/collection/DependencyDescription.java index 79b4880..3c3b287 100644 --- a/src/main/java/com/c2kernel/collection/DependencyDescription.java +++ b/src/main/java/com/c2kernel/collection/DependencyDescription.java @@ -1,6 +1,7 @@ package com.c2kernel.collection;
import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.property.PropertyDescriptionList;
import com.c2kernel.property.PropertyUtility;
import com.c2kernel.utils.CastorHashMap;
@@ -23,7 +24,7 @@ public class DependencyDescription extends Dependency implements CollectionDescr Dependency newDep = new Dependency(depName);
if (mMembers.list.size() == 1) { // constrain the members based on the property description
DependencyMember mem = mMembers.list.get(0);
- PropertyDescriptionList pdList = PropertyUtility.getPropertyDescriptionOutcome(mem.getSystemKey());
+ PropertyDescriptionList pdList = PropertyUtility.getPropertyDescriptionOutcome(mem.getItemPath());
if (pdList!=null) {
newDep.setProperties(PropertyUtility.createProperty(pdList));
newDep.setClassProps(pdList.getClassProps());
@@ -34,16 +35,16 @@ public class DependencyDescription extends Dependency implements CollectionDescr @Override
- public DependencyMember addMember(int entityKey) throws MembershipException {
+ public DependencyMember addMember(ItemPath itemPath) throws MembershipException {
checkMembership();
- return super.addMember(entityKey);
+ return super.addMember(itemPath);
}
@Override
- public DependencyMember addMember(int entityKey, CastorHashMap props, String classProps)
+ public DependencyMember addMember(ItemPath itemPath, CastorHashMap props, String classProps)
throws MembershipException {
checkMembership();
- return super.addMember(entityKey, props, classProps);
+ return super.addMember(itemPath, props, classProps);
}
public void checkMembership() throws MembershipException {
diff --git a/src/main/java/com/c2kernel/collection/DependencyMember.java b/src/main/java/com/c2kernel/collection/DependencyMember.java index 169f9ea..b5a8b13 100644 --- a/src/main/java/com/c2kernel/collection/DependencyMember.java +++ b/src/main/java/com/c2kernel/collection/DependencyMember.java @@ -1,11 +1,11 @@ package com.c2kernel.collection;
import java.util.StringTokenizer;
+import java.util.UUID;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.entity.proxy.ItemProxy;
import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.lookup.InvalidItemPathException;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.process.Gateway;
import com.c2kernel.property.Property;
@@ -23,9 +23,9 @@ import com.c2kernel.utils.Logger; public class DependencyMember implements CollectionMember
{
- private int mSystemKey = -1;
- private ItemProxy mItem = null;
- private int mId = -1;
+ private ItemPath mItemPath = null;
+ private ItemProxy mItem = null;
+ private int mId = -1;
private CastorHashMap mProperties = null;
private String mClassProps;
@@ -35,22 +35,21 @@ public class DependencyMember implements CollectionMember **************************************************************************/
public DependencyMember()
{
- mSystemKey = -1;
mProperties = new CastorHashMap();
}
@Override
- public void setSystemKey(int sysKey)
+ public void setItemPath(ItemPath itemPath)
{
- mSystemKey = sysKey;
+ mItemPath = itemPath;
mItem = null;
}
@Override
- public int getSystemKey()
+ public ItemPath getItemPath()
{
- return mSystemKey;
+ return mItemPath;
}
@Override
@@ -97,9 +96,9 @@ public class DependencyMember implements CollectionMember }
@Override
- public void assignItem(int ItemKey) throws MembershipException
+ public void assignItem(ItemPath itemPath) throws MembershipException
{
- if (ItemKey > -1) {
+ if (itemPath != null) {
if (mClassProps == null || getProperties() == null)
throw new MembershipException("ClassProps not yet set. Cannot check membership validity.");
@@ -110,9 +109,9 @@ public class DependencyMember implements CollectionMember String aClassProp = sub.nextToken();
try {
String memberValue = (String)getProperties().get(aClassProp);
- Property ItemProperty = (Property)Gateway.getStorage().get(ItemKey, ClusterStorage.PROPERTY+"/"+aClassProp, null);
+ Property ItemProperty = (Property)Gateway.getStorage().get(itemPath, ClusterStorage.PROPERTY+"/"+aClassProp, null);
if (ItemProperty == null)
- throw new MembershipException("Property "+aClassProp+ " does not exist for ItemKey=" + ItemKey );
+ throw new MembershipException("Property "+aClassProp+ " does not exist for item " + itemPath );
if (!ItemProperty.getValue().equalsIgnoreCase(memberValue))
throw new MembershipException("DependencyMember::checkProperty() Values of mandatory prop "+aClassProp+" do not match " + ItemProperty.getValue()+"!="+memberValue);
}
@@ -124,29 +123,34 @@ public class DependencyMember implements CollectionMember }
}
- mSystemKey = ItemKey;
+ mItemPath = itemPath;
mItem = null;
}
@Override
public void clearItem() {
- mSystemKey = -1;
+ mItemPath = null;
mItem = null;
}
@Override
public ItemProxy resolveItem() throws ObjectNotFoundException {
- if (mItem == null) {
- try {
- ItemPath path = new ItemPath(mSystemKey);
- mItem = Gateway.getProxyManager().getProxy(path);
- } catch (InvalidItemPathException ex) {
- throw new ObjectNotFoundException("No member defined", "");
- }
- }
+ if (mItem == null && mItemPath != null)
+ mItem = Gateway.getProxyManager().getProxy(mItemPath);
return mItem;
-
}
+ @Override
+ public void setChildUUID(String uuid) throws MembershipException {
+ mItemPath = new ItemPath(UUID.fromString(uuid));
+ }
+
+
+ @Override
+ public String getChildUUID() {
+ return mItemPath.getUUID().toString();
+ }
+
+
}
diff --git a/src/main/java/com/c2kernel/collection/Parent2ChildCollection.java b/src/main/java/com/c2kernel/collection/Parent2ChildCollection.java index 814cca8..26aa451 100644 --- a/src/main/java/com/c2kernel/collection/Parent2ChildCollection.java +++ b/src/main/java/com/c2kernel/collection/Parent2ChildCollection.java @@ -3,6 +3,7 @@ package com.c2kernel.collection; import java.util.Iterator;
import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.utils.CastorHashMap;
@@ -88,10 +89,10 @@ abstract public class Parent2ChildCollection<E extends CollectionMember> impleme mMembers = newMembers;
}
- public boolean contains(int sysKey) {
+ public boolean contains(ItemPath itemPath) {
for (Object name : mMembers.list) {
CollectionMember element = (CollectionMember)name;
- if (element.getSystemKey() == sysKey)
+ if (element.getItemPath().equals(itemPath))
return true;
}
return false;
@@ -102,7 +103,7 @@ abstract public class Parent2ChildCollection<E extends CollectionMember> impleme for (int i=0; i<size(); i++)
{
CollectionMember element = mMembers.list.get(i);
- if (element.getSystemKey() == -1)
+ if (element.getItemPath() == null)
return false;
}
return true;
@@ -124,7 +125,7 @@ abstract public class Parent2ChildCollection<E extends CollectionMember> impleme }
@Override
- public abstract E addMember(int entityKey, CastorHashMap props, String classProps) throws MembershipException;
+ public abstract E addMember(ItemPath itemPath, CastorHashMap props, String classProps) throws MembershipException;
public boolean equals(Parent2ChildCollection<?> other) {
boolean same = mName.equals(other.getName()) && mURLInfo.equals(other.getURLInfo()) && size() == other.size();
diff --git a/src/main/java/com/c2kernel/collection/gui/model/AggregationVertexFactory.java b/src/main/java/com/c2kernel/collection/gui/model/AggregationVertexFactory.java index 88dcc3a..1a20c5e 100644 --- a/src/main/java/com/c2kernel/collection/gui/model/AggregationVertexFactory.java +++ b/src/main/java/com/c2kernel/collection/gui/model/AggregationVertexFactory.java @@ -30,7 +30,7 @@ public class AggregationVertexFactory implements VertexFactory ) throws Exception
{
if (typeNameAndConstructionInfo.mInfo.equals("AggregationMember")) {
- mAggregation.addMember(-1, new CastorHashMap(), "",location, 40, 40);
+ mAggregation.addMember(null, new CastorHashMap(), "",location, 40, 40);
}
}
}
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);
- }
}
}
diff --git a/src/main/java/com/c2kernel/events/Event.java b/src/main/java/com/c2kernel/events/Event.java index 37c3c58..267f135 100644 --- a/src/main/java/com/c2kernel/events/Event.java +++ b/src/main/java/com/c2kernel/events/Event.java @@ -10,11 +10,16 @@ package com.c2kernel.events;
import java.util.Calendar;
+import java.util.UUID;
import com.c2kernel.common.GTimeStamp;
import com.c2kernel.common.InvalidDataException;
import com.c2kernel.entity.C2KLocalObject;
+import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.InvalidAgentPathException;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.ClusterStorage;
+import com.c2kernel.utils.Logger;
/**
@@ -27,10 +32,10 @@ import com.c2kernel.persistency.ClusterStorage; */
public class Event implements C2KLocalObject
{
-
- int mEntitySystemKey, mOriginState, mTransition, mTargetState;
+ ItemPath mItemPath; AgentPath mAgentPath;
+ int mOriginState, mTransition, mTargetState;
Integer mID, mSchemaVersion, mStateMachineVersion;
- String mName, mStepName, mStepPath, mStepType, mSchemaName, mStateMachineName, mViewName, mAgentName, mAgentRole;
+ String mName, mStepName, mStepPath, mStepType, mSchemaName, mStateMachineName, mViewName, mAgentRole;
GTimeStamp mTimeStamp;
public int getOriginState() {
@@ -72,11 +77,38 @@ public class Event implements C2KLocalObject /**
*/
- public void setEntitySystemKey( int systemKey )
+ public void setItemPath( ItemPath itemPath )
+ {
+ mItemPath = itemPath;
+ }
+
+ public void setItemUUID( String uuid )
{
- mEntitySystemKey = systemKey;
+ setItemPath(new ItemPath(UUID.fromString(uuid)));
+ }
+
+ public String getItemUUID() {
+ return getItemPath().getUUID().toString();
}
+ public void setAgentUUID( String uuid )
+ {
+ if (uuid == null) mAgentPath = null;
+ else
+ try {
+ setAgentPath(new AgentPath(UUID.fromString(uuid)));
+ } catch (InvalidAgentPathException e) {
+ Logger.error("Invalid agent path in Event: "+uuid);
+ }
+ }
+
+ public String getAgentUUID() {
+ if (mAgentPath != null)
+ return getAgentPath().getUUID().toString();
+ else
+ return null;
+ }
+
/**
* Set the Event Name, in parameter is a String
*/
@@ -125,9 +157,9 @@ public class Event implements C2KLocalObject /**
* Set the AgentInfo in the Event, in parameter is an AgentInfo
*/
- public void setAgentName(String agentName)
+ public void setAgentPath(AgentPath agentPath)
{
- mAgentName = agentName;
+ mAgentPath = agentPath;
}
public void setAgentRole(String agentRole)
@@ -154,9 +186,9 @@ public class Event implements C2KLocalObject /**
*/
- public int getEntitySystemKey()
+ public ItemPath getItemPath()
{
- return mEntitySystemKey;
+ return mItemPath;
}
/**
@@ -202,9 +234,9 @@ public class Event implements C2KLocalObject /**
* Return the AgentInfo of the Event.
*/
- public String getAgentName()
+ public AgentPath getAgentPath()
{
- return mAgentName;
+ return mAgentPath;
}
public String getAgentRole()
diff --git a/src/main/java/com/c2kernel/events/History.java b/src/main/java/com/c2kernel/events/History.java index bf77f40..c7e1ede 100644 --- a/src/main/java/com/c2kernel/events/History.java +++ b/src/main/java/com/c2kernel/events/History.java @@ -3,6 +3,8 @@ package com.c2kernel.events; import com.c2kernel.common.InvalidDataException;
import com.c2kernel.lifecycle.instance.stateMachine.Transition;
+import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.persistency.RemoteMap;
import com.c2kernel.utils.Logger;
@@ -21,20 +23,20 @@ public class History extends RemoteMap<Event> { int lastID = -1;
- public History(int sysKey, Object locker) {
- super(sysKey, ClusterStorage.HISTORY, locker);
+ public History(ItemPath itemPath, Object locker) {
+ super(itemPath, ClusterStorage.HISTORY, locker);
}
- public Event addEvent(String agentName, String agentRole,
+ public Event addEvent(AgentPath agentPath, String agentRole,
String stepName,
String stepPath,
String stepType,
String stateMachineName,
Integer stateMachineVersion,
Transition transition) {
- return addEvent(agentName, agentRole, stepName, stepPath, stepType, null, null, stateMachineName, stateMachineVersion, transition, null);
+ return addEvent(agentPath, agentRole, stepName, stepPath, stepType, null, null, stateMachineName, stateMachineVersion, transition, null);
}
- public Event addEvent(String agentName, String agentRole,
+ public Event addEvent(AgentPath agentPath, String agentRole,
String stepName,
String stepPath,
String stepType,
@@ -44,10 +46,10 @@ public class History extends RemoteMap<Event> { Integer stateMachineVersion,
Transition transition,
String viewName) {
- Logger.msg(7, "History.addEvent() - creating new event for "+transition.getName()+" on "+stepName+" in "+mSysKey);
+ Logger.msg(7, "History.addEvent() - creating new event for "+transition.getName()+" on "+stepName+" in "+mItemPath);
Event newEvent = new Event();
- newEvent.setEntitySystemKey(mSysKey);
- newEvent.setAgentName(agentName);
+ newEvent.setItemPath(mItemPath);
+ newEvent.setAgentPath(agentPath);
newEvent.setAgentRole(agentRole);
newEvent.setStepName(stepName);
newEvent.setStepPath(stepPath);
@@ -64,7 +66,7 @@ public class History extends RemoteMap<Event> { return storeNewEvent(newEvent);
}
- public Event addEvent(String agentName, String agentRole,
+ public Event addEvent(AgentPath agentPath, String agentRole,
String stepName,
String stepPath,
String stepType,
@@ -72,10 +74,10 @@ public class History extends RemoteMap<Event> { Integer stateMachineVersion,
Transition transition,
String timeString) throws InvalidDataException {
- return addEvent(agentName, agentRole, stepName, stepPath, stepType, null, null, stateMachineName, stateMachineVersion, transition, null, timeString);
+ return addEvent(agentPath, agentRole, stepName, stepPath, stepType, null, null, stateMachineName, stateMachineVersion, transition, null, timeString);
}
- public Event addEvent(String agentName, String agentRole,
+ public Event addEvent(AgentPath agentPath, String agentRole,
String stepName,
String stepPath,
String stepType,
@@ -86,10 +88,10 @@ public class History extends RemoteMap<Event> { Transition transition,
String viewName,
String timeString) throws InvalidDataException {
- Logger.msg(7, "History.addEvent() - creating new event for "+transition.getName()+" on "+stepName+" in "+mSysKey);
+ Logger.msg(7, "History.addEvent() - creating new event for "+transition.getName()+" on "+stepName+" in "+mItemPath);
Event newEvent = new Event();
- newEvent.setEntitySystemKey(mSysKey);
- newEvent.setAgentName(agentName);
+ newEvent.setItemPath(mItemPath);
+ newEvent.setAgentPath(agentPath);
newEvent.setAgentRole(agentRole);
newEvent.setStepName(stepName);
newEvent.setStepPath(stepPath);
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Activity.java b/src/main/java/com/c2kernel/lifecycle/instance/Activity.java index 88cbeb6..95e0ede 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/Activity.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/Activity.java @@ -19,6 +19,8 @@ import com.c2kernel.lifecycle.instance.stateMachine.State; import com.c2kernel.lifecycle.instance.stateMachine.StateMachine;
import com.c2kernel.lifecycle.instance.stateMachine.Transition;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.InvalidAgentPathException;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.lookup.RolePath;
import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.persistency.outcome.Outcome;
@@ -128,7 +130,7 @@ public class Activity extends WfVertex /** cf Item request
* @throws ObjectNotFoundException
* @throws PersistencyException */
- public String request(AgentPath agent, int itemSysKey, int transitionID, String requestData) throws AccessRightsException, InvalidTransitionException, InvalidDataException, ObjectNotFoundException, PersistencyException
+ public String request(AgentPath agent, ItemPath itemPath, int transitionID, String requestData) throws AccessRightsException, InvalidTransitionException, InvalidDataException, ObjectNotFoundException, PersistencyException
{
// Find requested transition
@@ -154,7 +156,7 @@ public class Activity extends WfVertex State newState = getStateMachine().traverse(this, transition, agent);
// Run extra logic in predefined steps here
- String outcome = runActivityLogic(agent, itemSysKey, transitionID, requestData);
+ String outcome = runActivityLogic(agent, itemPath, transitionID, requestData);
// set new state and reservation
setState(newState.getId());
@@ -165,26 +167,26 @@ public class Activity extends WfVertex try {
History hist = getWf().getHistory();
if (storeOutcome)
- newEvent = hist.addEvent(agent.getAgentName(), usedRole, getName(), getPath(), getType(), schema.docType, schema.docVersion,
+ newEvent = hist.addEvent(agent, usedRole, getName(), getPath(), getType(), schema.docType, schema.docVersion,
getStateMachine().getName(), getStateMachine().getVersion(), transition, viewName);
else
- newEvent = hist.addEvent(agent.getAgentName(), usedRole, getName(), getPath(), getType(),
+ newEvent = hist.addEvent(agent, usedRole, getName(), getPath(), getType(),
getStateMachine().getName(), getStateMachine().getVersion(), transition);
Logger.msg(7, "Activity::auditEvent() - Event:" + newEvent.getName() + " was added to the AuditTrail");
if (storeOutcome) {
Outcome newOutcome = new Outcome(newEvent.getID(), outcome, schema.docType, schema.docVersion);
- Gateway.getStorage().put(itemSysKey, newOutcome, getWf());
+ Gateway.getStorage().put(itemPath, newOutcome, getWf());
// update specific view if defined
if (viewName != null && !viewName.equals("")) {
- Viewpoint currentView = new Viewpoint(itemSysKey, schema.docType, viewName, schema.docVersion, newEvent.getID());
- Gateway.getStorage().put(itemSysKey, currentView, getWf());
+ Viewpoint currentView = new Viewpoint(itemPath, schema.docType, viewName, schema.docVersion, newEvent.getID());
+ Gateway.getStorage().put(itemPath, currentView, getWf());
}
// update last view
- Viewpoint currentView = new Viewpoint(itemSysKey, schema.docType, "last", schema.docVersion, newEvent.getID());
- Gateway.getStorage().put(itemSysKey, currentView, getWf());
+ Viewpoint currentView = new Viewpoint(itemPath, schema.docType, "last", schema.docVersion, newEvent.getID());
+ Gateway.getStorage().put(itemPath, currentView, getWf());
}
Gateway.getStorage().commit(getWf());
} catch (ClusterStorageException ex) {
@@ -195,18 +197,18 @@ public class Activity extends WfVertex if (newState.isFinished()) {
if (!getProperties().get("Breakpoint").equals(Boolean.TRUE))
- runNext(agent, itemSysKey);
+ runNext(agent, itemPath);
}
DateUtility.setToNow(mStateDate);
//refresh all the job lists
- pushJobsToAgents(itemSysKey);
+ pushJobsToAgents(itemPath);
return outcome;
}
- protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ protected String runActivityLogic(AgentPath agent, ItemPath itemPath,
int transitionID, String requestData) throws InvalidDataException {
// Overriden in predefined steps
return requestData;
@@ -281,7 +283,7 @@ public class Activity extends WfVertex * @throws PersistencyException
* @throws ObjectAlreadyExistsException */
@Override
- public void runNext(AgentPath agent, int itemSysKey) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
+ public void runNext(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
{
setActive(false);
try
@@ -305,7 +307,7 @@ public class Activity extends WfVertex }
Logger.debug(8, outVertices + " " + outVertices2);
if (!hasNoNext)
- ((WfVertex) outVertices[0]).run(agent, itemSysKey);
+ ((WfVertex) outVertices[0]).run(agent, itemPath);
else
{
if (getParent() != null && getParent().getName().equals("domain")) // workflow
@@ -315,7 +317,7 @@ public class Activity extends WfVertex {
CompositeActivity parent = (CompositeActivity) getParent();
if (parent != null)
- parent.runNext(agent, itemSysKey);
+ parent.runNext(agent, itemPath);
}
}
}
@@ -365,7 +367,7 @@ public class Activity extends WfVertex * @throws PersistencyException
*/
@Override
- public void run(AgentPath agent, int itemSysKey) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
+ public void run(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
{
Logger.debug(8, getPath() + " run " + getState());
@@ -373,12 +375,12 @@ public class Activity extends WfVertex boolean finished = getStateMachine().getState(getState()).isFinished();
if (finished)
{
- runNext(agent, itemSysKey);
+ runNext(agent, itemPath);
}
else
{
DateUtility.setToNow(mStateDate);
- pushJobsToAgents(itemSysKey);
+ pushJobsToAgents(itemPath);
}
}
/**
@@ -391,10 +393,10 @@ public class Activity extends WfVertex * @throws PersistencyException
*/
@Override
- public void runFirst(AgentPath agent, int itemSysKey) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
+ public void runFirst(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
{
Logger.debug(8, getPath() + " runfirst");
- run(agent, itemSysKey);
+ run(agent, itemPath);
}
/** @return the current ability to be executed */
public boolean getActive()
@@ -424,16 +426,17 @@ public class Activity extends WfVertex /**
* returns the lists of jobs for the activity and children (cf com.c2kernel.entity.Job)
+ * @throws InvalidAgentPathException
*/
- public ArrayList<Job> calculateJobs(AgentPath agent, int itemSysKey, boolean recurse) throws ObjectNotFoundException, InvalidDataException
+ public ArrayList<Job> calculateJobs(AgentPath agent, ItemPath itemPath, boolean recurse) throws ObjectNotFoundException, InvalidDataException, InvalidAgentPathException
{
- return calculateJobsBase(agent, itemSysKey, false);
+ return calculateJobsBase(agent, itemPath, false);
} //
- public ArrayList<Job> calculateAllJobs(AgentPath agent, int itemSysKey, boolean recurse) throws ObjectNotFoundException, InvalidDataException
+ public ArrayList<Job> calculateAllJobs(AgentPath agent, ItemPath itemPath, boolean recurse) throws ObjectNotFoundException, InvalidDataException, InvalidAgentPathException
{
- return calculateJobsBase(agent, itemSysKey, true);
+ return calculateJobsBase(agent, itemPath, true);
}
- private ArrayList<Job> calculateJobsBase(AgentPath agent, int itemSysKey, boolean includeInactive) throws ObjectNotFoundException, InvalidDataException
+ private ArrayList<Job> calculateJobsBase(AgentPath agent, ItemPath itemPath, boolean includeInactive) throws ObjectNotFoundException, InvalidDataException, InvalidAgentPathException
{
Logger.msg(7, "calculateJobs - " + getPath());
ArrayList<Job> jobs = new ArrayList<Job>();
@@ -443,13 +446,13 @@ public class Activity extends WfVertex Logger.msg(7, "Activity.calculateJobs() - Got " + transitions.size() + " transitions.");
for (Transition transition : transitions.keySet()) {
Logger.msg(7, "Creating Job object for transition " + transition);
- jobs.add(new Job(this, itemSysKey, transition, agent, transitions.get(transition)));
+ jobs.add(new Job(this, itemPath, transition, agent, transitions.get(transition)));
}
}
return jobs;
}
- public void pushJobsToAgents(int itemSysKey)
+ public void pushJobsToAgents(ItemPath itemPath)
{
String agentRole = getCurrentAgentRole();
if (agentRole == null || agentRole.length()==0) return;
@@ -463,7 +466,7 @@ public class Activity extends WfVertex }
if (myRole.hasJobList())
- new JobPusher(this, itemSysKey, myRole).start();
+ new JobPusher(this, itemPath, myRole).start();
}
/**
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/AndSplit.java b/src/main/java/com/c2kernel/lifecycle/instance/AndSplit.java index 0ecdb7f..e8e548e 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/AndSplit.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/AndSplit.java @@ -6,6 +6,7 @@ import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.common.PersistencyException;
import com.c2kernel.graph.model.Vertex;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.ItemPath;
/**
* @version $Revision: 1.16 $ $Date: 2005/05/10 15:14:54 $
* @author $Author: abranson $
@@ -20,12 +21,12 @@ public class AndSplit extends Split super();
}
@Override
- public void runNext(AgentPath agent, int itemSysKey) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
+ public void runNext(AgentPath agent, ItemPath item) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
{
AdvancementCalculator adv = new AdvancementCalculator();
adv.calculate((CompositeActivity) getParent());
Vertex[] outVertices = getOutGraphables();
for (Vertex outVertice : outVertices)
- ((WfVertex) outVertice).run(agent, itemSysKey);
+ ((WfVertex) outVertice).run(agent, item);
}
}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/CompositeActivity.java b/src/main/java/com/c2kernel/lifecycle/instance/CompositeActivity.java index e6d1bf9..949d918 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/CompositeActivity.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/CompositeActivity.java @@ -12,6 +12,8 @@ import com.c2kernel.graph.model.GraphModel; import com.c2kernel.graph.model.GraphPoint;
import com.c2kernel.graph.model.GraphableVertex;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.InvalidAgentPathException;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.utils.Logger;
/**
@@ -288,32 +290,33 @@ public class CompositeActivity extends Activity * @see com.c2kernel.lifecycle.instance.WfVertex#run()
*/
@Override
- public void run(AgentPath agent, int itemSysKey) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
+ public void run(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
{
- super.run(agent, itemSysKey);
+ super.run(agent, itemPath);
if (getChildrenGraphModel().getStartVertex() != null && !getStateMachine().getState(state).isFinished())
{
WfVertex first = (WfVertex) getChildrenGraphModel().getStartVertex();
- first.run(agent, itemSysKey);
+ first.run(agent, itemPath);
}
}
@Override
- public void runNext(AgentPath agent, int itemSysKey) throws InvalidDataException, AccessRightsException, InvalidTransitionException, ObjectNotFoundException, PersistencyException
+ public void runNext(AgentPath agent, ItemPath itemPath) throws InvalidDataException, AccessRightsException, InvalidTransitionException, ObjectNotFoundException, PersistencyException
{
if (!getStateMachine().getState(state).isFinished())
- request(agent, itemSysKey, CompositeActivity.COMPLETE, null);
- super.runNext(agent, itemSysKey);
+ request(agent, itemPath, CompositeActivity.COMPLETE, null);
+ super.runNext(agent, itemPath);
}
/**
* @throws InvalidDataException
* @throws ObjectNotFoundException
+ * @throws InvalidAgentPathException
* @see com.c2kernel.lifecycle.instance.Activity#calculateJobs()
*/
@Override
- public ArrayList<Job> calculateJobs(AgentPath agent, int itemSysKey, boolean recurse) throws ObjectNotFoundException, InvalidDataException
+ public ArrayList<Job> calculateJobs(AgentPath agent, ItemPath itemPath, boolean recurse) throws ObjectNotFoundException, InvalidDataException, InvalidAgentPathException
{
ArrayList<Job> jobs = new ArrayList<Job>();
boolean childActive = false;
@@ -322,16 +325,16 @@ public class CompositeActivity extends Activity if (getChildren()[i] instanceof Activity)
{
Activity child = (Activity) getChildren()[i];
- jobs.addAll(child.calculateJobs(agent, itemSysKey, recurse));
+ jobs.addAll(child.calculateJobs(agent, itemPath, recurse));
childActive |= child.active;
}
if (!childActive)
- jobs.addAll(super.calculateJobs(agent, itemSysKey, recurse));
+ jobs.addAll(super.calculateJobs(agent, itemPath, recurse));
return jobs;
}
@Override
- public ArrayList<Job> calculateAllJobs(AgentPath agent, int itemSysKey, boolean recurse) throws ObjectNotFoundException, InvalidDataException
+ public ArrayList<Job> calculateAllJobs(AgentPath agent, ItemPath itemPath, boolean recurse) throws ObjectNotFoundException, InvalidDataException, InvalidAgentPathException
{
ArrayList<Job> jobs = new ArrayList<Job>();
if (recurse)
@@ -339,9 +342,9 @@ public class CompositeActivity extends Activity if (getChildren()[i] instanceof Activity)
{
Activity child = (Activity) getChildren()[i];
- jobs.addAll(child.calculateAllJobs(agent, itemSysKey, recurse));
+ jobs.addAll(child.calculateAllJobs(agent, itemPath, recurse));
}
- jobs.addAll(super.calculateAllJobs(agent, itemSysKey, recurse));
+ jobs.addAll(super.calculateAllJobs(agent, itemPath, recurse));
return jobs;
}
@@ -413,21 +416,21 @@ public class CompositeActivity extends Activity }
@Override
- public String request(AgentPath agent, int itemSysKey, int transitionID, String requestData) throws AccessRightsException, InvalidTransitionException, InvalidDataException, ObjectNotFoundException, PersistencyException
+ public String request(AgentPath agent, ItemPath itemPath, int transitionID, String requestData) throws AccessRightsException, InvalidTransitionException, InvalidDataException, ObjectNotFoundException, PersistencyException
{
if (getChildrenGraphModel().getStartVertex() != null && !getStateMachine().getState(state).isFinished() && transitionID == CompositeActivity.START)
- ((WfVertex) getChildrenGraphModel().getStartVertex()).run(agent, itemSysKey);
+ ((WfVertex) getChildrenGraphModel().getStartVertex()).run(agent, itemPath);
- return super.request(agent, itemSysKey, transitionID, requestData);
+ return super.request(agent, itemPath, transitionID, requestData);
}
- public void refreshJobs(int itemSysKey)
+ public void refreshJobs(ItemPath itemPath)
{
GraphableVertex[] children = getChildren();
for (GraphableVertex element : children)
if (element instanceof CompositeActivity)
- ((CompositeActivity) element).refreshJobs(itemSysKey);
+ ((CompositeActivity) element).refreshJobs(itemPath);
else if (element instanceof Activity)
- ((Activity) element).pushJobsToAgents(itemSysKey);
+ ((Activity) element).pushJobsToAgents(itemPath);
}
}
\ No newline at end of file diff --git a/src/main/java/com/c2kernel/lifecycle/instance/JobPusher.java b/src/main/java/com/c2kernel/lifecycle/instance/JobPusher.java index 89e7708..d134daf 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/JobPusher.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/JobPusher.java @@ -6,6 +6,7 @@ import com.c2kernel.entity.Agent; import com.c2kernel.entity.AgentHelper;
import com.c2kernel.entity.agent.JobArrayList;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.lookup.Path;
import com.c2kernel.lookup.RolePath;
import com.c2kernel.process.Gateway;
@@ -14,43 +15,43 @@ import com.c2kernel.utils.Logger; final class JobPusher extends Thread {
private final Activity activity;
private final RolePath myRole;
- private final int itemSysKey;
+ private final ItemPath itemPath;
- JobPusher(Activity activity, int itemSysKey, RolePath role) {
+ JobPusher(Activity activity, ItemPath itemPath, RolePath role) {
this.activity = activity;
- this.itemSysKey = itemSysKey;
+ this.itemPath = itemPath;
this.myRole = role;
}
@Override
public void run()
{
- Thread.currentThread().setName("Agent job pusher for "+itemSysKey+":"+activity.getName()+" to role "+myRole);
+ Thread.currentThread().setName("Agent job pusher for "+itemPath+":"+activity.getName()+" to role "+myRole);
for (Iterator<Path> e = myRole.getChildren(); e.hasNext();)
{
AgentPath nextAgent = (AgentPath)e.next();
- Logger.msg(7, "Activity.pushJobsToAgents() - Calculating jobs for " + nextAgent.getAgentName());
+ Logger.msg(7, "Activity.pushJobsToAgents() - Calculating jobs for " + nextAgent);
try
{
// get joblist for user
- JobArrayList jobList = new JobArrayList(this.activity.calculateJobs(nextAgent, itemSysKey, false));
+ JobArrayList jobList = new JobArrayList(this.activity.calculateJobs(nextAgent, itemPath, false));
Logger.msg(7, "Activity.pushJobsToAgents() - User will receive " + jobList.list.size() + " jobs");
String stringJobs = Gateway.getMarshaller().marshall(jobList);
// push it to the agent
org.omg.CORBA.Object agentIOR = nextAgent.getIOR();
Agent thisAgent = AgentHelper.narrow(agentIOR);
Logger.msg(7, "Calling agent "+thisAgent.getSystemKey()+" from "+activity.getPath());
- thisAgent.refreshJobList(itemSysKey, activity.getPath(), stringJobs);
+ thisAgent.refreshJobList(itemPath.getSystemKey(), activity.getPath(), stringJobs);
}
catch (Exception ex)
{
Logger.error(
"Agent "
- + nextAgent.getAgentName()
+ + nextAgent
+ " of role "
+ myRole
+ " could not be found to be informed of a change in "
- + itemSysKey);
+ + itemPath);
Logger.error(ex);
}
}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Join.java b/src/main/java/com/c2kernel/lifecycle/instance/Join.java index 7f50ece..a811f8f 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/Join.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/Join.java @@ -9,6 +9,7 @@ import com.c2kernel.common.PersistencyException; import com.c2kernel.graph.model.Vertex;
import com.c2kernel.graph.traversal.GraphTraversal;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.ItemPath;
/**
* @version $Revision: 1.52 $ $Date: 2005/05/10 15:14:54 $
* @author $Author: abranson $
@@ -36,7 +37,7 @@ public class Join extends WfVertex * @see com.c2kernel.lifecycle.instance.WfVertex#runNext()
*/
@Override
- public void runNext(AgentPath agent, int itemSysKey) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
+ public void runNext(AgentPath agent, ItemPath item) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
{
AdvancementCalculator adv = new AdvancementCalculator();
adv.calculate((CompositeActivity) getParent());
@@ -46,10 +47,10 @@ public class Join extends WfVertex if (outVertices.length > 0)
{
WfVertex nextAct = (WfVertex) outVertices[0];
- nextAct.run(agent, itemSysKey);
+ nextAct.run(agent, item);
}
else
- super.runNext(agent, itemSysKey);
+ super.runNext(agent, item);
}
}
/**
@@ -157,9 +158,9 @@ public class Join extends WfVertex * @see com.c2kernel.lifecycle.instance.WfVertex#run()
*/
@Override
- public void run(AgentPath agent, int itemSysKey) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
+ public void run(AgentPath agent, ItemPath item) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
{
- runNext(agent, itemSysKey);
+ runNext(agent, item);
}
/**
* @see com.c2kernel.lifecycle.instance.WfVertex#addNext(com.c2kernel.lifecycle.instance.WfVertex)
@@ -188,9 +189,9 @@ public class Join extends WfVertex return loop2;
}
@Override
- public void runFirst(AgentPath agent, int itemSysKey) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
+ public void runFirst(AgentPath agent, ItemPath item) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
{
- runNext(agent, itemSysKey);
+ runNext(agent, item);
}
/*
* (non-Javadoc)
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Loop.java b/src/main/java/com/c2kernel/lifecycle/instance/Loop.java index 51d6133..1b16638 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/Loop.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/Loop.java @@ -7,6 +7,7 @@ import com.c2kernel.common.PersistencyException; import com.c2kernel.graph.model.Vertex;
import com.c2kernel.graph.traversal.GraphTraversal;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.utils.Logger;
/**
* @version $Revision: 1.35 $ $Date: 2005/05/10 15:14:54 $
@@ -30,15 +31,15 @@ public class Loop extends XOrSplit return true;
}
@Override
- public void followNext(Next activeNext, AgentPath agent, int itemSysKey) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
+ public void followNext(Next activeNext, AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
{
WfVertex v = activeNext.getTerminusVertex();
if (!isInPrev(v))
- v.run(agent, itemSysKey);
+ v.run(agent, itemPath);
else
{
v.reinit(getID());
- v.run(agent, itemSysKey);
+ v.run(agent, itemPath);
}
}
/**
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/OrSplit.java b/src/main/java/com/c2kernel/lifecycle/instance/OrSplit.java index b9fc263..305ec34 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/OrSplit.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/OrSplit.java @@ -4,6 +4,7 @@ import java.util.StringTokenizer; import com.c2kernel.common.InvalidDataException;
import com.c2kernel.graph.model.DirectedEdge;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.scripting.ScriptingEngineException;
import com.c2kernel.utils.Logger;
/**
@@ -20,13 +21,13 @@ public class OrSplit extends Split super();
}
@Override
- public void runNext(AgentPath agent, int itemSysKey) throws InvalidDataException
+ public void runNext(AgentPath agent, ItemPath itemPath) throws InvalidDataException
{
String nexts;
String scriptName = (String) getProperties().get("RoutingScriptName");
Integer scriptVersion = getVersionNumberProperty("RoutingScriptVersion");
try {
- nexts = this.evaluateScript(scriptName, scriptVersion, itemSysKey).toString();
+ nexts = this.evaluateScript(scriptName, scriptVersion, itemPath).toString();
} catch (ScriptingEngineException e) {
Logger.error(e);
throw new InvalidDataException("Error running routing script "+scriptName+" v"+scriptVersion, null);
@@ -48,7 +49,7 @@ public class OrSplit extends Split if (thisNext != null && thisNext.equals(nextEdge.getProperties().get("Alias")))
{
WfVertex term = nextEdge.getTerminusVertex();
- term.run(agent, itemSysKey);
+ term.run(agent, itemPath);
Logger.msg(7, "Running " + nextEdge.getProperties().get("Alias"));
active++;
}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Split.java b/src/main/java/com/c2kernel/lifecycle/instance/Split.java index a123391..8eb1ab1 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/Split.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/Split.java @@ -10,6 +10,7 @@ import com.c2kernel.common.PersistencyException; import com.c2kernel.graph.model.Vertex;
import com.c2kernel.graph.traversal.GraphTraversal;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.ItemPath;
/**
* @version $Revision: 1.47 $ $Date: 2006/05/29 13:17:45 $
@@ -40,7 +41,7 @@ public abstract class Split extends WfVertex * @see com.c2kernel.lifecycle.instance.WfVertex#runNext()
*/
@Override
- public abstract void runNext(AgentPath agent, int itemSysKey) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException;
+ public abstract void runNext(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException;
/**
* Method addNext.
@@ -154,9 +155,9 @@ public abstract class Split extends WfVertex * @see com.c2kernel.lifecycle.instance.WfVertex#run()
*/
@Override
- public void run(AgentPath agent, int itemSysKey) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
+ public void run(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
{
- runNext(agent, itemSysKey);
+ runNext(agent, itemPath);
}
/**
@@ -203,9 +204,9 @@ public abstract class Split extends WfVertex }
@Override
- public void runFirst(AgentPath agent, int itemSysKey) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
+ public void runFirst(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
{
- runNext(agent, itemSysKey);
+ runNext(agent, itemPath);
}
}
\ No newline at end of file diff --git a/src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java b/src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java index 2f0ef0d..c2596f8 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/WfVertex.java @@ -35,7 +35,7 @@ public abstract class WfVertex extends GraphableVertex * @throws AccessRightsException
* @throws InvalidTransitionException
* @throws PersistencyException */
- public abstract void runFirst(AgentPath agent, int itemSysKey) throws ScriptingEngineException, InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, ObjectAlreadyExistsException, PersistencyException;
+ public abstract void runFirst(AgentPath agent, ItemPath itemPath) throws ScriptingEngineException, InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, ObjectAlreadyExistsException, PersistencyException;
/**
* @see java.lang.Object#Object()
@@ -56,11 +56,11 @@ public abstract class WfVertex extends GraphableVertex * @throws PersistencyException
* @throws ObjectAlreadyExistsException
*/
- public void runNext(AgentPath agent, int itemSysKey) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
+ public void runNext(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
{
try
{
- ((CompositeActivity)getParent()).request(agent, itemSysKey, CompositeActivity.COMPLETE, null);
+ ((CompositeActivity)getParent()).request(agent, itemPath, CompositeActivity.COMPLETE, null);
}
catch (Exception e)
{
@@ -98,7 +98,7 @@ public abstract class WfVertex extends GraphableVertex * @throws InvalidTransitionException
* @throws PersistencyException
*/
- public abstract void run(AgentPath agent, int itemSysKey) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException;
+ public abstract void run(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException;
/**
* Method loop.
@@ -112,7 +112,7 @@ public abstract class WfVertex extends GraphableVertex */
public abstract Next addNext(WfVertex vertex);
- protected Object evaluateScript(String scriptName, Integer scriptVersion, int itemSysKey) throws ScriptingEngineException
+ protected Object evaluateScript(String scriptName, Integer scriptVersion, ItemPath itemPath) throws ScriptingEngineException
{
try
@@ -131,7 +131,7 @@ public abstract class WfVertex extends GraphableVertex {
value = value.substring(11);
if (value.startsWith("."))
- value = itemSysKey + value.substring(1);
+ value = itemPath.getUUID() + value.substring(1);
try {
inputParam = ViewpointDataHelper.get(value)[0];
} catch (ArrayIndexOutOfBoundsException ex) {
@@ -142,7 +142,7 @@ public abstract class WfVertex extends GraphableVertex {
value = value.substring(10);
try {
- inputParam = Gateway.getStorage().get(itemSysKey, ClusterStorage.PROPERTY+"/"+value, null);
+ inputParam = Gateway.getStorage().get(itemPath, ClusterStorage.PROPERTY+"/"+value, null);
} catch (ObjectNotFoundException ex) {
inputParam = null;
}
@@ -154,7 +154,7 @@ public abstract class WfVertex extends GraphableVertex //TODO: is this right?
if (requiredInput.containsKey("item")) {
- script.setInputParamValue("item", Gateway.getProxyManager().getProxy(new ItemPath(itemSysKey)));
+ script.setInputParamValue("item", Gateway.getProxyManager().getProxy(itemPath));
}
if (requiredInput.containsKey("agent")) {
AgentPath systemAgent = Gateway.getLookup().getAgentPath("system");
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/Workflow.java b/src/main/java/com/c2kernel/lifecycle/instance/Workflow.java index 451d7fd..33c80a4 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/Workflow.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/Workflow.java @@ -1,5 +1,6 @@ package com.c2kernel.lifecycle.instance;
import java.util.ArrayList;
+import java.util.UUID;
import com.c2kernel.common.AccessRightsException;
import com.c2kernel.common.InvalidDataException;
@@ -14,6 +15,8 @@ import com.c2kernel.graph.model.GraphPoint; import com.c2kernel.graph.model.TypeNameAndConstructionInfo;
import com.c2kernel.lifecycle.instance.predefined.PredefinedStepContainer;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.InvalidAgentPathException;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.utils.Language;
import com.c2kernel.utils.Logger;
@@ -24,7 +27,7 @@ import com.c2kernel.utils.Logger; public class Workflow extends CompositeActivity implements C2KLocalObject
{
public History history;
- private Integer itemSysKey = null;
+ private ItemPath itemPath = null;
/** TypeNameAndConstructionInfo[] variables added by Steve */
private final TypeNameAndConstructionInfo[] mVertexTypeNameAndConstructionInfo =
@@ -57,9 +60,9 @@ public class Workflow extends CompositeActivity implements C2KLocalObject public History getHistory() throws InvalidDataException {
if (history == null) {
- if (itemSysKey == null)
+ if (itemPath == null)
throw new InvalidDataException("Workflow not initialized.", "");
- history = new History(itemSysKey, this);
+ history = new History(itemPath, this);
}
return history;
}
@@ -98,12 +101,12 @@ public class Workflow extends CompositeActivity implements C2KLocalObject * @throws PersistencyException
*/
//requestData is xmlstring
- public String requestAction(AgentPath agent, String stepPath, int itemSysKey, int transitionID, String requestData)
+ public String requestAction(AgentPath agent, String stepPath, ItemPath itemPath, int transitionID, String requestData)
throws ObjectNotFoundException, AccessRightsException, InvalidTransitionException, InvalidDataException, ObjectAlreadyExistsException, PersistencyException
{
- Logger.msg(3, "Action: " + transitionID + " " + stepPath + " by " + agent.getAgentName());
+ Logger.msg(3, "Action: " + transitionID + " " + stepPath + " by " + agent);
if (search(stepPath) != null)
- return ((Activity) search(stepPath)).request(agent, itemSysKey, transitionID, requestData);
+ return ((Activity) search(stepPath)).request(agent, itemPath, transitionID, requestData);
else
throw new ObjectNotFoundException(stepPath + " not found", "");
}
@@ -172,12 +175,12 @@ public class Workflow extends CompositeActivity implements C2KLocalObject * @throws AccessRightsException
* @throws InvalidTransitionException
*/
- public void initialise(int systemKey, AgentPath agent) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException
+ public void initialise(ItemPath itemPath, AgentPath agent) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException
{
- itemSysKey = systemKey;
+ setItemPath(itemPath);
try
{
- runFirst(agent, systemKey);
+ runFirst(agent, itemPath);
}
catch (InvalidDataException ex)
{
@@ -188,13 +191,22 @@ public class Workflow extends CompositeActivity implements C2KLocalObject }
}
- public Integer getItemSysKey() {
- return itemSysKey;
+ public ItemPath getItemPath() {
+ return itemPath;
}
- public void setItemSysKey(Integer itemSysKey) {
- this.itemSysKey = itemSysKey;
+ public void setItemPath(ItemPath itemPath) {
+ this.itemPath = itemPath;
}
+
+ public void setItemUUID( String uuid )
+ {
+ setItemPath(new ItemPath(UUID.fromString(uuid)));
+ }
+
+ public String getItemUUID() {
+ return getItemPath().getUUID().toString();
+ }
/**
* if type = 0 only domain steps will be queried if type = 1 only predefined steps will be queried else both will be queried
@@ -204,14 +216,15 @@ public class Workflow extends CompositeActivity implements C2KLocalObject * @return
* @throws ObjectNotFoundException
* @throws InvalidDataException
+ * @throws InvalidAgentPathException
*/
- public ArrayList<Job> calculateJobs(AgentPath agent, int itemSysKey, int type) throws ObjectNotFoundException, InvalidDataException
+ public ArrayList<Job> calculateJobs(AgentPath agent, ItemPath itemPath, int type) throws ObjectNotFoundException, InvalidDataException, InvalidAgentPathException
{
ArrayList<Job> jobs = new ArrayList<Job>();
if (type != 1)
- jobs.addAll(((CompositeActivity) search("workflow/domain")).calculateJobs(agent, itemSysKey, true));
+ jobs.addAll(((CompositeActivity) search("workflow/domain")).calculateJobs(agent, itemPath, true));
if (type != 0)
- jobs.addAll(((CompositeActivity) search("workflow/predefined")).calculateJobs(agent, itemSysKey, true));
+ jobs.addAll(((CompositeActivity) search("workflow/predefined")).calculateJobs(agent, itemPath, true));
return jobs;
}
/**
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/XOrSplit.java b/src/main/java/com/c2kernel/lifecycle/instance/XOrSplit.java index 65bd4ba..f5d9432 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/XOrSplit.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/XOrSplit.java @@ -10,6 +10,7 @@ import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.common.PersistencyException;
import com.c2kernel.graph.model.DirectedEdge;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.scripting.ScriptingEngineException;
import com.c2kernel.utils.Logger;
@@ -28,14 +29,14 @@ public class XOrSplit extends Split }
@Override
- public void runNext(AgentPath agent, int itemSysKey) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
+ public void runNext(AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException
{
ArrayList<DirectedEdge> nextsToFollow = new ArrayList<DirectedEdge>();
String nexts;
String scriptName = (String) getProperties().get("RoutingScriptName");
Integer scriptVersion = getVersionNumberProperty("RoutingScriptVersion");
try {
- nexts = this.evaluateScript(scriptName, scriptVersion, itemSysKey).toString();
+ nexts = this.evaluateScript(scriptName, scriptVersion, itemPath).toString();
} catch (ScriptingEngineException e) {
Logger.error(e);
throw new InvalidDataException("Error running routing script "+scriptName+" v"+scriptVersion, "");
@@ -55,12 +56,12 @@ public class XOrSplit extends Split if (nextsToFollow.size() != 1)
throw new InvalidDataException("not good number of active next", null);
- followNext((Next)nextsToFollow.get(0), agent, itemSysKey);
+ followNext((Next)nextsToFollow.get(0), agent, itemPath);
}
- public void followNext(Next activeNext, AgentPath agent, int itemSysKey) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException {
- activeNext.getTerminusVertex().run(agent, itemSysKey);
+ public void followNext(Next activeNext, AgentPath agent, ItemPath itemPath) throws InvalidDataException, InvalidTransitionException, AccessRightsException, ObjectNotFoundException, PersistencyException {
+ activeNext.getTerminusVertex().run(agent, itemPath);
}
}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddC2KObject.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddC2KObject.java index 8416820..893ecea 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddC2KObject.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddC2KObject.java @@ -11,9 +11,12 @@ package com.c2kernel.lifecycle.instance.predefined;
+import java.util.Arrays;
+
import com.c2kernel.common.InvalidDataException;
import com.c2kernel.entity.C2KLocalObject;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.process.Gateway;
import com.c2kernel.utils.Logger;
@@ -35,25 +38,20 @@ public class AddC2KObject extends PredefinedStep //requestdata is xmlstring
@Override
- protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ protected String runActivityLogic(AgentPath agent, ItemPath item,
int transitionID, String requestData) throws InvalidDataException {
- Logger.msg(1, "AddC2KObject::request() - Starting.");
-
+ String[] params = getDataList(requestData);
+ if (Logger.doLog(3)) Logger.msg(3, "AddC2KObject: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
try
{
-
- Logger.msg(5, "AddC2KObject::request() - data:" + getDataList(requestData)[0]);
- C2KLocalObject obj = (C2KLocalObject)Gateway.getMarshaller().unmarshall(getDataList(requestData)[0]);
- Gateway.getStorage().put(itemSysKey, obj, null );
- Logger.msg(1, "AddC2KObject::request() - DONE.");
+ C2KLocalObject obj = (C2KLocalObject)Gateway.getMarshaller().unmarshall(params[0]);
+ Gateway.getStorage().put(item, obj, null );
return requestData;
}
catch( Exception ex )
{
- Logger.error("AddC2KObject::request() - during unmarshall.");
- Logger.error(ex);
- throw new InvalidDataException(ex.toString(), "");
+ throw unknownException(ex);
}
}
}
\ No newline at end of file diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddDomainPath.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddDomainPath.java index 4c02cbb..daa8fcc 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddDomainPath.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddDomainPath.java @@ -10,10 +10,11 @@ package com.c2kernel.lifecycle.instance.predefined; +import java.util.Arrays;
+
import com.c2kernel.common.InvalidDataException;
import com.c2kernel.lookup.AgentPath;
import com.c2kernel.lookup.DomainPath;
-import com.c2kernel.lookup.InvalidItemPathException;
import com.c2kernel.lookup.ItemPath;
import com.c2kernel.lookup.LookupManager;
import com.c2kernel.process.Gateway;
@@ -28,30 +29,22 @@ public class AddDomainPath extends PredefinedStep //requestdata is xmlstring
@Override
- protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ protected String runActivityLogic(AgentPath agent, ItemPath item,
int transitionID, String requestData) throws InvalidDataException {
- Logger.msg(1,"AddAlias::request() - Starting.");
+ String[] params = getDataList(requestData);
+ if (Logger.doLog(3)) Logger.msg(3, "AddDomainPath: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
try
{
LookupManager lookupManager = Gateway.getLookupManager();
- DomainPath domainPath = new DomainPath(getDataList(requestData)[0], new ItemPath(itemSysKey));
+ DomainPath domainPath = new DomainPath(params[0], item);
lookupManager.add(domainPath);
- Logger.msg(8,"AddDomainPath::request() - systemKey:" + itemSysKey +
- ". Adding dompath. DONE.");
return requestData;
}
- catch (InvalidItemPathException ex)
- {
- Logger.error(ex);
- throw new InvalidDataException(ex.toString(), "");
- }
catch( Exception ex )
{
- Logger.error("AddDomainPath::request() - during anyHelper.extract.");
- Logger.error(ex);
- throw new InvalidDataException(ex.toString(), "");
+ throw unknownException(ex);
}
}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddMemberToCollection.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddMemberToCollection.java index 98ef8e3..889ee80 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddMemberToCollection.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddMemberToCollection.java @@ -12,12 +12,16 @@ package com.c2kernel.lifecycle.instance.predefined;
+import java.util.Arrays;
+import java.util.UUID;
+
import com.c2kernel.collection.Dependency;
import com.c2kernel.collection.MembershipException;
import com.c2kernel.common.InvalidDataException;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.entity.C2KLocalObject;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.process.Gateway;
@@ -48,59 +52,55 @@ public class AddMemberToCollection extends PredefinedStep * 1 - target entity key
*/
@Override
- protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ protected String runActivityLogic(AgentPath agent, ItemPath item,
int transitionID, String requestData) throws InvalidDataException {
String collName;
- int entityKey;
+ ItemPath newChild;
Dependency dep;
CastorHashMap props = null;
- Logger.msg(1, "AddMemberToCollection::request() - Starting.");
-
// extract parameters
+ String[] params = getDataList(requestData);
+ if (Logger.doLog(3)) Logger.msg(3, "AddMemberToCollection: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
try {
- String[] params = getDataList(requestData);
collName = params[0];
- entityKey = Integer.parseInt(params[1]);
+ newChild = new ItemPath(UUID.fromString(params[1]));
if (params.length > 2)
props = (CastorHashMap)Gateway.getMarshaller().unmarshall(params[2]);
} catch (Exception e) {
- throw new InvalidDataException("Invalid parameters", "");
+ throw new InvalidDataException("AddMemberToCollection: Invalid parameters "+Arrays.toString(params), "");
}
// load collection
C2KLocalObject collObj;
try {
- collObj = Gateway.getStorage().get(itemSysKey, ClusterStorage.COLLECTION+"/"+collName, null);
+ collObj = Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName, null);
} catch (ObjectNotFoundException ex) {
- throw new InvalidDataException("Collection '"+collName+"' not found in this Item", "");
+ throw new InvalidDataException("AddMemberToCollection: Collection '"+collName+"' not found in this Item", "");
} catch (ClusterStorageException ex) {
Logger.error(ex);
- throw new InvalidDataException("Error loading collection '\"+collName+\"': "+ex.getMessage(), "");
+ throw new InvalidDataException("AddMemberToCollection: Error loading collection '\"+collName+\"': "+ex.getMessage(), "");
}
- if (!(collObj instanceof Dependency)) throw new InvalidDataException("AddMemberToCollection operates on Dependency collections only.", "");
+ if (!(collObj instanceof Dependency)) throw new InvalidDataException("AddMemberToCollection: AddMemberToCollection operates on Dependency collections only.", "");
dep = (Dependency)collObj;
// find member and assign entity
try {
if (props == null)
- dep.addMember(entityKey);
+ dep.addMember(newChild);
else
- dep.addMember(entityKey, props, null);
+ dep.addMember(newChild, props, null);
} catch (MembershipException e) {
- throw new InvalidDataException("Entity "+entityKey+" is the wrong type for this collection", "");
+ throw new InvalidDataException("AddMemberToCollection: Item "+newChild+" is the wrong type for this collection", "");
}
try {
- Gateway.getStorage().put(itemSysKey, dep, null);
+ Gateway.getStorage().put(newChild, dep, null);
} catch (ClusterStorageException e) {
- Logger.error(e);
- throw new InvalidDataException("Error storing collection", "");
+ throw unknownException(e);
}
-
- Logger.msg(1, "AddMemberToCollection::request() - DONE.");
return requestData;
}
}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewSlot.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewSlot.java index e38f71d..257c644 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewSlot.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewSlot.java @@ -12,11 +12,15 @@ package com.c2kernel.lifecycle.instance.predefined;
+import java.util.Arrays;
+import java.util.UUID;
+
import com.c2kernel.collection.Aggregation;
import com.c2kernel.common.InvalidDataException;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.entity.C2KLocalObject;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.process.Gateway;
@@ -50,46 +54,46 @@ public class AddNewSlot extends PredefinedStep * 1 - Item Description key (optional)
*/
@Override
- protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ protected String runActivityLogic(AgentPath agent, ItemPath item,
int transitionID, String requestData) throws InvalidDataException {
String collName;
- int descKey=-1;
+ ItemPath descKey = null;
Aggregation agg;
- Logger.msg(1, "AddNewSlot::request() - Starting.");
-
// extract parameters
+ String[] params = getDataList(requestData);
+ if (Logger.doLog(3)) Logger.msg(3, "AddNewSlot: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
+
try {
- String[] params = getDataList(requestData);
collName = params[0];
- if (params.length > 1) descKey = Integer.parseInt(params[1]);
+ if (params.length > 1 && params[1].length() > 0) descKey = new ItemPath(UUID.fromString(params[1]));
} catch (Exception e) {
- throw new InvalidDataException("Invalid parameters", "");
+ throw new InvalidDataException("AddNewSlot: Invalid parameters "+Arrays.toString(params), "");
}
// load collection
C2KLocalObject collObj;
try {
- collObj = Gateway.getStorage().get(itemSysKey, ClusterStorage.COLLECTION+"/"+collName, null);
+ collObj = Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName, null);
} catch (ObjectNotFoundException ex) {
- throw new InvalidDataException("Collection '"+collName+"' not found in this Item", "");
+ throw new InvalidDataException("AddNewSlot: Collection '"+collName+"' not found in this Item", "");
} catch (ClusterStorageException ex) {
Logger.error(ex);
- throw new InvalidDataException("Error loading collection '\"+collName+\"': "+ex.getMessage(), "");
+ throw new InvalidDataException("AddNewSlot: Error loading collection '\"+collName+\"': "+ex.getMessage(), "");
}
- if (!(collObj instanceof Aggregation)) throw new InvalidDataException("AddNewSlot operates on Aggregation collections only.", "");
+ if (!(collObj instanceof Aggregation)) throw new InvalidDataException("AddNewSlot: AddNewSlot operates on Aggregation collections only.", "");
agg = (Aggregation)collObj;
// get props
CastorHashMap props = new CastorHashMap();
StringBuffer classProps = new StringBuffer();
- if (descKey > -1) {
+ if (descKey != null) {
PropertyDescriptionList propList;
try {
propList = PropertyUtility.getPropertyDescriptionOutcome(descKey);
} catch (ObjectNotFoundException e) {
- throw new InvalidDataException("Item "+descKey+" does not contain a PropertyDescription outcome to define a slot", "");
+ throw new InvalidDataException("AddNewSlot: Item "+descKey+" does not contain a PropertyDescription outcome to define a slot", "");
}
for (PropertyDescription pd : propList.list) {
props.put(pd.getName(), pd.getDefaultValue());
@@ -101,13 +105,12 @@ public class AddNewSlot extends PredefinedStep agg.addSlot(props, classProps.toString());
try {
- Gateway.getStorage().put(itemSysKey, agg, null);
+ Gateway.getStorage().put(item, agg, null);
} catch (ClusterStorageException e) {
Logger.error(e);
- throw new InvalidDataException("Error storing collection", "");
+ throw new InvalidDataException("AddNewSlot: Error storing collection", "");
}
- Logger.msg(1, "AddNewSlot::request() - DONE.");
return requestData;
}
}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AssignItemToSlot.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AssignItemToSlot.java index 78d4087..724e974 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AssignItemToSlot.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AssignItemToSlot.java @@ -12,6 +12,9 @@ package com.c2kernel.lifecycle.instance.predefined;
+import java.util.Arrays;
+import java.util.UUID;
+
import com.c2kernel.collection.Aggregation;
import com.c2kernel.collection.AggregationMember;
import com.c2kernel.collection.MembershipException;
@@ -19,6 +22,7 @@ import com.c2kernel.common.InvalidDataException; import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.entity.C2KLocalObject;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.process.Gateway;
@@ -47,67 +51,64 @@ public class AssignItemToSlot extends PredefinedStep * 2 - target entity key
*/
@Override
- protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ protected String runActivityLogic(AgentPath agent, ItemPath item,
int transitionID, String requestData) throws InvalidDataException {
String collName;
int slotNo;
- int sysKey;
+ ItemPath childItem;
Aggregation agg;
- Logger.msg(1, "AssignItemToSlot::request() - Starting.");
-
-
// extract parameters
+ String[] params = getDataList(requestData);
+ if (Logger.doLog(3)) Logger.msg(3, "AssignItemToSlot: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
+
try {
- String[] params = getDataList(requestData);
collName = params[0];
slotNo = Integer.parseInt(params[1]);
- sysKey = Integer.parseInt(params[2]);
+ childItem = new ItemPath(UUID.fromString(params[2]));
} catch (Exception e) {
- throw new InvalidDataException("Invalid parameters", "");
+ throw new InvalidDataException("AssignItemToSlot: Invalid parameters "+Arrays.toString(params), "");
}
// load collection
C2KLocalObject collObj;
try {
- collObj = Gateway.getStorage().get(itemSysKey, ClusterStorage.COLLECTION+"/"+collName, null);
+ collObj = Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName, null);
} catch (ObjectNotFoundException ex) {
- throw new InvalidDataException("Collection '"+collName+"' not found in this Item", "");
+ throw new InvalidDataException("AssignItemToSlot: Collection '"+collName+"' not found in this Item", "");
} catch (ClusterStorageException ex) {
Logger.error(ex);
- throw new InvalidDataException("Error loading collection '\"+collName+\"': "+ex.getMessage(), "");
+ throw new InvalidDataException("AssignItemToSlot: Error loading collection '\"+collName+\"': "+ex.getMessage(), "");
}
- if (!(collObj instanceof Aggregation)) throw new InvalidDataException("AssignItemToSlot operates on Aggregation collections only.", "");
+ if (!(collObj instanceof Aggregation)) throw new InvalidDataException("AssignItemToSlot: AssignItemToSlot operates on Aggregation collections only.", "");
agg = (Aggregation)collObj;
// find member and assign entity
boolean stored = false;
for (AggregationMember member : agg.getMembers().list) {
if (member.getID() == slotNo) {
- if (member.getSystemKey() > -1)
- throw new InvalidDataException("Member slot not empty", "");
+ if (member.getItemPath() != null)
+ throw new InvalidDataException("AssignItemToSlot: Member slot "+slotNo+" not empty", "");
try {
- member.assignItem(sysKey);
+ member.assignItem(childItem);
} catch (MembershipException e) {
- throw new InvalidDataException("Entity "+sysKey+" does not fit in this slot", "");
+ throw new InvalidDataException("AssignItemToSlot: Item "+childItem+" does not fit in slot "+slotNo, "");
}
stored = true;
break;
}
}
if (!stored) {
- throw new InvalidDataException("Member slot "+slotNo+" not found.", "");
+ throw new InvalidDataException("AssignItemToSlot: Member slot "+slotNo+" not found.", "");
}
try {
- Gateway.getStorage().put(itemSysKey, agg, null);
+ Gateway.getStorage().put(item, agg, null);
} catch (ClusterStorageException e) {
- Logger.error(e);
- throw new InvalidDataException("Error storing collection", "");
+ unknownException(e);
}
- Logger.msg(1, "AssignItemToSlot::request() - DONE.");
return requestData;
}
}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/ClearSlot.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/ClearSlot.java index 772f62e..c6bb654 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/ClearSlot.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/ClearSlot.java @@ -12,11 +12,14 @@ package com.c2kernel.lifecycle.instance.predefined;
+import java.util.Arrays;
+
import com.c2kernel.collection.Aggregation;
import com.c2kernel.collection.AggregationMember;
import com.c2kernel.common.InvalidDataException;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.process.Gateway;
@@ -44,40 +47,40 @@ public class ClearSlot extends PredefinedStep * 1 - slot number
*/
@Override
- protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ protected String runActivityLogic(AgentPath agent, ItemPath item,
int transitionID, String requestData) throws InvalidDataException {
String collName;
int slotNo;
Aggregation agg;
- Logger.msg(1, "ClearSlot::request() - Starting.");
-
// extract parameters
+ String[] params = getDataList(requestData);
+ if (Logger.doLog(3)) Logger.msg(3, "ClearSlot: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
+
try {
- String[] params = getDataList(requestData);
collName = params[0];
slotNo = Integer.parseInt(params[1]);
} catch (Exception e) {
- throw new InvalidDataException("Invalid parameters", "");
+ throw new InvalidDataException("ClearSlot: Invalid parameters "+Arrays.toString(params), "");
}
// load collection
try {
- agg = (Aggregation)Gateway.getStorage().get(itemSysKey, ClusterStorage.COLLECTION+"/"+collName, null);
+ agg = (Aggregation)Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName, null);
} catch (ObjectNotFoundException ex) {
- throw new InvalidDataException("Collection '"+collName+"' not found in this Item", "");
+ throw new InvalidDataException("ClearSlot: Collection '"+collName+"' not found in this Item", "");
} catch (ClusterStorageException ex) {
Logger.error(ex);
- throw new InvalidDataException("Error loading collection '\"+collName+\"': "+ex.getMessage(), "");
+ throw new InvalidDataException("ClearSlot: Error loading collection '"+collName+"': "+ex.getMessage(), "");
}
// find member and clear
boolean stored = false;
for (AggregationMember member : agg.getMembers().list) {
if (member.getID() == slotNo) {
- if (member.getSystemKey() > -1)
- throw new InvalidDataException("Member slot already empty", "");
+ if (member.getItemPath() != null)
+ throw new InvalidDataException("ClearSlot: Member slot "+slotNo+" already empty", "");
member.clearItem();
stored = true;
break;
@@ -89,12 +92,11 @@ public class ClearSlot extends PredefinedStep try {
- Gateway.getStorage().put(itemSysKey, agg, null);
+ Gateway.getStorage().put(item, agg, null);
} catch (ClusterStorageException e) {
Logger.error(e);
throw new InvalidDataException("Error storing collection", "");
}
- Logger.msg(1, "ClearSlot::request() - DONE.");
return requestData;
}
}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/Import.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/Import.java index 29d4c54..8a80d60 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/Import.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/Import.java @@ -7,10 +7,13 @@ package com.c2kernel.lifecycle.instance.predefined;
+import java.util.Arrays;
+
import com.c2kernel.common.InvalidDataException;
import com.c2kernel.events.Event;
import com.c2kernel.events.History;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.persistency.TransactionManager;
import com.c2kernel.persistency.outcome.Outcome;
@@ -37,19 +40,18 @@ public class Import extends PredefinedStep //requestdata is xmlstring
@Override
- protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ protected String runActivityLogic(AgentPath agent, ItemPath item,
int transitionID, String requestData) throws InvalidDataException {
-
- Logger.msg(8,"Import::request()");
-
- Logger.msg(1,"Import::request() - Starting.");
String[] params = getDataList(requestData);
-
-
+ if (Logger.doLog(3)) Logger.msg(3, "Import: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
+
int split1 = params[0].indexOf('_');
int split2 = params[0].indexOf(':');
+ if (split1 == -1)
+ throw new InvalidDataException("Import: Invalid parameters "+Arrays.toString(params));
+
requestData = params[1];
String schemaName = params[0].substring(0, split1);
@@ -73,17 +75,17 @@ public class Import extends PredefinedStep TransactionManager storage = Gateway.getStorage();
Object locker = getWf();
History hist = getWf().getHistory();
- Event event = hist.addEvent(agent.getAgentName(), getCurrentAgentRole(), getName(), getPath(), getType(), schemaName, schemaVersion, getStateMachine().getName(), getStateMachine().getVersion(), getStateMachine().getTransition(transitionID), viewpoint, timestamp);
+ Event event = hist.addEvent(agent, getCurrentAgentRole(), getName(), getPath(), getType(), schemaName, schemaVersion, getStateMachine().getName(), getStateMachine().getVersion(), getStateMachine().getTransition(transitionID), viewpoint, timestamp);
try {
- storage.put(itemSysKey, new Outcome(event.getID(), requestData, schemaName, schemaVersion), locker);
- storage.put(itemSysKey, new Viewpoint(itemSysKey, schemaName, viewpoint, schemaVersion, event.getID()), locker);
+ storage.put(item, new Outcome(event.getID(), requestData, schemaName, schemaVersion), locker);
+ storage.put(item, new Viewpoint(item, schemaName, viewpoint, schemaVersion, event.getID()), locker);
if (!"last".equals(viewpoint))
- storage.put(itemSysKey, new Viewpoint(itemSysKey, schemaName, "last", schemaVersion, event.getID()), locker);
+ storage.put(item, new Viewpoint(item, schemaName, "last", schemaVersion, event.getID()), locker);
} catch (ClusterStorageException e) {
Logger.error(e);
storage.abort(locker);
- throw new InvalidDataException("Could not store imported outcome. Rolled back.");
+ throw new InvalidDataException("Import: Could not store imported outcome. Rolled back.", "");
}
storage.commit(locker);
return requestData;
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStep.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStep.java index d0fde2a..7a318ba 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStep.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/PredefinedStep.java @@ -12,6 +12,7 @@ import org.w3c.dom.NodeList; import org.w3c.dom.Text;
import org.xml.sax.InputSource;
+import com.c2kernel.common.InvalidDataException;
import com.c2kernel.lifecycle.instance.Activity;
import com.c2kernel.persistency.outcome.Outcome;
import com.c2kernel.utils.Logger;
@@ -121,12 +122,20 @@ public abstract class PredefinedStep extends Activity return xmlData.toString();
}
}
+ public InvalidDataException unknownException(Exception ex) {
+ String stepName = this.getClass().getSimpleName();
+ Logger.error(stepName+": Exception:");
+ Logger.error(ex);
+ return new InvalidDataException(stepName+": "+ex.getClass().getSimpleName()+". See log.", "");
+ }
+
// generic bundling of single parameter
static public String bundleData(String data)
{
return "<PredefinedStepOutcome><param><![CDATA[" + data + "]]></param></PredefinedStepOutcome>";
}
- static public String[] getDataList(String xmlData)
+
+ public static String[] getDataList(String xmlData)
{
try
{
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveC2KObject.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveC2KObject.java index 44d4c5d..fe4e1c8 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveC2KObject.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveC2KObject.java @@ -13,8 +13,11 @@ package com.c2kernel.lifecycle.instance.predefined; +import java.util.Arrays;
+
import com.c2kernel.common.InvalidDataException;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.process.Gateway;
import com.c2kernel.utils.Logger;
@@ -34,28 +37,21 @@ public class RemoveC2KObject extends PredefinedStep //requestdata is xmlstring
@Override
- protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ protected String runActivityLogic(AgentPath agent, ItemPath item,
int transitionID, String requestData) throws InvalidDataException {
- Logger.msg(1, "RemoveC2KObject::request() - Starting.");
+ String[] params = getDataList(requestData);
+ if (Logger.doLog(3)) Logger.msg(3, "RemoveC2KObject: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
- String path = null;
try
{
- path = getDataList(requestData)[0];
-
- Logger.msg(5, "RemoveC2KObject::request() - path:"+path);
-
- Gateway.getStorage().remove( itemSysKey, path, null );
+ String path = params[0];
+ Gateway.getStorage().remove( item, path, null );
}
catch( Exception ex )
{
- Logger.error("RemoveC2KObject::request() - invalid data - path:"+path);
- Logger.error(ex);
- throw new InvalidDataException(ex.toString(), "");
+ throw unknownException(ex);
}
-
- Logger.msg(1, "RemoveC2KObject::request() - DONE.");
return requestData;
}
}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java index df1c44e..4aabd6b 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java @@ -10,10 +10,13 @@ package com.c2kernel.lifecycle.instance.predefined; +import java.util.Arrays;
+
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.LookupManager;
import com.c2kernel.process.Gateway;
import com.c2kernel.utils.Logger;
@@ -27,34 +30,30 @@ public class RemoveDomainPath extends PredefinedStep //requestdata is xmlstring
@Override
- protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ protected String runActivityLogic(AgentPath agent, ItemPath item,
int transitionID, String requestData) throws InvalidDataException {
- Logger.msg(8,"RemoveDomainPath::request()");
-
-
- Logger.msg(1,"RemoveDomainPath::request() - Starting.");
+ String[] params = getDataList(requestData);
+ if (Logger.doLog(3)) Logger.msg(3, "RemoveDomainPath: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
- DomainPath domainPath = new DomainPath(getDataList(requestData)[0]);
+ DomainPath domainPath = new DomainPath(params[0]);
if (!domainPath.exists())
- throw new InvalidDataException("Domain path "+domainPath.toString()+" does not exist.", "");
+ throw new InvalidDataException("RemoveDomainPath: Domain path "+domainPath.toString()+" does not exist.", "");
if (domainPath.getType()!=DomainPath.ENTITY)
try {
- if (domainPath.getEntity().getSysKey() != itemSysKey)
- throw new InvalidDataException("Domain path "+domainPath.toString()+" is not an alias of the current Item "+itemSysKey, "");
+ if (!domainPath.getItemPath().equals(item))
+ throw new InvalidDataException("RemoveDomainPath: Domain path "+domainPath.toString()+" is not an alias of the current Item "+item, "");
} catch (ObjectNotFoundException ex) {
- throw new InvalidDataException("Domain path "+domainPath.toString()+" is a context.", "");
+ throw new InvalidDataException("RemoveDomainPath: Domain path "+domainPath.toString()+" is a context.", "");
}
try {
LookupManager lookupManager = Gateway.getLookupManager();
lookupManager.delete(domainPath);
- Logger.msg(8,"AddAlias::request() - context:" + domainPath.toString() + " DONE.");
return requestData;
} catch (Exception ex) {
- Logger.error(ex);
- throw new InvalidDataException("Problem updating directory", "");
+ throw unknownException(ex);
}
}
}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveSlotFromCollection.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveSlotFromCollection.java index 38638cd..726078b 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveSlotFromCollection.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/RemoveSlotFromCollection.java @@ -12,12 +12,16 @@ package com.c2kernel.lifecycle.instance.predefined;
+import java.util.Arrays;
+import java.util.UUID;
+
import com.c2kernel.collection.Collection;
import com.c2kernel.collection.CollectionMember;
import com.c2kernel.collection.MembershipException;
import com.c2kernel.common.InvalidDataException;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.process.Gateway;
@@ -46,42 +50,57 @@ public class RemoveSlotFromCollection extends PredefinedStep * 2 - target entity key
*/
@Override
- protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ protected String runActivityLogic(AgentPath agent, ItemPath item,
int transitionID, String requestData) throws InvalidDataException {
String collName;
- int slotNo;
- int sysKey = -1;
+ int slotNo = -1;
+ ItemPath currentChild = null;
Collection<? extends CollectionMember> coll;
- Logger.msg(1, "RemoveSlotFromCollection::request() - Starting.");
-
// extract parameters
+ String[] params = getDataList(requestData);
+ if (Logger.doLog(3)) Logger.msg(3, "RemoveSlotFromCollection: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
+
try {
- String[] params = getDataList(requestData);
collName = params[0];
- slotNo = params[1].length()>0?Integer.parseInt(params[1]):-1;
- if (params.length>2) sysKey = params[2].length()>0?Integer.parseInt(params[2]):-1;
+ if (params.length>1 && params[1].length()>0) slotNo = Integer.parseInt(params[1]);
+ if (params.length>2 && params[2].length()>0) currentChild = new ItemPath(UUID.fromString(params[2]));
} catch (Exception e) {
- throw new InvalidDataException("Invalid parameters", "");
+ throw new InvalidDataException("RemoveSlotFromCollection: Invalid parameters "+Arrays.toString(params), "");
}
- if (slotNo == -1 && sysKey == -1)
- throw new InvalidDataException("Must give either slot number or entity key", "");
+ if (slotNo == -1 && currentChild == null)
+ throw new InvalidDataException("RemoveSlotFromCollection: Must give either slot number or entity key", "");
// load collection
try {
- coll = (Collection<? extends CollectionMember>)Gateway.getStorage().get(itemSysKey, ClusterStorage.COLLECTION+"/"+collName, null);
+ coll = (Collection<? extends CollectionMember>)Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName, null);
} catch (ObjectNotFoundException ex) {
- throw new InvalidDataException("Collection '"+collName+"' not found in this Item", "");
+ throw new InvalidDataException("RemoveSlotFromCollection: Collection '"+collName+"' not found in this Item", "");
} catch (ClusterStorageException ex) {
Logger.error(ex);
- throw new InvalidDataException("Error loading collection '\"+collName+\"': "+ex.getMessage(), "");
+ throw new InvalidDataException("RemoveSlotFromCollection: Error loading collection '\"+collName+\"': "+ex.getMessage(), "");
}
+ // check the slot is there if it's given by id
+ CollectionMember slot = null;
+ if (slotNo > -1) {
+ try {
+ slot = coll.getMember(slotNo);
+ } catch (ObjectNotFoundException e) {
+ throw new InvalidDataException("RemoveSlotFromCollection: Slot "+slotNo+" not found in this collection", "");
+ }
+ }
+
+ // if both parameters are supplied, check the given item is actually in that slot
+ if (slot != null && !slot.getItemPath().equals(currentChild)) {
+ throw new InvalidDataException("RemoveSlotFromCollection: Item "+currentChild+" was not in slot "+slotNo, "");
+ }
+
if (slotNo == -1) { // find slot from entity key
for (CollectionMember member : coll.getMembers().list) {
- if (member.getSystemKey() == sysKey) {
+ if (member.getItemPath().equals(currentChild)) {
slotNo = member.getID();
break;
}
@@ -100,12 +119,12 @@ public class RemoveSlotFromCollection extends PredefinedStep // Store the collection
try {
- Gateway.getStorage().put(itemSysKey, coll, null);
+ Gateway.getStorage().put(item, coll, null);
} catch (ClusterStorageException e) {
Logger.error(e);
throw new InvalidDataException("Error storing collection", "");
}
- Logger.msg(1, "RemoveSlotFromCollection::request() - DONE.");
+
return requestData;
}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/ReplaceDomainWorkflow.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/ReplaceDomainWorkflow.java index 2163d4c..74570a0 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/ReplaceDomainWorkflow.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/ReplaceDomainWorkflow.java @@ -1,11 +1,14 @@ package com.c2kernel.lifecycle.instance.predefined;
//Java
+import java.util.Arrays;
+
import com.c2kernel.common.InvalidDataException;
import com.c2kernel.graph.model.GraphPoint;
import com.c2kernel.lifecycle.instance.CompositeActivity;
import com.c2kernel.lifecycle.instance.Workflow;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.process.Gateway;
import com.c2kernel.utils.Logger;
@@ -18,33 +21,31 @@ public class ReplaceDomainWorkflow extends PredefinedStep }
@Override
- protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ protected String runActivityLogic(AgentPath agent, ItemPath item,
int transitionID, String requestData) throws InvalidDataException {
+
Workflow lifeCycle = getWf();
-
- Logger.msg(1, "ReplaceDomainWorkflow::request() - Starting ");
-
+
+ String[] params = getDataList(requestData);
+ if (Logger.doLog(3)) Logger.msg(3, "AddC2KObject: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
+
try
{
- Logger.msg(8, "ReplaceDomainWorkflow::request() - data:" + getDataList(requestData)[0]);
lifeCycle.getChildGraphModel().removeVertex(lifeCycle.search("workflow/domain"));
- CompositeActivity domain = (CompositeActivity) Gateway.getMarshaller().unmarshall(getDataList(requestData)[0]);
+ CompositeActivity domain = (CompositeActivity) Gateway.getMarshaller().unmarshall(params[0]);
domain.setName("domain");
lifeCycle.initChild(domain, true, new GraphPoint(150, 100));
// if new workflow, activate it, otherwise refresh the jobs
- if (!domain.active) lifeCycle.run(agent, itemSysKey);
- else lifeCycle.refreshJobs(itemSysKey);
+ if (!domain.active) lifeCycle.run(agent, item);
+ else lifeCycle.refreshJobs(item);
// store new wf
- Gateway.getStorage().put(itemSysKey, lifeCycle, null);
- Logger.msg(1, "ReplaceDomainWorkflow::request() - DONE.");
+ Gateway.getStorage().put(item, lifeCycle, null);
return requestData;
}
catch (Exception ex)
{
- Logger.error("ReplaceDomainWorkflow::request() - during unmarshall.");
- Logger.error(ex);
- throw new InvalidDataException("ReplaceDomainWorkflow::request() - during unmarshall.", null);
+ throw unknownException(ex);
}
}
}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteProperty.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteProperty.java index abb0e95..079f8e0 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteProperty.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteProperty.java @@ -11,9 +11,12 @@ package com.c2kernel.lifecycle.instance.predefined;
+import java.util.Arrays;
+
import com.c2kernel.common.InvalidDataException;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.process.Gateway;
@@ -37,16 +40,14 @@ public class WriteProperty extends PredefinedStep //requestdata is xmlstring
@Override
- protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ protected String runActivityLogic(AgentPath agent, ItemPath item,
int transitionID, String requestData) throws InvalidDataException {
- Logger.msg(1, "WriteProperty::request() - Starting.");
String[] params = getDataList(requestData);
+ if (Logger.doLog(3)) Logger.msg(3, "WriteProperty: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
if (params.length != 2)
- throw new InvalidDataException("WriteProperty usage: [ name, value ]", "");
-
- Logger.msg(5, "WriteProperty::request() - name:" + params[0] +" val:"+params[1]);
+ throw new InvalidDataException("WriteProperty: invalid parameters "+Arrays.toString(params), "");
String name = params[0];
String newValue = params[1];
@@ -54,19 +55,17 @@ public class WriteProperty extends PredefinedStep Property prop;
try {
- prop = (Property)Gateway.getStorage().get(itemSysKey, ClusterStorage.PROPERTY+"/"+name, null);
+ prop = (Property)Gateway.getStorage().get(item, ClusterStorage.PROPERTY+"/"+name, null);
if (!prop.isMutable() && !newValue.equals(prop.getValue()))
- throw new InvalidDataException("Property '"+name+"' is not mutable.", "");
+ throw new InvalidDataException("WriteProperty: Property '"+name+"' is not mutable.", "");
prop.setValue(newValue);
- Gateway.getStorage().put(itemSysKey, prop, null);
+ Gateway.getStorage().put(item, prop, null);
} catch (ObjectNotFoundException e) {
throw new InvalidDataException("WriteProperty: Property '"+name+"' not found.", "");
} catch (ClusterStorageException e) {
- Logger.error(e);
- throw new InvalidDataException("Storage error. See logs.", "");
+ throw unknownException(e);
}
- Logger.msg(1, "WriteProperty::request() - DONE.");
return requestData;
}
}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteViewpoint.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteViewpoint.java index 741a9a2..e64aceb 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteViewpoint.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/WriteViewpoint.java @@ -1,9 +1,12 @@ package com.c2kernel.lifecycle.instance.predefined;
+import java.util.Arrays;
+
import com.c2kernel.common.InvalidDataException;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.events.Event;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.persistency.outcome.Viewpoint;
@@ -17,19 +20,19 @@ public class WriteViewpoint extends PredefinedStep { }
@Override
- protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ protected String runActivityLogic(AgentPath agent, ItemPath item,
int transitionID, String requestData) throws InvalidDataException {
String schemaName;
String viewName;
int evId;
-
- Logger.msg(1, "WriteViewpoint::request() - Starting.");
+
String[] params = getDataList(requestData);
+ if (Logger.doLog(3)) Logger.msg(3, "WriteViewpoint: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
// outcometype, name and evId. Event and Outcome should be checked so schema version should be discovered.
if (params.length != 3)
- throw new InvalidDataException("WriteViewpoint usage: [ schemaName, viewName, eventId ]", "");
+ throw new InvalidDataException("WriteViewpoint: Invalid parameters "+Arrays.toString(params), "");
schemaName = params[0];
viewName = params[1];
@@ -37,29 +40,29 @@ public class WriteViewpoint extends PredefinedStep { try {
evId = Integer.parseInt(params[2]);
} catch (NumberFormatException ex) {
- throw new InvalidDataException("Parameter 3 (EventId) must be an integer", "");
+ throw new InvalidDataException("WriteViewpoint: Parameter 3 (EventId) must be an integer", "");
}
// Find event
Event ev;
try {
- ev = (Event)Gateway.getStorage().get(itemSysKey, ClusterStorage.HISTORY+"/"+evId, null);
+ ev = (Event)Gateway.getStorage().get(item, ClusterStorage.HISTORY+"/"+evId, null);
} catch (ObjectNotFoundException e) {
Logger.error(e);
- throw new InvalidDataException("Event "+evId+" not found", "");
+ throw new InvalidDataException("WriteViewpoint: Event "+evId+" not found", "");
} catch (ClusterStorageException e) {
Logger.error(e);
- throw new InvalidDataException("Exception loading event", "");
+ throw new InvalidDataException("WriteViewpoint: Exception loading event", "");
}
// Write new viewpoint
- Viewpoint newView = new Viewpoint(itemSysKey, schemaName, viewName, ev.getSchemaVersion(), evId);
+ Viewpoint newView = new Viewpoint(item, schemaName, viewName, ev.getSchemaVersion(), evId);
try {
- Gateway.getStorage().put(itemSysKey, newView, null);
+ Gateway.getStorage().put(item, newView, null);
} catch (ClusterStorageException e) {
Logger.error(e);
- throw new InvalidDataException("Could not store new viewpoint", "");
+ throw new InvalidDataException("WriteViewpoint: Could not store new viewpoint", "");
}
return requestData;
}
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/CreateAgentFromDescription.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/CreateAgentFromDescription.java index a7971f3..520f70f 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/CreateAgentFromDescription.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/CreateAgentFromDescription.java @@ -19,6 +19,7 @@ import com.c2kernel.entity.CorbaServer; import com.c2kernel.entity.agent.ActiveEntity;
import com.c2kernel.lifecycle.instance.predefined.item.CreateItemFromDescription;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.lookup.RolePath;
import com.c2kernel.process.Gateway;
import com.c2kernel.utils.Logger;
@@ -42,7 +43,7 @@ public class CreateAgentFromDescription extends CreateItemFromDescription * @see com.c2kernel.lifecycle.instance.predefined.item.CreateItemFromDescription#runActivityLogic(com.c2kernel.lookup.AgentPath, int, int, java.lang.String)
*/
@Override
- protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ protected String runActivityLogic(AgentPath agent, ItemPath itemPath,
int transitionID, String requestData) throws InvalidDataException {
String[] input = getDataList(requestData);
@@ -67,8 +68,8 @@ public class CreateAgentFromDescription extends CreateItemFromDescription } catch (ObjectNotFoundException ex) { }
// generate new entity key
- Logger.msg(6, "CreateItemFromDescription - Requesting new sysKey");
- AgentPath newAgentPath = Gateway.getNextKeyManager().generateNextAgentKey();
+ Logger.msg(6, "CreateItemFromDescription - Requesting new agent path");
+ AgentPath newAgentPath = new AgentPath(newName);
// resolve the item factory
Logger.msg(6, "CreateItemFromDescription - Resolving item factory");
@@ -77,7 +78,7 @@ public class CreateAgentFromDescription extends CreateItemFromDescription Logger.msg(3, "CreateItemFromDescription - Creating Item");
CorbaServer factory = Gateway.getCorbaServer();
if (factory == null) throw new AccessRightsException("This process cannot create new Items", "");
- ActiveEntity newAgent = (ActiveEntity)factory.createEntity(newAgentPath);
+ ActiveEntity newAgent = factory.createAgent(newAgentPath);
Gateway.getLookupManager().add(newAgentPath);
// initialise it with its properties and workflow
@@ -85,10 +86,10 @@ public class CreateAgentFromDescription extends CreateItemFromDescription Logger.msg(3, "CreateItemFromDescription - Initializing Item");
newAgent.initialise(
- agent.getSysKey(),
- Gateway.getMarshaller().marshall(getNewProperties(itemSysKey, newName, agent)),
- Gateway.getMarshaller().marshall(getNewWorkflow(itemSysKey)),
- Gateway.getMarshaller().marshall(getNewCollections(itemSysKey))
+ agent.getSystemKey(),
+ Gateway.getMarshaller().marshall(getNewProperties(itemPath, newName, agent)),
+ Gateway.getMarshaller().marshall(getNewWorkflow(itemPath)),
+ Gateway.getMarshaller().marshall(getNewCollections(itemPath))
);
// add roles if given
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/RemoveAgent.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/RemoveAgent.java index 0630f6c..735a17d 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/RemoveAgent.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/RemoveAgent.java @@ -6,7 +6,8 @@ import com.c2kernel.common.ObjectCannotBeUpdated; import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.lifecycle.instance.predefined.PredefinedStep;
import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.InvalidItemPathException;
+import com.c2kernel.lookup.InvalidAgentPathException;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.lookup.RolePath;
import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.process.Gateway;
@@ -19,16 +20,16 @@ public class RemoveAgent extends PredefinedStep { }
@Override
- protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ protected String runActivityLogic(AgentPath agent, ItemPath itemPath,
int transitionID, String requestData) throws InvalidDataException {
Logger.msg(1, "RemoveAgent::request() - Starting.");
AgentPath targetAgent;
try {
- targetAgent = new AgentPath(itemSysKey);
- } catch (InvalidItemPathException ex) {
- throw new InvalidDataException("Could not resolve syskey "+itemSysKey+" as an Agent.");
+ targetAgent = new AgentPath(itemPath);
+ } catch (InvalidAgentPathException ex) {
+ throw new InvalidDataException("Could not resolve "+itemPath+" as an Agent.");
}
String agentName = targetAgent.getAgentName();
@@ -49,7 +50,7 @@ public class RemoveAgent extends PredefinedStep { //clear out all storages
try {
- Gateway.getStorage().removeCluster(targetAgent.getSysKey(), "", null);
+ Gateway.getStorage().removeCluster(targetAgent, "", null);
} catch (ClusterStorageException e) {
Logger.error(e);
throw new InvalidDataException("Error deleting storage for "+agentName, "");
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/SetAgentPassword.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/SetAgentPassword.java index 09fdefe..6c0caaa 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/SetAgentPassword.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/SetAgentPassword.java @@ -9,6 +9,7 @@ import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.lifecycle.instance.predefined.PredefinedStep;
import com.c2kernel.lookup.AgentPath;
import com.c2kernel.lookup.InvalidItemPathException;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.process.Gateway;
import com.c2kernel.utils.Logger;
@@ -19,16 +20,16 @@ public class SetAgentPassword extends PredefinedStep { }
@Override
- protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ protected String runActivityLogic(AgentPath agent, ItemPath item,
int transitionID, String requestData) throws InvalidDataException {
Logger.msg(1, "SetAgentPassword::request() - Starting.");
AgentPath targetAgent;
try {
- targetAgent = new AgentPath(itemSysKey);
+ targetAgent = new AgentPath(item);
} catch (InvalidItemPathException ex) {
- throw new InvalidDataException("Could not resolve syskey "+itemSysKey+" as an Agent.");
+ throw new InvalidDataException("Could not resolve syskey "+item+" as an Agent.");
}
String agentName = targetAgent.getAgentName();
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/SetAgentRoles.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/SetAgentRoles.java index 8bcba30..8cdcc49 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/SetAgentRoles.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/SetAgentRoles.java @@ -7,6 +7,7 @@ import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.lifecycle.instance.predefined.PredefinedStep;
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,7 +19,7 @@ public class SetAgentRoles extends PredefinedStep { }
@Override
- protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ protected String runActivityLogic(AgentPath agent, ItemPath item,
int transitionID, String requestData) throws InvalidDataException {
Logger.msg(1, "SetAgentRoles::request() - Starting.");
@@ -26,9 +27,9 @@ public class SetAgentRoles extends PredefinedStep { String[] params = getDataList(requestData);
AgentPath targetAgent;
try {
- targetAgent = new AgentPath(itemSysKey);
+ targetAgent = new AgentPath(item);
} catch (InvalidItemPathException ex) {
- throw new InvalidDataException("Could not resolve syskey "+itemSysKey+" as an Agent.");
+ throw new InvalidDataException("Could not resolve syskey "+item+" as an Agent.");
}
RolePath[] currentRoles = targetAgent.getRoles();
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java index 728631c..60218e8 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java @@ -53,7 +53,7 @@ public class CreateItemFromDescription extends PredefinedStep //requestdata is xmlstring
@Override
- protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ protected String runActivityLogic(AgentPath agent, ItemPath itemPath,
int transitionID, String requestData) throws InvalidDataException {
String[] input = getDataList(requestData);
@@ -65,17 +65,17 @@ public class CreateItemFromDescription extends PredefinedStep try {
// check if the path is already taken
DomainPath context = new DomainPath(new DomainPath(domPath), newName);
- Logger.debug(8,"context "+context.getSysKey()+" "+context.getPath()+" "+context.getString());
- if (context.getSysKey()!=-1)
- throw new ObjectAlreadyExistsException("The item name " +newName+ " exists already.", "");
+ //Logger.debug(8,"context "+context.getItemPath()+" "+context.getPath()+" "+context.getString());
+ if (context.exists())
+ throw new ObjectAlreadyExistsException("The path " +context+ " exists already.", "");
// get init objects
/* ITEM CREATION */
// generate new entity key
- Logger.msg(6, "CreateItemFromDescription - Requesting new sysKey");
- ItemPath entityPath = Gateway.getNextKeyManager().generateNextEntityKey();
+ Logger.msg(6, "CreateItemFromDescription - Requesting new item path");
+ ItemPath newItemPath = new ItemPath();
// resolve the item factory
Logger.msg(6, "CreateItemFromDescription - Resolving item factory");
@@ -84,8 +84,8 @@ public class CreateItemFromDescription extends PredefinedStep Logger.msg(3, "CreateItemFromDescription - Creating Item");
CorbaServer factory = Gateway.getCorbaServer();
if (factory == null) throw new AccessRightsException("This process cannot create new Items", "");
- TraceableEntity newItem = (TraceableEntity)factory.createEntity(entityPath);
- Gateway.getLookupManager().add(entityPath);
+ TraceableEntity newItem = factory.createItem(newItemPath);
+ Gateway.getLookupManager().add(newItemPath);
// initialise it with its properties and workflow
@@ -93,15 +93,15 @@ public class CreateItemFromDescription extends PredefinedStep Logger.msg(3, "CreateItemFromDescription - Initializing Item");
newItem.initialise(
- agent.getSysKey(),
- Gateway.getMarshaller().marshall(getNewProperties(itemSysKey, newName, agent)),
- Gateway.getMarshaller().marshall(getNewWorkflow(itemSysKey)),
- Gateway.getMarshaller().marshall(getNewCollections(itemSysKey))
+ agent.getSystemKey(),
+ Gateway.getMarshaller().marshall(getNewProperties(itemPath, newName, agent)),
+ Gateway.getMarshaller().marshall(getNewWorkflow(itemPath)),
+ Gateway.getMarshaller().marshall(getNewCollections(itemPath))
);
// add its domain path
Logger.msg(3, "CreateItemFromDescription - Creating "+context);
- context.setEntity(entityPath);
+ context.setEntity(newItemPath);
Gateway.getLookupManager().add(context);
return requestData;
} catch (Exception e) {
@@ -111,9 +111,9 @@ public class CreateItemFromDescription extends PredefinedStep }
- protected PropertyArrayList getNewProperties(int itemSysKey, String newName, AgentPath agent) throws ObjectNotFoundException {
+ protected PropertyArrayList getNewProperties(ItemPath itemPath, String newName, AgentPath agent) throws ObjectNotFoundException {
// copy properties -- intend to create from propdesc
- PropertyDescriptionList pdList = PropertyUtility.getPropertyDescriptionOutcome(itemSysKey);
+ PropertyDescriptionList pdList = PropertyUtility.getPropertyDescriptionOutcome(itemPath);
PropertyArrayList props = pdList.instanciate();
// set Name prop or create if not present
boolean foundName = false;
@@ -128,13 +128,13 @@ public class CreateItemFromDescription extends PredefinedStep return props;
}
- protected CompositeActivity getNewWorkflow(int itemSysKey) throws ClusterStorageException, ObjectNotFoundException, InvalidDataException {
+ protected CompositeActivity getNewWorkflow(ItemPath itemPath) throws ClusterStorageException, ObjectNotFoundException, InvalidDataException {
// loop through collections, collecting instantiated descriptions and finding the default workflow def
- String[] collNames = Gateway.getStorage().getClusterContents(itemSysKey, ClusterStorage.COLLECTION);
+ String[] collNames = Gateway.getStorage().getClusterContents(itemPath, ClusterStorage.COLLECTION);
String wfDefName = null; Integer wfDefVer = null;
for (String collName : collNames) {
if (collName.equalsIgnoreCase("workflow")) {
- Collection<? extends CollectionMember> thisCol = (Collection<? extends CollectionMember>)Gateway.getStorage().get(itemSysKey, ClusterStorage.COLLECTION+"/"+collName, null);
+ Collection<? extends CollectionMember> thisCol = (Collection<? extends CollectionMember>)Gateway.getStorage().get(itemPath, ClusterStorage.COLLECTION+"/"+collName, null);
ArrayList<? extends CollectionMember> members = thisCol.getMembers().list;
// get the first member from the wf collection
CollectionMember wfMember = members.get(0);
@@ -164,12 +164,12 @@ public class CreateItemFromDescription extends PredefinedStep }
}
- protected CollectionArrayList getNewCollections(int itemSysKey) throws ClusterStorageException, ObjectNotFoundException {
+ protected CollectionArrayList getNewCollections(ItemPath itemPath) throws ClusterStorageException, ObjectNotFoundException {
// loop through collections, collecting instantiated descriptions and finding the default workflow def
CollectionArrayList colls = new CollectionArrayList();
- String[] collNames = Gateway.getStorage().getClusterContents(itemSysKey, ClusterStorage.COLLECTION);
+ String[] collNames = Gateway.getStorage().getClusterContents(itemPath, ClusterStorage.COLLECTION);
for (String collName : collNames) {
- Collection<? extends CollectionMember> thisCol = (Collection<? extends CollectionMember>)Gateway.getStorage().get(itemSysKey, ClusterStorage.COLLECTION+"/"+collName, null);
+ Collection<? extends CollectionMember> thisCol = (Collection<? extends CollectionMember>)Gateway.getStorage().get(itemPath, ClusterStorage.COLLECTION+"/"+collName, null);
if (thisCol instanceof CollectionDescription) {
CollectionDescription<? extends CollectionMember> thisDesc = (CollectionDescription<? extends CollectionMember>)thisCol;
colls.put(thisDesc.newInstance());
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/Erase.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/Erase.java index 81eb329..b15928a 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/Erase.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/Erase.java @@ -40,7 +40,7 @@ public class Erase extends PredefinedStep //requestdata is xmlstring
@Override
- protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ protected String runActivityLogic(AgentPath agent, ItemPath item,
int transitionID, String requestData) throws InvalidDataException {
Logger.msg(1, "Erase::request() - Starting.");
@@ -48,19 +48,19 @@ public class Erase extends PredefinedStep try
{
// get all domain paths
- Iterator<Path> domPaths = Gateway.getLookup().searchAliases(new ItemPath(itemSysKey));
+ Iterator<Path> domPaths = Gateway.getLookup().searchAliases(item);
while (domPaths.hasNext()) {
DomainPath path = (DomainPath)domPaths.next();
// delete them
- if (path.getSysKey() == itemSysKey)
+ if (path.getItemPath().equals(item))
Gateway.getLookupManager().delete(path);
}
//clear out all storages
- Gateway.getStorage().removeCluster(itemSysKey, "", null);
+ Gateway.getStorage().removeCluster(item, "", null);
//remove entity path
- Gateway.getLookupManager().delete(new ItemPath(itemSysKey));
+ Gateway.getLookupManager().delete(item);
}
catch( Exception ex )
{
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/AddDomainContext.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/AddDomainContext.java index 585f96f..35438e8 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/AddDomainContext.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/AddDomainContext.java @@ -9,6 +9,7 @@ import com.c2kernel.common.ObjectCannotBeUpdated; import com.c2kernel.lifecycle.instance.predefined.PredefinedStep;
import com.c2kernel.lookup.AgentPath;
import com.c2kernel.lookup.DomainPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.process.Gateway;
import com.c2kernel.utils.Logger;
@@ -19,7 +20,7 @@ public class AddDomainContext extends PredefinedStep { }
@Override
- protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ protected String runActivityLogic(AgentPath agent, ItemPath item,
int transitionID, String requestData) throws InvalidDataException {
Logger.msg(1, "AddDomainContext::request() - Starting.");
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewAgent.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewAgent.java index f2396da..45ae445 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewAgent.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewAgent.java @@ -11,6 +11,7 @@ import com.c2kernel.common.InvalidDataException; import com.c2kernel.entity.imports.ImportAgent;
import com.c2kernel.lifecycle.instance.predefined.PredefinedStep;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.process.Gateway;
import com.c2kernel.utils.Logger;
@@ -24,14 +25,14 @@ public class CreateNewAgent extends PredefinedStep //requestdata is xmlstring
@Override
- protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ protected String runActivityLogic(AgentPath agent, ItemPath item,
int transitionID, String requestData) throws InvalidDataException {
String redactedRequestData;
try {
ImportAgent newAgent = (ImportAgent)Gateway.getMarshaller().unmarshall(requestData);
- newAgent.create(agent.getSysKey());
- newAgent.password = "REDACTED";
+ newAgent.create(agent, true);
+ newAgent.setPassword("REDACTED");
redactedRequestData = Gateway.getMarshaller().marshall(newAgent);
return redactedRequestData;
} catch (Exception ex) {
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewItem.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewItem.java index 19fd80a..a1d1755 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewItem.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/CreateNewItem.java @@ -14,6 +14,7 @@ import com.c2kernel.common.InvalidDataException; import com.c2kernel.entity.imports.ImportItem;
import com.c2kernel.lifecycle.instance.predefined.PredefinedStep;
import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.process.Gateway;
import com.c2kernel.utils.Logger;
@@ -27,12 +28,12 @@ public class CreateNewItem extends PredefinedStep //requestdata is xmlstring
@Override
- protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ protected String runActivityLogic(AgentPath agent, ItemPath item,
int transitionID, String requestData) throws InvalidDataException {
try {
- ImportItem item = (ImportItem)Gateway.getMarshaller().unmarshall(requestData);
- item.create(agent.getSysKey(), false);
+ ImportItem newItem = (ImportItem)Gateway.getMarshaller().unmarshall(requestData);
+ newItem.create(agent, false);
return requestData;
} catch (Exception ex) {
Logger.error(ex);
diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveDomainContext.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveDomainContext.java index 956166a..05d399c 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveDomainContext.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveDomainContext.java @@ -7,6 +7,7 @@ import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.lifecycle.instance.predefined.PredefinedStep;
import com.c2kernel.lookup.AgentPath;
import com.c2kernel.lookup.DomainPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.process.Gateway;
import com.c2kernel.utils.Logger;
@@ -16,7 +17,7 @@ public class RemoveDomainContext extends PredefinedStep { }
@Override
- protected String runActivityLogic(AgentPath agent, int itemSysKey,
+ protected String runActivityLogic(AgentPath agent, ItemPath item,
int transitionID, String requestData) throws InvalidDataException {
Logger.msg(1, "RemoveDomainContext::request() - Starting.");
@@ -25,7 +26,7 @@ public class RemoveDomainContext extends PredefinedStep { if (!pathToDelete.exists())
throw new InvalidDataException("Context "+pathToDelete+" does not exist", "");
try {
- pathToDelete.getEntity();
+ pathToDelete.getItemPath();
throw new InvalidDataException("Path "+pathToDelete+" is an Entity. Use its own Erase step instead, or RemoveAgent.", "");
} catch (ObjectNotFoundException ex) { }
if (Gateway.getLookup().getChildren(pathToDelete).hasNext())
diff --git a/src/main/java/com/c2kernel/lifecycle/routingHelpers/ViewpointDataHelper.java b/src/main/java/com/c2kernel/lifecycle/routingHelpers/ViewpointDataHelper.java index 61e3423..958d9a7 100644 --- a/src/main/java/com/c2kernel/lifecycle/routingHelpers/ViewpointDataHelper.java +++ b/src/main/java/com/c2kernel/lifecycle/routingHelpers/ViewpointDataHelper.java @@ -1,5 +1,7 @@ package com.c2kernel.lifecycle.routingHelpers;
+import java.util.UUID;
+
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.entity.proxy.ItemProxy;
import com.c2kernel.lookup.ItemPath;
@@ -54,7 +56,7 @@ public class ViewpointDataHelper ItemPath sourcePath;
try
{
- sourcePath = new ItemPath(Integer.parseInt(entityPath));
+ sourcePath = new ItemPath(UUID.fromString(entityPath));
} catch (Exception e) {
sourcePath = new ItemPath(entityPath);
}
diff --git a/src/main/java/com/c2kernel/lookup/AgentPath.java b/src/main/java/com/c2kernel/lookup/AgentPath.java index a0bb7fd..fb4ce0e 100644 --- a/src/main/java/com/c2kernel/lookup/AgentPath.java +++ b/src/main/java/com/c2kernel/lookup/AgentPath.java @@ -12,10 +12,12 @@ package com.c2kernel.lookup; import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+import java.util.UUID;
import org.apache.xerces.impl.dv.util.Base64;
import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.SystemKey;
import com.c2kernel.process.Gateway;
@@ -31,29 +33,40 @@ public class AgentPath extends ItemPath private String mAgentName=null;
private String mPassword=null;
- public AgentPath(int syskey, String agentName)
- throws InvalidAgentPathException,InvalidItemPathException
- {
- super(syskey);
- if (agentName!=null && agentName.length()>0)
- setAgentName(agentName);
- else
+ public AgentPath(SystemKey syskey) throws InvalidAgentPathException {
+ super(syskey);
+ try {
+ findAgentName();
+ } catch (ObjectNotFoundException e) {
+ throw new InvalidAgentPathException();
+ }
+ }
+ public AgentPath(UUID uuid) throws InvalidAgentPathException {
+ super(uuid);
+ try {
+ findAgentName();
+ } catch (ObjectNotFoundException e) {
throw new InvalidAgentPathException();
+ }
}
-
- public AgentPath(int syskey)
- throws InvalidItemPathException
- {
- super(syskey);
+
+ public AgentPath(ItemPath itemPath) throws InvalidAgentPathException {
+ super(itemPath.mUUID);
+ try {
+ findAgentName();
+ } catch (ObjectNotFoundException e) {
+ throw new InvalidAgentPathException();
+ }
}
-
- public AgentPath(ItemPath entity) {
- super();
- try {
- setSysKey(entity.getSysKey());
- } catch (InvalidItemPathException ex) {
- //won't happen as the entity path was valid
- }
+
+ public AgentPath(ItemPath itemPath, String agentName) {
+ super(itemPath.mUUID);
+ mAgentName = agentName;
+ }
+
+ public AgentPath(String agentName) {
+ super();
+ mAgentName = agentName;
}
public void setAgentName(String agentID)
@@ -64,14 +77,16 @@ public class AgentPath extends ItemPath public String getAgentName()
{
if (mAgentName==null)
- {
- try {
- mAgentName = Gateway.getLookup().getAgentName(this);
- } catch (ObjectNotFoundException e) {
- mAgentName = "";
- }
- }
- return mAgentName;
+ try {
+ findAgentName();
+ } catch (ObjectNotFoundException e) {
+ return null;
+ }
+ return mAgentName;
+ }
+
+ private void findAgentName() throws ObjectNotFoundException {
+ mAgentName = Gateway.getLookup().getAgentName(this);
}
public RolePath[] getRoles()
diff --git a/src/main/java/com/c2kernel/lookup/DomainPath.java b/src/main/java/com/c2kernel/lookup/DomainPath.java index 706719e..c8ae751 100644 --- a/src/main/java/com/c2kernel/lookup/DomainPath.java +++ b/src/main/java/com/c2kernel/lookup/DomainPath.java @@ -12,7 +12,6 @@ package com.c2kernel.lookup; import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.process.Gateway;
-import com.c2kernel.utils.Logger;
/**
@@ -47,7 +46,7 @@ public class DomainPath extends Path super(path, Path.UNKNOWN);
}
- public DomainPath(String path, ItemPath entity) throws InvalidItemPathException
+ public DomainPath(String path, ItemPath entity)
{
super(path, Path.UNKNOWN);
setEntity(entity);
@@ -86,13 +85,13 @@ public class DomainPath extends Path }
@Override
- public ItemPath getEntity() throws ObjectNotFoundException {
+ public ItemPath getItemPath() throws ObjectNotFoundException {
if (mType == UNKNOWN) { // must decide
checkType();
}
if (target == null)
- throw new ObjectNotFoundException("Path is a context", "");
+ throw new ObjectNotFoundException("Path "+toString()+" does not resolve to an Item", "");
return target;
}
@@ -108,7 +107,6 @@ public class DomainPath extends Path try {
setEntity(Gateway.getLookup().resolvePath(this));
} catch (InvalidItemPathException ex) {
- Logger.error(ex);
mType = CONTEXT;
} catch (ObjectNotFoundException ex) {
mType = CONTEXT;
@@ -123,17 +121,5 @@ public class DomainPath extends Path public String getName() {
return mPath[mPath.length-1];
}
-
- @Override
- public int getSysKey() {
- if (mType == UNKNOWN) { // must decide
- checkType();
- }
-
- if (mType == ENTITY) {
- return target.getSysKey();
- }
- else return INVALID;
- }
}
diff --git a/src/main/java/com/c2kernel/lookup/ItemPath.java b/src/main/java/com/c2kernel/lookup/ItemPath.java index 17e5659..2219c8a 100644 --- a/src/main/java/com/c2kernel/lookup/ItemPath.java +++ b/src/main/java/com/c2kernel/lookup/ItemPath.java @@ -10,9 +10,11 @@ package com.c2kernel.lookup;
-import java.util.ArrayList;
+import java.nio.ByteBuffer;
+import java.util.UUID;
import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.SystemKey;
/**
@@ -23,38 +25,29 @@ import com.c2kernel.common.ObjectNotFoundException; **/
public class ItemPath extends Path
{
- // no of components in a syskey
- public static final int elementNo = 3;
- // no of digits in a syskey component
- public static final int elementLen = 3;
- // maximum possible int syskey
- public static final int maxSysKey = (int)Math.pow(10, elementNo*elementLen)-1;
- protected static String mTypeRoot;
- /*
- * From syskey int
- * Note no EntityPath constructors allow setting of CONTEXT or ENTITY:
- * The object decides that for itself from the number of components
- */
-
- public ItemPath(int syskey) throws InvalidItemPathException {
- super();
- setSysKey(syskey);
+
+ public ItemPath() {
+ this(UUID.randomUUID());
}
- /*
- */
- public ItemPath()
- {
- super();
+ public ItemPath(UUID uuid) {
+ setSysKey(uuid);
+ mPath = new String[1];
+ mPath[0] = mUUID.toString();
}
+ public ItemPath(SystemKey syskey) {
+ setSysKey(syskey);
+ mPath = new String[1];
+ mPath[0] = mUUID.toString();
+ }
/*
*/
public ItemPath(String[] path) throws InvalidItemPathException
{
- super(path, Path.CONTEXT); // dummy - it will get replaced in checkSysPath()
- checkSysPath();
+ super(path, Path.CONTEXT);
+ getSysKeyFromPath();
}
/*
@@ -62,16 +55,19 @@ public class ItemPath extends Path public ItemPath(String path) throws InvalidItemPathException
{
super(path, Path.CONTEXT);
- checkSysPath();
+ getSysKeyFromPath();
}
- /*
- */
- public ItemPath(ItemPath parent, String child) throws InvalidItemPathException {
- super(parent, child);
- checkSysPath();
+ private void getSysKeyFromPath() throws InvalidItemPathException {
+ if (mPath.length > 0) {
+ try {
+ setSysKey(UUID.fromString(mPath[0]));
+ } catch (IllegalArgumentException ex) {
+ throw new InvalidItemPathException(mPath[0]+" is not a valid UUID");
+ }
+ }
}
-
+
// EntityPaths root in /entity
@Override
public String getRoot() {
@@ -79,81 +75,28 @@ public class ItemPath extends Path }
@Override
- public ItemPath getEntity() throws ObjectNotFoundException {
+ public ItemPath getItemPath() throws ObjectNotFoundException {
return this;
}
public byte[] getOID() {
- if (mSysKey == Path.INVALID) return null;
- return String.valueOf(mSysKey).getBytes();
+ if (mType == Path.CONTEXT) return null;
+ ByteBuffer bb = ByteBuffer.wrap(new byte[16]);
+ bb.putLong(mUUID.getMostSignificantBits());
+ bb.putLong(mUUID.getLeastSignificantBits());
+ return bb.array();
}
-
- /*************************************************************************/
-
- /** Returns int form of syskey (if possible)
- */
- @Override
- public int getSysKey() {
- if (mSysKey == Path.INVALID && mType == Path.ENTITY)
- try {
- if (mPath.length != elementNo)
- throw new InvalidItemPathException("Incorrect number of components for a system key");
- mSysKey = 0;
- for (String keypart : mPath) {
- if (keypart.length()!=elementLen+1)
- throw new InvalidItemPathException("Component '"+keypart+"' is not the correct size for a system key");
- for(int j=1; j<elementLen+1; j++) // skip the 'd' prefix
- {
- char c = keypart.charAt(j);
- if((c >= '0') && (c <='9'))
- mSysKey = mSysKey*10 + c - '0';
- else
- throw new InvalidItemPathException("Component '"+keypart+"' contained a non-numeric char (excluding first char 'd').");
-
- }
- }
- } catch (InvalidItemPathException ex) {
- mSysKey = Path.INVALID;
- }
- return mSysKey;
- }
-
- /** Sets path from int syskey
- */
- public void setSysKey(int sysKey) throws InvalidItemPathException
- {
- if (sysKey < 0 || sysKey > maxSysKey)
- throw new InvalidItemPathException("System key "+sysKey+" out of range");
- String stringPath = Integer.toString(sysKey);
- ArrayList<String> newKey = new ArrayList<String>();
- for (int i=0; i<elementNo; i++) {
- StringBuffer nextComponent = new StringBuffer("d");
- int start = stringPath.length()-elementLen;
- if (start < 0) {
- nextComponent.append("000000".substring(0,Math.abs(start))).append(stringPath);
- stringPath = "";
- }
- else {
- nextComponent.append(stringPath.substring(start));
- stringPath = stringPath.substring(0, start);
- }
- newKey.add(0, nextComponent.toString());
- }
-
- mPath = (newKey.toArray(mPath));
- mSysKey = sysKey;
- mStringPath = null;
- mType = Path.ENTITY;
- checkSysPath();
+
+ protected void setSysKey(UUID uuid) {
+ mUUID = uuid;
+ mSysKey = new SystemKey(uuid.getMostSignificantBits(), uuid.getLeastSignificantBits());
+ mType = Path.ENTITY;
}
-
- public void checkSysPath() throws InvalidItemPathException {
- if (mPath.length > elementNo)
- throw new InvalidItemPathException("EntityPath cannot have more than "+elementNo+" components: "+toString());
- if (mPath.length == elementNo)
- mType = Path.ENTITY;
- else
- mType = Path.CONTEXT;
+
+ protected void setSysKey(SystemKey sysKey) {
+ mSysKey = sysKey;
+ mUUID = new UUID(sysKey.msb, sysKey.lsb);
+ mType = Path.ENTITY;
}
}
diff --git a/src/main/java/com/c2kernel/lookup/Lookup.java b/src/main/java/com/c2kernel/lookup/Lookup.java index 5384e7c..87dec1d 100644 --- a/src/main/java/com/c2kernel/lookup/Lookup.java +++ b/src/main/java/com/c2kernel/lookup/Lookup.java @@ -1,6 +1,7 @@ package com.c2kernel.lookup;
import java.util.Iterator;
+import java.util.UUID;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.process.auth.Authenticator;
@@ -35,7 +36,7 @@ public interface Lookup { * @throws InvalidItemPathException When the system key is invalid/out-of-range
* @throws ObjectNotFoundException When the Item does not exist in the directory.
*/
- public ItemPath getItemPath(int sysKey) throws InvalidItemPathException, ObjectNotFoundException;
+ public ItemPath getItemPath(UUID sysKey) throws InvalidItemPathException, ObjectNotFoundException;
/**
* Find the ItemPath for which a DomainPath is an alias.
diff --git a/src/main/java/com/c2kernel/lookup/Path.java b/src/main/java/com/c2kernel/lookup/Path.java index d6be37f..f6993f7 100644 --- a/src/main/java/com/c2kernel/lookup/Path.java +++ b/src/main/java/com/c2kernel/lookup/Path.java @@ -13,8 +13,10 @@ package com.c2kernel.lookup; import java.io.Serializable;
import java.util.ArrayList;
import java.util.StringTokenizer;
+import java.util.UUID;
import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.SystemKey;
import com.c2kernel.process.Gateway;
@@ -31,17 +33,16 @@ public abstract class Path implements Serializable public static final short CONTEXT = 1;
public static final short ENTITY = 2;
- // invalid int key
- public static final int INVALID = -1;
-
protected String[] mPath = new String[0];
// slash delimited path
protected String mStringPath = null;
// entity or context
protected short mType = CONTEXT;
- // int syskey (only valid for entity SystemPaths)
- protected int mSysKey = INVALID;
+
+ // item UUID (only valid for ItemPaths and DomainPaths that are aliases for Items)
+ protected UUID mUUID;
+ protected SystemKey mSysKey;
// ior is stored in here when it is resolved
protected org.omg.CORBA.Object mIOR = null;
@@ -102,7 +103,8 @@ public abstract class Path implements Serializable {
mStringPath = null;
mPath = path.clone();
- mSysKey = INVALID;
+ mUUID = null;
+ mSysKey = null;
}
/* string path e.g. /system/d000/d000/d001
@@ -122,7 +124,8 @@ public abstract class Path implements Serializable mPath = (newPath.toArray(mPath));
mStringPath = null;
- mSysKey = INVALID;
+ mUUID = null;
+ mSysKey = null;
}
// lookup sets the IOR
@@ -138,7 +141,8 @@ public abstract class Path implements Serializable {
mStringPath = null;
mPath = (path.getPath().clone());
- mSysKey = INVALID;
+ mUUID = null;
+ mSysKey = null;
}
/*************************************************************************/
@@ -196,11 +200,15 @@ public abstract class Path implements Serializable return mType;
}
- public int getSysKey() {
+ public SystemKey getSystemKey() {
return mSysKey;
}
+
+ public UUID getUUID() {
+ return mUUID;
+ }
- public abstract ItemPath getEntity() throws ObjectNotFoundException;
+ public abstract ItemPath getItemPath() throws ObjectNotFoundException;
@Override
public boolean equals( Object path )
@@ -217,7 +225,7 @@ public abstract class Path implements Serializable StringBuffer comp = new StringBuffer("Components: { ");
for (String element : mPath)
comp.append("'").append(element).append("' ");
- return "Path - dump(): "+comp.toString()+"}\n string="+toString()+"\n int="+getSysKey()+"\n type="+mType;
+ return "Path - dump(): "+comp.toString()+"}\n string="+toString()+"\n uuid="+getUUID()+"\n type="+mType;
}
}
diff --git a/src/main/java/com/c2kernel/persistency/ClusterStorage.java b/src/main/java/com/c2kernel/persistency/ClusterStorage.java index 29f9174..cf7f401 100644 --- a/src/main/java/com/c2kernel/persistency/ClusterStorage.java +++ b/src/main/java/com/c2kernel/persistency/ClusterStorage.java @@ -1,6 +1,7 @@ package com.c2kernel.persistency;
import com.c2kernel.entity.C2KLocalObject;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.outcome.Outcome;
import com.c2kernel.persistency.outcome.Viewpoint;
import com.c2kernel.process.auth.Authenticator;
@@ -214,7 +215,7 @@ public abstract class ClusterStorage { * @throws ClusterStorageException
* when retrieval failed
*/
- public abstract C2KLocalObject get(Integer sysKey, String path)
+ public abstract C2KLocalObject get(ItemPath itemPath, String path)
throws ClusterStorageException;
/**
@@ -227,7 +228,7 @@ public abstract class ClusterStorage { * @throws ClusterStorageException
* When storage fails
*/
- public abstract void put(Integer sysKey, C2KLocalObject obj)
+ public abstract void put(ItemPath itemPath, C2KLocalObject obj)
throws ClusterStorageException;
/**
@@ -242,7 +243,7 @@ public abstract class ClusterStorage { * @throws ClusterStorageException
* When deletion fails or is not allowed
*/
- public abstract void delete(Integer sysKey, String path)
+ public abstract void delete(ItemPath itemPath, String path)
throws ClusterStorageException;
// directory listing
@@ -259,7 +260,7 @@ public abstract class ClusterStorage { * @throws ClusterStorageException
* When an error occurred during the query
*/
- public abstract String[] getClusterContents(Integer sysKey, String path)
+ public abstract String[] getClusterContents(ItemPath itemPath, String path)
throws ClusterStorageException;
}
diff --git a/src/main/java/com/c2kernel/persistency/ClusterStorageException.java b/src/main/java/com/c2kernel/persistency/ClusterStorageException.java index 3b3ad50..8648f9e 100644 --- a/src/main/java/com/c2kernel/persistency/ClusterStorageException.java +++ b/src/main/java/com/c2kernel/persistency/ClusterStorageException.java @@ -1,32 +1,19 @@ package com.c2kernel.persistency;
/**
- *
- * @author abranson
- * @author ogattaz
+ *
+ * @version $Revision: 1.2 $ $Date: 2003/07/14 07:57:06 $
+ * @author $Author: abranson $
*/
public class ClusterStorageException extends Exception {
-
- /**
- *
- */
- private static final long serialVersionUID = -497478376391615904L;
-
- /**
- *
- */
- public ClusterStorageException() {
- super();
- }
-
- /**
- * @param aMessage
- * the detail message.
- */
- public ClusterStorageException(String aMessage) {
- super(aMessage);
- }
+ public ClusterStorageException() {
+ super();
+ }
+
+ public ClusterStorageException(String s) {
+ super(s);
+ }
/**
* @param aMessage
diff --git a/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java b/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java index 5227ab8..c82a50d 100644 --- a/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java +++ b/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java @@ -12,6 +12,7 @@ import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.entity.agent.JobList;
import com.c2kernel.entity.proxy.ProxyMessage;
import com.c2kernel.events.History;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.outcome.Outcome;
import com.c2kernel.persistency.outcome.Viewpoint;
import com.c2kernel.process.Gateway;
@@ -23,10 +24,9 @@ import com.c2kernel.utils.WeakCache; /**
* instantiates ClusterStorages listed in properties file All read/write requests to storage pass through this object, which
* can query the capabilities of each declared storage, and channel requests accordingly. Transaction based.
- *
- * @author abranson
- * @author ogattaz
- *
+ *
+ * * @version $Revision: 1.62 $ $Date: 2006/02/01 13:27:46 $
+ * @author $Author: abranson $
*/
public class ClusterStorageManager {
HashMap<String, ClusterStorage> allStores = new HashMap<String, ClusterStorage>();
@@ -34,22 +34,12 @@ public class ClusterStorageManager { HashMap<String, ArrayList<ClusterStorage>> clusterWriters = new HashMap<String, ArrayList<ClusterStorage>>();
HashMap<String, ArrayList<ClusterStorage>> clusterReaders = new HashMap<String, ArrayList<ClusterStorage>>();
// we don't need a soft cache for the top level cache - the proxies and entities clear that when reaped
- HashMap<Integer, Map<String, C2KLocalObject>> memoryCache = new HashMap<Integer, Map<String, C2KLocalObject>>();
+ HashMap<ItemPath, Map<String, C2KLocalObject>> memoryCache = new HashMap<ItemPath, Map<String, C2KLocalObject>>();
- /**
- * 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.
- *
- * 2014/08/28 ogattaz : put in place a protection in the constructor : set
- * the clusterPriority at the right size according the fact that the
- * "clusterStorageProp" property could contains a List of instance of String
- * and/or ClusterStorage
- *
- * @param auth
- * an instance of Authenticator
- * @throws ClusterStorageException
- */
+ /**
+ * 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(Authenticator auth) throws ClusterStorageException {
Object clusterStorageProp = Gateway.getProperties().getObject("ClusterStorage");
if (clusterStorageProp == null || clusterStorageProp.equals("")) {
@@ -60,13 +50,10 @@ public class ClusterStorageManager { if (clusterStorageProp instanceof String)
rootStores = instantiateStores((String)clusterStorageProp);
else if (clusterStorageProp instanceof ArrayList<?>) {
- ArrayList<?> wTempStorages = (ArrayList<?>)clusterStorageProp;
-
- // set the clusterPriority at the right size
- clusterPriority = new String[wTempStorages.size()];
-
+ ArrayList<?> propStores = (ArrayList<?>)clusterStorageProp;
rootStores = new ArrayList<ClusterStorage>();
- for (Object thisStore : wTempStorages) {
+ clusterPriority = new String[propStores.size()];
+ for (Object thisStore : propStores) {
if (thisStore instanceof ClusterStorage)
rootStores.add((ClusterStorage)thisStore);
else
@@ -89,7 +76,7 @@ public class ClusterStorageManager { Logger.msg(5, "ClusterStorageManager.init() - Cluster storage " + newStorage.getClass().getName() +
" initialised successfully.");
allStores.put(newStorage.getId(), newStorage);
- clusterPriority[clusterNo++] = newStorage.getId();
+ clusterPriority[clusterNo++] = newStorage.getId();
}
clusterReaders.put(ClusterStorage.ROOT, rootStores); // all storages are queried for clusters at the root level
@@ -170,7 +157,7 @@ public class ClusterStorageManager { * Retrieves the ids of the next level of a cluster
* Does not look in any currently open transactions.
*/
- public String[] getClusterContents(Integer sysKey, String path) throws ClusterStorageException {
+ public String[] getClusterContents(ItemPath itemPath, String path) throws ClusterStorageException {
ArrayList<String> contents = new ArrayList<String>();
// get all readers
@@ -179,7 +166,7 @@ public class ClusterStorageManager { // try each in turn until we get a result
for (ClusterStorage thisReader : readers) {
try {
- String[] thisArr = thisReader.getClusterContents(sysKey, path);
+ String[] thisArr = thisReader.getClusterContents(itemPath, path);
if (thisArr != null) {
for (int j = 0; j < thisArr.length; j++)
if (!contents.contains(thisArr[j])) {
@@ -189,7 +176,7 @@ public class ClusterStorageManager { }
} catch (ClusterStorageException e) {
Logger.msg(5, "ClusterStorageManager.getClusterContents() - reader " + thisReader.getName() +
- " could not retrieve contents of " + sysKey + "/" + path + ": " + e.getMessage());
+ " could not retrieve contents of " + itemPath + "/" + path + ": " + e.getMessage());
}
}
@@ -199,16 +186,16 @@ public class ClusterStorageManager { }
/** Internal get method. Retrieves clusters from ClusterStorages & maintains the memory cache */
- public C2KLocalObject get(Integer sysKeyIntObj, String path) throws ClusterStorageException, ObjectNotFoundException {
+ public C2KLocalObject get(ItemPath itemPath, String path) throws ClusterStorageException, ObjectNotFoundException {
C2KLocalObject result = null;
// check cache first
Map<String, C2KLocalObject> sysKeyMemCache = null;
- sysKeyMemCache = memoryCache.get(sysKeyIntObj);
+ sysKeyMemCache = memoryCache.get(itemPath);
if (sysKeyMemCache != null) {
synchronized(sysKeyMemCache) {
C2KLocalObject obj = sysKeyMemCache.get(path);
if (obj != null) {
- Logger.msg(7, "ClusterStorageManager.get() - found "+sysKeyIntObj+"/"+path+" in memcache");
+ Logger.msg(7, "ClusterStorageManager.get() - found "+itemPath+"/"+path+" in memcache");
return obj;
}
}
@@ -220,7 +207,7 @@ public class ClusterStorageManager { StringTokenizer tok = new StringTokenizer(path,"/");
if (tok.countTokens() == 4) { // to not catch viewpoints called 'data'
Outcome data = null;
- Viewpoint view = (Viewpoint)get(sysKeyIntObj, path.substring(0, path.lastIndexOf("/")));
+ Viewpoint view = (Viewpoint)get(itemPath, path.substring(0, path.lastIndexOf("/")));
if (view != null)
data = view.getOutcome();
return data;
@@ -230,9 +217,9 @@ public class ClusterStorageManager { // deal out top level remote maps
if (path.indexOf('/') == -1) {
if (path.equals(ClusterStorage.HISTORY))
- result = new History(sysKeyIntObj, null);
+ result = new History(itemPath, null);
if (path.equals(ClusterStorage.JOB))
- result = new JobList(sysKeyIntObj, null);
+ result = new JobList(itemPath, null);
if (result!=null) {
synchronized(sysKeyMemCache) {
sysKeyMemCache.put(path, result);
@@ -246,16 +233,16 @@ public class ClusterStorageManager { ArrayList<ClusterStorage> readers = findStorages(ClusterStorage.getClusterType(path), false);
for (ClusterStorage thisReader : readers) {
try {
- result = thisReader.get(sysKeyIntObj, path);
- Logger.msg(7, "ClusterStorageManager.get() - reading "+path+" from "+thisReader.getName() + " for intkey=" + sysKeyIntObj);
+ result = thisReader.get(itemPath, path);
+ Logger.msg(7, "ClusterStorageManager.get() - reading "+path+" from "+thisReader.getName() + " for item " + itemPath);
if (result != null) { // got it!
// store it in the cache
if (sysKeyMemCache == null) { // create cache if needed
boolean useWeak = Gateway.getProperties().getBoolean("Storage.useWeakCache", false);
- Logger.msg(7,"ClusterStorageManager.put() - Creating "+(useWeak?"Weak":"Strong")+" cache for entity "+sysKeyIntObj);
+ Logger.msg(7,"ClusterStorageManager.put() - Creating "+(useWeak?"Weak":"Strong")+" cache for item "+itemPath);
sysKeyMemCache = useWeak?new WeakCache<String, C2KLocalObject>():new SoftCache<String, C2KLocalObject>(0);
synchronized (memoryCache) {
- memoryCache.put(sysKeyIntObj, sysKeyMemCache);
+ memoryCache.put(itemPath, sysKeyMemCache);
}
}
synchronized(sysKeyMemCache) {
@@ -265,37 +252,37 @@ public class ClusterStorageManager { return result;
}
} catch (ClusterStorageException e) {
- Logger.msg(7, "ClusterStorageManager.get() - reader " + thisReader.getName() + " could not retrieve " + sysKeyIntObj +
+ Logger.msg(7, "ClusterStorageManager.get() - reader " + thisReader.getName() + " could not retrieve " + itemPath +
"/" + path + ": " + e.getMessage());
}
}
- throw new ObjectNotFoundException("ClusterStorageManager.get() - Path " + path + " not found in " + sysKeyIntObj, "");
+ throw new ObjectNotFoundException("ClusterStorageManager.get() - Path " + path + " not found in " + itemPath, "");
}
/** Internal put method. Creates or overwrites a cluster in all writers. Used when committing transactions. */
- public void put(Integer sysKeyIntObj, C2KLocalObject obj) throws ClusterStorageException {
+ public void put(ItemPath itemPath, C2KLocalObject obj) throws ClusterStorageException {
String path = ClusterStorage.getPath(obj);
ArrayList<ClusterStorage> writers = findStorages(ClusterStorage.getClusterType(path), true);
for (ClusterStorage thisWriter : writers) {
try {
Logger.msg(7, "ClusterStorageManager.put() - writing "+path+" to "+thisWriter.getName());
- thisWriter.put(sysKeyIntObj, obj);
+ thisWriter.put(itemPath, obj);
} catch (ClusterStorageException e) {
Logger.error("ClusterStorageManager.put() - writer " + thisWriter.getName() + " could not store " +
- sysKeyIntObj + "/" + path + ": " + e.getMessage());
+ itemPath + "/" + path + ": " + e.getMessage());
throw e;
}
}
// put in mem cache if that worked
Map<String, C2KLocalObject> sysKeyMemCache;
- if (memoryCache.containsKey(sysKeyIntObj))
- sysKeyMemCache = memoryCache.get(sysKeyIntObj);
+ if (memoryCache.containsKey(itemPath))
+ sysKeyMemCache = memoryCache.get(itemPath);
else {
boolean useWeak = Gateway.getProperties().getBoolean("Storage.useWeakCache", false);
- Logger.msg(7,"ClusterStorageManager.put() - Creating "+(useWeak?"Weak":"Strong")+" cache for entity "+sysKeyIntObj);
+ Logger.msg(7,"ClusterStorageManager.put() - Creating "+(useWeak?"Weak":"Strong")+" cache for entity "+itemPath);
sysKeyMemCache = useWeak?new WeakCache<String, C2KLocalObject>():new SoftCache<String, C2KLocalObject>(0);
synchronized (memoryCache) {
- memoryCache.put(sysKeyIntObj, sysKeyMemCache);
+ memoryCache.put(itemPath, sysKeyMemCache);
}
}
@@ -306,45 +293,45 @@ public class ClusterStorageManager { if (Logger.doLog(9)) dumpCacheContents(9);
// transmit proxy event
- Gateway.getProxyServer().sendProxyEvent( new ProxyMessage(sysKeyIntObj.intValue(), path, ProxyMessage.ADDED));
+ Gateway.getProxyServer().sendProxyEvent( new ProxyMessage(itemPath, path, ProxyMessage.ADDED));
}
/** Deletes a cluster from all writers */
- public void remove(Integer sysKeyIntObj, String path) throws ClusterStorageException {
+ public void remove(ItemPath itemPath, String path) throws ClusterStorageException {
ArrayList<ClusterStorage> writers = findStorages(ClusterStorage.getClusterType(path), true);
for (ClusterStorage thisWriter : writers) {
try {
Logger.msg(7, "ClusterStorageManager.delete() - removing "+path+" from "+thisWriter.getName());
- thisWriter.delete(sysKeyIntObj, path);
+ thisWriter.delete(itemPath, path);
} catch (ClusterStorageException e) {
- Logger.error("ClusterStorageManager.delete() - writer " + thisWriter.getName() + " could not delete " + sysKeyIntObj +
+ Logger.error("ClusterStorageManager.delete() - writer " + thisWriter.getName() + " could not delete " + itemPath +
"/" + path + ": " + e.getMessage());
throw e;
}
}
- if (memoryCache.containsKey(sysKeyIntObj)) {
- Map<String, C2KLocalObject> sysKeyMemCache = memoryCache.get(sysKeyIntObj);
- synchronized (sysKeyMemCache) {
- sysKeyMemCache.remove(path);
+ if (memoryCache.containsKey(itemPath)) {
+ Map<String, C2KLocalObject> itemMemCache = memoryCache.get(itemPath);
+ synchronized (itemMemCache) {
+ itemMemCache.remove(path);
}
}
// transmit proxy event
- Gateway.getProxyServer().sendProxyEvent( new ProxyMessage(sysKeyIntObj.intValue(), path, ProxyMessage.DELETED));
+ Gateway.getProxyServer().sendProxyEvent( new ProxyMessage(itemPath, path, ProxyMessage.DELETED));
}
- public void clearCache(Integer sysKeyIntObj, String path) {
- Logger.msg(7, "CSM.clearCache() - removing "+sysKeyIntObj+"/"+path);
+ public void clearCache(ItemPath itemPath, String path) {
+ Logger.msg(7, "CSM.clearCache() - removing "+itemPath+"/"+path);
- if (memoryCache.containsKey(sysKeyIntObj)) {
- Map<String, C2KLocalObject> sysKeyMemCache = memoryCache.get(sysKeyIntObj);
+ if (memoryCache.containsKey(itemPath)) {
+ Map<String, C2KLocalObject> sysKeyMemCache = memoryCache.get(itemPath);
synchronized(sysKeyMemCache) {
for (Iterator<String> iter = sysKeyMemCache.keySet().iterator(); iter.hasNext();) {
String thisPath = iter.next();
if (thisPath.startsWith(path)) {
- Logger.msg(7, "CSM.clearCache() - removing "+sysKeyIntObj+"/"+thisPath);
+ Logger.msg(7, "CSM.clearCache() - removing "+itemPath+"/"+thisPath);
iter.remove();
}
}
@@ -352,18 +339,18 @@ public class ClusterStorageManager { }
}
- public void clearCache(Integer sysKeyIntObj) {
+ public void clearCache(ItemPath itemPath) {
- Logger.msg(5, "CSM.clearCache() - removing entire cache of "+sysKeyIntObj);
+ Logger.msg(5, "CSM.clearCache() - removing entire cache of "+itemPath);
- if (memoryCache.containsKey(sysKeyIntObj)) {
+ if (memoryCache.containsKey(itemPath)) {
synchronized (memoryCache) {
if (Logger.doLog(6)) {
- Map<String, C2KLocalObject> sysKeyMemCache = memoryCache.get(sysKeyIntObj);
+ Map<String, C2KLocalObject> sysKeyMemCache = memoryCache.get(itemPath);
int size = sysKeyMemCache.size();
Logger.msg(6, "CSM.clearCache() - "+size+" objects to remove.");
}
- memoryCache.remove(sysKeyIntObj);
+ memoryCache.remove(itemPath);
}
}
else
@@ -380,9 +367,9 @@ public class ClusterStorageManager { public void dumpCacheContents(int logLevel) {
if (!Logger.doLog(logLevel)) return;
synchronized(memoryCache) {
- for (Integer sysKey : memoryCache.keySet()) {
- Logger.msg(logLevel, "Cached Objects of Entity "+sysKey);
- Map<String, C2KLocalObject> sysKeyMemCache = memoryCache.get(sysKey);
+ for (ItemPath itemPath : memoryCache.keySet()) {
+ Logger.msg(logLevel, "Cached Objects of Entity "+itemPath);
+ Map<String, C2KLocalObject> sysKeyMemCache = memoryCache.get(itemPath);
try {
synchronized(sysKeyMemCache) {
for (Object name : sysKeyMemCache.keySet()) {
diff --git a/src/main/java/com/c2kernel/persistency/MemoryOnlyClusterStorage.java b/src/main/java/com/c2kernel/persistency/MemoryOnlyClusterStorage.java index cd5d122..dccf2af 100644 --- a/src/main/java/com/c2kernel/persistency/MemoryOnlyClusterStorage.java +++ b/src/main/java/com/c2kernel/persistency/MemoryOnlyClusterStorage.java @@ -6,17 +6,18 @@ import java.util.HashMap; import java.util.Map;
import com.c2kernel.entity.C2KLocalObject;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.process.auth.Authenticator;
import com.c2kernel.utils.Logger;
public class MemoryOnlyClusterStorage extends ClusterStorage {
- HashMap<Integer, Map<String, C2KLocalObject>> memoryCache = new HashMap<Integer, Map<String, C2KLocalObject>>();
+ HashMap<ItemPath, Map<String, C2KLocalObject>> memoryCache = new HashMap<ItemPath, Map<String, C2KLocalObject>>();
/**
*
*/
public MemoryOnlyClusterStorage() {
- memoryCache = new HashMap<Integer, Map<String,C2KLocalObject>>();
+ memoryCache = new HashMap<ItemPath, Map<String,C2KLocalObject>>();
}
@Override
@@ -44,26 +45,26 @@ public class MemoryOnlyClusterStorage extends ClusterStorage { }
@Override
- public C2KLocalObject get(Integer sysKey, String path)
+ public C2KLocalObject get(ItemPath thisItem, String path)
throws ClusterStorageException {
- Map<String, C2KLocalObject> sysKeyMemCache = memoryCache.get(sysKey);
+ Map<String, C2KLocalObject> sysKeyMemCache = memoryCache.get(thisItem);
if (sysKeyMemCache != null)
return sysKeyMemCache.get(path);
return null;
}
@Override
- public void put(Integer sysKey, C2KLocalObject obj)
+ public void put(ItemPath thisItem, C2KLocalObject obj)
throws ClusterStorageException {
// create item cache if not present
Map<String, C2KLocalObject> sysKeyMemCache;
synchronized (memoryCache) {
- if (memoryCache.containsKey(sysKey))
- sysKeyMemCache = memoryCache.get(sysKey);
+ if (memoryCache.containsKey(thisItem))
+ sysKeyMemCache = memoryCache.get(thisItem);
else {
sysKeyMemCache = new HashMap<String, C2KLocalObject>();
- memoryCache.put(sysKey, sysKeyMemCache);
+ memoryCache.put(thisItem, sysKeyMemCache);
}
}
@@ -76,16 +77,16 @@ public class MemoryOnlyClusterStorage extends ClusterStorage { }
@Override
- public void delete(Integer sysKey, String path)
+ public void delete(ItemPath thisItem, String path)
throws ClusterStorageException {
- Map<String, C2KLocalObject> sysKeyMemCache = memoryCache.get(sysKey);
+ Map<String, C2KLocalObject> sysKeyMemCache = memoryCache.get(thisItem);
if (sysKeyMemCache != null) {
synchronized (sysKeyMemCache) {
if (sysKeyMemCache.containsKey(path)) {
sysKeyMemCache.remove(path);
if (sysKeyMemCache.isEmpty()) {
synchronized (memoryCache) {
- memoryCache.remove(sysKey);
+ memoryCache.remove(thisItem);
}
}
}
@@ -94,9 +95,9 @@ public class MemoryOnlyClusterStorage extends ClusterStorage { }
@Override
- public String[] getClusterContents(Integer sysKey, String path)
+ public String[] getClusterContents(ItemPath thisItem, String path)
throws ClusterStorageException {
- Map<String, C2KLocalObject> sysKeyMemCache = memoryCache.get(sysKey);
+ Map<String, C2KLocalObject> sysKeyMemCache = memoryCache.get(thisItem);
ArrayList<String> result = new ArrayList<String>();
if (sysKeyMemCache != null) {
while (path.endsWith("/"))
@@ -114,10 +115,10 @@ public class MemoryOnlyClusterStorage extends ClusterStorage { return result.toArray(new String[result.size()]);
}
- public void dumpContents(int sysKey) {
+ public void dumpContents(ItemPath thisItem) {
synchronized(memoryCache) {
- Logger.msg(0, "Cached Objects of Entity "+sysKey);
- Map<String, C2KLocalObject> sysKeyMemCache = memoryCache.get(sysKey);
+ Logger.msg(0, "Cached Objects of Entity "+thisItem);
+ Map<String, C2KLocalObject> sysKeyMemCache = memoryCache.get(thisItem);
if (sysKeyMemCache == null) {
Logger.msg(0, "No cache found");
return;
diff --git a/src/main/java/com/c2kernel/persistency/NextKeyManager.java b/src/main/java/com/c2kernel/persistency/NextKeyManager.java deleted file mode 100644 index 1352405..0000000 --- a/src/main/java/com/c2kernel/persistency/NextKeyManager.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.c2kernel.persistency;
-
-import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
-import com.c2kernel.lookup.AgentPath;
-import com.c2kernel.lookup.ItemPath;
-import com.c2kernel.process.auth.Authenticator;
-
-/**
- * @author abranson
- *
- */
-public interface NextKeyManager {
-
-
- public void open(Authenticator auth);
- /**
- *
- * @return
- * @throws ObjectCannotBeUpdated
- * @throws ObjectNotFoundException
- */
- public ItemPath generateNextEntityKey()
- throws ObjectCannotBeUpdated, ObjectNotFoundException;
-
- /**
- * @return
- * @throws ObjectCannotBeUpdated
- * @throws ObjectNotFoundException
- */
- public AgentPath generateNextAgentKey()
- throws ObjectCannotBeUpdated, ObjectNotFoundException;
-
- /**
- * @param sysKey
- * @throws ObjectCannotBeUpdated
- * @throws ObjectNotFoundException
- */
- public void writeLastEntityKey(int sysKey) throws ObjectCannotBeUpdated, ObjectNotFoundException;
-
- /**
- * @return
- * @throws ObjectNotFoundException
- */
- public ItemPath getLastEntityPath() throws ObjectNotFoundException;
-
- /**
- * Shuts down the next key manager
- */
- public void close();
-}
diff --git a/src/main/java/com/c2kernel/persistency/ProxyLoader.java b/src/main/java/com/c2kernel/persistency/ProxyLoader.java index 57b91af..9a7f7bd 100644 --- a/src/main/java/com/c2kernel/persistency/ProxyLoader.java +++ b/src/main/java/com/c2kernel/persistency/ProxyLoader.java @@ -19,7 +19,7 @@ import com.c2kernel.utils.Logger; */
public class ProxyLoader extends ClusterStorage {
- HashMap<Integer, Item> entities = new HashMap<Integer, Item>();
+ HashMap<ItemPath, Item> entities = new HashMap<ItemPath, Item>();
Lookup lookup;
@Override
@@ -48,14 +48,14 @@ public class ProxyLoader extends ClusterStorage { // retrieve object by path
@Override
- public C2KLocalObject get(Integer sysKey, String path) throws ClusterStorageException {
+ public C2KLocalObject get(ItemPath thisItem, String path) throws ClusterStorageException {
try {
- Item thisEntity = getIOR(sysKey);
+ Item thisEntity = getIOR(thisItem);
String type = getClusterType(path);
// fetch the xml from the item
String queryData = thisEntity.queryData(path);
- if (Logger.doLog(6)) Logger.msg(6, "ProxyLoader - "+sysKey+":"+path+" = "+queryData);
+ if (Logger.doLog(6)) Logger.msg(6, "ProxyLoader - "+thisItem+":"+path+" = "+queryData);
if (queryData != null) {
if (type.equals(OUTCOME))
@@ -74,13 +74,13 @@ public class ProxyLoader extends ClusterStorage { // store object by path
@Override
- public void put(Integer sysKey, C2KLocalObject obj) throws ClusterStorageException {
+ public void put(ItemPath thisItem, C2KLocalObject obj) throws ClusterStorageException {
// not supported
throw new ClusterStorageException("Cannot write to items through the ProxyLoader");
}
// delete cluster
@Override
- public void delete(Integer sysKey, String path) throws ClusterStorageException {
+ public void delete(ItemPath thisItem, String path) throws ClusterStorageException {
// not supported
throw new ClusterStorageException("Cannot write to items through the ProxyLoader");
}
@@ -89,9 +89,9 @@ public class ProxyLoader extends ClusterStorage { // directory listing
@Override
- public String[] getClusterContents(Integer sysKey, String path) throws ClusterStorageException {
+ public String[] getClusterContents(ItemPath thisItem, String path) throws ClusterStorageException {
try {
- Item thisEntity = getIOR(sysKey);
+ Item thisEntity = getIOR(thisItem);
String contents = thisEntity.queryData(path+"/all");
StringTokenizer tok = new StringTokenizer(contents, ",");
String[] result = new String[tok.countTokens()];
@@ -105,16 +105,16 @@ public class ProxyLoader extends ClusterStorage { }
}
- private Item getIOR(Integer sysKey) throws ClusterStorageException {
- if (entities.containsKey(sysKey)) {
+ private Item getIOR(ItemPath thisPath) throws ClusterStorageException {
+ if (entities.containsKey(thisPath)) {
// check the cache
- Logger.msg(7, "ProxyLoader.getIOR() - "+sysKey+" cached.");
- return entities.get(sysKey);
+ Logger.msg(7, "ProxyLoader.getIOR() - "+thisPath+" cached.");
+ return entities.get(thisPath);
}
try {
- Logger.msg(7, "ProxyLoader.getIOR() - Resolving "+sysKey+".");
- org.omg.CORBA.Object ior = lookup.resolve(new ItemPath(sysKey.intValue()));
+ Logger.msg(7, "ProxyLoader.getIOR() - Resolving "+thisPath+".");
+ org.omg.CORBA.Object ior = lookup.resolve(thisPath);
Item thisItem = null;
try {
@@ -123,15 +123,15 @@ public class ProxyLoader extends ClusterStorage { try {
thisItem = AgentHelper.narrow(ior);
} catch (org.omg.CORBA.BAD_PARAM ex2) {
- throw new ClusterStorageException ("Could not narrow "+sysKey+" as a known Entity type");
+ throw new ClusterStorageException ("Could not narrow "+thisItem+" as a known Entity type");
}
}
- Logger.msg(7, "ProxyLoader.getIOR() - Found "+sysKey+".");
- entities.put(sysKey, thisItem);
+ Logger.msg(7, "ProxyLoader.getIOR() - Found "+thisItem+".");
+ entities.put(thisPath, thisItem);
return thisItem;
} catch (Exception e) {
- throw new ClusterStorageException("Error narrowing "+sysKey+": "+e.getMessage());
+ throw new ClusterStorageException("Error narrowing "+thisPath+": "+e.getMessage());
}
}
}
diff --git a/src/main/java/com/c2kernel/persistency/RemoteMap.java b/src/main/java/com/c2kernel/persistency/RemoteMap.java index 9f1d8a3..48ed220 100644 --- a/src/main/java/com/c2kernel/persistency/RemoteMap.java +++ b/src/main/java/com/c2kernel/persistency/RemoteMap.java @@ -30,7 +30,7 @@ public class RemoteMap<V extends C2KLocalObject> extends TreeMap<String, V> impl private int mID=-1;
private String mName;
- protected int mSysKey;
+ protected ItemPath mItemPath;
private String mPath = "";
Object keyLock = null;
TransactionManager storage;
@@ -39,7 +39,7 @@ public class RemoteMap<V extends C2KLocalObject> extends TreeMap<String, V> impl ItemProxy source;
Object mLocker; // if this remote map will participate in a transaction
- public RemoteMap(int sysKey, String path, Object locker) {
+ public RemoteMap(ItemPath itemPath, String path, Object locker) {
super(new Comparator<String>() {
@Override
@@ -54,7 +54,7 @@ public class RemoteMap<V extends C2KLocalObject> extends TreeMap<String, V> impl }
});
- mSysKey = sysKey;
+ mItemPath = itemPath;
mLocker = locker;
// split the path into path/name
@@ -88,7 +88,7 @@ public class RemoteMap<V extends C2KLocalObject> extends TreeMap<String, V> impl };
try {
- source = Gateway.getProxyManager().getProxy(new ItemPath(sysKey));
+ source = Gateway.getProxyManager().getProxy(mItemPath);
source.subscribe(new MemberSubscription<V>(listener, path, false));
} catch (Exception ex) {
Logger.error("Error subscribing to remote map. Changes will not be received");
@@ -103,7 +103,7 @@ public class RemoteMap<V extends C2KLocalObject> extends TreeMap<String, V> impl synchronized(this) {
String[] keys;
try {
- keys = storage.getClusterContents(mSysKey, mPath+mName);
+ keys = storage.getClusterContents(mItemPath, mPath+mName);
for (String key : keys) super.put(key, null);
} catch (ClusterStorageException e) {
Logger.error(e);
@@ -198,7 +198,7 @@ public class RemoteMap<V extends C2KLocalObject> extends TreeMap<String, V> impl try {
V value = super.get(key);
if (value == null) {
- value = (V)storage.get(mSysKey, mPath+mName+"/"+key, mLocker);
+ value = (V)storage.get(mItemPath, mPath+mName+"/"+key, mLocker);
super.put(key, value);
}
return value;
@@ -238,7 +238,7 @@ public class RemoteMap<V extends C2KLocalObject> extends TreeMap<String, V> impl public synchronized V put(String key, V value) {
try {
synchronized(this) {
- storage.put(mSysKey, value, mLocker);
+ storage.put(mItemPath, value, mLocker);
return putLocal(key, value);
}
} catch (ClusterStorageException e) {
@@ -259,7 +259,7 @@ public class RemoteMap<V extends C2KLocalObject> extends TreeMap<String, V> impl loadKeys();
if (containsKey(key)) try {
synchronized(keyLock) {
- storage.remove(mSysKey, mPath+mName+"/"+key, mLocker);
+ storage.remove(mItemPath, mPath+mName+"/"+key, mLocker);
return super.remove(key);
}
} catch (ClusterStorageException e) {
diff --git a/src/main/java/com/c2kernel/persistency/TransactionManager.java b/src/main/java/com/c2kernel/persistency/TransactionManager.java index 7362ae1..b28a440 100644 --- a/src/main/java/com/c2kernel/persistency/TransactionManager.java +++ b/src/main/java/com/c2kernel/persistency/TransactionManager.java @@ -7,18 +7,19 @@ import com.c2kernel.common.ObjectNotFoundException; import com.c2kernel.entity.C2KLocalObject;
import com.c2kernel.entity.agent.JobList;
import com.c2kernel.events.History;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.process.auth.Authenticator;
import com.c2kernel.utils.Logger;
public class TransactionManager {
- HashMap<Integer, Object> locks;
+ HashMap<ItemPath, Object> locks;
HashMap<Object, ArrayList<TransactionEntry>> pendingTransactions;
ClusterStorageManager storage;
public TransactionManager(Authenticator auth) throws ClusterStorageException {
storage = new ClusterStorageManager(auth);
- locks = new HashMap<Integer, Object>();
+ locks = new HashMap<ItemPath, Object>();
pendingTransactions = new HashMap<Object, ArrayList<TransactionEntry>>();
}
@@ -40,16 +41,16 @@ public class TransactionManager { storage.close();
}
- public String[] getClusterContents(int sysKey, String path) throws ClusterStorageException {
+ public String[] getClusterContents(ItemPath itemPath, String path) throws ClusterStorageException {
if (path.startsWith("/") && path.length() > 1) path = path.substring(1);
- return storage.getClusterContents(new Integer(sysKey), path);
+ return storage.getClusterContents(itemPath, path);
}
/**
* Public get method. Required a 'locker' object for a transaction key.
* Checks the transaction table first to see if the caller has uncommitted changes
*/
- public C2KLocalObject get(int sysKey, String path, Object locker)
+ public C2KLocalObject get(ItemPath itemPath, String path, Object locker)
throws ClusterStorageException,
ObjectNotFoundException {
if (path.startsWith("/") && path.length() > 1) path = path.substring(1);
@@ -57,56 +58,54 @@ public class TransactionManager { // deal out top level remote maps, if transactions aren't needed
if (path.indexOf('/') == -1) {
if (path.equals(ClusterStorage.HISTORY) && locker != null)
- return new History(sysKey, locker);
+ return new History(itemPath, locker);
if (path.equals(ClusterStorage.JOB) && locker != null)
- return new JobList(sysKey, locker);
+ return new JobList(itemPath, locker);
}
- Integer sysKeyIntObj = new Integer(sysKey);
// check to see if the locker has been modifying this cluster
- if (locks.containsKey(sysKeyIntObj) && locks.get(sysKeyIntObj).equals(locker)) {
+ if (locks.containsKey(itemPath) && locks.get(itemPath).equals(locker)) {
ArrayList<TransactionEntry> lockerTransaction = pendingTransactions.get(locker);
for (TransactionEntry thisEntry : lockerTransaction) {
- if (sysKey == thisEntry.sysKey.intValue() && path.equals(thisEntry.getPath())) {
+ if (itemPath.equals(thisEntry.itemPath) && path.equals(thisEntry.path)) {
if (thisEntry.obj == null)
- throw new ClusterStorageException("ClusterStorageManager.get() - Cluster " + path + " has been deleted in " + sysKey +
+ throw new ClusterStorageException("ClusterStorageManager.get() - Cluster " + path + " has been deleted in " + itemPath +
" but not yet committed");
return thisEntry.obj;
}
}
}
- return storage.get(sysKeyIntObj, path);
+ return storage.get(itemPath, path);
}
/**
* Public put method. Manages the transaction table keyed by the object 'locker'.
* If this object is null, transaction support is bypassed (so long as no lock exists on that object).
*/
- public void put(int sysKey, C2KLocalObject obj, Object locker) throws ClusterStorageException {
- Integer sysKeyIntObj = new Integer(sysKey);
+ public void put(ItemPath itemPath, C2KLocalObject obj, Object locker) throws ClusterStorageException {
Object tempLocker = null;
ArrayList<TransactionEntry> lockerTransaction;
String path = ClusterStorage.getPath(obj);
synchronized(locks) {
// look to see if this object is already locked
- if (locks.containsKey(sysKeyIntObj)) {
+ if (locks.containsKey(itemPath)) {
// if it's this locker, get the transaction list
- Object thisLocker = locks.get(sysKeyIntObj);
+ Object thisLocker = locks.get(itemPath);
if (thisLocker.equals(locker)) // retrieve the transaction list
lockerTransaction = pendingTransactions.get(locker);
else // locked by someone else
- throw new ClusterStorageException("ClusterStorageManager.get() - Access denied: Object " + sysKeyIntObj +
+ throw new ClusterStorageException("ClusterStorageManager.get() - Access denied: Object " + itemPath +
" has been locked for writing by " + thisLocker);
}
else { // no locks for this item
if (locker == null) { // lock the item until the non-transactional put is complete :/
tempLocker = new Object();
- locks.put(sysKeyIntObj, tempLocker);
+ locks.put(itemPath, tempLocker);
lockerTransaction = null;
}
else { // initialise the transaction
- locks.put(sysKeyIntObj, locker);
+ locks.put(itemPath, locker);
lockerTransaction = new ArrayList<TransactionEntry>();
pendingTransactions.put(locker, lockerTransaction);
}
@@ -114,13 +113,13 @@ public class TransactionManager { }
if (tempLocker != null) { // non-locking put/delete
- storage.put(sysKeyIntObj, obj);
- locks.remove(sysKeyIntObj);
+ storage.put(itemPath, obj);
+ locks.remove(itemPath);
return;
}
// create the new entry in the transaction table
- TransactionEntry newEntry = new TransactionEntry(sysKeyIntObj, path, obj);
+ TransactionEntry newEntry = new TransactionEntry(itemPath, obj);
/* equals() in TransactionEntry only compares sysKey and path, so we can use
* contains() in ArrayList to looks for preexisting entries for this cluster
* and overwrite them.
@@ -132,29 +131,28 @@ public class TransactionManager { /** Public delete method. Uses the put method, with null as the object value.
*/
- public void remove(int sysKey, String path, Object locker) throws ClusterStorageException {
- Integer sysKeyIntObj = new Integer(sysKey);
+ public void remove(ItemPath itemPath, String path, Object locker) throws ClusterStorageException {
ArrayList<TransactionEntry> lockerTransaction;
Object tempLocker = null;
synchronized(locks) {
// look to see if this object is already locked
- if (locks.containsKey(sysKeyIntObj)) {
+ if (locks.containsKey(itemPath)) {
// if it's this locker, get the transaction list
- Object thisLocker = locks.get(sysKeyIntObj);
+ Object thisLocker = locks.get(itemPath);
if (thisLocker.equals(locker)) // retrieve the transaction list
lockerTransaction = pendingTransactions.get(locker);
else // locked by someone else
- throw new ClusterStorageException("ClusterStorageManager.get() - Access denied: Object " + sysKeyIntObj +
+ throw new ClusterStorageException("ClusterStorageManager.get() - Access denied: Object " + itemPath +
" has been locked for writing by " + thisLocker);
}
else { // either we are the locker, or there is no locker
if (locker == null) { // non-locking put/delete
tempLocker = new Object();
- locks.put(sysKeyIntObj, tempLocker);
+ locks.put(itemPath, tempLocker);
lockerTransaction = null;
}
else {// initialise the transaction
- locks.put(sysKeyIntObj, locker);
+ locks.put(itemPath, locker);
lockerTransaction = new ArrayList<TransactionEntry>();
pendingTransactions.put(locker, lockerTransaction);
}
@@ -162,13 +160,13 @@ public class TransactionManager { }
if (tempLocker != null) {
- storage.remove(sysKeyIntObj, path);
- locks.remove(sysKeyIntObj);
+ storage.remove(itemPath, path);
+ locks.remove(itemPath);
return;
}
// create the new entry in the transaction table
- TransactionEntry newEntry = new TransactionEntry(sysKeyIntObj, path, null);
+ TransactionEntry newEntry = new TransactionEntry(itemPath, path);
/* equals() in TransactionEntry only compares sysKey and path, so we can use
* contains() in ArrayList to looks for preexisting entries for this cluster
* and overwrite them.
@@ -188,13 +186,13 @@ public class TransactionManager { *
* @throws ClusterStorageException - when deleting fails
*/
- public void removeCluster(int sysKey, String path, Object locker) throws ClusterStorageException {
+ public void removeCluster(ItemPath itemPath, String path, Object locker) throws ClusterStorageException {
- String[] children = getClusterContents(sysKey, path);
+ String[] children = getClusterContents(itemPath, path);
for (String element : children)
- removeCluster(sysKey, path+(path.length()>0?"/":"")+element, locker);
+ removeCluster(itemPath, path+(path.length()>0?"/":"")+element, locker);
if (children.length==0 && path.indexOf("/") > -1)
- remove(sysKey, path, locker);
+ remove(itemPath, path, locker);
}
/**
@@ -209,10 +207,10 @@ public class TransactionManager { for (TransactionEntry thisEntry : lockerTransactions) {
try {
if (thisEntry.obj == null)
- storage.remove(thisEntry.sysKey, thisEntry.path);
+ storage.remove(thisEntry.itemPath, thisEntry.path);
else
- storage.put(thisEntry.sysKey, thisEntry.obj);
- locks.remove(thisEntry.sysKey);
+ storage.put(thisEntry.itemPath, thisEntry.obj);
+ locks.remove(thisEntry.itemPath);
} catch (Exception e) {
exceptions.put(thisEntry, e);
}
@@ -238,22 +236,22 @@ public class TransactionManager { public void abort(Object locker) {
synchronized(locks) {
if (locks.containsValue(locker)) {
- for (Integer thisKey : locks.keySet()) {
- if (locks.get(thisKey).equals(locker))
- locks.remove(thisKey);
+ for (ItemPath thisPath : locks.keySet()) {
+ if (locks.get(thisPath).equals(locker))
+ locks.remove(thisPath);
}
}
pendingTransactions.remove(locker);
}
}
- public void clearCache(int sysKey, String path) {
- if (sysKey == -1)
+ public void clearCache(ItemPath itemPath, String path) {
+ if (itemPath == null)
storage.clearCache();
else if (path == null)
- storage.clearCache(new Integer(sysKey));
+ storage.clearCache(itemPath);
else
- storage.clearCache(new Integer(sysKey), path);
+ storage.clearCache(itemPath, path);
}
@@ -264,9 +262,9 @@ public class TransactionManager { if (locks.size() == 0)
Logger.msg(logLevel, " None");
else
- for (Integer thisKey : locks.keySet()) {
- Object locker = locks.get(thisKey);
- Logger.msg(logLevel, " "+thisKey+" locked by "+locker);
+ for (ItemPath thisPath : locks.keySet()) {
+ Object locker = locks.get(thisPath);
+ Logger.msg(logLevel, " "+thisPath+" locked by "+locker);
}
Logger.msg(logLevel, "Open transactions:");
@@ -285,17 +283,19 @@ public class TransactionManager { /** Used in the transaction table to store details of a put until commit
*/
class TransactionEntry {
- public Integer sysKey;
+ public ItemPath itemPath;
public String path;
public C2KLocalObject obj;
- public TransactionEntry(Integer sysKey, String path, C2KLocalObject obj) {
- this.sysKey = sysKey;
- this.path = path;
+ public TransactionEntry(ItemPath itemPath, C2KLocalObject obj) {
+ this.itemPath = itemPath;
+ this.path = ClusterStorage.getPath(obj);
this.obj = obj;
}
-
- public String getPath() {
- return ClusterStorage.getPath(obj);
+
+ public TransactionEntry(ItemPath itemPath, String path) {
+ this.itemPath = itemPath;
+ this.path = path;
+ this.obj = null;
}
@Override
@@ -305,7 +305,7 @@ public class TransactionManager { report.append("Delete");
else
report.append("Put "+obj.getClass().getName());
- report.append(" at ").append(path).append(" in ").append(sysKey);
+ report.append(" at ").append(path).append(" in ").append(itemPath);
return report.toString();
}
@@ -314,7 +314,7 @@ public class TransactionManager { */
@Override
public int hashCode() {
- return sysKey.hashCode()*getPath().hashCode();
+ return itemPath.hashCode()*path.hashCode();
}
/**
diff --git a/src/main/java/com/c2kernel/persistency/XMLClusterStorage.java b/src/main/java/com/c2kernel/persistency/XMLClusterStorage.java index e6c6e9f..8f01d8e 100644 --- a/src/main/java/com/c2kernel/persistency/XMLClusterStorage.java +++ b/src/main/java/com/c2kernel/persistency/XMLClusterStorage.java @@ -57,10 +57,10 @@ public class XMLClusterStorage extends ClusterStorage { // retrieve object by path
@Override
- public C2KLocalObject get(Integer sysKey, String path) throws ClusterStorageException {
+ public C2KLocalObject get(ItemPath itemPath, String path) throws ClusterStorageException {
try {
String type = ClusterStorage.getClusterType(path);
- String filePath = getFilePath(sysKey, path)+".xml";
+ String filePath = getFilePath(itemPath, path)+".xml";
String objString = FileStringUtility.file2String(filePath);
if (objString.length() == 0) return null;
Logger.debug(9, objString);
@@ -72,16 +72,16 @@ public class XMLClusterStorage extends ClusterStorage { }
} catch (Exception e) {
- Logger.msg(3,"XMLClusterStorage.get() - The path "+path+" from "+sysKey+" does not exist.: "+e.getMessage());
+ Logger.msg(3,"XMLClusterStorage.get() - The path "+path+" from "+itemPath+" does not exist.: "+e.getMessage());
}
return null;
}
// store object by path
@Override
- public void put(Integer sysKey, C2KLocalObject obj) throws ClusterStorageException {
+ public void put(ItemPath itemPath, C2KLocalObject obj) throws ClusterStorageException {
try {
- String filePath = getFilePath(sysKey, getPath(obj)+".xml");
+ String filePath = getFilePath(itemPath, getPath(obj)+".xml");
Logger.msg(7, "Writing "+filePath);
String data = Gateway.getMarshaller().marshall(obj);
@@ -93,32 +93,32 @@ public class XMLClusterStorage extends ClusterStorage { FileStringUtility.string2File(filePath, data);
} catch (Exception e) {
Logger.error(e);
- throw new ClusterStorageException("XMLClusterStorage.put() - Could not write "+getPath(obj)+" to "+sysKey);
+ throw new ClusterStorageException("XMLClusterStorage.put() - Could not write "+getPath(obj)+" to "+itemPath);
}
}
// delete cluster
@Override
- public void delete(Integer sysKey, String path) throws ClusterStorageException {
+ public void delete(ItemPath itemPath, String path) throws ClusterStorageException {
try {
- String filePath = getFilePath(sysKey, path+".xml");
+ String filePath = getFilePath(itemPath, path+".xml");
boolean success = FileStringUtility.deleteDir(filePath, true, true);
if (success) return;
- filePath = getFilePath(sysKey, path);
+ filePath = getFilePath(itemPath, path);
success = FileStringUtility.deleteDir(filePath, true, true);
if (success) return;
} catch(Exception e) { }
- throw new ClusterStorageException("XMLClusterStorage.delete() - Failure deleting path "+path+" in "+sysKey);
+ throw new ClusterStorageException("XMLClusterStorage.delete() - Failure deleting path "+path+" in "+itemPath);
}
/* navigation */
// directory listing
@Override
- public String[] getClusterContents(Integer sysKey, String path) throws ClusterStorageException {
+ public String[] getClusterContents(ItemPath itemPath, String path) throws ClusterStorageException {
String[] result = new String[0];
try {
- String filePath = getFilePath(sysKey, path);
+ String filePath = getFilePath(itemPath, path);
ArrayList<String> paths = FileStringUtility.listDir( filePath, true, false );
if (paths == null) return result; // dir doesn't exist yet
ArrayList<String> contents = new ArrayList<String>();
@@ -142,14 +142,13 @@ public class XMLClusterStorage extends ClusterStorage { return result;
} catch (Exception e) {
Logger.error(e);
- throw new ClusterStorageException("XMLClusterStorage.getClusterContents() - Could not get contents of "+path+" from "+sysKey+": "+e.getMessage());
+ throw new ClusterStorageException("XMLClusterStorage.getClusterContents() - Could not get contents of "+path+" from "+itemPath+": "+e.getMessage());
}
}
- protected String getFilePath(Integer sysKey, String path) throws InvalidItemPathException {
- ItemPath thisEntity = new ItemPath(sysKey.intValue());
+ protected String getFilePath(ItemPath itemPath, String path) throws InvalidItemPathException {
if (path.length() == 0 || path.charAt(0) != '/') path = "/"+path;
- String filePath = rootDir+thisEntity.toString()+path;
+ String filePath = rootDir+itemPath.toString()+path;
Logger.msg(8, "XMLClusterStorage.getFilePath() - "+filePath);
return filePath;
}
diff --git a/src/main/java/com/c2kernel/persistency/outcome/Viewpoint.java b/src/main/java/com/c2kernel/persistency/outcome/Viewpoint.java index a3fe283..db7e8d7 100644 --- a/src/main/java/com/c2kernel/persistency/outcome/Viewpoint.java +++ b/src/main/java/com/c2kernel/persistency/outcome/Viewpoint.java @@ -1,10 +1,12 @@ package com.c2kernel.persistency.outcome;
+import java.util.UUID;
+
import com.c2kernel.common.InvalidDataException;
import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.entity.C2KLocalObject;
import com.c2kernel.events.Event;
-import com.c2kernel.lookup.Path;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.process.Gateway;
@@ -26,7 +28,7 @@ public class Viewpoint implements C2KLocalObject { int ID = -1; // not really used in this
// db fields
- int sysKey;
+ ItemPath itemPath;
String schemaName;
String name;
int schemaVersion;
@@ -35,14 +37,14 @@ public class Viewpoint implements C2KLocalObject { public Viewpoint() {
eventId = NONE;
- sysKey = Path.INVALID;
+ itemPath = null;
schemaVersion = NONE;
schemaName = null;
name = null;
}
- public Viewpoint(int sysKey, String schemaName, String name, int schemaVersion, int eventId) {
- this.sysKey = sysKey;
+ public Viewpoint(ItemPath itemPath, String schemaName, String name, int schemaVersion, int eventId) {
+ this.itemPath = itemPath;
this.schemaName = schemaName;
this.name = name;
this.schemaVersion = schemaVersion;
@@ -51,7 +53,7 @@ public class Viewpoint implements C2KLocalObject { public Outcome getOutcome() throws ObjectNotFoundException, ClusterStorageException {
if (eventId == NONE) throw new ObjectNotFoundException("No last eventId defined", "");
- Outcome retVal = (Outcome)Gateway.getStorage().get(sysKey, ClusterStorage.OUTCOME+"/"+schemaName+"/"+schemaVersion+"/"+eventId, null);
+ Outcome retVal = (Outcome)Gateway.getStorage().get(itemPath, ClusterStorage.OUTCOME+"/"+schemaName+"/"+schemaVersion+"/"+eventId, null);
return retVal;
}
@@ -106,8 +108,8 @@ public class Viewpoint implements C2KLocalObject { * Returns the sysKey.
* @return int
*/
- public int getSysKey() {
- return sysKey;
+ public ItemPath getItemPath() {
+ return itemPath;
}
/**
@@ -155,9 +157,18 @@ public class Viewpoint implements C2KLocalObject { * Sets the sysKey.
* @param sysKey The sysKey to set
*/
- public void setSysKey(int sysKey) {
- this.sysKey = sysKey;
+ public void setItemPath(ItemPath itemPath) {
+ this.itemPath = itemPath;
}
+
+ public void setItemUUID( String uuid )
+ {
+ setItemPath(new ItemPath(UUID.fromString(uuid)));
+ }
+
+ public String getItemUUID() {
+ return getItemPath().getUUID().toString();
+ }
/**
* Method getEvent.
@@ -169,7 +180,7 @@ public class Viewpoint implements C2KLocalObject { if (eventId == NONE)
throw new InvalidDataException("No last eventId defined", "");
- return (Event)Gateway.getStorage().get(sysKey, ClusterStorage.HISTORY+"/"+eventId, null);
+ return (Event)Gateway.getStorage().get(itemPath, ClusterStorage.HISTORY+"/"+eventId, null);
}
@Override
diff --git a/src/main/java/com/c2kernel/process/AbstractMain.java b/src/main/java/com/c2kernel/process/AbstractMain.java index 0ecfd01..0baf9ce 100644 --- a/src/main/java/com/c2kernel/process/AbstractMain.java +++ b/src/main/java/com/c2kernel/process/AbstractMain.java @@ -21,12 +21,11 @@ import com.c2kernel.process.resource.BadArgumentsException; import com.c2kernel.utils.FileStringUtility;
import com.c2kernel.utils.Logger;
-
-/**
- * @author abranson
- * @author ogattaz
+/**************************************************************************
*
- */
+ * @author $Author: abranson $ $Date: 2004/10/25 15:27:35 $
+ * @version $Revision: 1.67 $
+ **************************************************************************/
abstract public class AbstractMain
{
public static boolean isServer = false;
@@ -37,22 +36,8 @@ abstract public class AbstractMain public static String MAIN_ARG_LOGLEVEL = "logLevel";
public static String MAIN_ARG_LOGFILE = "logFile";
public static String MAIN_ARG_CONNECT = "connect";
- public static String MAIN_ARG_HELP = "help";
- /**
- *
- * @return a help text
- */
- public static String getUsageHelpText() {
- return "USAGE: com.c2kernel.process.AbstractMain \n"
- + " -config <server/client config file> \n"
- + " [-connect <LC connect file> ] (or LocalCentre in conf)\n"
- + " [-help] \n"
- + " [-noNewLogStream] (for embedded mode: the logger is already configured ) \n"
- + " [-logLevel 0-19] \n"
- + " [-logFile <path to log file>]";
- }
/**************************************************************************
* reading and setting input paramaters
@@ -98,13 +83,6 @@ abstract public class AbstractMain }
- // print the help and die
- if (argProps.containsKey(MAIN_ARG_HELP)){
- System.out.println();
- System.out.println(getUsageHelpText());
- Logger.die("Stop kernel");
- }
-
if (argProps.containsKey("logFile"))
try {
logStream = new PrintStream(new FileOutputStream(argProps.getProperty("logFile"), true));
diff --git a/src/main/java/com/c2kernel/process/Bootstrap.java b/src/main/java/com/c2kernel/process/Bootstrap.java index 46e2cb6..23582bb 100644 --- a/src/main/java/com/c2kernel/process/Bootstrap.java +++ b/src/main/java/com/c2kernel/process/Bootstrap.java @@ -5,6 +5,7 @@ import java.util.HashMap; import java.util.Iterator;
import java.util.Set;
import java.util.StringTokenizer;
+import java.util.UUID;
import org.custommonkey.xmlunit.Diff;
import org.custommonkey.xmlunit.XMLUnit;
@@ -101,12 +102,16 @@ public class Bootstrap StringTokenizer str = new StringTokenizer(bootList, "\n\r");
while (str.hasMoreTokens()) {
String thisItem = str.nextToken();
- int delim = thisItem.indexOf('/');
- String itemType = thisItem.substring(0,delim);
- String itemName = thisItem.substring(delim+1);
+ ItemPath itemPath = null;
+ String[] itemParts = thisItem.split("/");
+ if (itemParts.length == 3) { // includes UUID
+ itemPath = new ItemPath(UUID.fromString(itemParts[2]));
+ }
+ String itemType = itemParts[0];
+ String itemName = itemParts[1];
try {
String location = "boot/"+thisItem+(itemType.equals("OD")?".xsd":".xml");
- verifyResource(ns, itemName, 0, itemType, location, reset);
+ verifyResource(ns, itemName, 0, itemType, itemPath, location, reset);
} catch (Exception e) {
Logger.error(e);
Logger.die("Error importing bootstrap items. Unsafe to continue.");
@@ -114,8 +119,7 @@ public class Bootstrap }
}
-
- public static DomainPath verifyResource(String ns, String itemName, Integer version, String itemType, String dataLocation, boolean reset) throws Exception {
+ public static DomainPath verifyResource(String ns, String itemName, Integer version, String itemType, ItemPath itemPath, String dataLocation, boolean reset) throws Exception {
if (version == null) version = 0;
LookupManager lookupManager = Gateway.getLookupManager();
ResourceImportHandler typeImpHandler = getHandler(itemType);
@@ -126,13 +130,18 @@ public class Bootstrap ItemProxy thisProxy;
Iterator<Path> en = Gateway.getLookup().search(typeImpHandler.getTypeRoot(), itemName);
if (!en.hasNext()) {
+ if (itemPath == null) itemPath = new ItemPath();
Logger.msg("Bootstrap.verifyResource() - "+typeImpHandler.getName()+" "+itemName+" not found. Creating new.");
- thisProxy = createResourceItem(typeImpHandler, itemName, ns);
+ thisProxy = createResourceItem(typeImpHandler, itemName, ns, itemPath);
}
else {
DomainPath path = (DomainPath)en.next();
thisProxy = Gateway.getProxyManager().getProxy(path);
-
+ if (itemPath != null && !path.getItemPath().equals(itemPath)) {
+ Logger.warning("Resource "+itemType+"/"+itemName+" should have path "+itemPath+" but was found with path "+path.getItemPath());
+ itemPath = path.getItemPath();
+ }
+ if (itemPath == null) itemPath = path.getItemPath();
// Verify module property and location
String moduleName = (ns==null?"kernel":ns);
@@ -148,12 +157,12 @@ public class Bootstrap }
if (!moduleName.equals(itemModule)) { // write module property
- Gateway.getStorage().put(thisProxy.getSystemKey(), new Property("Module", moduleName, false), thisProxy);
+ Gateway.getStorage().put(itemPath, new Property("Module", moduleName, false), thisProxy);
}
if (!modDomPath.equals(path)) { // move item to module subtree
Logger.msg("Module item "+itemName+" found with path "+path.toString()+". Moving to "+modDomPath.toString());
- modDomPath.setEntity(new ItemPath(thisProxy.getSystemKey()));
+ modDomPath.setEntity(itemPath);
if (!modDomPath.exists())
lookupManager.add(modDomPath);
lookupManager.delete(path);
@@ -198,15 +207,15 @@ public class Bootstrap // store
Logger.msg("Bootstrap.verifyResource() - Writing new "+newOutcome.getSchemaType()+" v"+version+" to "+typeImpHandler.getName()+" "+itemName);
- History hist = new History(thisProxy.getSystemKey(), thisProxy);
+ History hist = new History(itemPath, thisProxy);
Transition predefDone = new Transition(0, "Done", 0, 0);
- Event newEvent = hist.addEvent("system", "Admin", "Bootstrap", "Bootstrap", "Bootstrap", newOutcome.getSchemaType(), 0, "PredefinedStep", 0, predefDone, String.valueOf(version));
+ Event newEvent = hist.addEvent(systemAgents.get("system").getPath(), "Admin", "Bootstrap", "Bootstrap", "Bootstrap", newOutcome.getSchemaType(), 0, "PredefinedStep", 0, predefDone, String.valueOf(version));
newOutcome.setID(newEvent.getID());
- Viewpoint newLastView = new Viewpoint(thisProxy.getSystemKey(), newOutcome.getSchemaType(), "last", 0, newEvent.getID());
- Viewpoint newNumberView = new Viewpoint(thisProxy.getSystemKey(), newOutcome.getSchemaType(), String.valueOf(version), 0, newEvent.getID());
- Gateway.getStorage().put(thisProxy.getSystemKey(), newOutcome, thisProxy);
- Gateway.getStorage().put(thisProxy.getSystemKey(), newLastView, thisProxy);
- Gateway.getStorage().put(thisProxy.getSystemKey(), newNumberView, thisProxy);
+ Viewpoint newLastView = new Viewpoint(itemPath, newOutcome.getSchemaType(), "last", 0, newEvent.getID());
+ Viewpoint newNumberView = new Viewpoint(itemPath, newOutcome.getSchemaType(), String.valueOf(version), 0, newEvent.getID());
+ Gateway.getStorage().put(itemPath, newOutcome, thisProxy);
+ Gateway.getStorage().put(itemPath, newLastView, thisProxy);
+ Gateway.getStorage().put(itemPath, newNumberView, thisProxy);
}
Gateway.getStorage().commit(thisProxy);
return modDomPath;
@@ -241,7 +250,7 @@ public class Bootstrap * @param itemName
* @param data
*/
- private static ItemProxy createResourceItem(ResourceImportHandler impHandler, String itemName, String ns) throws Exception {
+ private static ItemProxy createResourceItem(ResourceImportHandler impHandler, String itemName, String ns, ItemPath itemPath) throws Exception {
// create props
PropertyDescriptionList pdList = impHandler.getPropDesc();
PropertyArrayList props = new PropertyArrayList();
@@ -263,21 +272,20 @@ public class Bootstrap }
- ItemPath entityPath = Gateway.getNextKeyManager().generateNextEntityKey();
- Gateway.getCorbaServer().createEntity(entityPath);
- lookupManager.add(entityPath);
+ Gateway.getCorbaServer().createItem(itemPath);
+ lookupManager.add(itemPath);
DomainPath newDomPath = impHandler.getPath(itemName, ns);
- newDomPath.setEntity(entityPath);
+ newDomPath.setEntity(itemPath);
lookupManager.add(newDomPath);
- ItemProxy newItemProxy = Gateway.getProxyManager().getProxy(entityPath);
- newItemProxy.initialise( 1, props, ca, null);
+ ItemProxy newItemProxy = Gateway.getProxyManager().getProxy(itemPath);
+ newItemProxy.initialise( systemAgents.get("system").getPath(), props, ca, null);
return newItemProxy;
}
/**************************************************************************
* Checks for the existence of the admin users so you can use Cristal
**************************************************************************/
- private static void checkAgent(String name, String pass, String role, boolean joblist) throws Exception {
+ private static void checkAgent(String name, String pass, String role, UUID uuid, boolean joblist) throws Exception {
Logger.msg(1, "Bootstrap.checkAgent() - Checking for existence of '"+name+"' user.");
LookupManager lookup = Gateway.getLookupManager();
@@ -297,19 +305,17 @@ public class Bootstrap }
try {
- ItemPath entityPath = Gateway.getNextKeyManager().generateNextEntityKey();
- AgentPath agentPath = new AgentPath(entityPath.getSysKey(), name);
+ AgentPath agentPath = new AgentPath(new ItemPath(uuid), name);
agentPath.setPassword(pass);
- Gateway.getCorbaServer().createEntity(agentPath);
+ Gateway.getCorbaServer().createAgent(agentPath);
lookup.add(agentPath);
// assign admin role
Logger.msg("Bootstrap.checkAgent() - Assigning role '"+role+"'");
rolePath.addAgent(agentPath);
- Gateway.getStorage().put(agentPath.getSysKey(), new Property("Name", name, true), null);
- Gateway.getStorage().put(agentPath.getSysKey(), new Property("Type", "Agent", false), null);
+ Gateway.getStorage().put(agentPath, new Property("Name", name, true), null);
+ Gateway.getStorage().put(agentPath, new Property("Type", "Agent", false), null);
systemAgents.put(name, Gateway.getProxyManager().getAgentProxy(agentPath));
- Logger.msg("Bootstrap.checkAgent() - Done");
} catch (Exception ex) {
Logger.error("Unable to create "+name+" user.");
throw ex;
@@ -323,13 +329,13 @@ public class Bootstrap // check for administrative user
String adminPassword = Gateway.getProperties().getProperty("AdminPassword", "admin12345");
- checkAgent("admin", adminPassword, "Admin", false);
-
// check for import user
- checkAgent("system", adminPassword, "Admin", false);
+ checkAgent("system", adminPassword, "Admin", new UUID(0, 0), false);
+
+ checkAgent("admin", adminPassword, "Admin", new UUID(0, 1), false);
// check for local usercode user
- checkAgent(InetAddress.getLocalHost().getHostName(), "uc", "UserCode", true);
+ checkAgent(InetAddress.getLocalHost().getHostName(), "uc", "UserCode", UUID.randomUUID(), true);
}
public static void createServerItem() throws Exception {
@@ -338,22 +344,22 @@ public class Bootstrap thisServerPath = new DomainPath("/servers/"+serverName);
ItemPath serverEntity;
try {
- serverEntity = thisServerPath.getEntity();
+ serverEntity = thisServerPath.getItemPath();
} catch (ObjectNotFoundException ex) {
Logger.msg("Creating server item "+thisServerPath);
- serverEntity = Gateway.getNextKeyManager().generateNextEntityKey();
- Gateway.getCorbaServer().createEntity(serverEntity);
+ serverEntity = new ItemPath();
+ Gateway.getCorbaServer().createItem(serverEntity);
lookupManager.add(serverEntity);
thisServerPath.setEntity(serverEntity);
lookupManager.add(thisServerPath);
}
- Gateway.getStorage().put(serverEntity.getSysKey(), new Property("Name", serverName, false), null);
- Gateway.getStorage().put(serverEntity.getSysKey(), new Property("Type", "Server", false), null);
- Gateway.getStorage().put(serverEntity.getSysKey(), new Property("KernelVersion", Gateway.getKernelVersion(), true), null);
+ Gateway.getStorage().put(serverEntity, new Property("Name", serverName, false), null);
+ Gateway.getStorage().put(serverEntity, new Property("Type", "Server", false), null);
+ Gateway.getStorage().put(serverEntity, new Property("KernelVersion", Gateway.getKernelVersion(), true), null);
if (Gateway.getProperties().getProperty("ItemServer.Proxy.port") != null)
- Gateway.getStorage().put(serverEntity.getSysKey(),
+ Gateway.getStorage().put(serverEntity,
new Property("ProxyPort", Gateway.getProperties().getProperty("ItemServer.Proxy.port"), false), null);
- Gateway.getStorage().put(serverEntity.getSysKey(),
+ Gateway.getStorage().put(serverEntity,
new Property("ConsolePort", String.valueOf(Logger.getConsolePort()), true), null);
Gateway.getProxyManager().connectToProxyServer(Gateway.getProperties().getProperty("ItemServer.name"), Gateway.getProperties().getInt("ItemServer.Proxy.port"));
@@ -362,7 +368,7 @@ public class Bootstrap public static void initServerItemWf() throws Exception {
CompositeActivityDef serverWfCa = (CompositeActivityDef)LocalObjectLoader.getActDef("ServerItemWorkflow", 0);
Workflow wf = new Workflow((CompositeActivity)serverWfCa.instantiate(), new ServerPredefinedStepContainer());
- wf.initialise(thisServerPath.getSysKey(), systemAgents.get("system").getPath());
- Gateway.getStorage().put(thisServerPath.getSysKey(), wf, null);
+ wf.initialise(thisServerPath.getItemPath(), systemAgents.get("system").getPath());
+ Gateway.getStorage().put(thisServerPath.getItemPath(), wf, null);
}
}
diff --git a/src/main/java/com/c2kernel/process/Gateway.java b/src/main/java/com/c2kernel/process/Gateway.java index 85262e8..c2dd646 100644 --- a/src/main/java/com/c2kernel/process/Gateway.java +++ b/src/main/java/com/c2kernel/process/Gateway.java @@ -20,7 +20,6 @@ import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.Lookup;
import com.c2kernel.lookup.LookupManager;
import com.c2kernel.persistency.ClusterStorageException;
-import com.c2kernel.persistency.NextKeyManager;
import com.c2kernel.persistency.TransactionManager;
import com.c2kernel.process.auth.Authenticator;
import com.c2kernel.process.module.ModuleManager;
@@ -61,7 +60,6 @@ public class Gateway static private boolean orbDestroyed = false;
static private Lookup mLookup;
static private LookupManager mLookupManager = null;
- static private NextKeyManager mNextKeyManager;
static private TransactionManager mStorage;
static private ProxyManager mProxyManager;
static private ProxyServer mProxyServer;
@@ -161,10 +159,6 @@ public class Gateway else {
throw new CannotManageException("Lookup implementation is not a LookupManager. Cannot write to directory");
}
-
- // init next key manager
- mNextKeyManager = (NextKeyManager)mC2KProps.getInstance("NextKeyManager");
- mNextKeyManager.open(auth);
// start entity proxy server
mProxyServer = new ProxyServer(mC2KProps.getProperty("ItemServer.name"));
@@ -290,11 +284,6 @@ public class Gateway if (mCorbaServer != null)
mCorbaServer.close();
mCorbaServer = null;
-
- // close next key manager
- if (mNextKeyManager != null)
- mNextKeyManager.close();
- mNextKeyManager = null;
// disconnect from storages
if (mStorage != null)
@@ -428,9 +417,5 @@ public class Gateway }
}
-
- public static NextKeyManager getNextKeyManager() {
- return mNextKeyManager;
- }
}
diff --git a/src/main/java/com/c2kernel/process/ItemHTTPBridge.java b/src/main/java/com/c2kernel/process/ItemHTTPBridge.java index 6ad8e01..86e3659 100644 --- a/src/main/java/com/c2kernel/process/ItemHTTPBridge.java +++ b/src/main/java/com/c2kernel/process/ItemHTTPBridge.java @@ -1,8 +1,12 @@ package com.c2kernel.process;
import java.util.StringTokenizer;
+import java.util.UUID;
+import com.c2kernel.common.ObjectNotFoundException;
import com.c2kernel.entity.C2KLocalObject;
+import com.c2kernel.lookup.DomainPath;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.utils.server.HTTPRequestHandler;
/* QueryData over HTTP Socket Handler
@@ -25,21 +29,26 @@ public class ItemHTTPBridge extends HTTPRequestHandler { public String processRequest() {
System.out.println("ItemHTTPBridge::ProcessRequest()");
StringTokenizer tok = new StringTokenizer(resource, "?");
- //String itemPath = tok.nextToken();
+ String path = tok.nextToken();
String query = tok.nextToken();
- int sysKey = -1;
- //Path path = Gateway.getLDAPLookup().;
+ ItemPath itemPath;
+ try {
+ itemPath = new ItemPath(UUID.fromString(path));
+ } catch (IllegalArgumentException ex) {
+ DomainPath domPath = new DomainPath(path);
+ if (!domPath.exists())
+ return error("404 Not Found", "The path "+path+" you requested was not found.");
+ try {
+ itemPath = domPath.getItemPath();
+ } catch (ObjectNotFoundException e) {
+ return error("404 Not Found", "The path "+path+" you requested was not found.");
+ }
+ }
+
if (method.equals("GET")) {
try {
- //DomainPath domPath = new DomainPath(itemPath);
- //EntityPath entityPath = domPath.getEntity();
-
- if (sysKey > -1) {
- C2KLocalObject response = Gateway.getStorage().get(sysKey, query, null);
- return Gateway.getMarshaller().marshall(response);
- }
- else
- return error("404 Not Found", "The entity "+sysKey+" you requested was not found.");
+ C2KLocalObject response = Gateway.getStorage().get(itemPath, query, null);
+ return Gateway.getMarshaller().marshall(response);
}
catch (Exception e) {
return error("400 Bad Request", "Usage: GET <path to item>?<path to kernel object><br>"+e.getClass().getName());
diff --git a/src/main/java/com/c2kernel/process/UserCodeProcess.java b/src/main/java/com/c2kernel/process/UserCodeProcess.java index 0d35025..6b34bf5 100644 --- a/src/main/java/com/c2kernel/process/UserCodeProcess.java +++ b/src/main/java/com/c2kernel/process/UserCodeProcess.java @@ -84,7 +84,7 @@ public class UserCodeProcess extends StandardClient implements ProxyObserver<Job }
if (thisJob != null) {
- String jobKey = thisJob.getItemSysKey()+":"+thisJob.getStepPath();
+ String jobKey = thisJob.getItemPath()+":"+thisJob.getStepPath();
int transitionId = thisJob.getTransition().getId();
try {
if (transitionId==START) {
@@ -95,7 +95,7 @@ public class UserCodeProcess extends StandardClient implements ProxyObserver<Job agent.execute(thisJob);
}
else {
- Logger.msg(5, "Start conditions failed "+thisJob.getStepName()+" in "+thisJob.getItemSysKey());
+ Logger.msg(5, "Start conditions failed "+thisJob.getStepName()+" in "+thisJob.getItemPath());
}
}
else if (transitionId==COMPLETE) {
@@ -160,7 +160,7 @@ public class UserCodeProcess extends StandardClient implements ProxyObserver<Job Job thisJob = (Job)c2kLocalObject;
if (thisJob.getTransition().getId() == transition) {
Logger.msg(1,"=================================================================");
- Logger.msg(1, "Got "+thisJob.getTransition().getName()+" job for "+thisJob.getStepName()+" in "+thisJob.getItemSysKey());
+ Logger.msg(1, "Got "+thisJob.getTransition().getName()+" job for "+thisJob.getStepName()+" in "+thisJob.getItemPath());
return thisJob;
}
}
diff --git a/src/main/java/com/c2kernel/process/module/Module.java b/src/main/java/com/c2kernel/process/module/Module.java index 1272026..2f4592f 100644 --- a/src/main/java/com/c2kernel/process/module/Module.java +++ b/src/main/java/com/c2kernel/process/module/Module.java @@ -4,34 +4,38 @@ import java.util.ArrayList; import java.util.Properties;
import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.entity.imports.ImportAgent;
import com.c2kernel.entity.imports.ImportDependency;
import com.c2kernel.entity.imports.ImportDependencyMember;
-import com.c2kernel.entity.imports.ImportAgent;
import com.c2kernel.entity.imports.ImportItem;
-import com.c2kernel.entity.imports.ImportRole;
import com.c2kernel.entity.imports.ImportOutcome;
+import com.c2kernel.entity.imports.ImportRole;
import com.c2kernel.entity.proxy.AgentProxy;
import com.c2kernel.entity.proxy.ItemProxy;
import com.c2kernel.lookup.DomainPath;
import com.c2kernel.lookup.RolePath;
-import com.c2kernel.process.Bootstrap;
import com.c2kernel.process.Gateway;
+import com.c2kernel.property.Property;
import com.c2kernel.scripting.ErrorInfo;
import com.c2kernel.scripting.ScriptingEngineException;
import com.c2kernel.utils.Logger;
-public class Module {
+public class Module extends ImportItem {
- public String ns, name;
- public ModuleInfo info;
- public String resURL;
- public ModuleImports imports = new ModuleImports();
- public ArrayList<ModuleConfig> config = new ArrayList<ModuleConfig>();
- public ArrayList<ModuleScript> scripts = new ArrayList<ModuleScript>();
- public ImportItem moduleItem;
+ private ModuleInfo info;
+ private String resURL;
+ private ModuleImports imports = new ModuleImports();
+ private ArrayList<ModuleConfig> config = new ArrayList<ModuleConfig>();
+ private ArrayList<ModuleScript> scripts = new ArrayList<ModuleScript>();
public Module() {
super();
+ // Module properties
+ properties.add(new com.c2kernel.property.Property("Type", "Module", false));
+ setInitialPath("/desc/modules/");
+ setWorkflow("NoWorkflow");
+ setWorkflowVer(0);
+ imports.list.add(this);
}
public void runScript(String event, AgentProxy user, boolean isServer) throws ScriptingEngineException {
@@ -51,36 +55,41 @@ public class Module { }
}
- public void addModuleItem(String moduleXML) {
- ImportItem moduleItem = new ImportItem(name, "/desc/modules/", "NoWorkflow", 0);
- // Module properties
- moduleItem.properties.add(new com.c2kernel.property.Property("Namespace", ns, false));
- moduleItem.properties.add(new com.c2kernel.property.Property("Name", name, false));
- moduleItem.properties.add(new com.c2kernel.property.Property("Type", "Module", false));
- moduleItem.properties.add(new com.c2kernel.property.Property("Version", info.version, true));
- // Add dependency for all children
- ImportDependency children = new ImportDependency("Contents");
- for (ModuleImport thisImport : imports.list) {
- DomainPath path = thisImport.path;
- if (path != null)
- children.dependencyMemberList.add(new ImportDependencyMember(path.toString()));
- }
- moduleItem.dependencyList.add(children);
- // Add moduleXML
+ public void setModuleXML(String moduleXML) {
ImportOutcome moduleOutcome = new ImportOutcome("Module", 0, "last", null);
moduleOutcome.data = moduleXML;
- moduleItem.outcomes.add(moduleOutcome);
- imports.list.add(moduleItem);
+ outcomes.add(moduleOutcome);
}
+ @Override
+ public void setNamespace(String ns) {
+ super.setNamespace(ns);
+ replaceProp(new Property("Namespace", ns, false));
+ }
+
+ @Override
+ public void setName(String name) {
+ super.setName(name);
+ replaceProp(new Property("Name", name, false));
+ }
+
+ private void replaceProp(Property newProp) {
+ for (Property prop : properties) {
+ if (prop.getName().equals("Namespace")) {
+ prop.setMutable(newProp.isMutable());
+ prop.setValue(newProp.getValue());
+ return;
+ }
+ }
+ properties.add(newProp);
+ }
public void importAll(ItemProxy serverEntity, AgentProxy systemAgent, String moduleXML, boolean reset) throws Exception {
- int systemAgentId = systemAgent.getSystemKey();
- addModuleItem(moduleXML);
+ setModuleXML(moduleXML);
for (ModuleResource thisRes : imports.getResources()) {
try {
- thisRes.path = Bootstrap.verifyResource(ns, thisRes.name, thisRes.version,
- thisRes.resourceType, thisRes.resourceLocation, reset);
+ thisRes.setNamespace(ns);
+ thisRes.create(systemAgent.getPath(), reset);
} catch (Exception ex) {
Logger.error(ex);
Logger.die("Error importing module resources. Unsafe to continue.");
@@ -91,13 +100,13 @@ public class Module { RolePath rolePath;
try {
rolePath = Gateway.getLookup().getRolePath(thisRole.name);
- if (rolePath.hasJobList() != thisRole.jobList) {
+ if (rolePath.hasJobList() != thisRole.hasJobList()) {
Logger.msg("Module.importAll() - Role '"+thisRole.name+"' has incorrect joblist settings. Correcting.");
- rolePath.setHasJobList(thisRole.jobList);
+ rolePath.setHasJobList(thisRole.hasJobList());
}
} catch (ObjectNotFoundException ex) {
Logger.msg("Module.importAll() - Role '"+thisRole.name+"' not found. Creating.");
- thisRole.create(systemAgentId);
+ thisRole.create(systemAgent.getPath(), reset);
}
}
@@ -108,12 +117,12 @@ public class Module { continue;
} catch (ObjectNotFoundException ex) { }
Logger.msg("Module.importAll() - User '"+thisAgent.name+"' not found. Creating.");
- thisAgent.create(systemAgentId);
+ thisAgent.create(systemAgent.getPath(), reset);
}
for (ImportItem thisItem : imports.getItems()) {
thisItem.setNamespace(ns);
- thisItem.create(systemAgentId, reset);
+ thisItem.create(systemAgent.getPath(), reset);
}
}
@@ -126,12 +135,13 @@ public class Module { }
return props;
}
-
- public String getNs() {
- return ns;
+
+ public ArrayList<ModuleScript> getScripts() {
+ return scripts;
}
- public String getName() {
- return name;
+
+ public void setResURL(String resURL) {
+ this.resURL = resURL;
}
public String getDesc() {
return info.desc;
@@ -148,4 +158,43 @@ public class Module { public boolean hasDependency(String dep) {
return info.dependency.contains(dep);
}
+
+ public ModuleInfo getInfo() {
+ return info;
+ }
+
+ public void setInfo(ModuleInfo info) {
+ this.info = info;
+ replaceProp(new Property("Version", info.version, true));
+ }
+
+ public ModuleImports getImports() {
+ return imports;
+ }
+
+ public void setImports(ModuleImports imp) {
+ // Add dependency for all children
+ imports = imp;
+ ImportDependency children = new ImportDependency("Contents");
+ for (ModuleImport thisImport : imports.list) {
+ DomainPath path = thisImport.domainPath;
+ if (path != null)
+ children.dependencyMemberList.add(new ImportDependencyMember(path.toString()));
+ }
+ dependencyList.add(children);
+ }
+
+ public void setConfig(ArrayList<ModuleConfig> config) {
+ this.config = config;
+ }
+
+ public void setScripts(ArrayList<ModuleScript> scripts) {
+ this.scripts = scripts;
+ }
+
+ public ArrayList<ModuleConfig> getConfig() {
+ return config;
+ }
+
+
} diff --git a/src/main/java/com/c2kernel/process/module/ModuleImport.java b/src/main/java/com/c2kernel/process/module/ModuleImport.java index 1f5b16d..f54b47d 100644 --- a/src/main/java/com/c2kernel/process/module/ModuleImport.java +++ b/src/main/java/com/c2kernel/process/module/ModuleImport.java @@ -1,10 +1,66 @@ package com.c2kernel.process.module;
+import java.util.UUID;
+
+import com.c2kernel.common.CannotManageException;
+import com.c2kernel.common.ObjectAlreadyExistsException;
+import com.c2kernel.common.ObjectCannotBeUpdated;
+import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.lookup.AgentPath;
import com.c2kernel.lookup.DomainPath;
+import com.c2kernel.lookup.ItemPath;
public abstract class ModuleImport {
- public String name;
- public DomainPath path;
+ protected String ns;
+ protected String name;
+ protected DomainPath domainPath;
+ protected ItemPath itemPath;
+
+ public ModuleImport() {
+ }
+
+ public abstract void create(AgentPath agentPath, boolean reset) throws ObjectNotFoundException,
+ ObjectCannotBeUpdated, CannotManageException, ObjectAlreadyExistsException;
+
+ public void setID( String uuid )
+ {
+ if (uuid != null) itemPath = new ItemPath(UUID.fromString(uuid));
+ }
+
+ public String getID() {
+ return itemPath==null?null:itemPath.getUUID().toString();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setNamespace(String ns) {
+ this.ns = ns;
+ }
+ public String getNamespace() {
+ return ns;
+ }
+
+ public DomainPath getDomainPath() {
+ return domainPath;
+ }
+
+ public void setDomainPath(DomainPath domainPath) {
+ this.domainPath = domainPath;
+ }
+
+ public ItemPath getItemPath() {
+ return itemPath;
+ }
+
+ public void setItemPath(ItemPath itemPath) {
+ this.itemPath = itemPath;
+ }
}
\ No newline at end of file diff --git a/src/main/java/com/c2kernel/process/module/ModuleManager.java b/src/main/java/com/c2kernel/process/module/ModuleManager.java index 6a69ff8..4fde044 100644 --- a/src/main/java/com/c2kernel/process/module/ModuleManager.java +++ b/src/main/java/com/c2kernel/process/module/ModuleManager.java @@ -49,13 +49,13 @@ public class ModuleManager { if (errors.length() > 0)
throw new ModuleException("Module XML found at "+newModuleURL+" was not valid: "+errors);
Module newModule = (Module)Gateway.getMarshaller().unmarshall(moduleXML);
- if (newModule.resURL != null && newModule.resURL.length()>0) Gateway.getResource().addModuleBaseURL(newModule.ns, newModule.resURL);
+ if (newModule.getResURL() != null && newModule.getResURL().length()>0) Gateway.getResource().addModuleBaseURL(newModule.getNamespace(), newModule.getResURL());
modules.add(newModule);
- modulesXML.put(newModule.ns, moduleXML);
+ modulesXML.put(newModule.getNamespace(), moduleXML);
if (loadedModules.contains(newModule.getName())) throw new ModuleException("Module name clash: "+newModule.getName());
- if (moduleNs.contains(newModule.getNs())) throw new ModuleException("Module namespace clash: "+newModule.getNs());
- Logger.debug(4, "Module found: "+newModule.getNs()+" - "+newModule.getName());
- loadedModules.add(newModule.getName()); moduleNs.add(newModule.getNs());
+ if (moduleNs.contains(newModule.getNamespace())) throw new ModuleException("Module namespace clash: "+newModule.getNamespace());
+ Logger.debug(4, "Module found: "+newModule.getNamespace()+" - "+newModule.getName());
+ loadedModules.add(newModule.getName()); moduleNs.add(newModule.getNamespace());
} catch (ModuleException e) {
Logger.error("Could not load module description from "+newModuleURL);
throw e;
@@ -156,9 +156,9 @@ public class ModuleManager { Logger.msg("Registering module "+thisMod.getName());
try {
- String nsReset = Gateway.getProperties().getProperty("Module."+thisMod.ns+".reset");
+ String nsReset = Gateway.getProperties().getProperty("Module."+thisMod.getNamespace()+".reset");
boolean thisReset = nsReset == null?reset:nsReset.equals("true");
- thisMod.importAll(serverEntity, user, modulesXML.get(thisMod.ns), thisReset);
+ thisMod.importAll(serverEntity, user, modulesXML.get(thisMod.getNamespace()), thisReset);
} catch (Exception e) {
Logger.error(e);
throw new ModuleException("Error importing items for module "+thisMod.getName());
diff --git a/src/main/java/com/c2kernel/process/module/ModuleResource.java b/src/main/java/com/c2kernel/process/module/ModuleResource.java index b36623f..874c7cc 100644 --- a/src/main/java/com/c2kernel/process/module/ModuleResource.java +++ b/src/main/java/com/c2kernel/process/module/ModuleResource.java @@ -1,5 +1,13 @@ package com.c2kernel.process.module;
+import com.c2kernel.common.CannotManageException;
+import com.c2kernel.common.ObjectAlreadyExistsException;
+import com.c2kernel.common.ObjectCannotBeUpdated;
+import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.process.Bootstrap;
+import com.c2kernel.utils.Logger;
+
public class ModuleResource extends ModuleImport {
public Integer version;
@@ -8,4 +16,42 @@ public class ModuleResource extends ModuleImport { public ModuleResource() {
}
+
+ @Override
+ public void create(AgentPath agentPath, boolean reset)
+ throws ObjectNotFoundException, ObjectCannotBeUpdated,
+ CannotManageException, ObjectAlreadyExistsException {
+ try {
+ domainPath = Bootstrap.verifyResource(ns, name, version, resourceType, itemPath, resourceLocation, reset);
+ } catch (Exception e) {
+ Logger.error(e);
+ throw new CannotManageException("Exception verifying module resource "+ns+"/"+name);
+ }
+ }
+
+ public int getVersion() {
+ return version;
+ }
+
+ public void setVersion(int version) {
+ this.version = version;
+ }
+
+ public String getResourceType() {
+ return resourceType;
+ }
+
+ public void setResourceType(String resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ public String getResourceLocation() {
+ return resourceLocation;
+ }
+
+ public void setResourceLocation(String resourceLocation) {
+ this.resourceLocation = resourceLocation;
+ }
+
+
}
\ No newline at end of file diff --git a/src/main/java/com/c2kernel/property/PropertyUtility.java b/src/main/java/com/c2kernel/property/PropertyUtility.java index 968ff13..1e35c98 100644 --- a/src/main/java/com/c2kernel/property/PropertyUtility.java +++ b/src/main/java/com/c2kernel/property/PropertyUtility.java @@ -13,6 +13,7 @@ import java.util.ArrayList; import java.util.Iterator;
import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.ClusterStorage;
import com.c2kernel.persistency.outcome.Outcome;
import com.c2kernel.process.Gateway;
@@ -54,17 +55,17 @@ public class PropertyUtility }
- static public PropertyDescriptionList getPropertyDescriptionOutcome(int entityKey) throws ObjectNotFoundException
+ static public PropertyDescriptionList getPropertyDescriptionOutcome(ItemPath itemPath) throws ObjectNotFoundException
{
try
{
- Outcome outc = (Outcome) Gateway.getStorage().get(entityKey, ClusterStorage.VIEWPOINT+"/PropertyDescription/last/data", null);
+ Outcome outc = (Outcome) Gateway.getStorage().get(itemPath, ClusterStorage.VIEWPOINT+"/PropertyDescription/last/data", null);
return (PropertyDescriptionList)Gateway.getMarshaller().unmarshall(outc.getData());
}
catch (Exception ex)
{
Logger.error(ex);
- throw new ObjectNotFoundException("Problem getting PropertyDescription from "+entityKey, "");
+ throw new ObjectNotFoundException("Problem getting PropertyDescription from "+itemPath, "");
}
}
diff --git a/src/main/resources/boot/OD/Agent.xsd b/src/main/resources/boot/OD/Agent.xsd index 1f8f9ed..998992a 100644 --- a/src/main/resources/boot/OD/Agent.xsd +++ b/src/main/resources/boot/OD/Agent.xsd @@ -10,6 +10,7 @@ </xs:sequence>
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="password" type="xs:string" use="required" />
+ <xs:attribute name="id" type="xs:string" use="optional" />
</xs:complexType>
</xs:element>
<xs:complexType name="property">
diff --git a/src/main/resources/boot/OD/Item.xsd b/src/main/resources/boot/OD/Item.xsd index 22c4ace..2169161 100644 --- a/src/main/resources/boot/OD/Item.xsd +++ b/src/main/resources/boot/OD/Item.xsd @@ -82,6 +82,7 @@ </xs:sequence>
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="workflow" type="xs:string" use="optional" />
+ <xs:attribute name="id" type="xs:string" use="optional" />
<xs:attribute name="initialPath" type="xs:string" use="optional" />
</xs:complexType>
</xs:element>
diff --git a/src/main/resources/boot/OD/Module.xsd b/src/main/resources/boot/OD/Module.xsd index d25352e..9fb93b2 100644 --- a/src/main/resources/boot/OD/Module.xsd +++ b/src/main/resources/boot/OD/Module.xsd @@ -56,6 +56,7 @@ <xs:extension base="xs:string">
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="version" type="xs:integer" use="optional" />
+ <xs:attribute name="id" type="xs:string" use="optional" />
<xs:attribute name="type" type="xs:string" use="required" />
</xs:extension>
</xs:simpleContent>
@@ -149,6 +150,7 @@ </xs:element>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required" />
+ <xs:attribute name="id" type="xs:string" use="optional" />
<xs:attribute name="workflow" type="xs:string"
use="required" />
<xs:attribute name="workflowVer" type="xs:int"
diff --git a/src/main/resources/mapFiles/CollectionMap.xml b/src/main/resources/mapFiles/CollectionMap.xml index ff6a61b..d04cc10 100644 --- a/src/main/resources/mapFiles/CollectionMap.xml +++ b/src/main/resources/mapFiles/CollectionMap.xml @@ -15,12 +15,12 @@ <field name="ID" type="integer" direct="false">
<bind-xml name="ID" node="attribute"/>
</field>
- <field name="mSystemKey"
- type="integer"
+ <field name="mItemPath"
+ type="string"
direct="false"
- get-method="getSystemKey"
- set-method="setSystemKey">
- <bind-xml name="SystemKey" node="attribute"/>
+ get-method="getChildUUID"
+ set-method="setChildUUID">
+ <bind-xml name="ChildUUID" node="attribute"/>
</field>
<field name="mProperties"
type="com.c2kernel.utils.KeyValuePair"
@@ -36,12 +36,12 @@ <class name="com.c2kernel.collection.AggregationMember"
extends="com.c2kernel.graph.model.GraphableVertex">
<map-to xml="AggregationMember"/>
- <field name="mSystemKey"
- type="integer"
+ <field name="mItemPath"
+ type="string"
direct="false"
- get-method="getSystemKey"
- set-method="setSystemKey">
- <bind-xml name="SystemKey" node="attribute"/>
+ get-method="getChildUUID"
+ set-method="setChildUUID">
+ <bind-xml name="ChildUUID" node="attribute"/>
</field>
<field name="mClassProps"
type="string"
diff --git a/src/main/resources/mapFiles/HistoryMap.xml b/src/main/resources/mapFiles/HistoryMap.xml index ced8483..8e7b591 100644 --- a/src/main/resources/mapFiles/HistoryMap.xml +++ b/src/main/resources/mapFiles/HistoryMap.xml @@ -6,9 +6,12 @@ <field name="mID" type="integer" direct="false" get-method="getID" set-method="setID">
<bind-xml name="ID" node="attribute"/>
</field>
- <field name="mEntitySystemKey" type="integer" direct="false" get-method="getEntitySystemKey" set-method="setEntitySystemKey">
- <bind-xml name="EntitySystemKey" node="attribute"/>
- </field>
+ <field name="mItemPath" type="string" direct="false" get-method="getItemUUID" set-method="setItemUUID">
+ <bind-xml name="ItemUUID" node="attribute"/>
+ </field>
+ <field name="mAgentPath" type="string" direct="false" get-method="getAgentUUID" set-method="setAgentUUID">
+ <bind-xml name="AgentUUID" node="attribute"/>
+ </field>
<field name="mStepName" type="string" direct="false" get-method="getStepName" set-method="setStepName">
<bind-xml name="StepName" node="attribute"/>
</field>
@@ -42,12 +45,6 @@ <field name="mTransition" type="integer" direct="false" get-method="getTransition" set-method="setTransition">
<bind-xml name="Transition" node="attribute"/>
</field>
-
- <field name="mAgentName" type="string" direct="false"
- get-method="getAgentName"
- set-method="setAgentName">
- <bind-xml name="AgentName" node="attribute"/>
- </field>
<field name="mAgentRole" type="string" direct="false"
get-method="getAgentRole"
set-method="setAgentRole">
diff --git a/src/main/resources/mapFiles/JobListMap.xml b/src/main/resources/mapFiles/JobListMap.xml index d09f7cc..7eb5237 100644 --- a/src/main/resources/mapFiles/JobListMap.xml +++ b/src/main/resources/mapFiles/JobListMap.xml @@ -5,9 +5,9 @@ <field name="id" type="integer" direct="false" get-method="getId" set-method="setId">
<bind-xml name="Id" node="attribute"/>
</field>
- <field name="itemSysKey" type="integer" direct="false" get-method="getItemSysKey" set-method="setItemSysKey">
- <bind-xml name="ItemSysKey" node="attribute"/>
- </field>
+ <field name="mItemPath" type="string" direct="false" get-method="getItemUUID" set-method="setItemUUID">
+ <bind-xml name="ItemUUID" node="attribute"/>
+ </field>
<field name="stepName" type="string" direct="false" get-method="getStepName" set-method="setStepName">
<bind-xml name="StepName" node="attribute"/>
</field>
@@ -20,9 +20,9 @@ <field name="transition" type="com.c2kernel.lifecycle.instance.stateMachine.Transition" direct="false" get-method="getTransition" set-method="setTransition">
<bind-xml name="Transition" node="element"/>
</field>
- <field name="agentName" type="string" direct="false" get-method="getAgentName" set-method="setAgentName">
- <bind-xml name="AgentName" node="attribute"/>
- </field>
+ <field name="mAgentPath" type="string" direct="false" get-method="getAgentUUID" set-method="setAgentUUID">
+ <bind-xml name="AgentUUID" node="attribute"/>
+ </field>
<field name="originStateName" type="string" direct="false" get-method="getOriginStateName" set-method="setOriginStateName">
<bind-xml name="OriginState" node="attribute"/>
</field>
diff --git a/src/main/resources/mapFiles/LifeCycleMap.xml b/src/main/resources/mapFiles/LifeCycleMap.xml index f2183d5..d0ff71c 100644 --- a/src/main/resources/mapFiles/LifeCycleMap.xml +++ b/src/main/resources/mapFiles/LifeCycleMap.xml @@ -66,9 +66,9 @@ </class>
<class name="com.c2kernel.lifecycle.instance.Workflow" extends="com.c2kernel.lifecycle.instance.CompositeActivity">
<map-to xml="Workflow"/>
- <field name="itemSysKey" type="integer" direct="false">
- <bind-xml name="itemSysKey" node="attribute"/>
- </field>
+ <field name="mItemPath" type="string" direct="false" get-method="getItemUUID" set-method="setItemUUID">
+ <bind-xml name="ItemUUID" node="attribute"/>
+ </field>
</class>
<class name="com.c2kernel.lifecycle.instance.Join" extends="com.c2kernel.lifecycle.instance.WfVertex">
<map-to xml="Join"/>
diff --git a/src/main/resources/mapFiles/ModuleMap.xml b/src/main/resources/mapFiles/ModuleMap.xml index 45f6cbe..f1980d8 100644 --- a/src/main/resources/mapFiles/ModuleMap.xml +++ b/src/main/resources/mapFiles/ModuleMap.xml @@ -2,25 +2,28 @@ <mapping>
<class name="com.c2kernel.process.module.Module">
<map-to xml="CristalModule" />
- <field name="ns" direct="true" type="string">
+ <field name="ns" direct="false" type="string" get-method="getNamespace" set-method="setNamespace">
<bind-xml name="ns" node="attribute" />
</field>
- <field name="name" direct="true" type="string">
+ <field name="name" direct="false" type="string">
<bind-xml name="name" node="attribute" />
</field>
- <field name="info" direct="true" type="com.c2kernel.process.module.ModuleInfo">
+ <field name="id" direct="false" type="string" get-method="getID" set-method="setID">
+ <bind-xml name="id" node="attribute" />
+ </field>
+ <field name="info" direct="false" type="com.c2kernel.process.module.ModuleInfo">
<bind-xml name="Info" node="element" />
</field>
- <field name="resURL" direct="true" type="string">
+ <field name="resURL" direct="false" type="string">
<bind-xml name="ResourceURL" node="element" />
</field>
- <field name="imports" direct="true" type="com.c2kernel.process.module.ModuleImports">
+ <field name="imports" direct="false" type="com.c2kernel.process.module.ModuleImports">
<bind-xml name="Imports" node="element" />
</field>
- <field name="config" collection="arraylist" direct="true" type="com.c2kernel.process.module.ModuleConfig">
+ <field name="config" collection="arraylist" direct="false" type="com.c2kernel.process.module.ModuleConfig">
<bind-xml name="Config" node="element" />
</field>
- <field name="scripts" collection="arraylist" direct="true" type="com.c2kernel.process.module.ModuleScript">
+ <field name="scripts" collection="arraylist" direct="false" type="com.c2kernel.process.module.ModuleScript">
<bind-xml name="Script" node="element" />
</field>
</class>
@@ -43,18 +46,23 @@ <bind-xml name="Dependency" node="element" />
</field>
</class>
- <class name="com.c2kernel.process.module.ModuleResource" extends="com.c2kernel.process.module.ModuleImport">
- <map-to xml="Resource"/>
- <field name="name" direct="true" type="string">
+ <class name="com.c2kernel.process.module.ModuleImport">
+ <field name="name" direct="false" type="string">
<bind-xml name="name" node="attribute" />
</field>
- <field name="version" direct="true" type="integer">
+ <field name="id" direct="false" type="string" get-method="getID" set-method="setID">
+ <bind-xml name="id" node="attribute" />
+ </field>
+ </class>
+ <class name="com.c2kernel.process.module.ModuleResource" extends="com.c2kernel.process.module.ModuleImport">
+ <map-to xml="Resource"/>
+ <field name="version" direct="false" type="integer">
<bind-xml name="version" node="attribute" />
</field>
- <field name="resourceType" direct="true" type="string">
+ <field name="resourceType" direct="false" type="string">
<bind-xml name="type" node="attribute" />
</field>
- <field name="resourceLocation" direct="true" type="string">
+ <field name="resourceLocation" direct="false" type="string">
<bind-xml node="text" />
</field>
</class>
diff --git a/src/main/resources/mapFiles/NewEntityMap.xml b/src/main/resources/mapFiles/NewEntityMap.xml index 1e58a9e..58de4d1 100644 --- a/src/main/resources/mapFiles/NewEntityMap.xml +++ b/src/main/resources/mapFiles/NewEntityMap.xml @@ -2,28 +2,31 @@ <mapping>
<class name="com.c2kernel.entity.imports.ImportItem">
<map-to xml="Item"/>
- <field name="name" type="string" direct="true">
+ <field name="name" type="string" direct="false">
<bind-xml name="name" node="attribute"/>
</field>
- <field name="initialPath" type="string" direct="true">
+ <field name="initialPath" type="string" direct="false">
<bind-xml name="initialPath" node="attribute"/>
</field>
- <field name="workflow" type="string" direct="true">
+ <field name="itemPath" type="string" direct="false" get-method="getID" set-method="setID">
+ <bind-xml name="id" node="attribute"/>
+ </field>
+ <field name="workflow" type="string" direct="false">
<bind-xml name="workflow" node="attribute"/>
</field>
- <field name="workflowVer" type="integer" direct="true">
+ <field name="workflowVer" type="integer" direct="false">
<bind-xml name="workflowVer" node="attribute"/>
</field>
- <field name="properties" collection="arraylist" direct="true" type="com.c2kernel.property.Property">
+ <field name="properties" collection="arraylist" direct="false" type="com.c2kernel.property.Property">
<bind-xml name="Property" node="element"/>
</field>
- <field name="outcomes" collection="arraylist" direct="true" type="com.c2kernel.entity.imports.ImportOutcome">
+ <field name="outcomes" collection="arraylist" direct="false" type="com.c2kernel.entity.imports.ImportOutcome">
<bind-xml name="Outcome" node="element"/>
</field>
- <field name="dependencyList" collection="arraylist" direct="true" type="com.c2kernel.entity.imports.ImportDependency">
+ <field name="dependencyList" collection="arraylist" direct="false" type="com.c2kernel.entity.imports.ImportDependency">
<bind-xml name="Dependency" node="element"/>
</field>
- <field name="aggregationList" collection="arraylist" direct="true" type="com.c2kernel.entity.imports.ImportAggregation">
+ <field name="aggregationList" collection="arraylist" direct="false" type="com.c2kernel.entity.imports.ImportAggregation">
<bind-xml name="Aggregation" node="element"/>
</field>
</class>
@@ -113,25 +116,28 @@ </class>
<class name="com.c2kernel.entity.imports.ImportAgent">
<map-to xml="Agent"/>
- <field name="name" type="string" direct="true">
+ <field name="name" type="string" direct="false">
<bind-xml name="name" node="attribute"/>
</field>
- <field name="password" type="string" direct="true">
+ <field name="password" type="string" direct="false">
<bind-xml name="password" node="attribute"/>
</field>
- <field name="roles" collection="arraylist" direct="true" type="string">
+ <field name="roles" collection="arraylist" direct="false" type="string">
<bind-xml name="Role" node="element"/>
</field>
- <field name="properties" collection="arraylist" direct="true" type="com.c2kernel.property.Property">
+ <field name="properties" collection="arraylist" direct="false" type="com.c2kernel.property.Property">
<bind-xml name="Property" node="element"/>
</field>
+ <field name="mItemPath" type="string" direct="false" get-method="getID" set-method="setID">
+ <bind-xml name="id" node="attribute"/>
+ </field>
</class>
<class name="com.c2kernel.entity.imports.ImportRole">
<map-to xml="Role"/>
- <field name="name" type="string" direct="true">
+ <field name="name" type="string" direct="false">
<bind-xml name="name" node="text"/>
</field>
- <field name="jobList" type="boolean" direct="true">
+ <field name="jobList" type="boolean" direct="false" get-method="hasJobList">
<bind-xml name="jobList" node="attribute"/>
</field>
</class>
diff --git a/src/main/resources/mapFiles/TransferMap.xml b/src/main/resources/mapFiles/TransferMap.xml index a280ef3..814bbb2 100644 --- a/src/main/resources/mapFiles/TransferMap.xml +++ b/src/main/resources/mapFiles/TransferMap.xml @@ -8,10 +8,10 @@ </field>
</class>
<class name="com.c2kernel.entity.transfer.TransferItem">
- <field name="sysKey" type="integer" direct="true">
- <bind-xml name="sysKey" node="attribute"/>
- </field>
- <field name="domainPaths" collection="arraylist" direct="true"
+ <field name="mItemPath" type="string" direct="false" get-method="getUUID" set-method="setUUID">
+ <bind-xml name="ItemUUID" node="attribute"/>
+ </field>
+ <field name="domainPaths" collection="arraylist" direct="false"
type="string">
<bind-xml name="DomainPaths" node="element"/>
</field>
diff --git a/src/main/resources/mapFiles/ViewpointMap.xml b/src/main/resources/mapFiles/ViewpointMap.xml index 6799418..eb14175 100644 --- a/src/main/resources/mapFiles/ViewpointMap.xml +++ b/src/main/resources/mapFiles/ViewpointMap.xml @@ -2,9 +2,9 @@ <mapping>
<class name="com.c2kernel.persistency.outcome.Viewpoint">
<map-to xml="Viewpoint"/>
- <field name="sysKey" type="integer" direct="false" get-method="getSysKey" set-method="setSysKey">
- <bind-xml name="SysKey" node="attribute"/>
- </field>
+ <field name="mItemPath" type="string" direct="false" get-method="getItemUUID" set-method="setItemUUID">
+ <bind-xml name="ItemUUID" node="attribute"/>
+ </field>
<field name="schemaName" type="string" direct="false" get-method="getSchemaName" set-method="setSchemaName">
<bind-xml name="SchemaName" node="attribute"/>
</field>
|
