Revision 1654

View differences:

org.gvsig.raster.wcs/tags/2.0.0/org.gvsig.raster.wcs.io/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.raster.wcs.io.DefaultWCSIOLibrary
org.gvsig.raster.wcs/tags/2.0.0/org.gvsig.raster.wcs.io/src/main/resources/org/gvsig/raster/wcs/io/i18n/text.properties
1
error_connecting=Error conectando con el servidor
2
malformed_url=URL mal formada
0 3

  
org.gvsig.raster.wcs/tags/2.0.0/org.gvsig.raster.wcs.io/src/main/resources/org/gvsig/raster/wcs/io/i18n/text_en.properties
1
error_connecting=Error connecting with the server
2
malformed_url=Malformed URL
0 3

  
org.gvsig.raster.wcs/tags/2.0.0/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/DefaultWCSIOLibrary.java
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
package org.gvsig.raster.wcs.io;
23

  
24
import org.gvsig.i18n.Messages;
25
import org.gvsig.tools.library.AbstractLibrary;
26
import org.gvsig.tools.library.LibraryException;
27
/**
28
 *
29
 * @author Nacho Brodin (nachobrodin@gmail.com)
30
 */
31
public class DefaultWCSIOLibrary extends AbstractLibrary {	
32

  
33
	public DefaultWCSIOLibrary() {
34
		/*super(DefaultWCSIOLibrary.class,Library.TYPE.IMPL);
35
		require(ToolsLibrary.class);
36
		require(DALLibrary.class);
37
		require(DALFileLibrary.class);*/
38
	}
39
	
40
	@Override
41
	protected void doInitialize() throws LibraryException {
42
		//RasterLibrary.wakeUp();
43
		WCSDataParametersImpl.registerPersistence();
44
		
45
		Messages.addResourceFamily("org.gvsig.raster.wcs.io.i18n.text",
46
				DefaultWCSIOLibrary.class.getClassLoader(),
47
				DefaultWCSIOLibrary.class.getClass().getName()); 
48
	}
49

  
50
	@Override
51
	protected void doPostInitialize() throws LibraryException {
52
		WCSServerExplorerParameters.registerDynClass();
53
		WCSDataParametersImpl.registerDynClass();
54
		WCSProvider.register();
55
	}
56
}
0 57

  
org.gvsig.raster.wcs/tags/2.0.0/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/downloader/TileDownloaderForWCS.java
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
package org.gvsig.raster.wcs.io.downloader;
23

  
24
import java.awt.geom.Rectangle2D;
25

  
26
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException;
27
import org.gvsig.raster.cache.tile.Tile;
28
import org.gvsig.raster.cache.tile.exception.TileGettingException;
29
import org.gvsig.raster.impl.provider.tile.BaseTileDownloader;
30
import org.gvsig.raster.wcs.io.WCSConnector;
31
import org.gvsig.raster.wcs.io.WCSDataParametersImpl;
32
import org.gvsig.raster.wcs.io.WCSProvider;
33
import org.gvsig.remoteclient.wcs.WCSStatus;
34

  
35
/** 
36
 * Tile getter 
37
 * @author Nacho Brodin (nachobrodin@gmail.com)
38
 */
39
public class TileDownloaderForWCS extends BaseTileDownloader {
40
	private WCSConnector             connector  = null;
41
	
42
	public TileDownloaderForWCS(WCSProvider prov, 
43
			int tilePxWidth,
44
			int tilePxHeight,
45
			WCSConnector connector) {
46
		super(prov, tilePxWidth, tilePxHeight);
47
		this.connector = connector;
48
	}
49
	
50
	/*
51
	 * (non-Javadoc)
52
	 * @see org.gvsig.raster.cache.tile.provider.Downloader#getTile(org.gvsig.raster.cache.tile.Tile)
53
	 */
54
	public synchronized Tile downloadTile(Tile tile) throws TileGettingException {
55
		try {
56
			Rectangle2D r = new Rectangle2D.Double(tile.getExtent().getMinX(), 
57
					tile.getExtent().getMinY() - tile.getExtent().getHeight(), 
58
					tile.getExtent().getWidth(), 
59
					tile.getExtent().getHeight());
60
			WCSDataParametersImpl p = (WCSDataParametersImpl)((WCSProvider)prov).getParameters();
61
			WCSStatus wcsStatus = new WCSStatus();
62
			wcsStatus.setCoveraName(p.getCoverageName());
63
			wcsStatus.setSrs((String)p.getSRSCode());
64
			wcsStatus.setFormat((String)p.getFormat());
65
			wcsStatus.setDepth(p.getDepth());
66
			wcsStatus.setOnlineResource(p.getOnlineResource() != null ? (String) p.getOnlineResource().get("GetCoverage") : null);
67
			wcsStatus.setExtent(r);
68
			wcsStatus.setHeight(tile.getHeightPx());
69
			wcsStatus.setWidth(tile.getWidthPx());
70
			
71
			connector.getCoverageURL(wcsStatus, tile.getCancelled(), tile.getFile());
72
			//Si borramos el rmf no se puede leer la etiqueta Alpha. En caso de que se modifique jgdal para
73
			//poder guardar esta etiqueta deberiamos borrar el rmf para ahorrar ficheros
74
			//File rmf = new File(tile.getFile().getAbsolutePath() + ".rmf");
75
			//if(rmf.exists())
76
				//rmf.delete();
77
		} catch (RemoteServiceException e) {
78
			throw new TileGettingException(e);
79
		}
80
		readTileFromDisk(tile);
81
		return tile;
82
	}
83
	
84
}
0 85

  
org.gvsig.raster.wcs/tags/2.0.0/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/downloader/WCSTileServer.java
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
package org.gvsig.raster.wcs.io.downloader;
23

  
24
import org.cresques.cts.IProjection;
25
import org.gvsig.fmap.dal.coverage.RasterLibrary;
26
import org.gvsig.fmap.dal.coverage.datastruct.Extent;
27
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException;
28
import org.gvsig.raster.cache.tile.TileCacheLibrary;
29
import org.gvsig.raster.cache.tile.TileCacheLocator;
30
import org.gvsig.raster.cache.tile.TileCacheManager;
31
import org.gvsig.raster.cache.tile.provider.CacheStruct;
32
import org.gvsig.raster.cache.tile.provider.Downloader;
33
import org.gvsig.raster.cache.tile.provider.TileServer;
34
import org.gvsig.raster.wcs.io.WCSProvider;
35
import org.slf4j.Logger;
36
import org.slf4j.LoggerFactory;
37

  
38
/** 
39
* Data server for the tile cache in a WMSProvider 
40
* @author Nacho Brodin (nachobrodin@gmail.com)
41
*/
42
public class WCSTileServer implements TileServer {
43
	private static Logger              logger               = LoggerFactory.getLogger(WCSTileServer.class);
44
	private CacheStruct                struct               = null;
45
	private Downloader                 downloader           = null;
46
	private WCSProvider                provider             = null;
47
	private String                     suffix               = ".tif";
48
	
49
	public WCSTileServer(WCSProvider prov) {
50
		this.provider = prov;
51
		this.suffix = prov.getFileSuffix();
52
	}
53
	
54
	/*
55
	 * (non-Javadoc)
56
	 * @see org.gvsig.raster.cache.tile.provider.TileServer#getDownloader()
57
	 */
58
	public Downloader getDownloader() {
59
		if(downloader == null ||
60
		   ((TileDownloaderForWCS)downloader).getTileSize()[0] != TileCacheLibrary.ALTERNATIVE_TILESIZE ||
61
		   ((TileDownloaderForWCS)downloader).getTileSize()[1] != TileCacheLibrary.ALTERNATIVE_TILESIZE) {
62
							
63
			try {
64
				downloader = new TileDownloaderForWCS(provider, TileCacheLibrary.ALTERNATIVE_TILESIZE, TileCacheLibrary.ALTERNATIVE_TILESIZE, provider.getConnector());
65
			} catch (RemoteServiceException e) {
66
				return null;
67
			}
68
		}
69
		return downloader;
70
	}
71

  
72
	public CacheStruct getStruct() {
73
		if(struct == null) {
74
			TileCacheManager  manager = TileCacheLocator.getManager();
75
			
76
			int coordinates = CacheStruct.FLAT;
77
			if(provider.getProjection() != null)
78
				coordinates = (provider.getProjection() != null && provider.getProjection().isProjected()) ? CacheStruct.FLAT : CacheStruct.GEOGRAFIC;
79
			else {
80
				Extent e = provider.getExtent();
81
				if(e.getULX() >= -180 && e.getULX() <= 180 && e.getLRX() >= -180 && e.getLRX() <= 180 && 
82
					e.getULY() >= -90 && e.getULY() <= 90 && e.getLRY() >= -90 && e.getLRY() <= 90) {
83
					coordinates = CacheStruct.GEOGRAFIC;
84
				}
85
			}
86
			
87
			String epsg = null;
88
			IProjection proj = provider.getProjection();
89
			if(proj != null)
90
				epsg = proj.getAbrev();
91
			
92
			struct = manager.createCacheStructure(coordinates, 
93
					TileCacheLibrary.DEFAULT_LEVELS, 
94
					provider.getExtent().toRectangle2D(), 
95
					provider.getCellSize(), 
96
					TileCacheLibrary.ALTERNATIVE_TILESIZE, 
97
					TileCacheLibrary.ALTERNATIVE_TILESIZE,
98
					provider.getURIOfFirstProvider(),
99
					provider.getParameters().getCoverageName(),
100
					TileCacheLibrary.DEFAULT_STRUCTURE,
101
					RasterLibrary.pathTileCache,
102
					getFileSuffix(),
103
					epsg,
104
					0);
105
		}
106
		return struct;
107
	}
108
	
109
	/*
110
	 * (non-Javadoc)
111
	 * @see org.gvsig.raster.cache.tile.provider.TileServer#setStruct(org.gvsig.raster.cache.tile.provider.CacheStruct)
112
	 */
113
	public void setStruct(CacheStruct struct) {
114
		if(struct != null) {
115
			this.struct = struct;
116
			if(struct.getTileSizeByLevel(0) != null) {
117
				try {
118
					downloader = new TileDownloaderForWCS(provider, 
119
							struct.getTileSizeByLevel(0)[0], 
120
							struct.getTileSizeByLevel(0)[1],
121
							provider.getConnector());
122
				} catch (RemoteServiceException ex) {
123
					logger.error("Constructing TileDownloaderForWCS: " + ex.getMessage());
124
				}
125
			}
126
		}
127
	}
128
	
129
	/*
130
	 * (non-Javadoc)
131
	 * @see org.gvsig.raster.cache.tile.provider.TileServer#getFileSuffix()
132
	 */
133
	public String getFileSuffix() {
134
		return suffix;
135
	}
136
	
137
	/*
138
	 * (non-Javadoc)
139
	 * @see org.gvsig.raster.cache.tile.provider.TileServer#setFileExtension(java.lang.String)
140
	 */
141
	public void setFileSuffix(String extension) {
142
		this.suffix = extension;
143
	}
144
}
0 145

  
org.gvsig.raster.wcs/tags/2.0.0/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/package.html
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
<html xmlns="http://www.w3.org/1999/xhtml">
4
<head>
5
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
<title>org.gvsig.raster.wcs.io package documentation</title>
7
</head>
8
<body>
9

  
10
	<p>WCS provider</p>
11

  
12
</body>
13
</html>
0 14

  
org.gvsig.raster.wcs/tags/2.0.0/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/WCSLayerNode.java
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
package org.gvsig.raster.wcs.io;
23

  
24
import java.awt.geom.Point2D;
25
import java.awt.geom.Rectangle2D;
26
import java.util.ArrayList;
27
import java.util.Hashtable;
28

  
29
/**
30
 * Class defining the node of the layer tree of a common WCS service.
31
 * @author jaume
32
 */
33
@SuppressWarnings("unchecked")
34
public class WCSLayerNode {
35
	private String       name                  = null;
36
	private ArrayList    srs                   = null;
37
	private String       title                 = null;
38
	private String       nativeSRS             = null;
39
	private ArrayList    formats               = null;
40
	private Point2D      maxRes                = null;
41
	private int          width                 = 0;
42
	private int          height                = 0;
43
	private ArrayList    timePositions         = null;
44
	private String       description           = null;
45
	private ArrayList    interpolationMethods  = null;
46
	private ArrayList    pList                 = null;
47
	private Hashtable    extents               = null;
48
	private String       latLonBox             = null;
49
	private String       lAbstract             = null;
50
	private ArrayList    children              = new ArrayList();
51
	private boolean      transparency;
52

  
53
	public void setName(String name) {
54
		this.name = name;
55
	}
56

  
57
	public void addAllSrs(ArrayList srs) {
58
		if (this.srs == null)
59
			this.srs = new ArrayList();
60
		this.srs.addAll(srs);
61
	}
62

  
63
	public void setTitle(String title) {
64
		this.title = title;
65
	}
66

  
67
	public void setNativeSRS(String nativeSRS) {
68
		this.nativeSRS = nativeSRS;
69
	}
70

  
71
	public String getName() {
72
		return name;
73
	}
74

  
75
	public void setFormats(ArrayList formats) {
76
		this.formats = formats;
77
	}
78

  
79
	public ArrayList getFormats() {
80
		return formats;
81
	}
82

  
83
	public ArrayList getSRSs() {
84
		if (!srs.contains(nativeSRS)) {
85
			ArrayList l = new ArrayList(srs);
86
			l.add(nativeSRS);
87
			return l;
88
		}
89
		return srs;
90
	}
91

  
92
	public String getTitle() {
93
		return title;
94
	}
95

  
96
	public Rectangle2D getExtent(String srs) {
97
		if ( extents != null ) {
98
			return (Rectangle2D) extents.get(srs);
99
		}
100
		return null;
101
	}
102
	
103
	public void addExtent(String srs, Rectangle2D extent) {
104
		if ( extents == null ) extents = new Hashtable();
105
		extents.put(srs, extent);
106
	}
107

  
108
	public Point2D getMaxRes() {
109
		return maxRes;
110
	}
111
	
112

  
113
	public void setMaxRes(Point2D maxRes) {
114
		this.maxRes = maxRes;
115
	}
116
	
117
	public String toString(){
118
    	String str;
119
    	if (getName()==null)
120
    		str = getTitle();
121
    	else
122
    		str = "["+getName()+"] "+getTitle();
123
        return str;
124
    }
125

  
126
	public void setTimePositions(ArrayList timePositions) {
127
		this.timePositions = timePositions;
128
	}
129
    
130
	public ArrayList getTimePositions() {
131
		return this.timePositions;
132
	}
133

  
134
	public String getDescription() {
135
		return this.description;
136
	}
137
	
138
	public void setDescription(String descr) {
139
		this.description = descr;
140
	}
141

  
142
	public String getLonLatEnvelope() {
143
		return "yet unimplemented";
144
	}
145

  
146
	public void setInterpolationMethods(ArrayList interpolationMethods) {
147
		this.interpolationMethods = interpolationMethods;
148
	}
149
	
150
	public ArrayList getInterpolationMethods() {
151
		return interpolationMethods;
152
	}
153

  
154
	public ArrayList getParameterList() {
155
		return pList;
156
	}
157
	
158
	public void addParameter(FMapWCSParameter p) {
159
		if (pList == null) pList = new ArrayList();
160
		pList.add(p);
161
	}
162
	
163
	/**
164
     * Gets the layer abstract.
165
     * @return Returns the abstract.
166
     */
167
    public String getAbstract() {
168
        return lAbstract;
169
    }
170

  
171
    /**
172
     * Sets the layer abstract.
173
     * @param abstract The abstract to set.
174
     */
175
    public void setAbstract(String _abstract) {
176
        lAbstract = _abstract;
177
    }
178
    
179
    public void setLatLonBox(String _latLonBox) {
180
        latLonBox = _latLonBox;
181
    }
182

  
183
    public String getLatLonBox() {
184
        return latLonBox;
185
    }
186
    
187
    /**
188
     * Gets the list of sons of this layer.
189
     */
190
    public ArrayList getChildren() {
191
        return children;
192
    }
193
    
194
    /**
195
     * Sets the list of sons of this layer.
196
     * @param children
197
     */
198
    public void setChildren(ArrayList children) {
199
        this.children = children;
200
    }
201
    
202
    /**
203
     * @return Returns the transparency.
204
     */
205
    public boolean isTransparent() {
206
        return transparency;
207
    }
208

  
209
    /**
210
     * @param transparency The transparency to set.
211
     */
212
    public void setTransparency(boolean transparency) {
213
        this.transparency = transparency;
214
    }
215

  
216
	public int getWidth() {
217
		return width;
218
	}
219

  
220
	public void setWidth(int width) {
221
		this.width = width;
222
	}
223

  
224
	public int getHeight() {
225
		return height;
226
	}
227

  
228
	public void setHeight(int height) {
229
		this.height = height;
230
	}
231

  
232
}
0 233

  
org.gvsig.raster.wcs/tags/2.0.0/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/FMapWCSParameter.java
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
package org.gvsig.raster.wcs.io;
23

  
24
import java.util.ArrayList;
25

  
26
/**
27
 * Class abstracting WCS's axis descriptions into FMap
28
 * @author jaume dominguez faus - jaume.dominguez@iver.es
29
 * @TODO add interval parameters support
30
 */
31
@SuppressWarnings("unchecked")
32
public class FMapWCSParameter {
33
	public static final int VALUE_LIST = 0;
34
	public static final int INTERVAL = 1;
35
	private String name;
36
	private int type;
37
	private ArrayList valueList;
38
	private String label;
39

  
40
	public void setName(String name) {
41
		this.name = name;
42
	}
43

  
44
	public void setType(int type) {
45
		this.type = type;
46
	}
47

  
48
	public int getType() {
49
		return type;
50
	}
51

  
52
	public void setValueList(ArrayList singleValues) {
53
		this.valueList = singleValues;
54
	}
55

  
56
	public void setLabel(String label) {
57
		this.label = label;
58
	}
59

  
60
	public String toString() {
61
		return (label!=null) ? label : name;
62
	}
63

  
64
	public ArrayList getValueList() {
65
		return valueList;
66
	}
67

  
68
	public String getName() {
69
		return name;
70
	}
71
}
0 72

  
org.gvsig.raster.wcs/tags/2.0.0/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/WCSServerExplorer.java
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
import org.gvsig.i18n.Messages;
49

  
50
/**
51
 * Explorer for a WCS server
52
 * @author Nacho Brodin (nachobrodin@gmail.com)
53
 */
54
public class WCSServerExplorer implements DataServerExplorerProvider {
55
	public static final String          NAME                     = "WCSRemoteServerExplorer";
56
	private WCSConnector                connector                = null;
57
	private WCSServerExplorerParameters parameters               = null;
58
	
59
	public WCSServerExplorer(
60
			WCSServerExplorerParameters parameters,
61
			DataServerExplorerProviderServices services)
62
			throws InitializeException {
63
		this.parameters = parameters;
64
	}
65
	
66
	/**
67
	 * Gets the provider's name
68
	 * @return
69
	 */
70
	public String getDataStoreProviderName() {
71
		return WCSProvider.NAME;
72
	}
73
	
74
	/*
75
	 * (non-Javadoc)
76
	 * @see org.gvsig.fmap.dal.coverage.store.remote.RemoteServerExplorerProvider#getDescription()
77
	 */
78
	public String getDescription() {
79
		return WCSProvider.DESCRIPTION;
80
	}
81
	
82
	public DataStoreParameters getStoreParameters() {
83
		DataManager manager = DALLocator.getDataManager();
84
		WCSDataParametersImpl params = null;
85
		try {
86
			params = (WCSDataParametersImpl) manager.createStoreParameters(this.getDataStoreProviderName());
87

  
88
			/*if(WCSProvider.TILED) {
89
				TileDataParameters tileParams = (TileDataParameters) manager.createStoreParameters("Tile Store");
90
				tileParams.setDataParameters(params);
91
				return tileParams;
92
			} */
93
			
94
		} catch (InitializeException e) {
95
			e.printStackTrace();
96
		} catch (ProviderNotRegisteredException e) {
97
			e.printStackTrace();
98
		}
99
		params.setURI(parameters.getHost());
100
		return params;
101
	}
102

  
103
	public boolean add(String provider, NewDataStoreParameters parameters,
104
			boolean overwrite) throws DataException {
105
		return false;
106
	}
107

  
108
	public boolean canAdd() {
109
		return false;
110
	}
111

  
112
	public boolean canAdd(String storeName) throws DataException {
113
		return false;
114
	}
115

  
116
	public NewDataStoreParameters getAddParameters(String storeName)
117
			throws DataException {
118
		return null;
119
	}
120

  
121
	@SuppressWarnings("unchecked")
122
	public List getDataStoreProviderNames() {
123
		return null;
124
	}
125

  
126

  
127
	/*
128
	 * (non-Javadoc)
129
	 * @see org.gvsig.fmap.dal.DataServerExplorer#getParameters()
130
	 */
131
	public DataServerExplorerParameters getParameters() {
132
		return parameters;
133
	}
134

  
135
	@SuppressWarnings("unchecked")
136
	public List list() throws DataException {
137
		return null;
138
	}
139

  
140
	@SuppressWarnings("unchecked")
141
	public List list(int mode) throws DataException {
142
		return null;
143
	}
144

  
145
	public void remove(DataStoreParameters parameters) throws DataException {
146
		
147
	}
148

  
149
	public void dispose() {
150
		
151
	}
152

  
153
	public String getProviderName() {
154
		return null;
155
	}
156
	
157
	/**
158
	 * Gets the online resources
159
	 * @return
160
	 */
161
	@SuppressWarnings("unchecked")
162
	public Hashtable getOnlineResources() {
163
		/*if(connector != null) {
164
			return connector.getOnlineResources();
165
		}*/
166
		return null;
167
	}
168
	
169
	//**********************************************
170
	//Connector
171
	//**********************************************
172

  
173
	/**
174
	 * Connects to the server and throws a getCapabilities. This loads 
175
	 * the basic information to make requests.
176
	 * @throws RemoteServiceException 
177
	 */
178
	public void connect(ICancellable cancellable) throws RemoteServiceException {
179
		URL url = null;
180
		boolean override = false;
181
		
182
		try {
183
			url = new URL(parameters.getHost());
184
		} catch (Exception e) {
185
			throw new RemoteServiceException(Messages.getText("malformed_url"), e);
186
		}
187
        try {
188
        	connector = WCSProvider.getConnectorFromURL(url);
189
        	if (!connector.connect(override, cancellable))
190
        		throw new RemoteServiceException(Messages.getText("error_connecting"));
191
        } catch (IOException e) {
192
			throw new RemoteServiceException(Messages.getText("error_connecting"), e);
193
		}
194
		
195
	}
196

  
197
	/**
198
	 * Returns true if this provider is connected to the server
199
	 * @return
200
	 */
201
	public boolean isConnected() {
202
		if(connector != null)
203
			return true;
204
		return false;
205
	}
206

  
207
	/**
208
	 * Gets the description of this service
209
	 * @return
210
	 */
211
	public String getAbstract() {
212
		if(connector != null)
213
			return connector.getDescription();
214
		return null;
215
	}
216

  
217
	/**
218
	 * Gets the server title
219
	 * @return
220
	 */
221
	public String getServerType() {
222
		if (getVersion() == null) 
223
			return "WCS";
224
        return "WCS "+ getVersion();
225
	}
226

  
227
	/**
228
	 * Gets the protocol supported by the server
229
	 * @return
230
	 */
231
	public String getVersion() {
232
		if(connector != null) {
233
			return (connector.getVersion() == null) ? "" : connector.getVersion();
234
		}
235
		return null;
236
	}
237

  
238
	/**
239
	 * Gets the host URI
240
	 * @return
241
	 */
242
	public String getHost() {
243
		return parameters.getHost();
244
	}
245
	
246
	/**
247
	 * Gets the title
248
	 * @return
249
	 */
250
	public String getTitle() {
251
		return null;
252
	}
253

  
254
	public DataServerExplorerProviderServices getServerExplorerProviderServices() {
255
		// TODO Auto-generated method stub
256
		return null;
257
	}
258

  
259
	/*
260
	 * (non-Javadoc)
261
	 * @see org.gvsig.fmap.dal.coverage.explorer.WCSServerExplorer#getMaxResolution(java.lang.String)
262
	 */
263
	public Point2D getMaxResolution(String layerName) {
264
		return connector.getMaxResolution(layerName);
265
	}
266

  
267
	/**
268
	 * Gets the coverage list
269
	 * @return
270
	 */
271
	public WCSLayerNode[] getCoverageList() {
272
		return connector.getLayerList();
273
	}
274
	
275
	/**
276
	 * Gets a layer searching by its name 
277
	 * @return
278
	 */
279
	public WCSLayerNode getCoverageByName(String name) {
280
		WCSLayerNode[] list = getCoverageList();
281
		for (int i = 0; i < list.length; i++) {
282
			if(list[i].getName().compareTo(name) == 0)
283
				return list[i];
284
		}
285
		return null;
286
	}
287
}
0 288

  
org.gvsig.raster.wcs/tags/2.0.0/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/WCSConnector.java
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
package org.gvsig.raster.wcs.io;
23

  
24
import java.awt.geom.Point2D;
25
import java.awt.geom.Rectangle2D;
26
import java.io.BufferedOutputStream;
27
import java.io.DataInputStream;
28
import java.io.DataOutputStream;
29
import java.io.File;
30
import java.io.FileOutputStream;
31
import java.io.IOException;
32
import java.io.OutputStreamWriter;
33
import java.net.ConnectException;
34
import java.net.HttpURLConnection;
35
import java.net.URL;
36
import java.security.KeyManagementException;
37
import java.security.NoSuchAlgorithmException;
38
import java.util.ArrayList;
39
import java.util.Hashtable;
40
import java.util.Iterator;
41
import java.util.Set;
42
import java.util.prefs.Preferences;
43

  
44
import javax.net.ssl.HttpsURLConnection;
45
import javax.net.ssl.SSLContext;
46
import javax.net.ssl.TrustManager;
47
import javax.net.ssl.X509TrustManager;
48

  
49
import org.gvsig.compat.net.ICancellable;
50
import org.gvsig.fmap.dal.coverage.exception.RemoteServiceException;
51
import org.gvsig.remoteclient.exceptions.ServerErrorException;
52
import org.gvsig.remoteclient.exceptions.WCSException;
53
import org.gvsig.remoteclient.utils.BoundaryBox;
54
import org.gvsig.remoteclient.wcs.WCSClient;
55
import org.gvsig.remoteclient.wcs.WCSCoverage;
56
import org.gvsig.remoteclient.wcs.WCSStatus;
57
import org.gvsig.remoteclient.wcs.WCSCoverage.AxisDescription;
58
import org.gvsig.remoteclient.wcs.WCSCoverage.RectifiedGrid;
59

  
60
/**
61
 * Connector between a WCS data provider and a WCSClient. 
62
 *
63
 * @author Nacho Brodin (nachobrodin@gmail.com)
64
 */
65
@SuppressWarnings("unchecked")
66
public class WCSConnector  {
67
	private WCSClient                     client;
68
	private Hashtable                     coverages;
69
    private WCSLayerNode[]                layerList;
70
    
71
    public WCSConnector(URL url) throws ConnectException, IOException {
72
    	client = new WCSClient(url.toString());
73
    }
74

  
75
	/**
76
	 * Returns the string "WCSDriver", which is the driver's name.
77
	 *
78
	 * Devuelve "WCSDriver", el nombre del driver.
79
	 * @return String
80
	 */
81
	public String getName() { 
82
		return "WCSDriver"; 
83
	}
84

  
85
	/**
86
	 * Sets the server that we want to connect to.
87
	 *
88
	 * Establece el servidor al que se quiere conectar.
89
	 *
90
	 * @param host
91
	 * @throws IOException
92
	 */
93
	public void setHost(String host) throws IOException{
94
		client = new WCSClient(host);
95
	}
96

  
97

  
98
	/**
99
	 * Returns a human-readable string containing the server's name.
100
	 *
101
	 * Devuelve el nombre legible del servidor devuelto por ?ste.
102
	 *
103
	 * @return String
104
	 */
105
	public String getLabel() {
106
		return client.getServiceTitle();
107
	}
108

  
109
	/**
110
	 * Returns a string containing the server's WCS version number.
111
	 *
112
	 * Devuelve el n?mero de versi?n WCS del servidor
113
	 *
114
	 * @return String
115
	 */
116
	public String getVersion(){
117
		return client.getVersion();
118
	}
119

  
120
	/**
121
	 * <p>
122
	 * Returns name and description of the server. It is supposed to be used
123
	 * as the source of the abstract field in your application's interface.
124
	 * </p>
125
	 * <p>
126
	 * Devuelve nombre y descripci?n (abstract) del servidor.
127
	 * </p>
128
	 * @return String
129
	 */
130
	public String getDescription(){
131
		return client.getDescription();
132
	}
133

  
134
	/**
135
	 * Returns the layer descriptor for a given coverage name.
136
	 * @param layerName
137
	 * @return WCSLayer
138
	 */
139
	public WCSLayerNode getLayer(String layerName) {
140
		getLayerList();
141
		return (WCSLayerNode) coverages.get(layerName);
142
	}
143

  
144
	/**
145
	 * Returns an array of WCSLayer's with the descriptors of all coverages
146
	 * @return WCSLayer[]
147
	 */
148
	public WCSLayerNode[] getLayerList() {
149
		if (coverages == null || coverages.isEmpty()) {
150
			// the WCSLayer collection will be built
151
			coverages = new Hashtable();
152
			Hashtable wcsCoverages  = client.getCoverageList();
153
			int sz = wcsCoverages.size();
154

  
155
			// Create an array with the WCSCoverages
156
			WCSCoverage[] coverageList = new WCSCoverage[sz];
157
			Iterator it = wcsCoverages.keySet().iterator();
158
			int i = 0;
159
			while (it.hasNext()) {
160
				coverageList[i] = (WCSCoverage) wcsCoverages.get(it.next());
161
				i++;
162
			}
163

  
164
			// Create a WCSLayer array from the previous WCSCoverage array
165
			layerList = new WCSLayerNode[sz];
166
			for (int j = 0; j < layerList.length; j++) {
167
				WCSLayerNode lyr = new WCSLayerNode();
168
				WCSCoverage cov = coverageList[j];
169
				// name
170
				lyr.setName(cov.getName());
171

  
172
				// title
173
				lyr.setTitle(cov.getTitle());
174

  
175
				// description
176
				lyr.setDescription(cov.getAbstract());
177

  
178
				// srs
179
				lyr.addAllSrs(cov.getAllSrs());
180

  
181
				// native srs
182
				lyr.setNativeSRS(cov.getNativeSRS());
183

  
184
				// extents
185
				Set k = cov.getBBoxes().keySet();
186
				if (!k.isEmpty()) {
187
					it = k.iterator();
188
					while (it.hasNext()) {
189
						String srs = (String) it.next();
190
						BoundaryBox bBox = cov.getBbox(srs);
191
						Rectangle2D r = new Rectangle2D.Double(
192
								bBox.getXmin(),
193
								bBox.getYmin(),
194
								bBox.getXmax() - bBox.getXmin(),
195
								bBox.getYmax() - bBox.getYmin()
196
						);
197
						lyr.addExtent(srs, r);
198
					}
199
				}
200

  
201
				// formats
202
				lyr.setFormats(cov.getFormats());
203

  
204
				// time positions
205
				lyr.setTimePositions(cov.getTimePositions());
206
				
207
				RectifiedGrid rf = cov.getRectifiedGrid();
208
				int w = rf.getHighGridEnvelopLimits()[0][0] - rf.getLowGridEnvelopLimits()[0][0];
209
				int h = rf.getHighGridEnvelopLimits()[0][1] - rf.getLowGridEnvelopLimits()[0][1]; 
210
				
211
				lyr.setWidth(w);
212
				lyr.setHeight(h);
213
				
214
				// max res
215
				lyr.setMaxRes(new Point2D.Double(cov.getResX(), cov.getResY()));
216

  
217
				// interpolations
218
				lyr.setInterpolationMethods(cov.getInterpolationMethods());
219

  
220
				// parameters
221
				k = cov.axisPool.keySet();
222
				if (!k.isEmpty()) {
223
					it = k.iterator();
224
					while (it.hasNext()) {
225
						AxisDescription ad = (AxisDescription) cov.axisPool.get(it.next());
226
						FMapWCSParameter p = new FMapWCSParameter();
227
						p.setName(ad.getName());
228
						p.setLabel(ad.getLabel());
229
						p.setType(ad.getInterval() == null ? FMapWCSParameter.VALUE_LIST : FMapWCSParameter.INTERVAL);
230
						if (p.getType() == FMapWCSParameter.VALUE_LIST) {
231
							p.setValueList(ad.getSingleValues());
232
						} /*else {
233
							p.setInterval(ad.getInterval());
234
						}*/
235
						lyr.addParameter(p);
236
					}
237
				}
238
				layerList[j] = lyr;
239
				coverages.put(lyr.getName(), lyr);
240
			}
241
		}
242
		return layerList;
243
	}
244

  
245
	/**
246
	 * Establishes the connection to the WCS server. Connecting to a WCS is
247
	 * an abstraction.<br>
248
	 * <p>
249
	 * Actually, it sends a GetCapabilities and a general DescribeCoverage
250
	 * request (not a coverage-specific DescribeCoverage request) to read the
251
	 * necessary data for building further GetCoverage requests.
252
	 * </p>
253
	 * @param override
254
	 * @throws IOException.
255
	 */
256
	public boolean connect(boolean override, ICancellable cancel)
257
			throws IOException {
258
		coverages = null;
259
		setHost(client.getHost());
260
		return client.connect(override, cancel);
261
	}
262

  
263
	/**
264
	 * No close operation is needed since WCS service it is a non-session based
265
	 * protocol. So, this does nothing and you can omit it.<br>
266
	 */
267
	public void close() {
268
//		connected = false;
269
	}
270

  
271
	/**
272
	 * Returns the label of an specific coverage given by the coverage name
273
	 * @param coverage name (string)
274
	 * @return string
275
	 */
276
	public String getLabel(String coverageName) {
277
		return client.getLabel(coverageName);
278
	}
279

  
280
	/**
281
	 * Returns the coverage's MAX extent from the server.
282
	 * @return Rectangle2D
283
	 * @throws IOException
284
	 */
285
	public Rectangle2D getFullExtent(String coverageName, String srs)
286
			throws IOException {
287
		return client.getExtent(coverageName, srs);
288
	}
289

  
290
	/**
291
	 * Returns the max resolution of a specific coverage given by the coverage's name.
292
	 * @param coverage name (string)
293
	 * @return double
294
	 */
295
	public Point2D getMaxResolution(String coverageName) {
296
		if (coverages.containsKey(coverageName)) {
297
			return ((WCSLayerNode) coverages.get(coverageName)).getMaxRes();
298
		}
299
		return null;
300
	}
301
	
302
	/**
303
	 * Gets the maximum width in pixels of this coverage
304
	 * @param coverageName
305
	 * @return
306
	 */
307
	public int getWidth(String coverageName) {
308
		if (coverages.containsKey(coverageName)) {
309
			return ((WCSLayerNode) coverages.get(coverageName)).getWidth();
310
		}
311
		return 0;
312
	}
313

  
314
	/**
315
	 * Gets the maximum height in pixels of this coverage
316
	 * @param coverageName
317
	 * @return
318
	 */
319
	public int getHeight(String coverageName) {
320
		if (coverages.containsKey(coverageName)) {
321
			return ((WCSLayerNode) coverages.get(coverageName)).getHeight();
322
		}
323
		return 0;
324
	}
325

  
326
	/**
327
	 * Returns an ArrayList containing a set of Strings with the coverage's SRSs.
328
	 * @param coverage name (string)
329
	 * @return ArrayList
330
	 */
331
	public ArrayList getSRSs(String coverageName) {
332
		if (coverages.containsKey(coverageName)) {
333
			return ((WCSLayerNode) coverages.get(coverageName)).getSRSs();
334
		}
335
		return null;
336
	}
337

  
338
	/**
339
	 * Returns a String containing a description of an specific coverage.
340
	 * @param coverage name (string)
341
	 * @return string
342
	 */
343
	public String getCoverageDescription(String coverageName) {
344
		if (coverages.containsKey(coverageName)) {
345
			return ((WCSLayerNode) coverages.get(coverageName)).getDescription();
346
		}
347
		return null;
348
	}
349

  
350
	/**
351
	 * Returns an ArrayList containing strings for the time positions of an
352
	 * specific coverage given by the coverage's name.
353
	 * @param coverage name (string)
354
	 * @return ArrayList
355
	 */
356
	public ArrayList getTimes(String coverageName) {
357
		if (coverages.containsKey(coverageName)) {
358
			return ((WCSLayerNode) coverages.get(coverageName)).getTimePositions();
359
		}
360
		return null;
361
	}
362

  
363
	/**
364
	 * Sends a GetCoverage request to the client.
365
	 * @param status
366
	 * @return
367
	 * @throws WCSException
368
	 */
369
	public File getCoverage(WCSStatus status, ICancellable cancel) throws RemoteServiceException {
370
		try {
371
			return client.getCoverage(status, cancel);
372
		} catch (ServerErrorException e) {
373
			throw new RemoteServiceException(getName(), e);
374
		} catch (org.gvsig.remoteclient.exceptions.WCSException e) {
375
			throw new RemoteServiceException(e.getMessage(), e);
376
		}
377
	}
378
	
379
	/**
380
	 * Sends a GetCoverage request to the client.
381
	 * @param status
382
	 * @return
383
	 * @throws WCSException
384
	 */
385
	public void getCoverageURL(WCSStatus status, ICancellable cancel, File file) throws RemoteServiceException {
386
		try {
387
			URL url = client.getCoverageURL(status, cancel);
388
			downloadFile(url, file, cancel);
389
			String exceptionMessage = client.getExceptionMessage(file);
390
			if(exceptionMessage != null)
391
				throw new RemoteServiceException(exceptionMessage);
392
		} catch(IOException e) {
393
			throw new RemoteServiceException("WMS: error downloading the file. File:" + file.getAbsolutePath() + "...." + e.getMessage());
394
		} catch (ServerErrorException e) {
395
			throw new RemoteServiceException("WMS Unexpected server error."+e.getMessage());
396
		}  catch (org.gvsig.remoteclient.exceptions.WMSException e) {
397
			throw new RemoteServiceException(e.getMessage());
398
		}
399
	}
400
	
401
	public void downloadFile(URL url, File dstFile, ICancellable cancel) throws IOException {
402
		Preferences prefs = Preferences.userRoot().node( "gvsig.downloader" );
403
		// by default 1 minute (60000 milliseconds.
404
		int timeout = prefs.getInt("timeout", 60000);
405

  
406
		DataOutputStream dos;
407
		DataInputStream is;
408
		OutputStreamWriter os = null;
409
		HttpURLConnection connection = null;
410
		//If the used protocol is HTTPS
411
		if (url.getProtocol().equals("https")) {
412
			try {
413
				disableHttsValidation();
414
			} catch (KeyManagementException e) {
415
				e.printStackTrace();
416
			} catch (NoSuchAlgorithmException e) {
417
				e.printStackTrace();
418
			}
419
		}
420
		connection = (HttpURLConnection)url.openConnection();
421
		connection.setConnectTimeout(timeout);
422
		is = new DataInputStream(url.openStream());
423

  
424
		dos = new DataOutputStream( new BufferedOutputStream(new FileOutputStream(dstFile)));
425
		byte[] buffer = new byte[1024 * 4];
426

  
427

  
428
		long readed = 0;
429
		for (int i = is.read(buffer); i > 0; i = is.read(buffer)){
430
			dos.write(buffer, 0, i);
431
			readed += i;
432
			if(cancel != null && cancel.isCanceled())
433
				return;
434
		}
435
		if(os != null) {
436
			os.close();
437
		}
438
		dos.close();
439
		is.close();
440
		is = null;
441
		dos = null;
442
	}
443

  
444
	/**
445
	 * This method disables the Https certificate validation.
446
	 * @throws KeyManagementException
447
	 * @throws NoSuchAlgorithmException
448
	 */
449
	private void disableHttsValidation() throws KeyManagementException, NoSuchAlgorithmException{
450
		// Create a trust manager that does not validate certificate chains
451
		TrustManager[] trustAllCerts = new TrustManager[] {
452
				new X509TrustManager() {
453
					public java.security.cert.X509Certificate[] getAcceptedIssuers() {
454
						return null;
455
					}
456
					public void checkClientTrusted(
457
							java.security.cert.X509Certificate[] certs, String authType) {
458
					}
459
					public void checkServerTrusted(
460
							java.security.cert.X509Certificate[] certs, String authType) {
461
					}
462
				}
463
		};
464

  
465
		// Install the all-trusting trust manager
466
		SSLContext sc = SSLContext.getInstance("SSL");
467
		sc.init(null, trustAllCerts, new java.security.SecureRandom());
468
		HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
469
	}
470
   
471
}
0 472

  
org.gvsig.raster.wcs/tags/2.0.0/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/WCSProvider.java
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
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff