svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.arcims.feature.extension / src / main / java / org / gvsig / fmap / dal / serverexplorer / arcims / ArcImsServerExplorer.java @ 32356
History | View | Annotate | Download (8.62 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2010 Prodevelop S.L. main development
|
26 |
* http://www.prodevelop.es
|
27 |
*/
|
28 |
|
29 |
package org.gvsig.fmap.dal.serverexplorer.arcims; |
30 |
|
31 |
import java.io.IOException; |
32 |
import java.net.ConnectException; |
33 |
import java.util.ArrayList; |
34 |
import java.util.Hashtable; |
35 |
import java.util.Iterator; |
36 |
import java.util.List; |
37 |
|
38 |
import org.gvsig.fmap.dal.DALLocator; |
39 |
import org.gvsig.fmap.dal.DataManager; |
40 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
41 |
import org.gvsig.fmap.dal.DataStoreParameters; |
42 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
43 |
import org.gvsig.fmap.dal.exception.DataException; |
44 |
import org.gvsig.fmap.dal.exception.InitializeException; |
45 |
import org.gvsig.fmap.dal.feature.Feature; |
46 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProvider; |
47 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices; |
48 |
import org.gvsig.fmap.dal.store.arcims.ArcImsStoreParameters; |
49 |
import org.gvsig.fmap.dal.store.arcims.ArcImsStoreProvider; |
50 |
import org.gvsig.remoteclient.arcims.ArcImsClient; |
51 |
import org.gvsig.remoteclient.arcims.ArcImsFeatureClient; |
52 |
import org.gvsig.remoteclient.arcims.ArcImsStatus; |
53 |
import org.gvsig.remoteclient.arcims.ArcImsVectStatus; |
54 |
import org.gvsig.remoteclient.arcims.utils.ServiceInfoTags; |
55 |
import org.gvsig.remoteclient.wfs.WFSClient; |
56 |
import org.gvsig.remoteclient.wfs.WFSFeature; |
57 |
import org.gvsig.remoteclient.wfs.WFSStatus; |
58 |
import org.gvsig.remoteclient.wfs.exceptions.WFSException; |
59 |
import org.gvsig.remoteclient.wms.ICancellable; |
60 |
import org.gvsig.tools.dispose.impl.AbstractDisposable; |
61 |
import org.gvsig.tools.exception.BaseException; |
62 |
|
63 |
/**
|
64 |
* vsanjaime
|
65 |
*/
|
66 |
public class ArcImsServerExplorer extends AbstractDisposable implements |
67 |
DataServerExplorerProvider { |
68 |
|
69 |
public static final String NAME = "ArcIMSServerExplorer"; |
70 |
private ArcImsServerExplorerParameters parameters = null; |
71 |
private DataManager dataManager = DALLocator.getDataManager();
|
72 |
private String url = null; |
73 |
|
74 |
//ArcIMS Parameters
|
75 |
private ArcImsStatus arcimsStatus = null; |
76 |
private ArcImsClient arcimsClient = null; |
77 |
|
78 |
|
79 |
|
80 |
/**
|
81 |
* @param parameters
|
82 |
*/
|
83 |
public ArcImsServerExplorer(ArcImsServerExplorerParameters parameters, DataServerExplorerProviderServices services) throws InitializeException{ |
84 |
super();
|
85 |
this.parameters = parameters;
|
86 |
this.url = parameters.getUrl();
|
87 |
|
88 |
if (arcimsClient == null){ |
89 |
// TODO put service, now is "" in ArcImsfeatureClient constructor
|
90 |
try {
|
91 |
arcimsClient = new ArcImsFeatureClient(this.url, "", ServiceInfoTags.vFEATURESERVICE); |
92 |
if (arcimsStatus == null){ |
93 |
arcimsStatus = new ArcImsVectStatus();
|
94 |
|
95 |
} |
96 |
arcimsClient.getCapabilities(arcimsStatus); |
97 |
} catch (Exception e) { |
98 |
throw new InitializeException("Not possible to connect with " + this.url, e); |
99 |
} |
100 |
} |
101 |
} |
102 |
|
103 |
/**
|
104 |
* Returns all the feature information retrieved using a
|
105 |
* describeFeatureTypeOpearion
|
106 |
* @param layerName
|
107 |
* Feature name
|
108 |
* @return
|
109 |
* @throws WFSException
|
110 |
*/
|
111 |
public Feature getFeatureInfo(String nameSpace, String layerName) throws WFSException{ |
112 |
describeFeatureType(layerName, nameSpace, null);
|
113 |
return (Feature) arcimsClient.getFeatures().get(layerName);
|
114 |
} |
115 |
|
116 |
private void describeFeatureType(String featureType, String nameSpace, ICancellable cancel) throws WFSException { |
117 |
arcimsStatus = new WFSStatus(featureType, nameSpace);
|
118 |
arcimsClient.describeFeatureType(arcimsStatus, false, cancel);
|
119 |
} |
120 |
|
121 |
/**
|
122 |
* Returns an array of WFSLayerNode's with the descriptors of
|
123 |
* all features (retrieved using the getCapabilities operation)
|
124 |
* @return WFSLayerNode[]
|
125 |
*/
|
126 |
public Hashtable getFeatures(){ |
127 |
return arcimsClient.getFeatures();
|
128 |
} |
129 |
|
130 |
/* (non-Javadoc)
|
131 |
* @see org.gvsig.fmap.dal.DataServerExplorer#add(org.gvsig.fmap.dal.NewDataStoreParameters, boolean)
|
132 |
*/
|
133 |
public boolean add(NewDataStoreParameters parameters, boolean overwrite) |
134 |
throws DataException {
|
135 |
// TODO Auto-generated method stub
|
136 |
return false; |
137 |
} |
138 |
|
139 |
/* (non-Javadoc)
|
140 |
* @see org.gvsig.fmap.dal.DataServerExplorer#canAdd()
|
141 |
*/
|
142 |
public boolean canAdd() { |
143 |
// TODO Auto-generated method stub
|
144 |
return false; |
145 |
} |
146 |
|
147 |
/* (non-Javadoc)
|
148 |
* @see org.gvsig.fmap.dal.DataServerExplorer#canAdd(java.lang.String)
|
149 |
*/
|
150 |
public boolean canAdd(String storeName) throws DataException { |
151 |
// TODO Auto-generated method stub
|
152 |
return false; |
153 |
} |
154 |
|
155 |
@Override
|
156 |
protected void doDispose() throws BaseException { |
157 |
// Nothing to do
|
158 |
} |
159 |
|
160 |
/* (non-Javadoc)
|
161 |
* @see org.gvsig.fmap.dal.DataServerExplorer#getAddParameters(java.lang.String)
|
162 |
*/
|
163 |
public NewDataStoreParameters getAddParameters(String storeName) |
164 |
throws DataException {
|
165 |
// TODO Auto-generated method stub
|
166 |
return null; |
167 |
} |
168 |
|
169 |
/* (non-Javadoc)
|
170 |
* @see org.gvsig.fmap.dal.DataServerExplorer#getName()
|
171 |
*/
|
172 |
public String getName() { |
173 |
return NAME;
|
174 |
} |
175 |
|
176 |
/* (non-Javadoc)
|
177 |
* @see org.gvsig.fmap.dal.DataServerExplorer#getParameters()
|
178 |
*/
|
179 |
public DataServerExplorerParameters getParameters() {
|
180 |
return parameters;
|
181 |
} |
182 |
|
183 |
/* (non-Javadoc)
|
184 |
* @see org.gvsig.fmap.dal.DataServerExplorer#list()
|
185 |
*/
|
186 |
public List list() throws DataException { |
187 |
List list = new ArrayList(); |
188 |
Hashtable features = arcimsClient.getFeatures();
|
189 |
Iterator it = features.keySet().iterator();
|
190 |
DataStoreParameters dsp = null;
|
191 |
while (it.hasNext()){
|
192 |
String key = (String)it.next(); |
193 |
WFSFeature feature = (WFSFeature)features.get(key); |
194 |
list.add(getParametersFor(feature)); |
195 |
} |
196 |
return list;
|
197 |
} |
198 |
|
199 |
public DataStoreParameters getParametersFor(WFSFeature feature)
|
200 |
throws DataException {
|
201 |
ArcImsStoreParameters params = (ArcImsStoreParameters)dataManager |
202 |
.createStoreParameters(ArcImsStoreProvider.NAME); |
203 |
params.setUrl(url); |
204 |
params.setFeatureType(feature.getNamespace().getName(), |
205 |
feature.getNamespace().getLocation(), |
206 |
feature.getName()); |
207 |
return params;
|
208 |
} |
209 |
|
210 |
/* (non-Javadoc)
|
211 |
* @see org.gvsig.fmap.dal.DataServerExplorer#list(int)
|
212 |
*/
|
213 |
public List list(int mode) throws DataException { |
214 |
return list();
|
215 |
} |
216 |
|
217 |
/* (non-Javadoc)
|
218 |
* @see org.gvsig.fmap.dal.DataServerExplorer#remove(org.gvsig.fmap.dal.DataStoreParameters)
|
219 |
*/
|
220 |
public void remove(DataStoreParameters parameters) throws DataException { |
221 |
// TODO Auto-generated method stub
|
222 |
|
223 |
} |
224 |
|
225 |
/* (non-Javadoc)
|
226 |
* @see org.gvsig.fmap.dal.spi.DataServerExplorerProvider#getServerExplorerProviderServices()
|
227 |
*/
|
228 |
public DataServerExplorerProviderServices getServerExplorerProviderServices() {
|
229 |
// TODO Auto-generated method stub
|
230 |
return null; |
231 |
} |
232 |
|
233 |
/* (non-Javadoc)
|
234 |
* @see org.gvsig.fmap.dal.spi.DataServerExplorerProvider#initialize(org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices)
|
235 |
*/
|
236 |
public void initialize( |
237 |
DataServerExplorerProviderServices dataServerExplorerProviderServices) { |
238 |
// TODO Auto-generated method stub
|
239 |
|
240 |
} |
241 |
|
242 |
/**
|
243 |
* @return
|
244 |
*/
|
245 |
public String getTitle() { |
246 |
String title = arcimsClient.getServiceInformation().title;
|
247 |
if (title == null){ |
248 |
return "None"; |
249 |
} |
250 |
return title;
|
251 |
} |
252 |
|
253 |
/**
|
254 |
* @return
|
255 |
*/
|
256 |
public String getAbstract() { |
257 |
String _abstract = arcimsClient.getServiceInformation().abstr;
|
258 |
if (_abstract == null){ |
259 |
return "None"; |
260 |
} |
261 |
return _abstract;
|
262 |
} |
263 |
|
264 |
/**
|
265 |
* @return
|
266 |
*/
|
267 |
public String getServerType() { |
268 |
String serverVersion = arcimsClient.getVersion();
|
269 |
if (serverVersion == null) { |
270 |
return "WFS"; |
271 |
} |
272 |
return "WFS "+ serverVersion; |
273 |
} |
274 |
|
275 |
/**
|
276 |
* @return
|
277 |
*/
|
278 |
public String getUrl() { |
279 |
return arcimsClient.getHost();
|
280 |
} |
281 |
|
282 |
/**
|
283 |
* @return
|
284 |
*/
|
285 |
public int getBuffer() { |
286 |
return arcimsStatus.getBuffer();
|
287 |
} |
288 |
|
289 |
/**
|
290 |
* @return
|
291 |
*/
|
292 |
public int getTimeOut() { |
293 |
return arcimsStatus.getTimeout();
|
294 |
} |
295 |
|
296 |
/**
|
297 |
* @param userName
|
298 |
*/
|
299 |
public void setUserName(String userName) { |
300 |
arcimsStatus.setUserName(userName); |
301 |
} |
302 |
|
303 |
/**
|
304 |
* @param buffer
|
305 |
*/
|
306 |
public void setBuffer(int buffer) { |
307 |
arcimsStatus.setBuffer(buffer); |
308 |
} |
309 |
|
310 |
/**
|
311 |
* @param timeout
|
312 |
*/
|
313 |
public void setTimeOut(int timeout) { |
314 |
arcimsStatus.setTimeout(timeout); |
315 |
} |
316 |
|
317 |
/**
|
318 |
* @return
|
319 |
*/
|
320 |
public String getVersion() { |
321 |
return arcimsClient.getVersion();
|
322 |
} |
323 |
} |