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. --- .../com/c2kernel/persistency/outcome/Outcome.java | 32 +++++++++++----------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/main/java/com/c2kernel/persistency/outcome/Outcome.java') diff --git a/src/main/java/com/c2kernel/persistency/outcome/Outcome.java b/src/main/java/com/c2kernel/persistency/outcome/Outcome.java index 8dbe94e..ac2d970 100644 --- a/src/main/java/com/c2kernel/persistency/outcome/Outcome.java +++ b/src/main/java/com/c2kernel/persistency/outcome/Outcome.java @@ -40,8 +40,8 @@ import org.w3c.dom.ls.DOMImplementationLS; import org.w3c.dom.ls.LSSerializer; import org.xml.sax.InputSource; -import com.c2kernel.common.InvalidDataException; -import com.c2kernel.common.ObjectNotFoundException; +import com.c2kernel.common.InvalidData; +import com.c2kernel.common.ObjectNotFound; import com.c2kernel.common.PersistencyException; import com.c2kernel.entity.C2KLocalObject; import com.c2kernel.persistency.ClusterStorage; @@ -95,14 +95,14 @@ public class Outcome implements C2KLocalObject { // derive all the meta data from the path StringTokenizer tok = new StringTokenizer(path,"/"); if (tok.countTokens() != 3 && !(tok.nextToken().equals(ClusterStorage.OUTCOME))) - throw new PersistencyException("Outcome() - Outcome path must have three components: "+path, null); + throw new PersistencyException("Outcome() - Outcome path must have three components: "+path); mSchemaType = tok.nextToken(); String verstring = tok.nextToken(); String objId = tok.nextToken(); try { mSchemaVersion = Integer.parseInt(verstring); } catch (NumberFormatException ex) { - throw new PersistencyException("Outcome() - Outcome version was an invalid number: "+verstring, null); + throw new PersistencyException("Outcome() - Outcome version was an invalid number: "+verstring); } try { mID = new Integer(objId); @@ -144,10 +144,10 @@ public class Outcome implements C2KLocalObject { mData = null; } - public String getFieldByXPath(String xpath) throws XPathExpressionException, InvalidDataException { + public String getFieldByXPath(String xpath) throws XPathExpressionException, InvalidData { Node field = getNodeByXPath(xpath); if (field == null) - throw new InvalidDataException(xpath, ""); + throw new InvalidData(xpath); else if (field.getNodeType()==Node.TEXT_NODE || field.getNodeType()==Node.CDATA_SECTION_NODE) return field.getNodeValue(); @@ -155,28 +155,28 @@ public class Outcome implements C2KLocalObject { else if (field.getNodeType()==Node.ELEMENT_NODE) { NodeList fieldChildren = field.getChildNodes(); if (fieldChildren.getLength() == 0) - throw new InvalidDataException("No child node for element", ""); + throw new InvalidData("No child node for element"); else if (fieldChildren.getLength() == 1) { Node child = fieldChildren.item(0); if (child.getNodeType()==Node.TEXT_NODE || child.getNodeType()==Node.CDATA_SECTION_NODE) return child.getNodeValue(); else - throw new InvalidDataException("Can't get data from child node of type "+child.getNodeName(), ""); + throw new InvalidData("Can't get data from child node of type "+child.getNodeName()); } else - throw new InvalidDataException("Element "+xpath+" has too many children", ""); + throw new InvalidData("Element "+xpath+" has too many children"); } else if (field.getNodeType()==Node.ATTRIBUTE_NODE) return field.getNodeValue(); else - throw new InvalidDataException("Don't know what to do with node "+field.getNodeName(), ""); + throw new InvalidData("Don't know what to do with node "+field.getNodeName()); } - public void setFieldByXPath(String xpath, String data) throws XPathExpressionException, InvalidDataException { + public void setFieldByXPath(String xpath, String data) throws XPathExpressionException, InvalidData { Node field = getNodeByXPath(xpath); if (field == null) - throw new InvalidDataException(xpath, ""); + throw new InvalidData(xpath); else if (field.getNodeType()==Node.ELEMENT_NODE) { NodeList fieldChildren = field.getChildNodes(); @@ -191,16 +191,16 @@ public class Outcome implements C2KLocalObject { child.setNodeValue(data); break; default: - throw new InvalidDataException("Can't set child node of type "+child.getNodeName(), ""); + throw new InvalidData("Can't set child node of type "+child.getNodeName()); } } else - throw new InvalidDataException("Element "+xpath+" has too many children", ""); + throw new InvalidData("Element "+xpath+" has too many children"); } else if (field.getNodeType()==Node.ATTRIBUTE_NODE) field.setNodeValue(data); else - throw new InvalidDataException("Don't know what to do with node "+field.getNodeName(), ""); + throw new InvalidData("Don't know what to do with node "+field.getNodeName()); } @@ -211,7 +211,7 @@ public class Outcome implements C2KLocalObject { return mData; } - public Schema getSchema() throws ObjectNotFoundException { + public Schema getSchema() throws ObjectNotFound { return LocalObjectLoader.getSchema(mSchemaType, mSchemaVersion); } -- cgit v1.2.3