comparison gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/fis/FISArtifact.java @ 88:1b12021905b9

Some CodeCleanup done. ExceptionDocument will now be returned gnv-artifacts/trunk@125 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Tim Englich <tim.englich@intevation.de>
date Thu, 24 Sep 2009 10:45:24 +0000
parents 5eb62df21f9a
children cde042a0a395
comparison
equal deleted inserted replaced
87:ce398a7a99fc 88:1b12021905b9
77 /** 77 /**
78 * @see de.intevation.artifactdatabase.DefaultArtifact#advance(org.w3c.dom.Document, de.intevation.artifacts.CallContext) 78 * @see de.intevation.artifactdatabase.DefaultArtifact#advance(org.w3c.dom.Document, de.intevation.artifacts.CallContext)
79 */ 79 */
80 @Override 80 @Override
81 public Document advance(Document target, CallContext context) { 81 public Document advance(Document target, CallContext context) {
82
83 Document result = null;
82 if (this.productArtifact == null){ 84 if (this.productArtifact == null){
83 if (this.current != null){ 85 if (this.current != null){
84 try { 86
85 String uuid = Config.getStringXPath(target, "action/uuid/@value"); // TODO: müssen wir für das subartifact eine veränderte uuid führen? 87 String uuid = Config.getStringXPath(target, "action/uuid/@value");
86 String hash = Config.getStringXPath(target, "action/hash/@value"); 88 String hash = Config.getStringXPath(target, "action/hash/@value");
87 this.productArtifact = this.current.getArtifactFactory().createArtifact(uuid, context); 89 this.productArtifact = this.current.getArtifactFactory().createArtifact(uuid, context);
88 Document feedDocument = xmlUtilities.reInitDocument(this.createFeedProductArtifactDocument(uuid, hash)); 90 Document feedDocument = xmlUtilities.reInitDocument(this.createFeedProductArtifactDocument(uuid, hash));
89 log.debug("Feed ==> "+this.xmlUtilities.writeDocument2String(feedDocument)); 91 log.debug("Feed ==> "+this.xmlUtilities.writeDocument2String(feedDocument));
90 Document descibeDocument = xmlUtilities.reInitDocument(this.productArtifact.describe(context)); 92 Document descibeDocument = xmlUtilities.reInitDocument(this.productArtifact.describe(context));
91 log.debug("Descibe ==> "+this.xmlUtilities.writeDocument2String(descibeDocument)); 93 log.debug("Descibe ==> "+this.xmlUtilities.writeDocument2String(descibeDocument));
92 this.productArtifact.feed(feedDocument, context); 94 this.productArtifact.feed(feedDocument, context);
93 String targetName = Config.getStringXPath(descibeDocument, "result/reachable-states/state/@name"); 95 String targetName = Config.getStringXPath(descibeDocument, "result/reachable-states/state/@name");
94 Document advanceDocument = xmlUtilities.reInitDocument(this.createAdvanceProductArtifactDocument(uuid, hash, targetName)); 96 Document advanceDocument = xmlUtilities.reInitDocument(this.createAdvanceProductArtifactDocument(uuid, hash, targetName));
95 log.debug("Advance ==> "+this.xmlUtilities.writeDocument2String(advanceDocument)); 97 log.debug("Advance ==> "+this.xmlUtilities.writeDocument2String(advanceDocument));
96 return this.productArtifact.advance(advanceDocument, context); 98 result = this.productArtifact.advance(advanceDocument, context);
97 } catch (RuntimeException e) {
98 log.error(e,e);
99 }
100 }else{ 99 }else{
101 log.warn("Artifact is not configured properly. Call feed first."); 100 String msg = "Artifact is not configured properly. Call feed first.";
102 // TODO Fehlerdokument erzeugen. 101 log.error(msg);
103 } 102 result = new ArtifactXMLUtilities().createExceptionReport(msg, XMLUtils.newDocument());
104 return null; 103 }
105 }else{ 104 }else{
106 return this.productArtifact.advance(target, context); 105 result = this.productArtifact.advance(target, context);
107 } 106 }
107 return result;
108 } 108 }
109 private Document createAdvanceProductArtifactDocument(String uuid, String hash, String targetName){ 109 private Document createAdvanceProductArtifactDocument(String uuid, String hash, String targetName){
110 Document document = XMLUtils.newDocument(); 110 Document document = XMLUtils.newDocument();
111 Element rootNode = xmlUtilities.createArtifactElement(document, "action"); 111 Element rootNode = xmlUtilities.createArtifactElement(document, "action");
112 112
191 public Document feed(Document target, CallContext context) { 191 public Document feed(Document target, CallContext context) {
192 if (this.productArtifact == null){ 192 if (this.productArtifact == null){
193 String productName = Config.getStringXPath(target, "action/data/input[@name='product']/@value"); 193 String productName = Config.getStringXPath(target, "action/data/input[@name='product']/@value");
194 if (this.products.containsKey(productName)) { 194 if (this.products.containsKey(productName)) {
195 this.current = this.products.get(productName); 195 this.current = this.products.get(productName);
196 // TODO : success-Dokument erzeugen
197 return null;
196 }else{ 198 }else{
197 log.error("Product does not exists for "+productName); 199 String msg = "Product does not exists for "+productName;
198 // TODO: Fehlerdokument erzeugen. 200 log.error(msg);
199 } 201 return new ArtifactXMLUtilities().createExceptionReport(msg, XMLUtils.newDocument());
200 return null; 202 }
201 }else{ 203 }else{
202 return this.productArtifact.feed(target, context); 204 return this.productArtifact.feed(target, context);
203 } 205 }
204 } 206 }
205 207

http://dive4elements.wald.intevation.org