gvsig-raster / org.gvsig.raster.wcs / trunk / org.gvsig.raster.wcs / org.gvsig.raster.wcs.io / src / main / java / org / gvsig / raster / wcs / io / WCSServerExplorer.java @ 859
History | View | Annotate | Download (6.94 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 |
* 2009 IVER T.I {{Task}}
|
26 |
*/
|
27 |
|
28 |
package org.gvsig.raster.wcs.io; |
29 |
|
30 |
import java.awt.geom.Point2D; |
31 |
import java.io.IOException; |
32 |
import java.net.URL; |
33 |
import java.util.Hashtable; |
34 |
import java.util.List; |
35 |
|
36 |
import org.gvsig.compat.net.ICancellable; |
37 |
import org.gvsig.fmap.dal.DALLocator; |
38 |
import org.gvsig.fmap.dal.DataManager; |
39 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
40 |
import org.gvsig.fmap.dal.DataStoreParameters; |
41 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
42 |
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException; |
43 |
import org.gvsig.fmap.dal.exception.DataException; |
44 |
import org.gvsig.fmap.dal.exception.InitializeException; |
45 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
46 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProvider; |
47 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices; |
48 |
|
49 |
/**
|
50 |
* Explorer for a WCS server
|
51 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
52 |
*/
|
53 |
public class WCSServerExplorer implements DataServerExplorerProvider { |
54 |
public static final String NAME = "WCSRemoteServerExplorer"; |
55 |
private WCSConnector connector = null; |
56 |
private WCSServerExplorerParameters parameters = null; |
57 |
|
58 |
public WCSServerExplorer(
|
59 |
WCSServerExplorerParameters parameters, |
60 |
DataServerExplorerProviderServices services) |
61 |
throws InitializeException {
|
62 |
this.parameters = parameters;
|
63 |
} |
64 |
|
65 |
/**
|
66 |
* Gets the provider's name
|
67 |
* @return
|
68 |
*/
|
69 |
public String getDataStoreProviderName() { |
70 |
return WCSProvider.NAME;
|
71 |
} |
72 |
|
73 |
/*
|
74 |
* (non-Javadoc)
|
75 |
* @see org.gvsig.fmap.dal.coverage.store.remote.RemoteServerExplorerProvider#getDescription()
|
76 |
*/
|
77 |
public String getDescription() { |
78 |
return WCSProvider.DESCRIPTION;
|
79 |
} |
80 |
|
81 |
public DataStoreParameters getStoreParameters() {
|
82 |
DataManager manager = DALLocator.getDataManager(); |
83 |
WCSDataParametersImpl params = null;
|
84 |
try {
|
85 |
params = (WCSDataParametersImpl) manager.createStoreParameters(this.getDataStoreProviderName());
|
86 |
|
87 |
/*if(WCSProvider.TILED) {
|
88 |
TileDataParameters tileParams = (TileDataParameters) manager.createStoreParameters("Tile Store");
|
89 |
tileParams.setDataParameters(params);
|
90 |
return tileParams;
|
91 |
} */
|
92 |
|
93 |
} catch (InitializeException e) {
|
94 |
e.printStackTrace(); |
95 |
} catch (ProviderNotRegisteredException e) {
|
96 |
e.printStackTrace(); |
97 |
} |
98 |
params.setURI(parameters.getHost()); |
99 |
return params;
|
100 |
} |
101 |
|
102 |
public boolean add(String provider, NewDataStoreParameters parameters, |
103 |
boolean overwrite) throws DataException { |
104 |
return false; |
105 |
} |
106 |
|
107 |
public boolean canAdd() { |
108 |
return false; |
109 |
} |
110 |
|
111 |
public boolean canAdd(String storeName) throws DataException { |
112 |
return false; |
113 |
} |
114 |
|
115 |
public NewDataStoreParameters getAddParameters(String storeName) |
116 |
throws DataException {
|
117 |
return null; |
118 |
} |
119 |
|
120 |
@SuppressWarnings("unchecked") |
121 |
public List getDataStoreProviderNames() { |
122 |
return null; |
123 |
} |
124 |
|
125 |
|
126 |
/*
|
127 |
* (non-Javadoc)
|
128 |
* @see org.gvsig.fmap.dal.DataServerExplorer#getParameters()
|
129 |
*/
|
130 |
public DataServerExplorerParameters getParameters() {
|
131 |
return parameters;
|
132 |
} |
133 |
|
134 |
@SuppressWarnings("unchecked") |
135 |
public List list() throws DataException { |
136 |
return null; |
137 |
} |
138 |
|
139 |
@SuppressWarnings("unchecked") |
140 |
public List list(int mode) throws DataException { |
141 |
return null; |
142 |
} |
143 |
|
144 |
public void remove(DataStoreParameters parameters) throws DataException { |
145 |
|
146 |
} |
147 |
|
148 |
public void dispose() { |
149 |
|
150 |
} |
151 |
|
152 |
public String getProviderName() { |
153 |
return null; |
154 |
} |
155 |
|
156 |
/**
|
157 |
* Gets the online resources
|
158 |
* @return
|
159 |
*/
|
160 |
@SuppressWarnings("unchecked") |
161 |
public Hashtable getOnlineResources() { |
162 |
/*if(connector != null) {
|
163 |
return connector.getOnlineResources();
|
164 |
}*/
|
165 |
return null; |
166 |
} |
167 |
|
168 |
//**********************************************
|
169 |
//Connector
|
170 |
//**********************************************
|
171 |
|
172 |
/**
|
173 |
* Connects to the server and throws a getCapabilities. This loads
|
174 |
* the basic information to make requests.
|
175 |
* @throws RemoteServiceException
|
176 |
*/
|
177 |
public void connect(ICancellable cancellable) throws RemoteServiceException { |
178 |
URL url = null; |
179 |
boolean override = false; |
180 |
|
181 |
try {
|
182 |
url = new URL(parameters.getHost()); |
183 |
} catch (Exception e) { |
184 |
throw new RemoteServiceException("Malformed URL",e); |
185 |
} |
186 |
try {
|
187 |
connector = WCSProvider.getConnectorFromURL(url); |
188 |
if (!connector.connect(override, cancellable))
|
189 |
throw new RemoteServiceException("Error connecting"); |
190 |
} catch (IOException e) { |
191 |
throw new RemoteServiceException("Error connecting",e); |
192 |
} |
193 |
|
194 |
} |
195 |
|
196 |
/**
|
197 |
* Returns true if this provider is connected to the server
|
198 |
* @return
|
199 |
*/
|
200 |
public boolean isConnected() { |
201 |
if(connector != null) |
202 |
return true; |
203 |
return false; |
204 |
} |
205 |
|
206 |
/**
|
207 |
* Gets the description of this service
|
208 |
* @return
|
209 |
*/
|
210 |
public String getAbstract() { |
211 |
if(connector != null) |
212 |
return connector.getDescription();
|
213 |
return null; |
214 |
} |
215 |
|
216 |
/**
|
217 |
* Gets the server title
|
218 |
* @return
|
219 |
*/
|
220 |
public String getServerType() { |
221 |
if (getVersion() == null) |
222 |
return "WCS"; |
223 |
return "WCS "+ getVersion(); |
224 |
} |
225 |
|
226 |
/**
|
227 |
* Gets the protocol supported by the server
|
228 |
* @return
|
229 |
*/
|
230 |
public String getVersion() { |
231 |
if(connector != null) { |
232 |
return (connector.getVersion() == null) ? "" : connector.getVersion(); |
233 |
} |
234 |
return null; |
235 |
} |
236 |
|
237 |
/**
|
238 |
* Gets the host URI
|
239 |
* @return
|
240 |
*/
|
241 |
public String getHost() { |
242 |
return parameters.getHost();
|
243 |
} |
244 |
|
245 |
/**
|
246 |
* Gets the title
|
247 |
* @return
|
248 |
*/
|
249 |
public String getTitle() { |
250 |
return null; |
251 |
} |
252 |
|
253 |
public DataServerExplorerProviderServices getServerExplorerProviderServices() {
|
254 |
// TODO Auto-generated method stub
|
255 |
return null; |
256 |
} |
257 |
|
258 |
/*
|
259 |
* (non-Javadoc)
|
260 |
* @see org.gvsig.fmap.dal.coverage.explorer.WCSServerExplorer#getMaxResolution(java.lang.String)
|
261 |
*/
|
262 |
public Point2D getMaxResolution(String layerName) { |
263 |
return connector.getMaxResolution(layerName);
|
264 |
} |
265 |
|
266 |
/**
|
267 |
* Gets the coverage list
|
268 |
* @return
|
269 |
*/
|
270 |
public WCSLayerNode[] getCoverageList() { |
271 |
return connector.getLayerList();
|
272 |
} |
273 |
|
274 |
/**
|
275 |
* Gets a layer searching by its name
|
276 |
* @return
|
277 |
*/
|
278 |
public WCSLayerNode getCoverageByName(String name) { |
279 |
WCSLayerNode[] list = getCoverageList();
|
280 |
for (int i = 0; i < list.length; i++) { |
281 |
if(list[i].getName().compareTo(name) == 0) |
282 |
return list[i];
|
283 |
} |
284 |
return null; |
285 |
} |
286 |
} |