Mercurial > dive4elements > river
changeset 123:ebb1cb69d847
The operations feed() and advance() return the current description of the artifact now.
flys-artifacts/trunk@1449 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 10 Mar 2011 08:38:05 +0000 |
parents | d3b8b0b1d010 |
children | b7a9557957d1 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java |
diffstat | 2 files changed, 16 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Thu Mar 10 05:56:17 2011 +0000 +++ b/flys-artifacts/ChangeLog Thu Mar 10 08:38:05 2011 +0000 @@ -1,3 +1,11 @@ +2011-03-10 Ingo Weinzierl <ingo@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java: The + operations feed() and advance() return the description of the artifact + using the describe() operation. This avoids additional server round trips + in the client - the clients gets to know about the new state of the + artifact immediately. + 2011-03-10 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Thu Mar 10 05:56:17 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Thu Mar 10 08:38:05 2011 +0000 @@ -144,6 +144,8 @@ */ @Override public Document feed(Document target, CallContext context) { + logger.info("FLYSArtifact.feed()"); + Document doc = XMLUtils.newDocument(); XMLUtils.ElementCreator creator = new XMLUtils.ElementCreator( @@ -156,7 +158,7 @@ try { saveData(target, XPATH_FEED_INPUT); - creator.addAttr(result, "type", OPERATION_SUCCESSFUL, true); + return describe(target, context); } catch (IllegalArgumentException iae) { creator.addAttr(result, "type", OPERATION_FAILED, true); @@ -180,6 +182,8 @@ * @return a document that contains a SUCCESS or FAILURE message. */ public Document advance(Document target, CallContext context) { + logger.info("FLYSArtifact.advance()"); + Document doc = XMLUtils.newDocument(); XMLUtils.ElementCreator ec = new XMLUtils.ElementCreator( @@ -188,7 +192,6 @@ ArtifactNamespaceContext.NAMESPACE_PREFIX); Element result = ec.create("result"); - doc.appendChild(result); String targetState = XMLUtils.xpathString( target, XPATH_ADVANCE_TARGET, ArtifactNamespaceContext.INSTANCE); @@ -201,16 +204,15 @@ setCurrentStateId(targetState); - ec.addAttr(result, "type", OPERATION_SUCCESSFUL, true); - - return doc; + return describe(target, context); } // TODO IMPLEMENT STEP BACK! logger.warn("Advance: Cannot advance to '" + targetState + "'"); + ec.addAttr(result, "type", OPERATION_FAILED, true); - ec.addAttr(result, "type", OPERATION_FAILED, true); + doc.appendChild(result); return doc; }