Author: rhauch
Date: 2008-07-01 16:14:16 -0400 (Tue, 01 Jul 2008)
New Revision: 322
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/GraphCommand.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGraphCommand.java
Log:
DNA-115 - Create federation service
http://jira.jboss.com/jira/browse/DNA-115
Added an error field to the GraphCommand, allowing connector implementations to set errors
on individual commands (especially useful when multiple commands are submitted via a
single "execute" call).
Modified: trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/GraphCommand.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/GraphCommand.java 2008-06-30
21:45:21 UTC (rev 321)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/GraphCommand.java 2008-07-01
20:14:16 UTC (rev 322)
@@ -23,14 +23,23 @@
/**
* The base interface for all repository commands
+ *
* @author Randall Hauch
*/
public interface GraphCommand {
/**
* Return whether this command has been cancelled.
+ *
* @return true if this command has been cancelled, or false otherwise.
*/
boolean isCancelled();
+ /**
+ * Set the error for this command.
+ *
+ * @param error the exception
+ */
+ void setError( Throwable error );
+
}
Modified:
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGraphCommand.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGraphCommand.java 2008-06-30
21:45:21 UTC (rev 321)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/graph/commands/impl/BasicGraphCommand.java 2008-07-01
20:14:16 UTC (rev 322)
@@ -40,6 +40,7 @@
public abstract class BasicGraphCommand implements GraphCommand {
private boolean cancelled = false;
+ private Throwable error;
/**
*
@@ -61,6 +62,30 @@
this.cancelled = cancelled;
}
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.spi.graph.commands.GraphCommand#setError(java.lang.Throwable)
+ */
+ public void setError( Throwable t ) {
+ error = t;
+ }
+
+ /**
+ * @return error
+ */
+ public Throwable getError() {
+ return error;
+ }
+
+ public boolean hasError() {
+ return error != null;
+ }
+
+ public boolean hasNoError() {
+ return error == null;
+ }
+
//
----------------------------------------------------------------------------------------------------------------
// Utility methods used by concrete command implementations
//
----------------------------------------------------------------------------------------------------------------
@@ -105,7 +130,9 @@
return children;
}
- protected static void setProperty( Map<Name, List<Object>>
propertyValues, Name propertyName, Object... values ) {
+ protected static void setProperty( Map<Name, List<Object>>
propertyValues,
+ Name propertyName,
+ Object... values ) {
if (values == null || values.length == 0) {
propertyValues.remove(propertyName);
} else {
@@ -135,7 +162,9 @@
}
}
- protected static void setProperty( Map<Name, List<Object>>
propertyValues, Name propertyName, Iterable<?> values ) {
+ protected static void setProperty( Map<Name, List<Object>>
propertyValues,
+ Name propertyName,
+ Iterable<?> values ) {
if (values == null) {
propertyValues.remove(propertyName);
} else {
@@ -147,7 +176,9 @@
}
}
- protected static void setProperty( Map<Name, List<Object>>
propertyValues, Name propertyName, Iterator<?> values ) {
+ protected static void setProperty( Map<Name, List<Object>>
propertyValues,
+ Name propertyName,
+ Iterator<?> values ) {
if (values == null) {
propertyValues.remove(propertyName);
} else {