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. --- src/main/java/com/c2kernel/process/Gateway.java | 50 ++++++++++++------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'src/main/java/com/c2kernel/process/Gateway.java') diff --git a/src/main/java/com/c2kernel/process/Gateway.java b/src/main/java/com/c2kernel/process/Gateway.java index 50075c0..25f5d9a 100644 --- a/src/main/java/com/c2kernel/process/Gateway.java +++ b/src/main/java/com/c2kernel/process/Gateway.java @@ -29,9 +29,10 @@ import java.net.MalformedURLException; import java.util.Enumeration; import java.util.Properties; -import com.c2kernel.common.CannotManageException; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.CannotManage; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.ObjectNotFound; +import com.c2kernel.common.PersistencyException; import com.c2kernel.entity.CorbaServer; import com.c2kernel.entity.proxy.AgentProxy; import com.c2kernel.entity.proxy.ProxyManager; @@ -39,7 +40,6 @@ import com.c2kernel.entity.proxy.ProxyServer; import com.c2kernel.lookup.AgentPath; import com.c2kernel.lookup.Lookup; import com.c2kernel.lookup.LookupManager; -import com.c2kernel.persistency.ClusterStorageException; import com.c2kernel.persistency.TransactionManager; import com.c2kernel.process.auth.Authenticator; import com.c2kernel.process.module.ModuleManager; @@ -97,9 +97,9 @@ public class Gateway * * @param props - java.util.Properties containing all application properties. * If null, the java system properties are used - * @throws InvalidDataException - invalid properties caused a failure in initialisation + * @throws InvalidData - invalid properties caused a failure in initialisation */ - static public void init(Properties props) throws InvalidDataException { + static public void init(Properties props) throws InvalidData { init(props, null); } @@ -111,9 +111,9 @@ public class Gateway * If null, the java system properties are used * @param res - ResourceLoader for the kernel to use to resolve all class resource requests * such as for bootstrap descriptions and version information - * @throws InvalidDataException - invalid properties caused a failure in initialisation + * @throws InvalidData - invalid properties caused a failure in initialisation */ - static public void init(Properties props, ResourceLoader res) throws InvalidDataException { + static public void init(Properties props, ResourceLoader res) throws InvalidData { // Init properties & resources mC2KProps.clear(); @@ -130,7 +130,7 @@ public class Gateway try { mMarshaller = new CastorXMLUtility(mResource, props, mResource.getKernelResourceURL("mapFiles/")); } catch (MalformedURLException e1) { - throw new InvalidDataException("Invalid Resource Location", ""); + throw new InvalidData("Invalid Resource Location"); } @@ -139,7 +139,7 @@ public class Gateway mModules = new ModuleManager(mResource.getModuleDefURLs(), AbstractMain.isServer); } catch (Exception e) { Logger.error(e); - throw new InvalidDataException("Could not load module definitions.", ""); + throw new InvalidData("Could not load module definitions."); } // merge in module props @@ -168,9 +168,9 @@ public class Gateway * bootstrap to create the root LDAP contexts, initialises the CORBA server and * time-out manager. * - * @throws InvalidDataException - error initialising + * @throws InvalidData - error initialising */ - static public void startServer(Authenticator auth) throws InvalidDataException, CannotManageException { + static public void startServer(Authenticator auth) throws InvalidData, CannotManage { try { // check top level directory contexts if (mLookup instanceof LookupManager) { @@ -178,7 +178,7 @@ public class Gateway mLookupManager.initializeDirectory(); } else { - throw new CannotManageException("Lookup implementation is not a LookupManager. Cannot write to directory"); + throw new CannotManage("Lookup implementation is not a LookupManager. Cannot write to directory"); } // start entity proxy server @@ -222,12 +222,12 @@ public class Gateway * Connects to the LDAP server in an administrative context - using the admin username and * password given in the LDAP.user and LDAP.password props of the kernel properties. * - * @throws InvalidDataException - bad params - * @throws ClusterStorageException - error starting storages + * @throws InvalidData - bad params + * @throws PersistencyException - error starting storages */ static public Authenticator connect() - throws InvalidDataException, - ClusterStorageException + throws InvalidData, + PersistencyException { try { Authenticator auth = (Authenticator)mC2KProps.getInstance("Authenticator"); @@ -242,7 +242,7 @@ public class Gateway return auth; } catch (Exception ex) { Logger.error(ex); - throw new InvalidDataException("Cannot connect server process. Please check config.", ""); + throw new InvalidData("Cannot connect server process. Please check config."); } @@ -254,18 +254,18 @@ public class Gateway * @param agentName - username * @param agentPassword - password * @return an AgentProxy on the requested user - * @throws InvalidDataException - * @throws ClusterStorageException + * @throws InvalidData + * @throws PersistencyException * @throws ClassNotFoundException * @throws IllegalAccessException * @throws InstantiationException */ static public AgentProxy connect(String agentName, String agentPassword, String resource) - throws InvalidDataException, ObjectNotFoundException, ClusterStorageException, InstantiationException, IllegalAccessException, ClassNotFoundException + throws InvalidData, ObjectNotFound, PersistencyException, InstantiationException, IllegalAccessException, ClassNotFoundException { Authenticator auth = (Authenticator)mC2KProps.getInstance("Authenticator"); if (!auth.authenticate(agentName, agentPassword, resource)) - throw new InvalidDataException("Login failed", ""); + throw new InvalidData("Login failed"); mLookup = (Lookup)mC2KProps.getInstance("Lookup"); mLookup.open(auth); @@ -286,7 +286,7 @@ public class Gateway } static public AgentProxy connect(String agentName, String agentPassword) - throws InvalidDataException, ObjectNotFoundException, ClusterStorageException, InstantiationException, IllegalAccessException, ClassNotFoundException + throws InvalidData, ObjectNotFound, PersistencyException, InstantiationException, IllegalAccessException, ClassNotFoundException { return connect(agentName, agentPassword, null); } @@ -358,10 +358,10 @@ public class Gateway return mLookup; } - static public LookupManager getLookupManager() throws CannotManageException + static public LookupManager getLookupManager() throws CannotManage { if (mLookupManager == null) - throw new CannotManageException("No Lookup Manager created. Not a server process.", ""); + throw new CannotManage("No Lookup Manager created. Not a server process."); else return mLookupManager; } -- cgit v1.2.3