summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java')
-rw-r--r--src/main/java/com/c2kernel/lifecycle/instance/predefined/item/CreateItemFromDescription.java126
1 files changed, 63 insertions, 63 deletions
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 d2c48ff..02ea642 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
@@ -24,10 +24,12 @@ import com.c2kernel.collection.Collection;
import com.c2kernel.collection.CollectionArrayList;
import com.c2kernel.collection.CollectionDescription;
import com.c2kernel.collection.CollectionMember;
-import com.c2kernel.common.AccessRightsException;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectAlreadyExistsException;
-import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.CannotManage;
+import com.c2kernel.common.InvalidData;
+import com.c2kernel.common.ObjectAlreadyExists;
+import com.c2kernel.common.ObjectCannotBeUpdated;
+import com.c2kernel.common.ObjectNotFound;
+import com.c2kernel.common.PersistencyException;
import com.c2kernel.entity.CorbaServer;
import com.c2kernel.entity.TraceableEntity;
import com.c2kernel.lifecycle.CompositeActivityDef;
@@ -37,7 +39,6 @@ import com.c2kernel.lookup.AgentPath;
import com.c2kernel.lookup.DomainPath;
import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.ClusterStorage;
-import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.process.Gateway;
import com.c2kernel.property.Property;
import com.c2kernel.property.PropertyArrayList;
@@ -61,7 +62,7 @@ public class CreateItemFromDescription extends PredefinedStep
//requestdata is xmlstring
@Override
protected String runActivityLogic(AgentPath agent, ItemPath itemPath,
- int transitionID, String requestData) throws InvalidDataException {
+ int transitionID, String requestData) throws InvalidData, ObjectNotFound, ObjectAlreadyExists, CannotManage, ObjectCannotBeUpdated, PersistencyException {
String[] input = getDataList(requestData);
String newName = input[0];
@@ -72,65 +73,64 @@ public class CreateItemFromDescription extends PredefinedStep
Logger.msg(1, "CreateItemFromDescription - Starting.");
- try {
- // check if the path is already taken
- DomainPath context = new DomainPath(new DomainPath(domPath), newName);
- //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 item path");
- ItemPath newItemPath = new ItemPath();
-
- // 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 = factory.createItem(newItemPath);
- Gateway.getLookupManager().add(newItemPath);
-
-
- // initialise it with its properties and workflow
-
- Logger.msg(3, "CreateItemFromDescription - Initializing Item");
-
- newItem.initialise(
- agent.getSystemKey(),
- Gateway.getMarshaller().marshall(getNewProperties(itemPath, descVer, initProps, newName, agent)),
- Gateway.getMarshaller().marshall(getNewWorkflow(itemPath, descVer)),
- Gateway.getMarshaller().marshall(getNewCollections(itemPath, descVer))
- );
-
- // add its domain path
- Logger.msg(3, "CreateItemFromDescription - Creating "+context);
- context.setItemPath(newItemPath);
- Gateway.getLookupManager().add(context);
- return requestData;
- } catch (Exception e) {
- Logger.error(e);
- throw new InvalidDataException(e.getMessage(), "");
- }
+ // check if the path is already taken
+ DomainPath context = new DomainPath(new DomainPath(domPath), newName);
+ //Logger.debug(8,"context "+context.getItemPath()+" "+context.getPath()+" "+context.getString());
+ if (context.exists())
+ throw new ObjectAlreadyExists("The path " +context+ " exists already.");
+
+ // get init objects
+
+ /* ITEM CREATION */
+
+ // generate new entity key
+ Logger.msg(6, "CreateItemFromDescription - Requesting new item path");
+ ItemPath newItemPath = new ItemPath();
+
+ // 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 CannotManage("This process cannot create new Items");
+ TraceableEntity newItem = factory.createItem(newItemPath);
+ Gateway.getLookupManager().add(newItemPath);
+
+ // initialise it with its properties and workflow
+
+ Logger.msg(3, "CreateItemFromDescription - Initializing Item");
+
+ try {
+ newItem.initialise(
+ agent.getSystemKey(),
+ Gateway.getMarshaller().marshall(getNewProperties(itemPath, descVer, initProps, newName, agent)),
+ Gateway.getMarshaller().marshall(getNewWorkflow(itemPath, descVer)),
+ Gateway.getMarshaller().marshall(getNewCollections(itemPath, descVer))
+ );
+ } catch (PersistencyException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new InvalidData("CreateAgentFromDescription: Problem initializing new Agent. See log: "+e.getMessage());
+ }
+ // add its domain path
+ Logger.msg(3, "CreateItemFromDescription - Creating "+context);
+ context.setItemPath(newItemPath);
+ Gateway.getLookupManager().add(context);
+ return requestData;
}
- protected PropertyArrayList getInitProperties(String input) throws InvalidDataException {
+ protected PropertyArrayList getInitProperties(String input) throws InvalidData {
try {
return (PropertyArrayList)Gateway.getMarshaller().unmarshall(input);
} catch (Exception e) {
Logger.error(e);
- throw new InvalidDataException("Initial property parameter was not a marshalled PropertyArrayList: "+input, "");
+ throw new InvalidData("Initial property parameter was not a marshalled PropertyArrayList: "+input);
}
}
- protected PropertyArrayList getNewProperties(ItemPath itemPath, String descVer, PropertyArrayList initProps, String newName, AgentPath agent) throws ObjectNotFoundException, InvalidDataException {
+ protected PropertyArrayList getNewProperties(ItemPath itemPath, String descVer, PropertyArrayList initProps, String newName, AgentPath agent) throws ObjectNotFound, InvalidData {
// copy properties -- intend to create from propdesc
PropertyDescriptionList pdList = PropertyUtility.getPropertyDescriptionOutcome(itemPath, descVer);
PropertyArrayList props = pdList.instantiate(initProps);
@@ -147,7 +147,7 @@ public class CreateItemFromDescription extends PredefinedStep
return props;
}
- protected CompositeActivity getNewWorkflow(ItemPath itemPath, String descVer) throws ClusterStorageException, ObjectNotFoundException, InvalidDataException {
+ protected CompositeActivity getNewWorkflow(ItemPath itemPath, String descVer) throws ObjectNotFound, InvalidData, PersistencyException {
// find the workflow def for the given description version
String wfDefName = null; Integer wfDefVer = null;
@@ -159,26 +159,26 @@ public class CreateItemFromDescription extends PredefinedStep
try {
wfDefVer = Integer.parseInt(wfVerObj.toString());
} catch (NumberFormatException ex) {
- throw new InvalidDataException("Invalid workflow version number: "+wfVerObj.toString(), "");
+ throw new InvalidData("Invalid workflow version number: "+wfVerObj.toString());
}
// load workflow def
if (wfDefName == null)
- throw new InvalidDataException("No workflow given or defined", "");
+ throw new InvalidData("No workflow given or defined");
if (wfDefVer == null)
- throw new InvalidDataException("No workflow def version given","");
+ throw new InvalidData("No workflow def version given");
try {
CompositeActivityDef wfDef = (CompositeActivityDef)LocalObjectLoader.getActDef(wfDefName, wfDefVer);
return (CompositeActivity)wfDef.instantiate();
- } catch (ObjectNotFoundException ex) {
- throw new InvalidDataException("Workflow def '"+wfDefName+"'v"+wfDefVer+" not found", "");
+ } catch (ObjectNotFound ex) {
+ throw new InvalidData("Workflow def '"+wfDefName+"'v"+wfDefVer+" not found");
} catch (ClassCastException ex) {
- throw new InvalidDataException("Activity def '"+wfDefName+"' was not Composite", "");
+ throw new InvalidData("Activity def '"+wfDefName+"' was not Composite");
}
}
- protected CollectionArrayList getNewCollections(ItemPath itemPath, String descVer) throws ClusterStorageException, ObjectNotFoundException {
+ protected CollectionArrayList getNewCollections(ItemPath itemPath, String descVer) throws ObjectNotFound, PersistencyException {
// loop through collections, collecting instantiated descriptions and finding the default workflow def
CollectionArrayList colls = new CollectionArrayList();
String[] collNames = Gateway.getStorage().getClusterContents(itemPath, ClusterStorage.COLLECTION);