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/Collection.java | 46 ++++++++++++++++------ 1 file changed, 35 insertions(+), 11 deletions(-) (limited to 'src/main/java/com/c2kernel/collection/Collection.java') diff --git a/src/main/java/com/c2kernel/collection/Collection.java b/src/main/java/com/c2kernel/collection/Collection.java index 355fa1c..fa0230b 100644 --- a/src/main/java/com/c2kernel/collection/Collection.java +++ b/src/main/java/com/c2kernel/collection/Collection.java @@ -22,15 +22,39 @@ package com.c2kernel.collection; import java.util.Iterator; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.InvalidCollectionModification; +import com.c2kernel.common.ObjectAlreadyExists; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.entity.C2KLocalObject; +import com.c2kernel.graph.model.GraphModel; import com.c2kernel.lookup.ItemPath; import com.c2kernel.persistency.ClusterStorage; import com.c2kernel.utils.CastorHashMap; /** - * @version $Revision: 1.23 $ $Date: 2004/05/14 15:39:39 $ - * @author $Author: abranson $ + * Collections are Item local objects that reference other Items. + * + *

In parallel with the OO meta-model, Items can be linked to other Items in + * different ways. These links are modelled with Collections, which are local + * objects stored in an Item which reference a number of other Items in the same + * server. The Collections holds a CollectionMember, sometimes known as a slot, + * to reference each Item and store additional information about the link. + * + *

Features: + *

+ * + *

Collections are managed through predefined steps. */ abstract public class Collection implements C2KLocalObject { @@ -131,12 +155,12 @@ abstract public class Collection implements C2KLocal return true; } - public E getMember(int memberId) throws ObjectNotFoundException { + public E getMember(int memberId) throws ObjectNotFound { for (E element : mMembers.list) { if (element.getID() == memberId) return element; } - throw new ObjectNotFoundException("Member "+memberId+" not found in "+mName, ""); + throw new ObjectNotFound("Member "+memberId+" not found in "+mName); } public CollectionMemberList getMembers() @@ -144,12 +168,10 @@ abstract public class Collection implements C2KLocal return mMembers; } - public abstract E addMember(ItemPath itemPath, CastorHashMap props, String classProps) throws MembershipException; - - public abstract E addMember(ItemPath itemPath) throws MembershipException; - - public abstract void removeMember(int memberId) throws MembershipException; + public abstract E addMember(ItemPath itemPath, CastorHashMap props, String classProps) throws InvalidCollectionModification, ObjectAlreadyExists; + public abstract void removeMember(int memberId) throws ObjectNotFound; + @Override public boolean equals(Object other) { if (!(other instanceof Collection)) return false; @@ -161,10 +183,12 @@ abstract public class Collection implements C2KLocal E thisMem = i.next(); CollectionMember otherMem = otherColl.getMember(thisMem.getID()); if (!thisMem.equals(otherMem)) return false; - } catch (ObjectNotFoundException ex) { + } catch (ObjectNotFound ex) { return false; } } return true; } + + } -- cgit v1.2.3