diff options
Diffstat (limited to 'src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewSlot.java')
| -rw-r--r-- | src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewSlot.java | 32 |
1 files changed, 15 insertions, 17 deletions
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 87cbda0..19ef2ae 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewSlot.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/AddNewSlot.java @@ -24,13 +24,13 @@ package com.c2kernel.lifecycle.instance.predefined; import java.util.Arrays;
import com.c2kernel.collection.Aggregation;
-import com.c2kernel.common.InvalidDataException;
-import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.InvalidData;
+import com.c2kernel.common.ObjectNotFound;
+import com.c2kernel.common.PersistencyException;
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;
import com.c2kernel.property.PropertyDescription;
import com.c2kernel.property.PropertyDescriptionList;
@@ -62,10 +62,14 @@ public class AddNewSlot extends PredefinedStep * <li>Item Description key (optional)</li>
* <li>Item Description version (optional)</li>
* </ol>
+ *
+ * @throws InvalidData Then the parameters were incorrect
+ * @throws PersistencyException There was a problem loading or saving the collection from persistency
+ * @throws ObjectNotFound A required object, such as the collection or a PropertyDescription outcome, wasn't found
*/
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException {
+ int transitionID, String requestData) throws InvalidData, PersistencyException, ObjectNotFound {
String collName;
ItemPath descKey = null;
@@ -82,20 +86,18 @@ public class AddNewSlot extends PredefinedStep if (params.length > 1 && params[1].length() > 0) descKey = new ItemPath(params[1]);
if (params.length > 2 && params[2].length() > 0) descVer = params[2];
} catch (Exception e) {
- throw new InvalidDataException("AddNewSlot: Invalid parameters "+Arrays.toString(params), "");
+ throw new InvalidData("AddNewSlot: Invalid parameters "+Arrays.toString(params));
}
// load collection
C2KLocalObject collObj;
try {
collObj = Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName+"/last", null);
- } catch (ObjectNotFoundException ex) {
- throw new InvalidDataException("AddNewSlot: Collection '"+collName+"' not found in this Item", "");
- } catch (ClusterStorageException ex) {
+ } catch (PersistencyException ex) {
Logger.error(ex);
- throw new InvalidDataException("AddNewSlot: Error loading collection '\"+collName+\"': "+ex.getMessage(), "");
+ throw new PersistencyException("AddNewSlot: Error loading collection '\"+collName+\"': "+ex.getMessage());
}
- if (!(collObj instanceof Aggregation)) throw new InvalidDataException("AddNewSlot: AddNewSlot operates on Aggregation collections only.", "");
+ if (!(collObj instanceof Aggregation)) throw new InvalidData("AddNewSlot: AddNewSlot operates on Aggregation collections only.");
agg = (Aggregation)collObj;
// get props
@@ -103,11 +105,7 @@ public class AddNewSlot extends PredefinedStep StringBuffer classProps = new StringBuffer();
if (descKey != null) {
PropertyDescriptionList propList;
- try {
- propList = PropertyUtility.getPropertyDescriptionOutcome(descKey, descVer);
- } catch (ObjectNotFoundException e) {
- throw new InvalidDataException("AddNewSlot: Item "+descKey+" does not contain a PropertyDescription outcome to define a slot", "");
- }
+ propList = PropertyUtility.getPropertyDescriptionOutcome(descKey, descVer);
for (PropertyDescription pd : propList.list) {
props.put(pd.getName(), pd.getDefaultValue());
if (pd.getIsClassIdentifier())
@@ -119,9 +117,9 @@ public class AddNewSlot extends PredefinedStep try {
Gateway.getStorage().put(item, agg, null);
- } catch (ClusterStorageException e) {
+ } catch (PersistencyException e) {
Logger.error(e);
- throw new InvalidDataException("AddNewSlot: Error storing collection", "");
+ throw new PersistencyException("AddNewSlot: Error saving collection '"+collName+"': "+e.getMessage());
}
return requestData;
|
