summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveDomainContext.java
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2014-10-03 17:30:41 +0200
committerAndrew Branson <andrew.branson@cern.ch>2014-10-03 17:30:41 +0200
commit275d0bbf555c8917be82ce4cc21eb4cabb00f4c5 (patch)
treeddcc6b14077d90d1b970b67829f07120547dbb62 /src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveDomainContext.java
parenta139f95bfeca603333b8c0310ae09c6805e58584 (diff)
Huge exception overhaul: Merged ClusterStorageException with
PersistencyException. Replaced MembershipException with InvalidCollectionModification CORBA Exception. Made all predef steps throw more accurate exceptions when they go wrong, and let more exceptions bubble through from underneath.
Diffstat (limited to 'src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveDomainContext.java')
-rw-r--r--src/main/java/com/c2kernel/lifecycle/instance/predefined/server/RemoveDomainContext.java37
1 files changed, 18 insertions, 19 deletions
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 d90f163..2d78e69 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
@@ -20,10 +20,12 @@
*/
package com.c2kernel.lifecycle.instance.predefined.server;
-import com.c2kernel.common.CannotManageException;
-import com.c2kernel.common.InvalidDataException;
+import java.util.Arrays;
+
+import com.c2kernel.common.CannotManage;
+import com.c2kernel.common.InvalidData;
import com.c2kernel.common.ObjectCannotBeUpdated;
-import com.c2kernel.common.ObjectNotFoundException;
+import com.c2kernel.common.ObjectNotFound;
import com.c2kernel.lifecycle.instance.predefined.PredefinedStep;
import com.c2kernel.lookup.AgentPath;
import com.c2kernel.lookup.DomainPath;
@@ -38,28 +40,25 @@ public class RemoveDomainContext extends PredefinedStep {
@Override
protected String runActivityLogic(AgentPath agent, ItemPath item,
- int transitionID, String requestData) throws InvalidDataException {
+ int transitionID, String requestData) throws InvalidData, ObjectNotFound, ObjectCannotBeUpdated, CannotManage {
- Logger.msg(1, "RemoveDomainContext::request() - Starting.");
-
- DomainPath pathToDelete = new DomainPath(getDataList(requestData)[0]);
+ String[] params = getDataList(requestData);
+ if (Logger.doLog(3)) Logger.msg(3, "RemoveDomainContext: called by "+agent+" on "+item+" with parameters "+Arrays.toString(params));
+ if (params.length != 1) throw new InvalidData("RemoveDomainContext: Invalid parameters "+Arrays.toString(params));
+
+ DomainPath pathToDelete = new DomainPath(params[0]);
if (!pathToDelete.exists())
- throw new InvalidDataException("Context "+pathToDelete+" does not exist", "");
+ throw new ObjectNotFound("Context "+pathToDelete+" does not exist");
+
try {
pathToDelete.getItemPath();
- throw new InvalidDataException("Path "+pathToDelete+" is an Entity. Use its own Erase step instead, or RemoveAgent.", "");
- } catch (ObjectNotFoundException ex) { }
+ throw new InvalidData("Path "+pathToDelete+" is an Entity. Use its own Erase step instead, or RemoveAgent.");
+ } catch (ObjectNotFound ex) { }
+
if (Gateway.getLookup().getChildren(pathToDelete).hasNext())
- throw new InvalidDataException("Context "+pathToDelete+" is not empty. Cannot delete.", "");
+ throw new ObjectCannotBeUpdated("Context "+pathToDelete+" is not empty. Cannot delete.");
- try {
- Gateway.getLookupManager().delete(pathToDelete);
- } catch (ObjectCannotBeUpdated e) {
- Logger.error(e);
- throw new InvalidDataException("Exception deleting path"+pathToDelete+": "+e.getMessage(), "");
- } catch (CannotManageException e) {
- throw new InvalidDataException("Cannot alter directory in a non-server process", "");
- }
+ Gateway.getLookupManager().delete(pathToDelete);
return requestData;
}
}