From 275d0bbf555c8917be82ce4cc21eb4cabb00f4c5 Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Fri, 3 Oct 2014 17:30:41 +0200 Subject: 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. --- .../instance/predefined/agent/RemoveAgent.java | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/RemoveAgent.java') diff --git a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/RemoveAgent.java b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/RemoveAgent.java index ca1a8e4..65608c7 100644 --- a/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/RemoveAgent.java +++ b/src/main/java/com/c2kernel/lifecycle/instance/predefined/agent/RemoveAgent.java @@ -20,16 +20,16 @@ */ package com.c2kernel.lifecycle.instance.predefined.agent; -import com.c2kernel.common.CannotManageException; -import com.c2kernel.common.InvalidDataException; +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.common.PersistencyException; import com.c2kernel.lifecycle.instance.predefined.PredefinedStep; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.InvalidAgentPathException; import com.c2kernel.lookup.ItemPath; import com.c2kernel.lookup.RolePath; -import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.process.Gateway; import com.c2kernel.utils.Logger; @@ -41,7 +41,7 @@ public class RemoveAgent extends PredefinedStep { @Override protected String runActivityLogic(AgentPath agent, ItemPath itemPath, - int transitionID, String requestData) throws InvalidDataException { + int transitionID, String requestData) throws InvalidData { Logger.msg(1, "RemoveAgent::request() - Starting."); @@ -49,7 +49,7 @@ public class RemoveAgent extends PredefinedStep { try { targetAgent = new AgentPath(itemPath); } catch (InvalidAgentPathException ex) { - throw new InvalidDataException("Could not resolve "+itemPath+" as an Agent."); + throw new InvalidData("Could not resolve "+itemPath+" as an Agent."); } String agentName = targetAgent.getAgentName(); @@ -59,28 +59,28 @@ public class RemoveAgent extends PredefinedStep { Gateway.getLookupManager().removeRole(targetAgent, role); } catch (ObjectCannotBeUpdated e) { Logger.error(e); - throw new InvalidDataException("Error removing "+agentName+" from Role "+role.getName(), ""); - } catch (ObjectNotFoundException e) { + throw new InvalidData("Error removing "+agentName+" from Role "+role.getName()); + } catch (ObjectNotFound e) { Logger.error(e); - throw new InvalidDataException("Tried to remove "+agentName+" from Role "+role.getName()+" that doesn't exist.", ""); - } catch (CannotManageException e) { - throw new InvalidDataException("Tried to alter roles in a non-server process.", ""); + throw new InvalidData("Tried to remove "+agentName+" from Role "+role.getName()+" that doesn't exist."); + } catch (CannotManage e) { + throw new InvalidData("Tried to alter roles in a non-server process."); } } //clear out all storages try { Gateway.getStorage().removeCluster(targetAgent, "", null); - } catch (ClusterStorageException e) { + } catch (PersistencyException e) { Logger.error(e); - throw new InvalidDataException("Error deleting storage for "+agentName, ""); + throw new InvalidData("Error deleting storage for "+agentName); } //remove entity path try { Gateway.getLookupManager().delete(targetAgent); } catch (Exception e) { - throw new InvalidDataException("Error deleting AgentPath for "+agentName, ""); + throw new InvalidData("Error deleting AgentPath for "+agentName); } return requestData; -- cgit v1.2.3