# HG changeset patch # User Tim Englich # Date 1253790211 0 # Node ID cde042a0a395cf2da1e50a6bab8c0adc72bdb42e # Parent 1b12021905b93d9a557da12c95bf41f34516ccdb Successreporting added gnv-artifacts/trunk@126 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 1b12021905b9 -r cde042a0a395 gnv-artifacts/Changelog --- a/gnv-artifacts/Changelog Thu Sep 24 10:45:24 2009 +0000 +++ b/gnv-artifacts/Changelog Thu Sep 24 11:03:31 2009 +0000 @@ -1,3 +1,11 @@ +2009-09-24 Tim Englich + + * src/main/java/de/intevation/gnv/utils/ArtifactXMLUtilities.java (createSuccessReport) Edited: + Added a centraL Method for creating an Successreoprt. + * src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java Edited, + src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java Edited: + Add ResultReporting to the different Metshods of an Artifact + 2009-09-24 Tim Englich * src/main/java/de/intevation/gnv/chart/VerticalProfileChartFactory.java Edited: diff -r 1b12021905b9 -r cde042a0a395 gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java Thu Sep 24 10:45:24 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/GNVArtifactBase.java Thu Sep 24 11:03:31 2009 +0000 @@ -91,6 +91,7 @@ */ @Override public Document advance(Document target, CallContext context) { + log.debug("GNVArtifactBase.advance"); Document result = XMLUtils.newDocument(); try { if (this.current != null){ @@ -108,6 +109,7 @@ nextStep.putInputData(this.current.getInputData()); // 4. Umschalten auf neue Transistion this.current = nextStep; + result = new ArtifactXMLUtilities().createSuccessReport("Advance success", XMLUtils.newDocument()); } catch (TransitionException e) { log.error(e,e); result = new ArtifactXMLUtilities().createExceptionReport(e.getLocalizedMessage(), XMLUtils.newDocument()); @@ -154,15 +156,20 @@ */ @Override public Document feed(Document target, CallContext context) { + log.debug("GNVArtifactBase.feed"); Document result = XMLUtils.newDocument(); try { if (this.current != null){ this.current.putInputData(this.parseInputData(target)); - // TODO Ergebnisdokument erzeugen. + result = new ArtifactXMLUtilities().createSuccessReport("Feed success", XMLUtils.newDocument()); + }else{ + String msg = "No Transition instantiated"; + log.warn(msg); + result = new ArtifactXMLUtilities().createExceptionReport(msg, XMLUtils.newDocument()); } } catch (TransitionException e) { log.error(e,e); - return new ArtifactXMLUtilities().createExceptionReport(e.getLocalizedMessage(), XMLUtils.newDocument()); + result = new ArtifactXMLUtilities().createExceptionReport(e.getLocalizedMessage(), XMLUtils.newDocument()); } return result; } @@ -232,9 +239,8 @@ Element hashNode = xmlUtilities.createArtifactElement(document,"hash"); hashNode.setAttribute("value", this.hash()); parent.appendChild(hashNode); + } - - } protected void createReachableStates(Element parent,Document document){ Element stateNode = xmlUtilities.createArtifactElement(document,"reachable-states"); if (this.current != null){ @@ -358,6 +364,7 @@ } } catch (TransitionException e) { log.error(e,e); + throw new IOException(e.getMessage()); } } diff -r 1b12021905b9 -r cde042a0a395 gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java Thu Sep 24 10:45:24 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java Thu Sep 24 11:03:31 2009 +0000 @@ -189,20 +189,24 @@ */ @Override public Document feed(Document target, CallContext context) { + log.debug("FISArtifact.feed"); + Document result = null; if (this.productArtifact == null){ String productName = Config.getStringXPath(target, "action/data/input[@name='product']/@value"); + log.debug("Looking for ProductArtifact "+productName); if (this.products.containsKey(productName)) { this.current = this.products.get(productName); - // TODO : success-Dokument erzeugen - return null; + result = new ArtifactXMLUtilities().createSuccessReport("Feed success New ProductArtifact created", XMLUtils.newDocument()); }else{ String msg = "Product does not exists for "+productName; log.error(msg); - return new ArtifactXMLUtilities().createExceptionReport(msg, XMLUtils.newDocument()); + result = new ArtifactXMLUtilities().createExceptionReport(msg, XMLUtils.newDocument()); } }else{ - return this.productArtifact.feed(target, context); + log.debug("Feed a Productartifact"); + result = this.productArtifact.feed(target, context); } + return result; } /** @@ -257,8 +261,6 @@ this.products.put(productName, new DefaultProduct(productName, parameter,artifactFactory)); } } - - } } diff -r 1b12021905b9 -r cde042a0a395 gnv-artifacts/src/main/java/de/intevation/gnv/utils/ArtifactXMLUtilities.java --- a/gnv-artifacts/src/main/java/de/intevation/gnv/utils/ArtifactXMLUtilities.java Thu Sep 24 10:45:24 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/utils/ArtifactXMLUtilities.java Thu Sep 24 11:03:31 2009 +0000 @@ -105,7 +105,6 @@ try { byte[] barray = this.writeDocument2String(document).getBytes("UTF-8"); InputStream inputStream = new ByteArrayInputStream(barray); - //StringBufferInputStream inputStream = new StringBufferInputStream(); return this.readDocument(inputStream); } catch (UnsupportedEncodingException e) { log.error(e,e); @@ -129,5 +128,15 @@ return document; } + public Document createSuccessReport(String message, Document document){ + log.debug("ArtifactXMLUtilities.creatSuccessReport"); + Element reportNode = this.createArtifactElement(document, "result"); + document.appendChild(reportNode); + Element successNode = this.createArtifactElement(document, "success"); + successNode.setTextContent(message); + reportNode.appendChild(successNode); + return document; + } + } diff -r 1b12021905b9 -r cde042a0a395 gnv-artifacts/src/test/ressources/log.conf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/src/test/ressources/log.conf Thu Sep 24 11:03:31 2009 +0000 @@ -0,0 +1,4 @@ +.level=FINEST +handlers=java.util.logging.ConsoleHandler +java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter +java.util.logging.FileHandler.pattern=rest-%u-%g.log