comparison gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java @ 389:416ff31f6273

Removed local-name() method from xsl stylesheet and adjusted xpathes while reading xml documents. gnv/trunk@511 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 06 Jan 2010 09:13:45 +0000
parents 4ec95d586f31
children ee8003fffc71
comparison
equal deleted inserted replaced
388:6e16dc005704 389:416ff31f6273
126 126
127 private Collection<ArtifactObject> getArtifactFactories(Document document, 127 private Collection<ArtifactObject> getArtifactFactories(Document document,
128 String server) { 128 String server) {
129 XMLUtils xmlUtils = new XMLUtils(); 129 XMLUtils xmlUtils = new XMLUtils();
130 NodeList artifactFactories = xmlUtils.getNodeSetXPath(document, 130 NodeList artifactFactories = xmlUtils.getNodeSetXPath(document,
131 "/result/factories/factory"); 131 "/art:result/art:factories/art:factory");
132 Collection<ArtifactObject> resultValues = new ArrayList<ArtifactObject>( 132 Collection<ArtifactObject> resultValues = new ArrayList<ArtifactObject>(
133 artifactFactories.getLength()); 133 artifactFactories.getLength());
134 if (artifactFactories != null) { 134 if (artifactFactories != null) {
135 for (int i = 0; i < artifactFactories.getLength(); i++) { 135 for (int i = 0; i < artifactFactories.getLength(); i++) {
136 Node artifactFactoryNode = artifactFactories.item(i); 136 Node artifactFactoryNode = artifactFactories.item(i);
137 String name = xmlUtils.getStringXPath(artifactFactoryNode, 137 String name = xmlUtils.getStringXPath(artifactFactoryNode,
138 "@name"); 138 "@art:name");
139 String description = xmlUtils.getStringXPath( 139 String description = xmlUtils.getStringXPath(
140 artifactFactoryNode, "@description"); 140 artifactFactoryNode, "@art:description");
141 ArtifactFactory artifactFactory = new ArtifactFactory(name, 141 ArtifactFactory artifactFactory = new ArtifactFactory(name,
142 description, server); 142 description, server);
143 resultValues.add(artifactFactory); 143 resultValues.add(artifactFactory);
144 } 144 }
145 } 145 }
146 log.debug("Artifact Factories: " + resultValues.size());
146 return resultValues; 147 return resultValues;
147 } 148 }
148 149
149 /** 150 /**
150 * @throws IOException 151 * @throws IOException
263 } 264 }
264 } 265 }
265 266
266 private ArtifactObject getArtifact(Document document) { 267 private ArtifactObject getArtifact(Document document) {
267 XMLUtils xmlUtils = new XMLUtils(); 268 XMLUtils xmlUtils = new XMLUtils();
268 String uuid = xmlUtils.getStringXPath(document, "/result/uuid/@value"); 269 String uuid = xmlUtils.getStringXPath(document, "/art:result/art:uuid/@value");
269 String hash = xmlUtils.getStringXPath(document, "/result/hash/@value"); 270 String hash = xmlUtils.getStringXPath(document, "/art:result/art:hash/@value");
270 log.info("NEW Artifact: " + uuid + " / " + hash); 271 log.info("NEW Artifact: " + uuid + " / " + hash);
271 return new Artifact(uuid, hash); 272 return new Artifact(uuid, hash);
272 } 273 }
273 274
274 private Document createCreateRequestBody(String artifactFactoryName) { 275 private Document createCreateRequestBody(String artifactFactoryName) {
385 // ArtifactDatabase 386 // ArtifactDatabase
386 this.check4ExceptionReport(document); 387 this.check4ExceptionReport(document);
387 XMLUtils xmlUtils = new XMLUtils(); 388 XMLUtils xmlUtils = new XMLUtils();
388 if (artifact instanceof ArtifactDescription) { 389 if (artifact instanceof ArtifactDescription) {
389 ArtifactDescription ad = (ArtifactDescription) artifact; 390 ArtifactDescription ad = (ArtifactDescription) artifact;
390 Node uiNode = xmlUtils.getNodeXPath(document, "/result/ui"); 391 Node uiNode = xmlUtils.getNodeXPath(document, "/art:result/art:ui");
391 Node outputNode = xmlUtils 392 Node outputNode = xmlUtils
392 .getNodeXPath(document, "/result/outputs"); 393 .getNodeXPath(document, "/art:result/art:outputs");
393 394
394 Map<String, OutputMode> outputModes = null; 395 Map<String, OutputMode> outputModes = null;
395 if (outputNode != null) { 396 if (outputNode != null) {
396 NodeList outputModesNodes = xmlUtils.getNodeSetXPath( 397 NodeList outputModesNodes = xmlUtils.getNodeSetXPath(
397 outputNode, "output"); 398 outputNode, "art:output");
398 if (outputModesNodes != null) { 399 if (outputModesNodes != null) {
399 outputModes = new HashMap<String, OutputMode>( 400 outputModes = new HashMap<String, OutputMode>(
400 outputModesNodes.getLength()); 401 outputModesNodes.getLength());
401 for (int i = 0; i < outputModesNodes.getLength(); i++) { 402 for (int i = 0; i < outputModesNodes.getLength(); i++) {
402 Node outputModeNode = outputModesNodes.item(i); 403 Node outputModeNode = outputModesNodes.item(i);
404 "@name"); 405 "@name");
405 String mimeType = xmlUtils.getStringXPath( 406 String mimeType = xmlUtils.getStringXPath(
406 outputModeNode, "@mime-type"); 407 outputModeNode, "@mime-type");
407 408
408 NodeList parameterNodes = xmlUtils.getNodeSetXPath( 409 NodeList parameterNodes = xmlUtils.getNodeSetXPath(
409 outputModeNode, "parameter/parameter"); 410 outputModeNode, "art:parameter/art:parameter");
410 Collection<OutputParameter> parameter = null; 411 Collection<OutputParameter> parameter = null;
411 if (parameterNodes != null) { 412 if (parameterNodes != null) {
412 parameter = new ArrayList<OutputParameter>( 413 parameter = new ArrayList<OutputParameter>(
413 parameterNodes.getLength()); 414 parameterNodes.getLength());
414 for (int j = 0; j < parameterNodes.getLength(); j++) { 415 for (int j = 0; j < parameterNodes.getLength(); j++) {
431 432
432 } 433 }
433 } 434 }
434 435
435 String currentState = xmlUtils.getStringXPath(document, 436 String currentState = xmlUtils.getStringXPath(document,
436 "/result/state/@name"); 437 "/art:result/art:state/@name");
437 NodeList statesList = xmlUtils.getNodeSetXPath(document, 438 NodeList statesList = xmlUtils.getNodeSetXPath(document,
438 "/result/reachable-states/state/@name"); 439 "/art:result/art:reachable-states/art:state/@name");
439 Collection<String> reachableStates = new ArrayList<String>( 440 Collection<String> reachableStates = new ArrayList<String>(
440 statesList.getLength()); 441 statesList.getLength());
441 for (int i = 0; i < statesList.getLength(); i++) { 442 for (int i = 0; i < statesList.getLength(); i++) {
442 reachableStates.add(statesList.item(i).getNodeValue()); 443 reachableStates.add(statesList.item(i).getNodeValue());
443 } 444 }
444 445
445 NodeList inputNodes = xmlUtils.getNodeSetXPath(document, 446 NodeList inputNodes = xmlUtils.getNodeSetXPath(document,
446 "/result/model/input"); 447 "/art:result/art:model/art:input");
447 if (inputNodes != null) { 448 if (inputNodes != null) {
448 Collection<String> inputParameter = new ArrayList<String>( 449 Collection<String> inputParameter = new ArrayList<String>(
449 inputNodes.getLength()); 450 inputNodes.getLength());
450 for (int i = 0; i < inputNodes.getLength(); i++) { 451 for (int i = 0; i < inputNodes.getLength(); i++) {
451 Node inputNode = inputNodes.item(i); 452 Node inputNode = inputNodes.item(i);
705 InputStream is = this.doPostRequest(requestUrl, requestBody); 706 InputStream is = this.doPostRequest(requestUrl, requestBody);
706 Document resultDocument = xmlUtils.readDocument(is); 707 Document resultDocument = xmlUtils.readDocument(is);
707 if (resultDocument != null) { 708 if (resultDocument != null) {
708 709
709 NodeList statisticSetNodes = xmlUtils.getNodeSetXPath(resultDocument, 710 NodeList statisticSetNodes = xmlUtils.getNodeSetXPath(resultDocument,
710 "/statistics/statistic"); 711 "/art:statistics/art:statistic");
711 resultValues = new ArrayList<ArtifactStatisticsSet> 712 resultValues = new ArrayList<ArtifactStatisticsSet>
712 (statisticSetNodes.getLength()); 713 (statisticSetNodes.getLength());
713 for (int i = 0; i < statisticSetNodes.getLength(); i++) { 714 for (int i = 0; i < statisticSetNodes.getLength(); i++) {
714 Element statisticSetNode = (Element)statisticSetNodes.item(i); 715 Element statisticSetNode = (Element)statisticSetNodes.item(i);
715 String name = statisticSetNode.getAttribute("name"); 716 String name = statisticSetNode.getAttribute("name");
716 ArtifactStatisticsSet set = 717 ArtifactStatisticsSet set =
717 new DefaultArtifactStatisticsSet(name); 718 new DefaultArtifactStatisticsSet(name);
718 NodeList resultNodes = xmlUtils.getNodeSetXPath(statisticSetNode, 719 NodeList resultNodes = xmlUtils.getNodeSetXPath(statisticSetNode,
719 "statistic-value"); 720 "art:statistic-value");
720 if (resultNodes != null) { 721 if (resultNodes != null) {
721 for (int j = 0; j < resultNodes.getLength(); j++) { 722 for (int j = 0; j < resultNodes.getLength(); j++) {
722 Element statisticNode = (Element)resultNodes.item(j); 723 Element statisticNode = (Element)resultNodes.item(j);
723 String statisticName = statisticNode. 724 String statisticName = statisticNode.
724 getAttribute("name"); 725 getAttribute("name");

http://dive4elements.wald.intevation.org