diff options
| author | Andrew Branson <andrew.branson@cern.ch> | 2014-10-03 17:30:41 +0200 |
|---|---|---|
| committer | Andrew Branson <andrew.branson@cern.ch> | 2014-10-03 17:30:41 +0200 |
| commit | 275d0bbf555c8917be82ce4cc21eb4cabb00f4c5 (patch) | |
| tree | ddcc6b14077d90d1b970b67829f07120547dbb62 /src/main/java/com/c2kernel/persistency/outcome | |
| parent | a139f95bfeca603333b8c0310ae09c6805e58584 (diff) | |
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.
Diffstat (limited to 'src/main/java/com/c2kernel/persistency/outcome')
4 files changed, 31 insertions, 31 deletions
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);
}
diff --git a/src/main/java/com/c2kernel/persistency/outcome/OutcomeInitiator.java b/src/main/java/com/c2kernel/persistency/outcome/OutcomeInitiator.java index e152df9..2c4427e 100644 --- a/src/main/java/com/c2kernel/persistency/outcome/OutcomeInitiator.java +++ b/src/main/java/com/c2kernel/persistency/outcome/OutcomeInitiator.java @@ -20,11 +20,11 @@ */
package com.c2kernel.persistency.outcome;
-import com.c2kernel.common.InvalidDataException;
+import com.c2kernel.common.InvalidData;
import com.c2kernel.entity.agent.Job;
public interface OutcomeInitiator {
- public String initOutcome(Job job) throws InvalidDataException;
+ public String initOutcome(Job job) throws InvalidData;
}
diff --git a/src/main/java/com/c2kernel/persistency/outcome/OutcomeValidator.java b/src/main/java/com/c2kernel/persistency/outcome/OutcomeValidator.java index defac3a..d89f7e7 100644 --- a/src/main/java/com/c2kernel/persistency/outcome/OutcomeValidator.java +++ b/src/main/java/com/c2kernel/persistency/outcome/OutcomeValidator.java @@ -38,7 +38,7 @@ import org.xml.sax.ErrorHandler; import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
-import com.c2kernel.common.InvalidDataException;
+import com.c2kernel.common.InvalidData;
import com.c2kernel.utils.Logger;
/**************************************************************************
@@ -69,7 +69,7 @@ public class OutcomeValidator implements ErrorHandler, XMLErrorHandler { XMLGrammarPoolImpl schemaGrammarPool = new XMLGrammarPoolImpl(1);
SymbolTable sym = new SymbolTable();
- public static OutcomeValidator getValidator(Schema schema) throws InvalidDataException {
+ public static OutcomeValidator getValidator(Schema schema) throws InvalidData {
if (schema.docType.equals("Schema") &&
schema.docVersion==0)
@@ -82,11 +82,11 @@ public class OutcomeValidator implements ErrorHandler, XMLErrorHandler { errors = new StringBuffer();
}
- public OutcomeValidator(Schema schema) throws InvalidDataException {
+ public OutcomeValidator(Schema schema) throws InvalidData {
this.schema = schema;
if (schema.docType.equals("Schema"))
- throw new InvalidDataException("Use SchemaValidator to validate schema", "");
+ throw new InvalidData("Use SchemaValidator to validate schema");
errors = new StringBuffer();
Logger.msg(5, "Parsing "+schema.docType+" version "+schema.docVersion+". "+schema.schema.length()+" chars");
@@ -103,11 +103,11 @@ public class OutcomeValidator implements ErrorHandler, XMLErrorHandler { try {
preparser.preparseGrammar(XMLGrammarDescription.XML_SCHEMA, new XMLInputSource(null, null, null, new StringReader(schema.schema), null));
} catch (IOException ex) {
- throw new InvalidDataException("Error parsing schema: "+ex.getMessage(), "");
+ throw new InvalidData("Error parsing schema: "+ex.getMessage());
}
if (errors.length() > 0) {
- throw new InvalidDataException("Schema error: \n"+errors.toString(), "");
+ throw new InvalidData("Schema error: \n"+errors.toString());
}
}
diff --git a/src/main/java/com/c2kernel/persistency/outcome/Viewpoint.java b/src/main/java/com/c2kernel/persistency/outcome/Viewpoint.java index 2a5118f..151bf65 100644 --- a/src/main/java/com/c2kernel/persistency/outcome/Viewpoint.java +++ b/src/main/java/com/c2kernel/persistency/outcome/Viewpoint.java @@ -20,14 +20,14 @@ */
package com.c2kernel.persistency.outcome;
-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.events.Event;
import com.c2kernel.lookup.InvalidItemPathException;
import com.c2kernel.lookup.ItemPath;
import com.c2kernel.persistency.ClusterStorage;
-import com.c2kernel.persistency.ClusterStorageException;
import com.c2kernel.process.Gateway;
/**
@@ -70,8 +70,8 @@ public class Viewpoint implements C2KLocalObject { this.eventId = eventId;
}
- public Outcome getOutcome() throws ObjectNotFoundException, ClusterStorageException {
- if (eventId == NONE) throw new ObjectNotFoundException("No last eventId defined", "");
+ public Outcome getOutcome() throws ObjectNotFound, PersistencyException {
+ if (eventId == NONE) throw new ObjectNotFound("No last eventId defined");
Outcome retVal = (Outcome)Gateway.getStorage().get(itemPath, ClusterStorage.OUTCOME+"/"+schemaName+"/"+schemaVersion+"/"+eventId, null);
return retVal;
}
@@ -194,10 +194,10 @@ public class Viewpoint implements C2KLocalObject { * @return GDataRecord
*/
public Event getEvent()
- throws InvalidDataException, ClusterStorageException, ObjectNotFoundException
+ throws InvalidData, PersistencyException, ObjectNotFound
{
if (eventId == NONE)
- throw new InvalidDataException("No last eventId defined", "");
+ throw new InvalidData("No last eventId defined");
return (Event)Gateway.getStorage().get(itemPath, ClusterStorage.HISTORY+"/"+eventId, null);
}
|
