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/collection/Aggregation.java | 33 ++++++++++++---------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'src/main/java/com/c2kernel/collection/Aggregation.java') diff --git a/src/main/java/com/c2kernel/collection/Aggregation.java b/src/main/java/com/c2kernel/collection/Aggregation.java index 575cd39..b4d1b6b 100644 --- a/src/main/java/com/c2kernel/collection/Aggregation.java +++ b/src/main/java/com/c2kernel/collection/Aggregation.java @@ -20,7 +20,9 @@ */ package com.c2kernel.collection; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.InvalidCollectionModification; +import com.c2kernel.common.ObjectAlreadyExists; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.graph.model.GraphModel; import com.c2kernel.graph.model.GraphPoint; import com.c2kernel.graph.model.TypeNameAndConstructionInfo; @@ -33,8 +35,7 @@ import com.c2kernel.utils.Language; import com.c2kernel.utils.Logger; /** - * @version $Revision: 1.59 $ $Date: 2004/08/10 07:56:08 $ - * @author $Author: abranson $ + * A Collection with a graph layout */ abstract public class Aggregation extends Collection @@ -116,7 +117,7 @@ abstract public class Aggregation extends Collection } public AggregationMember addMember(ItemPath itemPath, CastorHashMap props, String classProps, GraphPoint location, int w, int h) - throws MembershipException + throws InvalidCollectionModification, ObjectAlreadyExists { AggregationMember aggMem = addSlot(props, classProps, location, w, h); if (itemPath != null) { // some clients use this method when not setting a member @@ -129,24 +130,27 @@ abstract public class Aggregation extends Collection @Override - public AggregationMember addMember(ItemPath itemPath, CastorHashMap props, String classProps) throws MembershipException + public AggregationMember addMember(ItemPath itemPath, CastorHashMap props, String classProps) throws InvalidCollectionModification, ObjectAlreadyExists { return addMember(itemPath, props, classProps, null, -1, -1); } + + public AggregationMember addMember(CastorHashMap props, String classProps, GraphPoint location, int w, int h) throws InvalidCollectionModification { + try { + return addMember(null, props, classProps, location, w, h); + } catch (ObjectAlreadyExists e) { // not assigning an item so this won't happen + return null; + } + } + public AggregationMember addSlot(CastorHashMap props, String classProps) { return addSlot(props, classProps, null, -1, -1); } @Override - public AggregationMember addMember(ItemPath itemPath) throws MembershipException { - throw new MembershipException("Aggregations cannot accept arbitrary members without type info"); - - } - - @Override - public void removeMember(int memberId) throws MembershipException { + public void removeMember(int memberId) throws ObjectNotFound { for (AggregationMember element : mMembers.list) { if (element.getID() == memberId) { element.clearItem(); @@ -154,7 +158,7 @@ abstract public class Aggregation extends Collection return; } } - throw new MembershipException("Member "+memberId+" not found"); + throw new ObjectNotFound("Member "+memberId+" not found"); } static public boolean getIsComposite(ItemPath itemPath, String name) @@ -163,10 +167,9 @@ abstract public class Aggregation extends Collection try { for(String collName: Gateway.getProxyManager().getProxy(itemPath).getContents(ClusterStorage.COLLECTION) ) if (name == null || name.equals(collName)) return true; - } catch (ObjectNotFoundException e) { + } catch (ObjectNotFound e) { return false; } return false; } - } -- cgit v1.2.3