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. --- .../java/com/c2kernel/persistency/ProxyLoader.java | 31 +++++++++++----------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'src/main/java/com/c2kernel/persistency/ProxyLoader.java') diff --git a/src/main/java/com/c2kernel/persistency/ProxyLoader.java b/src/main/java/com/c2kernel/persistency/ProxyLoader.java index 26e43d7..f8704e3 100644 --- a/src/main/java/com/c2kernel/persistency/ProxyLoader.java +++ b/src/main/java/com/c2kernel/persistency/ProxyLoader.java @@ -22,7 +22,8 @@ package com.c2kernel.persistency; import java.util.HashMap; import java.util.StringTokenizer; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.ObjectNotFound; +import com.c2kernel.common.PersistencyException; import com.c2kernel.entity.AgentHelper; import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.entity.Item; @@ -43,12 +44,12 @@ public class ProxyLoader extends ClusterStorage { Lookup lookup; @Override - public void open(Authenticator auth) throws ClusterStorageException { + public void open(Authenticator auth) throws PersistencyException { lookup = Gateway.getLookup(); } @Override - public void close() throws ClusterStorageException { + public void close() throws PersistencyException { } // introspection @Override @@ -68,7 +69,7 @@ public class ProxyLoader extends ClusterStorage { // retrieve object by path @Override - public C2KLocalObject get(ItemPath thisItem, String path) throws ClusterStorageException { + public C2KLocalObject get(ItemPath thisItem, String path) throws PersistencyException { try { Item thisEntity = getIOR(thisItem); String type = getClusterType(path); @@ -83,33 +84,33 @@ public class ProxyLoader extends ClusterStorage { else return (C2KLocalObject)Gateway.getMarshaller().unmarshall(queryData); } - } catch (ObjectNotFoundException e) { + } catch (ObjectNotFound e) { return null; } catch (Exception e) { Logger.error(e); - throw new ClusterStorageException(e.getMessage()); + throw new PersistencyException(e.getMessage()); } return null; } // store object by path @Override - public void put(ItemPath thisItem, C2KLocalObject obj) throws ClusterStorageException { + public void put(ItemPath thisItem, C2KLocalObject obj) throws PersistencyException { // not supported - throw new ClusterStorageException("Cannot write to items through the ProxyLoader"); + throw new PersistencyException("Cannot write to items through the ProxyLoader"); } // delete cluster @Override - public void delete(ItemPath thisItem, String path) throws ClusterStorageException { + public void delete(ItemPath thisItem, String path) throws PersistencyException { // not supported - throw new ClusterStorageException("Cannot write to items through the ProxyLoader"); + throw new PersistencyException("Cannot write to items through the ProxyLoader"); } /* navigation */ // directory listing @Override - public String[] getClusterContents(ItemPath thisItem, String path) throws ClusterStorageException { + public String[] getClusterContents(ItemPath thisItem, String path) throws PersistencyException { try { Item thisEntity = getIOR(thisItem); String contents = thisEntity.queryData(path+"/all"); @@ -121,11 +122,11 @@ public class ProxyLoader extends ClusterStorage { return result; } catch (Exception e) { Logger.error(e); - throw new ClusterStorageException(e.getMessage()); + throw new PersistencyException(e.getMessage()); } } - private Item getIOR(ItemPath thisPath) throws ClusterStorageException { + private Item getIOR(ItemPath thisPath) throws PersistencyException { if (entities.containsKey(thisPath)) { // check the cache Logger.msg(7, "ProxyLoader.getIOR() - "+thisPath+" cached."); @@ -143,7 +144,7 @@ public class ProxyLoader extends ClusterStorage { try { thisItem = AgentHelper.narrow(ior); } catch (org.omg.CORBA.BAD_PARAM ex2) { - throw new ClusterStorageException ("Could not narrow "+thisItem+" as a known Entity type"); + throw new PersistencyException ("Could not narrow "+thisItem+" as a known Entity type"); } } @@ -151,7 +152,7 @@ public class ProxyLoader extends ClusterStorage { entities.put(thisPath, thisItem); return thisItem; } catch (Exception e) { - throw new ClusterStorageException("Error narrowing "+thisPath+": "+e.getMessage()); + throw new PersistencyException("Error narrowing "+thisPath+": "+e.getMessage()); } } } -- cgit v1.2.3