summaryrefslogtreecommitdiff
path: root/source/com/c2kernel/lifecycle/instance/predefined
diff options
context:
space:
mode:
Diffstat (limited to 'source/com/c2kernel/lifecycle/instance/predefined')
-rwxr-xr-xsource/com/c2kernel/lifecycle/instance/predefined/AddC2KObject.java74
-rwxr-xr-xsource/com/c2kernel/lifecycle/instance/predefined/AddDomainPath.java66
-rwxr-xr-xsource/com/c2kernel/lifecycle/instance/predefined/AddStepsFromDescription.java55
-rwxr-xr-xsource/com/c2kernel/lifecycle/instance/predefined/AssignItemToSlot.java116
-rwxr-xr-xsource/com/c2kernel/lifecycle/instance/predefined/CreateItemFromDescription.java181
-rwxr-xr-xsource/com/c2kernel/lifecycle/instance/predefined/Erase.java83
-rwxr-xr-xsource/com/c2kernel/lifecycle/instance/predefined/Import.java68
-rwxr-xr-xsource/com/c2kernel/lifecycle/instance/predefined/PredefinedStep.java149
-rwxr-xr-xsource/com/c2kernel/lifecycle/instance/predefined/PredefinedStepContainer.java57
-rwxr-xr-xsource/com/c2kernel/lifecycle/instance/predefined/RemoveC2KObject.java66
-rwxr-xr-xsource/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java58
-rwxr-xr-xsource/com/c2kernel/lifecycle/instance/predefined/ReplaceDomainWorkflow.java52
-rwxr-xr-xsource/com/c2kernel/lifecycle/instance/predefined/ServerPredefinedStepContainer.java40
-rwxr-xr-xsource/com/c2kernel/lifecycle/instance/predefined/WriteProperty.java76
-rwxr-xr-xsource/com/c2kernel/lifecycle/instance/predefined/entitycreation/Aggregation.java26
-rwxr-xr-xsource/com/c2kernel/lifecycle/instance/predefined/entitycreation/AggregationMember.java21
-rwxr-xr-xsource/com/c2kernel/lifecycle/instance/predefined/entitycreation/CreateNewAgent.java46
-rwxr-xr-xsource/com/c2kernel/lifecycle/instance/predefined/entitycreation/CreateNewItem.java45
-rwxr-xr-xsource/com/c2kernel/lifecycle/instance/predefined/entitycreation/Dependency.java46
-rwxr-xr-xsource/com/c2kernel/lifecycle/instance/predefined/entitycreation/DependencyMember.java18
-rwxr-xr-xsource/com/c2kernel/lifecycle/instance/predefined/entitycreation/Geometry.java29
-rwxr-xr-xsource/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewAgent.java65
-rwxr-xr-xsource/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java145
-rwxr-xr-xsource/com/c2kernel/lifecycle/instance/predefined/entitycreation/Property.java26
24 files changed, 1608 insertions, 0 deletions
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/AddC2KObject.java b/source/com/c2kernel/lifecycle/instance/predefined/AddC2KObject.java
new file mode 100755
index 0000000..27759be
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/instance/predefined/AddC2KObject.java
@@ -0,0 +1,74 @@
+/**************************************************************************
+ * AddC2KObject
+ *
+ * $Workfile$
+ * $Revision: 1.31 $
+ * $Date: 2004/10/21 08:02:19 $
+ *
+ * Copyright (C) 2001 CERN - European Organization for Nuclear Research
+ * All rights reserved.
+ **************************************************************************/
+
+package com.c2kernel.lifecycle.instance.predefined;
+
+import com.c2kernel.common.AccessRightsException;
+import com.c2kernel.common.InvalidDataException;
+import com.c2kernel.common.InvalidTransitionException;
+import com.c2kernel.entity.C2KLocalObject;
+import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.EntityPath;
+import com.c2kernel.process.Gateway;
+import com.c2kernel.utils.CastorXMLUtility;
+import com.c2kernel.utils.Logger;
+
+/**************************************************************************
+ *
+ * @author $Author: abranson $ $Date: 2004/10/21 08:02:19 $
+ * @version $Revision: 1.31 $
+ **************************************************************************/
+public class AddC2KObject extends PredefinedStep
+{
+ /**************************************************************************
+ * Constructor for Castror
+ **************************************************************************/
+ public AddC2KObject()
+ {
+ super();
+ }
+
+ //requestdata is xmlstring
+ public void request( AgentPath agent, int transitionID, String requestData)
+ throws AccessRightsException,
+ InvalidTransitionException,
+ InvalidDataException
+ {
+
+ Logger.msg(1, "AddC2KObject::request() - Starting.");
+
+ checkAccessRights(agent);
+ EntityPath entityPath = getItemEntityPath();
+
+ if (entityPath!=null)
+ {
+ try
+ {
+
+ Logger.msg(5, "AddC2KObject::request() - data:" + getDataList(requestData)[0]);
+
+ C2KLocalObject obj = (C2KLocalObject)CastorXMLUtility.unmarshall(getDataList(requestData)[0]);
+ Gateway.getStorage().put(entityPath.getSysKey(), obj, null );
+ sendEventStoreOutcome(transitionID, requestData, agent);
+ }
+ catch( Exception ex )
+ {
+ Logger.error("AddC2KObject::request() - during unmarshall.");
+ Logger.error(ex);
+ throw new InvalidDataException(ex.toString(), "");
+ }
+
+ Logger.msg(1, "AddC2KObject::request() - DONE.");
+ }
+ else
+ throw new InvalidDataException("EntityPath is null.", "");
+ }
+}
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/AddDomainPath.java b/source/com/c2kernel/lifecycle/instance/predefined/AddDomainPath.java
new file mode 100755
index 0000000..6756895
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/instance/predefined/AddDomainPath.java
@@ -0,0 +1,66 @@
+/**************************************************************************
+ * AddDomainPath
+ *
+ * Copyright (C) 2001 CERN - European Organization for Nuclear Research
+ * All rights reserved.
+ **************************************************************************/
+
+package com.c2kernel.lifecycle.instance.predefined;
+
+
+
+
+import com.c2kernel.common.AccessRightsException;
+import com.c2kernel.common.InvalidDataException;
+import com.c2kernel.common.InvalidTransitionException;
+import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.DomainPath;
+import com.c2kernel.lookup.EntityPath;
+import com.c2kernel.lookup.InvalidEntityPathException;
+import com.c2kernel.lookup.LDAPLookup;
+import com.c2kernel.process.Gateway;
+import com.c2kernel.utils.Logger;
+
+public class AddDomainPath extends PredefinedStep
+{
+ public AddDomainPath()
+ {
+ super();
+ }
+
+ //requestdata is xmlstring
+ public void request( AgentPath agent, int transitionID, String requestData)
+ throws AccessRightsException,
+ InvalidTransitionException,
+ InvalidDataException
+ {
+ Logger.msg(8,"AddAlias::request()");
+ LDAPLookup lookupManager = Gateway.getLDAPLookup();
+
+ Logger.msg(1,"AddAlias::request() - Starting.");
+
+ checkAccessRights(agent);
+
+ try
+ {
+ EntityPath entityPath = getItemEntityPath();
+ DomainPath domainPath = new DomainPath(getDataList(requestData)[0], entityPath);
+ lookupManager.add(domainPath);
+ Logger.msg(8,"AddDomainPath::request() - systemKey:" + entityPath.getSysKey() +
+ ". Adding dompath. DONE.");
+ }
+ catch (InvalidEntityPathException 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(), "");
+ }
+
+ sendEventStoreOutcome(transitionID, requestData, agent);
+ }
+}
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/AddStepsFromDescription.java b/source/com/c2kernel/lifecycle/instance/predefined/AddStepsFromDescription.java
new file mode 100755
index 0000000..c4fab0c
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/instance/predefined/AddStepsFromDescription.java
@@ -0,0 +1,55 @@
+package com.c2kernel.lifecycle.instance.predefined;
+
+//Java
+import java.awt.Point;
+
+import com.c2kernel.common.AccessRightsException;
+import com.c2kernel.common.InvalidDataException;
+import com.c2kernel.common.InvalidTransitionException;
+import com.c2kernel.lifecycle.CompositeActivityDef;
+import com.c2kernel.lifecycle.instance.CompositeActivity;
+import com.c2kernel.lifecycle.instance.Workflow;
+import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.process.Gateway;
+import com.c2kernel.utils.CastorXMLUtility;
+import com.c2kernel.utils.Logger;
+
+public class AddStepsFromDescription extends PredefinedStep
+{
+ public AddStepsFromDescription()
+ {
+ super();
+ }
+
+ public void request( AgentPath agent, int transitionID, String requestData)
+ throws AccessRightsException, InvalidTransitionException, InvalidDataException
+ {
+ Workflow lifeCycle = getWf();
+
+ Logger.msg(1, "AddStepsFromDescription::request() - Starting ");
+
+ checkAccessRights(agent);
+
+ try
+ {
+
+ Logger.msg(8, "AddStepsFromDescription::request() - data:" + getDataList(requestData)[0]);
+ lifeCycle.getChildGraphModel().removeVertex(lifeCycle.search("workflow/domain"));
+ CompositeActivityDef actDef = (CompositeActivityDef) CastorXMLUtility.unmarshall(getDataList(requestData)[0]);
+ CompositeActivity domain = (CompositeActivity)actDef.instantiate();
+ lifeCycle.initChild(domain, true, new Point(150, 100));
+ domain.setName("domain");
+ domain.setType(actDef.getName());
+ lifeCycle.run(agent);
+ Gateway.getStorage().put(getItemEntityPath().getSysKey(), lifeCycle, null);
+ Logger.msg(1, "AddStepsFromDescription::request() - DONE.");
+ sendEventStoreOutcome(transitionID, requestData, agent);
+ }
+ catch (Exception ex)
+ {
+ Logger.error("AddStepsFromDescription::request() - during unmarshall.");
+ Logger.error(ex);
+ throw new InvalidDataException("AddStepsFromDescription::request() - during unmarshall.", "");
+ }
+ }
+}
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/AssignItemToSlot.java b/source/com/c2kernel/lifecycle/instance/predefined/AssignItemToSlot.java
new file mode 100755
index 0000000..88f89c3
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/instance/predefined/AssignItemToSlot.java
@@ -0,0 +1,116 @@
+/**************************************************************************
+ * AssignItemToSlot
+ *
+ * $Workfile$
+ * $Revision: 1.8 $
+ * $Date: 2004/10/21 08:02:19 $
+ *
+ * Copyright (C) 2001 CERN - European Organization for Nuclear Research
+ * All rights reserved.
+ **************************************************************************/
+
+package com.c2kernel.lifecycle.instance.predefined;
+
+import java.util.Iterator;
+
+import com.c2kernel.collection.Collection;
+import com.c2kernel.collection.CollectionMember;
+import com.c2kernel.collection.MembershipException;
+import com.c2kernel.common.AccessRightsException;
+import com.c2kernel.common.InvalidDataException;
+import com.c2kernel.common.InvalidTransitionException;
+import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.EntityPath;
+import com.c2kernel.persistency.ClusterStorage;
+import com.c2kernel.persistency.ClusterStorageException;
+import com.c2kernel.process.Gateway;
+import com.c2kernel.utils.Logger;
+
+/**************************************************************************
+ *
+ * @author $Author: abranson $ $Date: 2004/10/21 08:02:19 $
+ * @version $Revision: 1.8 $
+ **************************************************************************/
+public class AssignItemToSlot extends PredefinedStep
+{
+ /**************************************************************************
+ * Constructor for Castor
+ **************************************************************************/
+ public AssignItemToSlot()
+ {
+ super();
+ }
+
+
+ /**
+ * Params:
+ * 0 - collection name
+ * 1 - slot number
+ * 2 - target entity key
+ */
+ public void request(AgentPath agent, int transitionID, String requestData)
+ throws AccessRightsException,
+ InvalidTransitionException,
+ InvalidDataException
+ {
+ EntityPath entityPath = getItemEntityPath();
+ String collName;
+ int slotNo;
+ int entityKey;
+ Collection coll;
+
+ Logger.msg(1, "AssignItemToSlot::request() - Starting.");
+
+ checkAccessRights(agent);
+
+ // extract parameters
+ try {
+ entityPath = getItemEntityPath();
+ String[] params = getDataList(requestData);
+ collName = params[0];
+ slotNo = Integer.parseInt(params[1]);
+ entityKey = Integer.parseInt(params[2]);
+ } catch (Exception e) {
+ throw new InvalidDataException("Invalid parameters", "");
+ }
+
+ // load collection
+ try {
+ coll = (Collection)Gateway.getStorage().get(entityPath.getSysKey(), ClusterStorage.COLLECTION+"/"+collName, null);
+ } catch (Exception e) {
+ Logger.error(e);
+ throw new InvalidDataException("Error loading collection "+collName, "");
+ }
+
+ // find member and assign entity
+ boolean stored = false;
+ for (Iterator iter = coll.getMembers().list.iterator(); iter.hasNext();) {
+ CollectionMember member = (CollectionMember)iter.next();
+ if (member.getID() == slotNo) {
+ if (member.getEntityKey() > -1)
+ throw new InvalidDataException("Member slot not empty", "");
+ try {
+ member.assignEntity(entityKey);
+ } catch (MembershipException e) {
+ throw new InvalidDataException("Entity "+entityKey+" does not fit in this slot", "");
+ }
+ stored = true;
+ break;
+ }
+ }
+ if (!stored) {
+ throw new InvalidDataException("Member slot "+slotNo+" not found.", "");
+ }
+
+
+ try {
+ Gateway.getStorage().put(entityPath.getSysKey(), coll, null);
+ } catch (ClusterStorageException e) {
+ Logger.error(e);
+ throw new InvalidDataException("Error storing collection", "");
+ }
+ sendEventStoreOutcome(transitionID, requestData, agent);
+
+ Logger.msg(1, "AssignItemToSlot::request() - DONE.");
+ }
+}
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/CreateItemFromDescription.java b/source/com/c2kernel/lifecycle/instance/predefined/CreateItemFromDescription.java
new file mode 100755
index 0000000..eddec34
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/instance/predefined/CreateItemFromDescription.java
@@ -0,0 +1,181 @@
+/**************************************************************************
+ * CreateItemFromDescription
+ *
+ * $Workfile$
+ * $Revision: 1.47 $
+ * $Date: 2005/10/13 08:13:58 $
+ *
+ * Copyright (C) 2001 CERN - European Organization for Nuclear Research
+ * All rights reserved.
+ **************************************************************************/
+
+package com.c2kernel.lifecycle.instance.predefined;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import com.c2kernel.collection.Collection;
+import com.c2kernel.collection.CollectionDescription;
+import com.c2kernel.collection.CollectionMember;
+import com.c2kernel.common.AccessRightsException;
+import com.c2kernel.common.InvalidDataException;
+import com.c2kernel.common.InvalidTransitionException;
+import com.c2kernel.common.ObjectAlreadyExistsException;
+import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.entity.CorbaServer;
+import com.c2kernel.entity.TraceableEntity;
+import com.c2kernel.lifecycle.CompositeActivityDef;
+import com.c2kernel.lifecycle.instance.stateMachine.Transitions;
+import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.DomainPath;
+import com.c2kernel.lookup.EntityPath;
+import com.c2kernel.lookup.LDAPLookup;
+import com.c2kernel.persistency.ClusterStorage;
+import com.c2kernel.persistency.TransactionManager;
+import com.c2kernel.process.Gateway;
+import com.c2kernel.property.Property;
+import com.c2kernel.property.PropertyArrayList;
+import com.c2kernel.property.PropertyDescription;
+import com.c2kernel.property.PropertyDescriptionList;
+import com.c2kernel.property.PropertyUtility;
+import com.c2kernel.utils.CastorXMLUtility;
+import com.c2kernel.utils.LocalObjectLoader;
+import com.c2kernel.utils.Logger;
+
+/**************************************************************************
+ *
+ * @author $Author: abranson $ $Date: 2005/10/13 08:13:58 $
+ * @version $Revision: 1.47 $
+ **************************************************************************/
+public class CreateItemFromDescription extends PredefinedStep
+{
+ public CreateItemFromDescription()
+ {
+ super();
+ }
+
+ //requestdata is xmlstring
+ public void request(AgentPath agent, int transitionID, String requestData)
+ throws AccessRightsException, InvalidTransitionException, InvalidDataException,ObjectAlreadyExistsException
+ {
+ String[] input = getDataList(requestData);
+ String newName = input[0];
+ String domPath = input[1];
+ CompositeActivityDef wfDef;
+ String wfDefName = null;
+ if (input.length > 2) // override wf
+ wfDefName = input[2];
+
+ PropertyArrayList props = new PropertyArrayList();
+ Logger.msg(1, "AddNewItem::request() - Starting.");
+ TransactionManager storage = Gateway.getStorage();
+ LDAPLookup lookup = Gateway.getLDAPLookup();
+ EntityPath myPath = getItemEntityPath();
+ checkAccessRights(agent);
+
+ 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.");
+
+ // get init objects
+ String[] collNames = storage.getClusterContents(myPath.getSysKey(), ClusterStorage.COLLECTION);
+ ArrayList collections = new ArrayList();
+
+
+ // loop through collections to instantiate
+ for (int i = 0; i < collNames.length; i++) {
+ Collection thisCol = (Collection)storage.get(myPath.getSysKey(), ClusterStorage.COLLECTION+"/"+collNames[i], null);
+ if (thisCol instanceof CollectionDescription) {
+ CollectionDescription thisDesc = (CollectionDescription)thisCol;
+ collections.add(CastorXMLUtility.marshall(thisDesc.newInstance()));
+ }
+ else if (thisCol.getName().equals("Workflow") && wfDefName == null) {
+ ArrayList members = thisCol.getMembers().list;
+ // get the first member from the wf collection
+ CollectionMember wfMember = (CollectionMember)members.get(0);
+ wfDefName = wfMember.resolveEntity().getName();
+ }
+ }
+
+ // load workflow def
+ if (wfDefName == null)
+ throw new InvalidDataException("No workflow given or defined", "");
+
+ try {
+ wfDef = (CompositeActivityDef)LocalObjectLoader.getActDef(wfDefName, "last");
+ } catch (ObjectNotFoundException ex) {
+ throw new InvalidDataException("Workflow def '"+wfDefName+"' item not found", "");
+ } catch (ClassCastException ex) {
+ throw new InvalidDataException("Activity def '"+wfDefName+"' was not Composite", "");
+ }
+
+
+ // copy properties -- intend to create from propdesc
+ PropertyDescriptionList pdList = PropertyUtility.getPropertyDescriptionOutcome(myPath.getSysKey());
+ for (int i = 0; i < pdList.list.size(); i++) {
+ PropertyDescription pd = (PropertyDescription) pdList.list.get(i);
+ String propName = pd.getName();
+ String propVal = pd.getDefaultValue();
+ if (propName.equals("Name"))
+ propVal = newName;
+ props.list.add( new Property(propName, propVal));
+ }
+ props.list.add( new Property("Creator", agent.getAgentName()));
+
+ /* ITEM CREATION */
+
+ // generate new entity key
+ Logger.msg(6, "CreateItemFromDescription - Requesting new sysKey");
+ EntityPath entityPath = lookup.getNextKeyManager().generateNextEntityKey();
+
+ // resolve the item factory
+ Logger.msg(6, "CreateItemFromDescription - Resolving item factory");
+
+ // create the Item object
+ 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.getLDAPLookup().add(entityPath);
+
+
+ // initialise it with its properties and workflow
+
+ Logger.msg(3, "CreateItemFromDescription - Initializing Item");
+
+ newItem.initialise(
+ agent.getSysKey(),
+ CastorXMLUtility.marshall(props),
+ CastorXMLUtility.marshall(wfDef.instantiate()));
+
+ // add collections
+ if (collections.size() > 0) {
+ Logger.msg(6, "CreateItemFromDescription - Adding Collections");
+ String[] colls = new String[1];
+ for (Iterator iter = collections.iterator(); iter.hasNext();) {
+ colls[0] = (String)iter.next();
+ newItem.requestAction(agent.getSysKey(), "workflow/predefined/AddC2KObject", Transitions.COMPLETE, PredefinedStep.bundleData(colls));
+ }
+ }
+
+ // add its domain path
+ Logger.msg(3, "CreateItemFromDescription - Creating "+context);
+ context.setEntity(entityPath);
+ Gateway.getLDAPLookup().add(context);
+ } catch (ObjectAlreadyExistsException e) {
+ Logger.error(e);
+ throw e;
+ } catch (AccessRightsException e) {
+ Logger.error(e);
+ throw e;
+ } catch (Exception e) {
+ Logger.error(e);
+ throw new InvalidDataException(e.getMessage(), "");
+ }
+
+ sendEventStoreOutcome(transitionID, requestData, agent);
+ }
+}
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/Erase.java b/source/com/c2kernel/lifecycle/instance/predefined/Erase.java
new file mode 100755
index 0000000..5c04f93
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/instance/predefined/Erase.java
@@ -0,0 +1,83 @@
+/**************************************************************************
+ * RemoveC2KObject
+ *
+ * $Workfile$
+ * $Revision: 1.10 $
+ * $Date: 2005/11/15 15:56:38 $
+ *
+ * Copyright (C) 2001 CERN - European Organization for Nuclear Research
+ * All rights reserved.
+ **************************************************************************/
+
+package com.c2kernel.lifecycle.instance.predefined;
+
+
+
+import java.util.Enumeration;
+
+import com.c2kernel.common.AccessRightsException;
+import com.c2kernel.common.InvalidDataException;
+import com.c2kernel.common.InvalidTransitionException;
+import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.DomainPath;
+import com.c2kernel.lookup.EntityPath;
+import com.c2kernel.persistency.ClusterStorage;
+import com.c2kernel.process.Gateway;
+import com.c2kernel.property.Property;
+import com.c2kernel.utils.Logger;
+
+
+/**************************************************************************
+ *
+ * @author $Author: abranson $ $Date: 2005/11/15 15:56:38 $
+ * @version $Revision: 1.10 $
+ **************************************************************************/
+public class Erase extends PredefinedStep
+{
+ public Erase()
+ {
+ super();
+ }
+
+ //requestdata is xmlstring
+ public void request(AgentPath agent, int transitionID, String requestData)
+ throws AccessRightsException,
+ InvalidTransitionException,
+ InvalidDataException
+ {
+ Logger.msg(1, "Erase::request() - Starting.");
+
+ checkAccessRights(agent);
+ try
+ {
+ EntityPath entityPath = getItemEntityPath();
+
+ // find entity name
+ Property name = (Property)Gateway.getStorage().get(entityPath.getSysKey(), ClusterStorage.PROPERTY+"/Name", null);
+
+ // get all domain paths
+ Enumeration domPaths = Gateway.getLDAPLookup().search(new DomainPath(), name.getValue());
+ while (domPaths.hasMoreElements()) {
+ DomainPath path = (DomainPath)domPaths.nextElement();
+ // delete them
+ if (path.getSysKey() == entityPath.getSysKey())
+ Gateway.getLDAPLookup().delete(path);
+ }
+
+ //clear out all storages
+ Gateway.getStorage().removeCluster(entityPath.getSysKey(), "", null);
+
+ //remove domain path
+ Gateway.getLDAPLookup().delete(entityPath);
+ }
+ catch( Exception ex )
+ {
+
+ Logger.error(ex);
+ throw new InvalidDataException(ex.toString(), "");
+ }
+
+ Logger.msg(1, "Erase::request() - DONE.");
+ }
+
+}
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/Import.java b/source/com/c2kernel/lifecycle/instance/predefined/Import.java
new file mode 100755
index 0000000..36b7fc9
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/instance/predefined/Import.java
@@ -0,0 +1,68 @@
+/**************************************************************************
+ * AddDomainPath
+ *
+ * Copyright (C) 2001 CERN - European Organization for Nuclear Research
+ * All rights reserved.
+ **************************************************************************/
+
+package com.c2kernel.lifecycle.instance.predefined;
+
+import com.c2kernel.common.*;
+import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.utils.Logger;
+
+/**************************************************************************
+ *
+ * $Revision: 1.21 $
+ * $Date: 2005/06/02 12:17:22 $
+ *
+ * Params: Schemaname_version:Viewpoint (optional), Outcome
+ *
+ * Copyright (C) 2003 CERN - European Organization for Nuclear Research
+ * All rights reserved.
+ **************************************************************************/
+public class Import extends PredefinedStep
+{
+ public Import()
+ {
+ super();
+ }
+
+ //requestdata is xmlstring
+ public void request( AgentPath agent, int transitionID, String requestData)
+ throws AccessRightsException,
+ InvalidTransitionException,
+ InvalidDataException
+ {
+ Logger.msg(8,"Import::request()");
+
+ Logger.msg(1,"Import::request() - Starting.");
+
+ checkAccessRights(agent);
+
+ String[] params = getDataList(requestData);
+
+
+ int split1 = params[0].indexOf('_');
+ int split2 = params[0].indexOf(':');
+
+ String schemaName = params[0].substring(0, split1);
+ String viewpoint = "last";
+ int schemaVersion;
+ if (split2 > -1) {
+ schemaVersion = Integer.parseInt(params[0].substring(split1+1, split2));
+ viewpoint = params[0].substring(split2+1);
+ }
+ else
+ schemaVersion = Integer.parseInt(params[0].substring(split1+1));
+
+ // set type & ver
+ getProperties().put("SchemaType", schemaName);
+ getProperties().put("SchemaVersion", String.valueOf(schemaVersion));
+ getProperties().put("Viewpoint", viewpoint);
+
+ requestData = params[1];
+
+ sendEventStoreOutcome(transitionID, requestData, agent);
+ }
+}
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/PredefinedStep.java b/source/com/c2kernel/lifecycle/instance/predefined/PredefinedStep.java
new file mode 100755
index 0000000..8d95438
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/instance/predefined/PredefinedStep.java
@@ -0,0 +1,149 @@
+package com.c2kernel.lifecycle.instance.predefined;
+import java.io.StringReader;
+import java.io.StringWriter;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import org.apache.xml.serialize.Method;
+import org.apache.xml.serialize.OutputFormat;
+import org.apache.xml.serialize.XMLSerializer;
+import org.w3c.dom.CDATASection;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.xml.sax.InputSource;
+import com.c2kernel.lifecycle.instance.Activity;
+import com.c2kernel.utils.Logger;
+/***********************************************************************************************************************************************************************************************************************************************************************************************************
+ * @author $Author: sgaspard $ $Date: 2004/09/21 10:32:17 $
+ * @version $Revision: 1.14 $
+ **********************************************************************************************************************************************************************************************************************************************************************************************************/
+public class PredefinedStep extends Activity
+{
+ /*******************************************************************************************************************************************************************************************************************************************************************************************************
+ * predefined Steps are always Active, and have only one transition subclasses could override this method (if necessary)
+ ******************************************************************************************************************************************************************************************************************************************************************************************************/
+ private boolean isPredefined = false;
+ public boolean getActive()
+ {
+ if (isPredefined)
+ return true;
+ else
+ return super.getActive();
+ }
+ public String getTransitions()
+ {
+ if (isPredefined)
+ return "<PossibleTransitions>done</PossibleTransitions>";
+ else
+ return super.getTransitions();
+ }
+ public String getErrors()
+ {
+ if (isPredefined)
+ return getName();
+ else
+ return super.getErrors();
+ }
+ public boolean verify()
+ {
+ if (isPredefined)
+ return true;
+ else
+ return super.verify();
+ }
+ /**
+ * Returns the isPredefined.
+ *
+ * @return boolean
+ */
+ public boolean getIsPredefined()
+ {
+ return isPredefined;
+ }
+ /**
+ * Sets the isPredefined.
+ *
+ * @param isPredefined
+ * The isPredefined to set
+ */
+ public void setIsPredefined(boolean isPredefined)
+ {
+ this.isPredefined = isPredefined;
+ }
+ public String getType()
+ {
+ return getName();
+ }
+ // generic bundling of parameters
+ static public String bundleData(String[] data)
+ {
+ try
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder builder = factory.newDocumentBuilder();
+ Document dom = builder.newDocument();
+ Element root = dom.createElement("PredefinedStepOutcome");
+ dom.appendChild(root);
+ for (int i = 0; i < data.length; i++)
+ {
+ Element param = dom.createElement("param");
+ Text t = dom.createTextNode(data[i]);
+ param.appendChild(t);
+ root.appendChild(param);
+ }
+ // xalan method - use internal xerces one instead
+// TransformerFactory transFactory = TransformerFactory.newInstance();
+// Transformer transformer = transFactory.newTransformer();
+// StringWriter stringOut = new StringWriter();
+// transformer.transform(new DOMSource(dom), new StreamResult(stringOut));
+// return stringOut.toString();
+
+ OutputFormat format = new OutputFormat(Method.XML, null, false);
+ StringWriter stringOut = new StringWriter();
+ XMLSerializer serial = new XMLSerializer(stringOut, format);
+ serial.asDOMSerializer();
+ serial.serialize(dom);
+ return stringOut.toString();
+ }
+ catch (Exception e)
+ {
+ Logger.error(e);
+ StringBuffer xmlData = new StringBuffer().append("<PredefinedStepOutcome>");
+ for (int i = 0; i < data.length; i++)
+ xmlData.append("<param><![CDATA[").append(data[i]).append("]]></param>");
+ xmlData.append("</PredefinedStepOutcome>");
+ return xmlData.toString();
+ }
+ }
+ // generic bundling of single parameter
+ static public String bundleData(String data)
+ {
+ return "<PredefinedStepOutcome><param><![CDATA[" + data + "]]></param></PredefinedStepOutcome>";
+ }
+ static public String[] getDataList(String xmlData)
+ {
+ try
+ {
+ Document scriptDoc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader(xmlData)));
+ NodeList nodeList = scriptDoc.getElementsByTagName("param");
+ String[] result = new String[nodeList.getLength()];
+ for (int i = 0; i < nodeList.getLength(); i++)
+ {
+ Node n = nodeList.item(i).getFirstChild();
+ if (n instanceof CDATASection)
+ result[i] = ((CDATASection) n).getData();
+ else if (n instanceof Text)
+ result[i] = ((Text) n).getData();
+ }
+ return result;
+ }
+ catch (Exception ex)
+ {
+ Logger.error("Exception::PredefinedStep::getDataList()");
+ Logger.error(ex);
+ }
+ return null;
+ }
+}
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/PredefinedStepContainer.java b/source/com/c2kernel/lifecycle/instance/predefined/PredefinedStepContainer.java
new file mode 100755
index 0000000..10a9d12
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/instance/predefined/PredefinedStepContainer.java
@@ -0,0 +1,57 @@
+package com.c2kernel.lifecycle.instance.predefined;
+import com.c2kernel.graph.model.GraphPoint;
+import com.c2kernel.lifecycle.instance.CompositeActivity;
+public class PredefinedStepContainer extends CompositeActivity
+{
+ protected int num = 0;
+
+ public PredefinedStepContainer()
+ {
+ super();
+ setName("predefined");
+ getProperties().put("Description", "Contains all predefined Steps");
+ createChildren();
+ }
+ public void createChildren()
+ {
+ predInit("CreateItemFromDescription", "Create a new item using this item as its description", new CreateItemFromDescription());
+ predInit("AddDomainPath", "Adds a new path to this entity in the LDAP domain tree", new AddDomainPath());
+ predInit("RemoveDomainPath", "Removes an existing path to this Entity from the LDAP domain tree", new RemoveDomainPath());
+ predInit("AddStepsFromDescription", "Creates the domain-specific LifeCycle from a description", new AddStepsFromDescription());
+ predInit("ReplaceDomainWorkflow", "Replaces the domain CA with the supplied one. Used by the GUI to save new Wf layout", new ReplaceDomainWorkflow());
+ predInit("AddC2KObject", "Adds a new named C2Kernel object to this Item", new AddC2KObject());
+ predInit("WriteProperty", "Writes a property to the Item", new WriteProperty());
+ predInit("RemoveC2KObject", "Removes the named C2Kernel object from this Item.", new RemoveC2KObject());
+ predInit("AssignItemToSlot", "Assigns the referenced entity to a pre-existing slot in a collection of this one", new AssignItemToSlot());
+ predInit("Erase", "Deletes all objects and domain paths for this item.", new Erase());
+ predInit("Import", "Imports an outcome into the Item, with a given schema and viewpoint", new Import());
+ }
+
+ public void predInit(String alias, String Description, PredefinedStep act)
+ {
+ act.setName(alias);
+ act.setType(alias);
+ act.getProperties().put("Description", Description);
+ act.getProperties().put("SchemaType", "PredefinedStepOutcome");
+ act.getProperties().put("SchemaVersion", "0");
+ act.setCentrePoint(new GraphPoint());
+ act.setIsPredefined(true);
+ addChild(act, new GraphPoint(100, 75 * ++num));
+ }
+ public boolean verify()
+ {
+ return true;
+ }
+ public String getErrors()
+ {
+ return "predefined";
+ }
+ public boolean getActive()
+ {
+ return true;
+ }
+ public String getTransitions()
+ {
+ return "<PossibleTransitions></PossibleTransitions>";
+ }
+}
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/RemoveC2KObject.java b/source/com/c2kernel/lifecycle/instance/predefined/RemoveC2KObject.java
new file mode 100755
index 0000000..8004488
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/instance/predefined/RemoveC2KObject.java
@@ -0,0 +1,66 @@
+/**************************************************************************
+ * RemoveC2KObject
+ *
+ * $Workfile$
+ * $Revision: 1.28 $
+ * $Date: 2005/11/15 15:56:38 $
+ *
+ * Copyright (C) 2001 CERN - European Organization for Nuclear Research
+ * All rights reserved.
+ **************************************************************************/
+
+package com.c2kernel.lifecycle.instance.predefined;
+
+
+
+import com.c2kernel.common.AccessRightsException;
+import com.c2kernel.common.InvalidDataException;
+import com.c2kernel.common.InvalidTransitionException;
+import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.EntityPath;
+import com.c2kernel.process.Gateway;
+import com.c2kernel.utils.Logger;
+
+
+/**************************************************************************
+ *
+ * @author $Author: abranson $ $Date: 2005/11/15 15:56:38 $
+ * @version $Revision: 1.28 $
+ **************************************************************************/
+public class RemoveC2KObject extends PredefinedStep
+{
+ public RemoveC2KObject()
+ {
+ super();
+ }
+
+ //requestdata is xmlstring
+ public void request(AgentPath agent, int transitionID, String requestData)
+ throws AccessRightsException,
+ InvalidTransitionException,
+ InvalidDataException
+ {
+ Logger.msg(1, "RemoveC2KObject::request() - Starting.");
+
+ checkAccessRights(agent);
+ String path = null;
+ try
+ {
+ path = getDataList(requestData)[0];
+ EntityPath entityPath = getItemEntityPath();
+
+ Logger.msg(5, "RemoveC2KObject::request() - path:"+path);
+
+ Gateway.getStorage().remove( entityPath.getSysKey(), path, null );
+ sendEventStoreOutcome(transitionID, requestData, agent);
+ }
+ catch( Exception ex )
+ {
+ Logger.error("RemoveC2KObject::request() - invalid data - path:"+path);
+ Logger.error(ex);
+ throw new InvalidDataException(ex.toString(), "");
+ }
+
+ Logger.msg(1, "RemoveC2KObject::request() - DONE.");
+ }
+}
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java b/source/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java
new file mode 100755
index 0000000..af118e5
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/instance/predefined/RemoveDomainPath.java
@@ -0,0 +1,58 @@
+/**************************************************************************
+ * AddDomainPath
+ *
+ * Copyright (C) 2001 CERN - European Organization for Nuclear Research
+ * All rights reserved.
+ **************************************************************************/
+
+package com.c2kernel.lifecycle.instance.predefined;
+
+
+
+
+import com.c2kernel.common.AccessRightsException;
+import com.c2kernel.common.InvalidDataException;
+import com.c2kernel.common.InvalidTransitionException;
+import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.DomainPath;
+import com.c2kernel.lookup.LDAPLookup;
+import com.c2kernel.process.Gateway;
+import com.c2kernel.utils.Logger;
+
+public class RemoveDomainPath extends PredefinedStep
+{
+ public RemoveDomainPath()
+ {
+ super();
+ }
+
+ //requestdata is xmlstring
+ public void request( AgentPath agent, int transitionID, String requestData)
+ throws AccessRightsException,
+ InvalidTransitionException,
+ InvalidDataException
+ {
+ Logger.msg(8,"RemoveDomainPath::request()");
+ LDAPLookup lookupManager = Gateway.getLDAPLookup();
+
+ Logger.msg(1,"RemoveDomainPath::request() - Starting.");
+
+ checkAccessRights(agent);
+
+ try
+ {
+ DomainPath domainPath = new DomainPath(getDataList(requestData)[0]);
+ lookupManager.delete(domainPath);
+ Logger.msg(8,"AddAlias::request() - context:" + domainPath.toString() + " DONE.");
+
+ }
+ catch( Exception ex )
+ {
+ Logger.error("AddAlias::request() - during anyHelper.extract.");
+ Logger.error(ex);
+ throw new InvalidDataException(ex.toString(), "");
+ }
+
+ sendEventStoreOutcome(transitionID, requestData, agent);
+ }
+}
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/ReplaceDomainWorkflow.java b/source/com/c2kernel/lifecycle/instance/predefined/ReplaceDomainWorkflow.java
new file mode 100755
index 0000000..e8c6a6f
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/instance/predefined/ReplaceDomainWorkflow.java
@@ -0,0 +1,52 @@
+package com.c2kernel.lifecycle.instance.predefined;
+
+//Java
+import java.awt.Point;
+
+import com.c2kernel.common.AccessRightsException;
+import com.c2kernel.common.InvalidDataException;
+import com.c2kernel.common.InvalidTransitionException;
+import com.c2kernel.lifecycle.instance.CompositeActivity;
+import com.c2kernel.lifecycle.instance.Workflow;
+import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.process.Gateway;
+import com.c2kernel.utils.CastorXMLUtility;
+import com.c2kernel.utils.Logger;
+
+public class ReplaceDomainWorkflow extends PredefinedStep
+{
+ public ReplaceDomainWorkflow()
+ {
+ super();
+ }
+
+ public void request( AgentPath agent, int transitionID, String requestData)
+ throws AccessRightsException, InvalidTransitionException, InvalidDataException
+ {
+ Workflow lifeCycle = getWf();
+
+ Logger.msg(1, "ReplaceDomainWorkflow::request() - Starting ");
+
+ checkAccessRights(agent);
+
+ try
+ {
+
+ Logger.msg(8, "ReplaceDomainWorkflow::request() - data:" + getDataList(requestData)[0]);
+ lifeCycle.getChildGraphModel().removeVertex(lifeCycle.search("workflow/domain"));
+ CompositeActivity domain = (CompositeActivity) CastorXMLUtility.unmarshall(getDataList(requestData)[0]);
+ lifeCycle.initChild(domain, true, new Point(150, 100));
+ Gateway.getStorage().put(getItemEntityPath().getSysKey(), lifeCycle, null);
+ Logger.msg(1, "ReplaceDomainWorkflow::request() - DONE.");
+ sendEventStoreOutcome(transitionID, requestData, agent);
+ // refresh jobs
+ lifeCycle.refreshJobs();
+ }
+ catch (Exception ex)
+ {
+ Logger.error("ReplaceDomainWorkflow::request() - during unmarshall.");
+ Logger.error(ex);
+ throw new InvalidDataException("ReplaceDomainWorkflow::request() - during unmarshall.", null);
+ }
+ }
+}
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/ServerPredefinedStepContainer.java b/source/com/c2kernel/lifecycle/instance/predefined/ServerPredefinedStepContainer.java
new file mode 100755
index 0000000..363d1fc
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/instance/predefined/ServerPredefinedStepContainer.java
@@ -0,0 +1,40 @@
+package com.c2kernel.lifecycle.instance.predefined;
+
+import com.c2kernel.graph.model.GraphPoint;
+import com.c2kernel.lifecycle.instance.predefined.entitycreation.CreateNewAgent;
+import com.c2kernel.lifecycle.instance.predefined.entitycreation.CreateNewItem;
+
+/**************************************************************************
+ *
+ * $Revision: 1.2 $
+ * $Date: 2005/06/02 10:19:33 $
+ *
+ * Copyright (C) 2003 CERN - European Organization for Nuclear Research
+ * All rights reserved.
+ **************************************************************************/
+
+// public static final String codeRevision = "$Revision: 1.2 $ $Date: 2005/06/02 10:19:33 $ $Author: abranson $";
+public class ServerPredefinedStepContainer extends PredefinedStepContainer {
+
+
+ public void createChildren()
+ {
+ super.createChildren();
+ serverPredInit("CreateNewItem", "Creates a new Item in this Server without description.", new CreateNewItem(), "NewItem");
+ serverPredInit("CreateNewAgent", "Creates a new Item in this Server without description.", new CreateNewAgent(), "NewAgent");
+ }
+
+ public void serverPredInit(String alias, String Description, PredefinedStep act, String schema)
+ {
+ act.setName(alias);
+ act.setType(alias);
+ act.getProperties().put("Description", Description);
+ act.getProperties().put("SchemaType", schema);
+ act.getProperties().put("SchemaVersion", "0");
+ act.getProperties().put("AgentRole", "Admin");
+ act.setCentrePoint(new GraphPoint());
+ act.setIsPredefined(true);
+ addChild(act, new GraphPoint(100, 75 * ++num));
+ }
+
+}
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/WriteProperty.java b/source/com/c2kernel/lifecycle/instance/predefined/WriteProperty.java
new file mode 100755
index 0000000..da526a2
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/instance/predefined/WriteProperty.java
@@ -0,0 +1,76 @@
+/**************************************************************************
+ * WriteProperty
+ *
+ * $Workfile$
+ * $Revision: 1.3 $
+ * $Date: 2004/10/21 08:02:19 $
+ *
+ * Copyright (C) 2001 CERN - European Organization for Nuclear Research
+ * All rights reserved.
+ **************************************************************************/
+
+package com.c2kernel.lifecycle.instance.predefined;
+
+import com.c2kernel.common.AccessRightsException;
+import com.c2kernel.common.InvalidDataException;
+import com.c2kernel.common.InvalidTransitionException;
+import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.lookup.EntityPath;
+import com.c2kernel.process.Gateway;
+import com.c2kernel.property.Property;
+import com.c2kernel.utils.Logger;
+
+/**************************************************************************
+ *
+ * @author $Author: abranson $ $Date: 2004/10/21 08:02:19 $
+ * @version $Revision: 1.3 $
+ **************************************************************************/
+public class WriteProperty extends PredefinedStep
+{
+ /**************************************************************************
+ * Constructor for Castror
+ **************************************************************************/
+ public WriteProperty()
+ {
+ super();
+ }
+
+ //requestdata is xmlstring
+ public void request( AgentPath agent, int transitionID, String requestData)
+ throws AccessRightsException,
+ InvalidTransitionException,
+ InvalidDataException
+ {
+
+ Logger.msg(1, "WriteProperty::request() - Starting.");
+
+ checkAccessRights(agent);
+ EntityPath entityPath = getItemEntityPath();
+
+ if (entityPath!=null)
+ {
+ String[] params = getDataList(requestData);
+ if (params.length != 2)
+ throw new InvalidDataException("WriteProperty::request() - need 2 params - name and value", "");
+ try
+ {
+
+ Logger.msg(5, "WriteProperty::request() - name:" + params[0] +" val:"+params[1]);
+
+ Property newProp = new Property(params[0], params[1]);
+ Gateway.getStorage().put(entityPath.getSysKey(), newProp, null );
+ sendEventStoreOutcome(transitionID, requestData, agent);
+ }
+ catch( Exception ex )
+ {
+ Logger.error("WriteProperty::request() - during unmarshall.");
+ Logger.error(ex);
+ throw new InvalidDataException(ex.toString(), "");
+ }
+
+ Logger.msg(1, "WriteProperty::request() - DONE.");
+ }
+ else
+ throw new InvalidDataException("EntityPath is null.", "");
+ }
+}
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/Aggregation.java b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/Aggregation.java
new file mode 100755
index 0000000..4abb0e6
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/Aggregation.java
@@ -0,0 +1,26 @@
+package com.c2kernel.lifecycle.instance.predefined.entitycreation;
+
+import java.util.ArrayList;
+
+public class Aggregation implements java.io.Serializable {
+
+ public boolean isDescription;
+ public ArrayList aggregationMemberList;
+ public String name;
+
+ public Aggregation() {
+ super();
+ aggregationMemberList = new ArrayList();
+ }
+
+ public Aggregation(String name, boolean isDescription) {
+ this();
+ this.name = name;
+ this.isDescription = isDescription;
+ }
+
+ public com.c2kernel.collection.Aggregation create() {
+ // TODO: create aggregation
+ return new com.c2kernel.collection.AggregationInstance();
+ }
+}
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/AggregationMember.java b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/AggregationMember.java
new file mode 100755
index 0000000..87baa1d
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/AggregationMember.java
@@ -0,0 +1,21 @@
+package com.c2kernel.lifecycle.instance.predefined.entitycreation;
+
+public class AggregationMember implements java.io.Serializable {
+
+ public int slotNo;
+ public String itemDescriptionPath;
+ public String itemPath;
+ public Geometry geometry;
+
+
+ public AggregationMember() {
+ super();
+ }
+
+ public AggregationMember(int slotNo, String itemDescPath, String itemPath, Geometry geometry) {
+ this.slotNo = slotNo;
+ this.itemDescriptionPath = itemDescPath;
+ this.itemPath = itemPath;
+ this.geometry = geometry;
+ }
+}
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/CreateNewAgent.java b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/CreateNewAgent.java
new file mode 100755
index 0000000..b0eaaec
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/CreateNewAgent.java
@@ -0,0 +1,46 @@
+/**************************************************************************
+ * AddDomainPath
+ *
+ * Copyright (C) 2001 CERN - European Organization for Nuclear Research
+ * All rights reserved.
+ **************************************************************************/
+
+package com.c2kernel.lifecycle.instance.predefined.entitycreation;
+
+
+
+
+import com.c2kernel.common.AccessRightsException;
+import com.c2kernel.common.InvalidDataException;
+import com.c2kernel.common.InvalidTransitionException;
+import com.c2kernel.lifecycle.instance.predefined.PredefinedStep;
+import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.utils.CastorXMLUtility;
+import com.c2kernel.utils.Logger;
+
+public class CreateNewAgent extends PredefinedStep
+{
+ public CreateNewAgent()
+ {
+ super();
+ }
+
+ //requestdata is xmlstring
+ public void request( AgentPath agent, int transitionID, String requestData)
+ throws AccessRightsException,
+ InvalidTransitionException,
+ InvalidDataException
+ {
+ checkAccessRights(agent);
+
+ try {
+ NewAgent newAgent = (NewAgent)CastorXMLUtility.unmarshall(requestData);
+ newAgent.create(agent.getSysKey());
+ } catch (Exception ex) {
+ Logger.error(ex);
+ throw new InvalidDataException("Error creating agent", "");
+ }
+
+ sendEventStoreOutcome(transitionID, requestData, agent);
+ }
+}
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/CreateNewItem.java b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/CreateNewItem.java
new file mode 100755
index 0000000..49f8ada
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/CreateNewItem.java
@@ -0,0 +1,45 @@
+/**************************************************************************
+ * CreateNewItem
+ *
+ * Copyright (C) 2005 CERN - European Organization for Nuclear Research
+ * All rights reserved.
+ **************************************************************************/
+
+package com.c2kernel.lifecycle.instance.predefined.entitycreation;
+
+
+
+
+import com.c2kernel.common.AccessRightsException;
+import com.c2kernel.common.InvalidDataException;
+import com.c2kernel.common.InvalidTransitionException;
+import com.c2kernel.lifecycle.instance.predefined.PredefinedStep;
+import com.c2kernel.lookup.AgentPath;
+import com.c2kernel.utils.CastorXMLUtility;
+import com.c2kernel.utils.Logger;
+
+public class CreateNewItem extends PredefinedStep
+{
+ public CreateNewItem()
+ {
+ super();
+ }
+
+ //requestdata is xmlstring
+ public void request( AgentPath agent, int transitionID, String requestData)
+ throws AccessRightsException,
+ InvalidTransitionException,
+ InvalidDataException
+ {
+ checkAccessRights(agent);
+
+ try {
+ NewItem item = (NewItem)CastorXMLUtility.unmarshall(requestData);
+ item.create(agent.getSysKey());
+ } catch (Exception ex) {
+ Logger.error(ex);
+ throw new InvalidDataException("Error creating item", "");
+ }
+ sendEventStoreOutcome(transitionID, requestData, agent);
+ }
+}
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/Dependency.java b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/Dependency.java
new file mode 100755
index 0000000..0896534
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/Dependency.java
@@ -0,0 +1,46 @@
+package com.c2kernel.lifecycle.instance.predefined.entitycreation;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import com.c2kernel.collection.MembershipException;
+import com.c2kernel.lookup.DomainPath;
+import com.c2kernel.property.PropertyUtility;
+
+public class Dependency implements java.io.Serializable {
+
+ public String name;
+ public boolean isDescription;
+ public String itemDescriptionPath;
+ public ArrayList dependencyMemberList;
+
+ public Dependency() {
+ super();
+ dependencyMemberList = new ArrayList();
+ }
+
+ public Dependency(String itemDesc) {
+ this();
+ this.itemDescriptionPath = itemDesc;
+ }
+
+ /**
+ * @return
+ */
+ public com.c2kernel.collection.Dependency create() throws MembershipException{
+ com.c2kernel.collection.Dependency newDep = new com.c2kernel.collection.Dependency(name);
+ if (itemDescriptionPath != null) {
+ PropertyUtility.getPropertyDescriptionOutcome(new DomainPath(itemDescriptionPath).getSysKey());
+ //TODO: set props and class identifiers
+ }
+ for (Iterator mems = dependencyMemberList.iterator(); mems.hasNext();) {
+ DependencyMember thisMem = (DependencyMember) mems.next();
+ int syskey = new DomainPath(thisMem.itemPath).getSysKey();
+ if (syskey == -1)
+ throw new MembershipException("Cannot find "+thisMem.itemPath+" specified for collection.");
+ newDep.addMember(syskey);
+ }
+ return newDep;
+ }
+
+}
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/DependencyMember.java b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/DependencyMember.java
new file mode 100755
index 0000000..00ac445
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/DependencyMember.java
@@ -0,0 +1,18 @@
+
+package com.c2kernel.lifecycle.instance.predefined.entitycreation;
+
+public class DependencyMember implements java.io.Serializable {
+
+
+ public String itemPath;
+
+ public DependencyMember() {
+ super();
+ }
+
+ public DependencyMember(String itemPath) {
+ this.itemPath = itemPath;
+
+ }
+
+}
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/Geometry.java b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/Geometry.java
new file mode 100755
index 0000000..25a1455
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/Geometry.java
@@ -0,0 +1,29 @@
+
+
+package com.c2kernel.lifecycle.instance.predefined.entitycreation;
+
+
+
+public class Geometry implements java.io.Serializable {
+
+
+ public int x;
+
+ public int y;
+
+ public int width;
+
+ public int height;
+
+ public Geometry() {
+ super();
+ }
+
+ public Geometry(int x, int y, int width, int height) {
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ }
+
+}
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewAgent.java b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewAgent.java
new file mode 100755
index 0000000..fa575a3
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewAgent.java
@@ -0,0 +1,65 @@
+package com.c2kernel.lifecycle.instance.predefined.entitycreation;
+
+import java.security.NoSuchAlgorithmException;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import com.c2kernel.common.CannotManageException;
+import com.c2kernel.common.ObjectAlreadyExistsException;
+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.RolePath;
+import com.c2kernel.process.Gateway;
+import com.c2kernel.property.PropertyArrayList;
+import com.c2kernel.utils.CastorXMLUtility;
+import com.c2kernel.utils.Logger;
+
+public class NewAgent implements java.io.Serializable {
+
+ public String name;
+
+ public String password;
+
+ public ArrayList roles;
+
+ public NewAgent() {
+ super();
+ roles = new ArrayList();
+ }
+
+ public NewAgent(String name, String password) {
+ this.name = name;
+ this.password = password;
+ }
+
+ protected void create(int agentId) throws ObjectNotFoundException, ObjectCannotBeUpdated, NoSuchAlgorithmException, CannotManageException, ObjectAlreadyExistsException {
+ AgentPath newAgent = Gateway.getLDAPLookup().getNextKeyManager().generateNextAgentKey();
+ newAgent.setAgentName(name);
+ newAgent.setPassword(password);
+ ActiveEntity newAgentEnt = (ActiveEntity)Gateway.getCorbaServer().createEntity(newAgent);
+ Gateway.getLDAPLookup().add(newAgent);
+ // assemble properties
+ PropertyArrayList propList = new PropertyArrayList();
+ propList.list.add(new com.c2kernel.property.Property("Name", name));
+ propList.list.add(new com.c2kernel.property.Property("Type", "Agent"));
+ try {
+ newAgentEnt.initialise(CastorXMLUtility.marshall(propList));
+ } catch (Exception ex) {
+ Logger.error(ex);
+ throw new CannotManageException("Error initialising new agent");
+ }
+ for (Iterator iter = roles.iterator(); iter.hasNext();) {
+ String role = (String) iter.next();
+ RolePath thisRole;
+ try {
+ thisRole = Gateway.getLDAPLookup().getRoleManager().getRolePath(role);
+ } catch (ObjectNotFoundException ex) {
+ thisRole = Gateway.getLDAPLookup().getRoleManager().createRole(role, false);
+ }
+ thisRole.addAgent(newAgent);
+ }
+
+ }
+}
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java
new file mode 100755
index 0000000..4988700
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/NewItem.java
@@ -0,0 +1,145 @@
+package com.c2kernel.lifecycle.instance.predefined.entitycreation;
+
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import com.c2kernel.collection.MembershipException;
+import com.c2kernel.common.CannotManageException;
+import com.c2kernel.common.ObjectAlreadyExistsException;
+import com.c2kernel.common.ObjectCannotBeUpdated;
+import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.entity.TraceableEntity;
+import com.c2kernel.lifecycle.CompositeActivityDef;
+import com.c2kernel.lookup.DomainPath;
+import com.c2kernel.lookup.EntityPath;
+import com.c2kernel.persistency.ClusterStorageException;
+import com.c2kernel.process.Gateway;
+import com.c2kernel.property.PropertyArrayList;
+import com.c2kernel.utils.CastorXMLUtility;
+import com.c2kernel.utils.LocalObjectLoader;
+import com.c2kernel.utils.Logger;
+
+/**
+ * Complete Structure for new item
+ *
+ * @version $Revision: 1.8 $ $Date: 2006/03/03 13:52:21 $
+ */
+public class NewItem {
+
+ public String name;
+
+ /**
+ * The initial Domain Path to be created for this Item.
+ */
+ public String initialPath;
+
+ /**
+ * The name of the Composite Activity Definition to be
+ * instantiated for the workflow of this Item
+ */
+ public String workflow;
+
+ /**
+ * New Properties for the item
+ */
+ public ArrayList propertyList;
+
+ /**
+ * Field _aggregationList
+ */
+ public ArrayList aggregationList;
+
+ /**
+ * Field _dependencyList
+ */
+ public ArrayList dependencyList;
+
+
+ public NewItem() {
+ super();
+ propertyList = new ArrayList();
+ aggregationList = new ArrayList();
+ dependencyList = new ArrayList();
+ }
+
+ public NewItem(String name, String initialPath, String wf) {
+ this();
+ this.name = name;
+ this.initialPath = initialPath;
+ this.workflow = wf;
+ }
+
+ public void setProperty(String name, String value) {
+ for (Iterator iter = propertyList.iterator(); iter.hasNext();) {
+ Property prop = (Property) iter.next();
+ if (prop.name.equals(name)) {
+ prop.value = value;
+ return;
+ }
+ }
+ propertyList.add(new Property(name, value));
+ }
+
+ protected void create(int agentId) throws ObjectCannotBeUpdated, ObjectNotFoundException, CannotManageException, ObjectAlreadyExistsException {
+ DomainPath domPath = new DomainPath(new DomainPath(initialPath), name);
+ if (domPath.exists())
+ throw new ObjectAlreadyExistsException(domPath+" already exists!", "");
+
+ // create item
+ EntityPath entPath = Gateway.getLDAPLookup().getNextKeyManager().generateNextEntityKey();
+ TraceableEntity newItem = (TraceableEntity)Gateway.getCorbaServer().createEntity(entPath);
+ Gateway.getLDAPLookup().add(entPath);
+
+ // assemble properties
+ PropertyArrayList propList = new PropertyArrayList();
+ propList.list.add(new com.c2kernel.property.Property("Name", name));
+ for (Iterator iter = propertyList.iterator(); iter.hasNext();) {
+ Property element = (Property) iter.next();
+ propList.list.add(new com.c2kernel.property.Property(element.name, element.value));
+ }
+ // init the new item
+ try {
+
+ // find workflow def
+ CompositeActivityDef compact = (CompositeActivityDef)LocalObjectLoader.getActDef(workflow, "last");
+
+ newItem.initialise(
+ agentId,
+ CastorXMLUtility.marshall(propList),
+ CastorXMLUtility.marshall(compact.instantiate()));
+ } catch (Exception ex) {
+ Logger.error("Error initialising new item");
+ Logger.error(ex);
+ throw new CannotManageException("Problem initialising new item. See server log.", "");
+ }
+
+ // create collections
+
+ for (Iterator iter = dependencyList.iterator(); iter.hasNext();) {
+ Dependency element = (Dependency) iter.next();
+ try {
+ Gateway.getStorage().put(entPath.getSysKey(), element.create(), null);
+ } catch (ClusterStorageException ex) {
+ Logger.error(ex);
+ throw new CannotManageException("Could not create Dependency "+element.name, "");
+ } catch (MembershipException ex) {
+ Logger.error(ex);
+ throw new CannotManageException("A specified member is not of the correct type in "+element.name, "");
+ }
+ }
+
+ for (Iterator iter = aggregationList.iterator(); iter.hasNext();) {
+ Aggregation element = (Aggregation) iter.next();
+ try {
+ Gateway.getStorage().put(entPath.getSysKey(), element.create(), null);
+ } catch (ClusterStorageException ex) {
+ Logger.error(ex);
+ throw new CannotManageException("Could not create Aggregation "+element.name, "");
+ }
+ }
+ // register domain path
+ domPath.setEntity(entPath);
+ Gateway.getLDAPLookup().add(domPath);
+ }
+}
diff --git a/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/Property.java b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/Property.java
new file mode 100755
index 0000000..d99a3e3
--- /dev/null
+++ b/source/com/c2kernel/lifecycle/instance/predefined/entitycreation/Property.java
@@ -0,0 +1,26 @@
+package com.c2kernel.lifecycle.instance.predefined.entitycreation;
+/**
+ * New Properties for the item
+ *
+ * @version $Revision: 1.1 $ $Date: 2005/04/28 13:48:26 $
+ */
+public class Property implements java.io.Serializable {
+
+ public String name;
+ public String value;
+
+
+ //----------------/
+ //- Constructors -/
+ //----------------/
+
+ public Property() {
+ super();
+ }
+
+ public Property(String name, String value) {
+ super();
+ this.name = name;
+ this.value = value;
+ }
+}