Mercurial > dive4elements > gnv-client
comparison gnv/src/main/java/de/intevation/gnv/artifactdatabase/client/DefaultArtifactDatabaseClient.java @ 565:8355d7cacd09
Modified the Create-Artifact-Request-Body that a Geometry will be put into
the Parameter if one is given e.g. using the MapViewer-Interface request.
gnv/trunk@680 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Fri, 12 Feb 2010 09:29:54 +0000 |
parents | 3f39756e0c8a |
children | cbd397712ecf |
comparison
equal
deleted
inserted
replaced
564:97fa3896f505 | 565:8355d7cacd09 |
---|---|
110 while (it.hasNext()) { | 110 while (it.hasNext()) { |
111 String server = it.next(); | 111 String server = it.next(); |
112 String url = server + "/factories"; | 112 String url = server + "/factories"; |
113 Document document = this.doGetRequest(url); | 113 Document document = this.doGetRequest(url); |
114 if (resultValues == null) { | 114 if (resultValues == null) { |
115 resultValues = this.getArtifactFactories(document, server); | 115 resultValues = this.getArtifactFactories(document, server,null); |
116 } else { | 116 } else { |
117 resultValues.addAll(this.getArtifactFactories(document, | 117 resultValues.addAll(this.getArtifactFactories(document, |
118 server)); | 118 server,null)); |
119 } | 119 } |
120 } | 120 } |
121 } catch (IOException e) { | 121 } catch (IOException e) { |
122 log.error(e, e); | 122 log.error(e, e); |
123 throw new ArtifactDatabaseClientException(e); | 123 throw new ArtifactDatabaseClientException(e); |
124 } | 124 } |
125 return resultValues; | 125 return resultValues; |
126 } | 126 } |
127 | 127 |
128 private Collection<ArtifactObject> getArtifactFactories(Document document, | 128 private Collection<ArtifactObject> getArtifactFactories(Document document, |
129 String server) { | 129 String server, |
130 String geometry) { | |
130 XMLUtils xmlUtils = new XMLUtils(); | 131 XMLUtils xmlUtils = new XMLUtils(); |
131 NodeList artifactFactories = xmlUtils.getNodeSetXPath(document, | 132 NodeList artifactFactories = xmlUtils.getNodeSetXPath(document, |
132 "/art:result/art:factories/art:factory"); | 133 "/art:result/art:factories/art:factory"); |
133 Collection<ArtifactObject> resultValues = new ArrayList<ArtifactObject>( | 134 Collection<ArtifactObject> resultValues = new ArrayList<ArtifactObject>( |
134 artifactFactories.getLength()); | 135 artifactFactories.getLength()); |
142 | 143 |
143 NodeList parameterNodeList = xmlUtils.getNodeSetXPath( | 144 NodeList parameterNodeList = xmlUtils.getNodeSetXPath( |
144 artifactFactoryNode, | 145 artifactFactoryNode, |
145 "art:parameter"); | 146 "art:parameter"); |
146 | 147 |
147 if (parameterNodeList != null && | 148 if ((parameterNodeList != null && |
148 parameterNodeList.getLength() > 0){ | 149 parameterNodeList.getLength() > 0) || |
150 geometry != null){ | |
149 Collection<String> parameters = | 151 Collection<String> parameters = |
150 new ArrayList<String>(parameterNodeList.getLength()); | 152 new ArrayList<String>(parameterNodeList.getLength()); |
151 for (int j = 0; j < parameterNodeList.getLength(); j++){ | 153 for (int j = 0; j < parameterNodeList.getLength(); j++){ |
152 Element parameterNode = (Element)parameterNodeList.item(j); | 154 Element parameterNode = (Element)parameterNodeList.item(j); |
153 parameters.add(parameterNode.getAttribute("id")); | 155 parameters.add(parameterNode.getAttribute("id")); |
156 new ParametrizedArtifactFactory(name, | 158 new ParametrizedArtifactFactory(name, |
157 description, | 159 description, |
158 server); | 160 server); |
159 pao.addParameters("parameter", parameters); | 161 pao.addParameters("parameter", parameters); |
160 resultValues.add(pao); | 162 resultValues.add(pao); |
163 if (geometry != null){ | |
164 Collection<String> geometryList = new ArrayList<String>(1); | |
165 geometryList.add(geometry); | |
166 pao.addParameters("geometry",geometryList); | |
167 } | |
161 }else{ | 168 }else{ |
162 ArtifactObject artifactFactory = new ArtifactFactory(name, | 169 ArtifactObject artifactFactory = new ArtifactFactory(name, |
163 description, | 170 description, |
164 server); | 171 server); |
165 resultValues.add(artifactFactory); | 172 resultValues.add(artifactFactory); |
820 String server = it.next(); | 827 String server = it.next(); |
821 String url = server + "/service/metadata/"; | 828 String url = server + "/service/metadata/"; |
822 log.debug(url); | 829 log.debug(url); |
823 | 830 |
824 InputStream resultStream = this.doPostRequest(url, requestBody); | 831 InputStream resultStream = this.doPostRequest(url, requestBody); |
825 resultValues = this.parseMetaDataResult(resultStream, server); | 832 resultValues = this.parseMetaDataResult(resultStream, server,geometry); |
826 } | 833 } |
827 } catch (IOException e) { | 834 } catch (IOException e) { |
828 log.error(e,e); | 835 log.error(e,e); |
829 } | 836 } |
830 return resultValues; | 837 return resultValues; |
831 } | 838 } |
832 | 839 |
833 private Collection<ArtifactObject> parseMetaDataResult( | 840 private Collection<ArtifactObject> parseMetaDataResult( |
834 InputStream inputStream, | 841 InputStream inputStream, |
835 String server) throws ArtifactDatabaseClientException{ | 842 String server, |
843 String geometry) throws ArtifactDatabaseClientException{ | |
836 XMLUtils xmlUtils = new XMLUtils(); | 844 XMLUtils xmlUtils = new XMLUtils(); |
837 Document document = xmlUtils.readDocument(inputStream); | 845 Document document = xmlUtils.readDocument(inputStream); |
838 this.check4ExceptionReport(document); | 846 this.check4ExceptionReport(document); |
839 return this.getArtifactFactories(document, server); | 847 return this.getArtifactFactories(document, server,geometry); |
840 } | 848 } |
841 | 849 |
842 private Document createMetaDataRequestBody(Collection<MapService> mapServices, | 850 private Document createMetaDataRequestBody(Collection<MapService> mapServices, |
843 String geometry, | 851 String geometry, |
844 String srs){ | 852 String srs){ |