summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/lifecycle/instance/predefined/ClearSlot.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/c2kernel/lifecycle/instance/predefined/ClearSlot.java')
-rw-r--r--src/main/java/com/c2kernel/lifecycle/instance/predefined/ClearSlot.java28
1 files changed, 15 insertions, 13 deletions
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 acba2cb..a15b98f 100644
--- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/ClearSlot.java
+++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/ClearSlot.java
@@ -25,12 +25,13 @@ 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.common.InvalidData;
+import com.c2kernel.common.ObjectCannotBeUpdated;
+import com.c2kernel.common.ObjectNotFound;
+import com.c2kernel.common.PersistencyException;
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.utils.Logger;
@@ -54,10 +55,13 @@ public class ClearSlot extends PredefinedStep
* Params:
* 0 - collection name
* 1 - slot number
+ * @throws ObjectNotFound
+ * @throws PersistencyException
+ * @throws ObjectCannotBeUpdated
*/
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException {
+ int transitionID, String requestData) throws InvalidData, ObjectNotFound, PersistencyException, ObjectCannotBeUpdated {
String collName;
int slotNo;
@@ -71,17 +75,15 @@ public class ClearSlot extends PredefinedStep
collName = params[0];
slotNo = Integer.parseInt(params[1]);
} catch (Exception e) {
- throw new InvalidDataException("ClearSlot: Invalid parameters "+Arrays.toString(params), "");
+ throw new InvalidData("ClearSlot: Invalid parameters "+Arrays.toString(params));
}
// load collection
try {
agg = (Aggregation)Gateway.getStorage().get(item, ClusterStorage.COLLECTION+"/"+collName+"/last", null);
- } catch (ObjectNotFoundException ex) {
- throw new InvalidDataException("ClearSlot: Collection '"+collName+"' not found in this Item", "");
- } catch (ClusterStorageException ex) {
+ } catch (PersistencyException ex) {
Logger.error(ex);
- throw new InvalidDataException("ClearSlot: Error loading collection '"+collName+"': "+ex.getMessage(), "");
+ throw new PersistencyException("ClearSlot: Error loading collection '"+collName+"': "+ex.getMessage());
}
// find member and clear
@@ -89,22 +91,22 @@ public class ClearSlot extends PredefinedStep
for (AggregationMember member : agg.getMembers().list) {
if (member.getID() == slotNo) {
if (member.getItemPath() != null)
- throw new InvalidDataException("ClearSlot: Member slot "+slotNo+" already empty", "");
+ throw new ObjectCannotBeUpdated("ClearSlot: Member slot "+slotNo+" already empty");
member.clearItem();
stored = true;
break;
}
}
if (!stored) {
- throw new InvalidDataException("Member slot "+slotNo+" not found.", "");
+ throw new ObjectNotFound("ClearSlot: Member slot "+slotNo+" not found.");
}
try {
Gateway.getStorage().put(item, agg, null);
- } catch (ClusterStorageException e) {
+ } catch (PersistencyException e) {
Logger.error(e);
- throw new InvalidDataException("Error storing collection", "");
+ throw new PersistencyException("ClearSlot: Error storing collection");
}
return requestData;
}