Revision 33738
branches/v2_0_0_prep/libraries/libRemoteServices/pom.xml | ||
---|---|---|
30 | 30 |
</dependency> |
31 | 31 |
<dependency> |
32 | 32 |
<groupId>org.gvsig</groupId> |
33 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
34 |
</dependency> |
|
35 |
<dependency> |
|
36 |
<groupId>org.gvsig</groupId> |
|
37 |
<artifactId>org.gvsig.compat</artifactId> |
|
38 |
<version>2.0-SNAPSHOT</version> |
|
39 |
</dependency> |
|
40 |
<dependency> |
|
41 |
<groupId>org.gvsig</groupId> |
|
33 | 42 |
<artifactId>org.gvsig.fmap.geometry</artifactId> |
34 | 43 |
<version>2.0-SNAPSHOT</version> |
35 | 44 |
</dependency> |
... | ... | |
37 | 46 |
<properties> |
38 | 47 |
<build-dir>${basedir}/../build</build-dir> |
39 | 48 |
</properties> |
49 |
<profiles> |
|
50 |
<profile> |
|
51 |
<id>se</id> |
|
52 |
<dependencies> |
|
53 |
<dependency> |
|
54 |
<groupId>org.gvsig</groupId> |
|
55 |
<artifactId>org.gvsig.compat</artifactId> |
|
56 |
<classifier>se</classifier> |
|
57 |
</dependency> |
|
58 |
</dependencies> |
|
59 |
</profile> |
|
60 |
<profile> |
|
61 |
<id>cdc</id> |
|
62 |
<dependencies> |
|
63 |
<dependency> |
|
64 |
<groupId>org.gvsig.mobile</groupId> |
|
65 |
<artifactId>org.gvsig.mobile.compat</artifactId> |
|
66 |
<version>2.0-SNAPSHOT</version> |
|
67 |
</dependency> |
|
68 |
</dependencies> |
|
69 |
<build> |
|
70 |
<plugins> |
|
71 |
<plugin> |
|
72 |
<groupId>org.apache.maven.plugins</groupId> |
|
73 |
<artifactId>maven-compiler-plugin</artifactId> |
|
74 |
<configuration> |
|
75 |
<source>1.4</source> |
|
76 |
<target>1.4</target> |
|
77 |
</configuration> |
|
78 |
</plugin> |
|
79 |
</plugins> |
|
80 |
</build> |
|
81 |
</profile> |
|
82 |
</profiles> |
|
40 | 83 |
<build> |
41 | 84 |
<sourceDirectory>src</sourceDirectory> |
42 | 85 |
<testSourceDirectory>test</testSourceDirectory> |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wcs/WCSCoverage.java | ||
---|---|---|
47 | 47 |
import java.util.ArrayList; |
48 | 48 |
import java.util.Hashtable; |
49 | 49 |
|
50 |
import org.kxml2.io.KXmlParser; |
|
51 |
import org.xmlpull.v1.XmlPullParserException; |
|
52 |
|
|
50 | 53 |
import org.gvsig.remoteclient.ILayer; |
51 | 54 |
import org.gvsig.remoteclient.utils.BoundaryBox; |
52 | 55 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
53 |
import org.kxml2.io.KXmlParser; |
|
54 |
import org.xmlpull.v1.XmlPullParserException; |
|
55 | 56 |
|
56 | 57 |
/** |
57 | 58 |
* Describes a coverage in a WCS server. |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wcs/wcs_1_0_0/WCSCoverage1_0_0.java | ||
---|---|---|
46 | 46 |
|
47 | 47 |
import java.io.IOException; |
48 | 48 |
|
49 |
import org.gvsig.compat.CompatLocator; |
|
50 |
import org.gvsig.compat.lang.StringUtils; |
|
49 | 51 |
import org.gvsig.remoteclient.utils.BoundaryBox; |
50 | 52 |
import org.gvsig.remoteclient.utils.DescribeCoverageTags; |
51 | 53 |
import org.gvsig.remoteclient.wcs.WCSCoverage; |
... | ... | |
59 | 61 |
public class WCSCoverage1_0_0 extends WCSCoverage{ |
60 | 62 |
String axisDescriptionName; |
61 | 63 |
|
64 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
65 |
|
|
62 | 66 |
/* (non-Javadoc) |
63 | 67 |
* @see org.gvsig.remoteClient.wcs.WCSLayer#parse(org.kxml2.io.KXmlParser) |
64 | 68 |
*/ |
... | ... | |
98 | 102 |
parser.nextTag(); |
99 | 103 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.FORMATS); |
100 | 104 |
while (parser.getName().compareTo(DescribeCoverageTags.FORMATS) == 0) { |
101 |
String[] formats = parser.nextText().split(SEPARATOR);
|
|
105 |
String[] formats = stringUtils.split(parser.nextText(), SEPARATOR);
|
|
102 | 106 |
for (int i = 0; i < formats.length; i++) { |
103 | 107 |
addFormat(formats[i]); |
104 | 108 |
} |
... | ... | |
157 | 161 |
{ |
158 | 162 |
case KXmlParser.START_TAG: |
159 | 163 |
if (parser.getName().compareTo(DescribeCoverageTags.REQUEST_RESPONSE_CRSS)==0) { |
160 |
String[] values = parser.nextText().split(SEPARATOR);
|
|
164 |
String[] values = stringUtils.split(parser.nextText(), SEPARATOR);
|
|
161 | 165 |
for (int i = 0; i < values.length; i++) { |
162 | 166 |
addSRSs(values[i]); |
163 | 167 |
} |
... | ... | |
470 | 474 |
|
471 | 475 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_LOW) == 0) { |
472 | 476 |
value = parser.nextText(); |
473 |
String[] ss = value.split(SEPARATOR);
|
|
477 |
String[] ss = stringUtils.split(value, SEPARATOR);
|
|
474 | 478 |
int[] limits = new int[ss.length]; |
475 | 479 |
for (int i = 0; i < limits.length; i++) { |
476 | 480 |
limits[i] = Integer.parseInt(ss[i]); |
... | ... | |
478 | 482 |
rg.addLowGridEnvelopLimit(limits); |
479 | 483 |
} else if (parser.getName().compareTo(DescribeCoverageTags.GML_HIGH) == 0) { |
480 | 484 |
value = parser.nextText(); |
481 |
String[] ss = value.split(SEPARATOR);
|
|
485 |
String[] ss = stringUtils.split(value, SEPARATOR);
|
|
482 | 486 |
int[] limits = new int[ss.length]; |
483 | 487 |
for (int i = 0; i < limits.length; i++) { |
484 | 488 |
limits[i] = Integer.parseInt(ss[i]); |
... | ... | |
549 | 553 |
|
550 | 554 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_LOW) == 0) { |
551 | 555 |
value = parser.nextText(); |
552 |
String[] ss = value.split(SEPARATOR);
|
|
556 |
String[] ss = stringUtils.split(value, SEPARATOR);
|
|
553 | 557 |
int[] limits = new int[ss.length]; |
554 | 558 |
for (int i = 0; i < limits.length; i++) { |
555 | 559 |
limits[i] = Integer.parseInt(ss[i]); |
... | ... | |
557 | 561 |
rg.addLowGridEnvelopLimit(limits); |
558 | 562 |
} else if (parser.getName().compareTo(DescribeCoverageTags.GML_HIGH) == 0) { |
559 | 563 |
value = parser.nextText(); |
560 |
String[] ss = value.split(SEPARATOR);
|
|
564 |
String[] ss = stringUtils.split(value, SEPARATOR);
|
|
561 | 565 |
int[] limits = new int[ss.length]; |
562 | 566 |
for (int i = 0; i < limits.length; i++) { |
563 | 567 |
limits[i] = Integer.parseInt(ss[i]); |
... | ... | |
585 | 589 |
parser.nextTag(); |
586 | 590 |
if (parser.getName().compareTo(DescribeCoverageTags.GML_POS)==0) { |
587 | 591 |
value = parser.nextText(); |
588 |
String[] ss = value.split(SEPARATOR);
|
|
592 |
String[] ss = stringUtils.split(value, SEPARATOR);
|
|
589 | 593 |
double[] ori = new double[ss.length]; |
590 | 594 |
for (int i = 0; i < ori.length; i++) { |
591 | 595 |
ori[i] = Double.parseDouble(ss[i]); |
... | ... | |
594 | 598 |
} |
595 | 599 |
} else if (parser.getName().compareTo(DescribeCoverageTags.OFFSETVECTOR) == 0) { |
596 | 600 |
value = parser.nextText(); |
597 |
String[] ss = value.split(SEPARATOR);
|
|
601 |
String[] ss = stringUtils.split(value, SEPARATOR);
|
|
598 | 602 |
double[] offset = new double[ss.length]; |
599 | 603 |
for (int i = 0; i < offset.length; i++) { |
600 | 604 |
offset[i] = Double.parseDouble(ss[i]); |
... | ... | |
637 | 641 |
String[] coordinates; |
638 | 642 |
double minx, miny, maxx, maxy; |
639 | 643 |
value = parser.nextText(); |
640 |
coordinates = value.split(SEPARATOR);
|
|
644 |
coordinates = stringUtils.split(value, SEPARATOR);
|
|
641 | 645 |
minx = Double.parseDouble(coordinates[0]); |
642 | 646 |
miny = Double.parseDouble(coordinates[1]); |
643 | 647 |
|
... | ... | |
645 | 649 |
|
646 | 650 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.GML_POS); |
647 | 651 |
value = parser.nextText(); |
648 |
coordinates = value.split(SEPARATOR);
|
|
652 |
coordinates = stringUtils.split(value, SEPARATOR);
|
|
649 | 653 |
maxx = Double.parseDouble(coordinates[0]); |
650 | 654 |
maxy = Double.parseDouble(coordinates[1]); |
651 | 655 |
|
... | ... | |
689 | 693 |
String[] coordinates; |
690 | 694 |
double minx, miny, maxx, maxy; |
691 | 695 |
value = parser.nextText(); |
692 |
coordinates = value.split(SEPARATOR);
|
|
696 |
coordinates = stringUtils.split(value, SEPARATOR);
|
|
693 | 697 |
minx = Double.parseDouble(coordinates[0]); |
694 | 698 |
miny = Double.parseDouble(coordinates[1]); |
695 | 699 |
|
... | ... | |
697 | 701 |
//parser.nextTag(); |
698 | 702 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.GML_POS); |
699 | 703 |
value = parser.nextText(); |
700 |
coordinates = value.split(SEPARATOR);
|
|
704 |
coordinates = stringUtils.split(value, SEPARATOR);
|
|
701 | 705 |
maxx = Double.parseDouble(coordinates[0]); |
702 | 706 |
maxy = Double.parseDouble(coordinates[1]); |
703 | 707 |
|
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wcs/wcs_1_0_0/request/WCSGetCoverageRequest1_0_0.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
package org.gvsig.remoteclient.wcs.wcs_1_0_0.request; |
29 | 29 |
|
30 |
import org.gvsig.compat.CompatLocator; |
|
31 |
import org.gvsig.compat.lang.StringUtils; |
|
30 | 32 |
import org.gvsig.remoteclient.wcs.WCSProtocolHandler; |
31 | 33 |
import org.gvsig.remoteclient.wcs.WCSStatus; |
32 | 34 |
import org.gvsig.remoteclient.wcs.request.WCSGetCoverageRequest; |
... | ... | |
35 | 37 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
36 | 38 |
*/ |
37 | 39 |
public class WCSGetCoverageRequest1_0_0 extends WCSGetCoverageRequest{ |
38 |
|
|
40 |
|
|
41 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
42 |
|
|
39 | 43 |
public WCSGetCoverageRequest1_0_0(WCSStatus status, |
40 | 44 |
WCSProtocolHandler protocolHandler) { |
41 | 45 |
super(status, protocolHandler); |
... | ... | |
55 | 59 |
} else { |
56 | 60 |
req.append("&EXCEPTIONS=XML"); |
57 | 61 |
} |
58 |
return req.toString().replaceAll(" ", "%20");
|
|
62 |
return stringUtils.replaceAll(req.toString(), " ", "%20");
|
|
59 | 63 |
} |
60 | 64 |
|
61 | 65 |
} |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wcs/wcs_1_0_0/WCSProtocolHandler1_0_0.java | ||
---|---|---|
43 | 43 |
import java.io.File; |
44 | 44 |
import java.io.IOException; |
45 | 45 |
|
46 |
import org.gvsig.remoteclient.ogc.OGCServiceInformation; |
|
46 |
import org.kxml2.io.KXmlParser; |
|
47 |
import org.xmlpull.v1.XmlPullParserException; |
|
48 |
|
|
47 | 49 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
48 | 50 |
import org.gvsig.remoteclient.utils.DescribeCoverageTags; |
49 | 51 |
import org.gvsig.remoteclient.utils.EncodingXMLParser; |
... | ... | |
54 | 56 |
import org.gvsig.remoteclient.wcs.request.WCSGetCoverageRequest; |
55 | 57 |
import org.gvsig.remoteclient.wcs.wcs_1_0_0.request.WCSDescribeCoverageRequest1_0_0; |
56 | 58 |
import org.gvsig.remoteclient.wcs.wcs_1_0_0.request.WCSGetCoverageRequest1_0_0; |
57 |
import org.kxml2.io.KXmlParser; |
|
58 |
import org.xmlpull.v1.XmlPullParserException; |
|
59 | 59 |
|
60 | 60 |
/** |
61 | 61 |
* @author jaume |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wcs/WCSClient.java | ||
---|---|---|
48 | 48 |
import java.util.Hashtable; |
49 | 49 |
import java.util.Iterator; |
50 | 50 |
|
51 |
import org.gvsig.compat.net.ICancellable; |
|
51 | 52 |
import org.gvsig.remoteclient.exceptions.ServerErrorException; |
52 | 53 |
import org.gvsig.remoteclient.exceptions.WCSException; |
53 | 54 |
import org.gvsig.remoteclient.utils.BoundaryBox; |
54 |
import org.gvsig.remoteclient.wms.ICancellable; |
|
55 | 55 |
|
56 | 56 |
/** |
57 | 57 |
* WCSClient managing the low-level comunication to the server. It is used |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wcs/WCSProtocolHandler.java | ||
---|---|---|
42 | 42 |
|
43 | 43 |
import java.io.ByteArrayInputStream; |
44 | 44 |
import java.io.File; |
45 |
import java.io.FileInputStream; |
|
46 | 45 |
import java.io.IOException; |
47 | 46 |
import java.net.MalformedURLException; |
48 | 47 |
import java.net.URL; |
49 |
import java.nio.ByteBuffer; |
|
50 |
import java.nio.channels.FileChannel; |
|
51 | 48 |
import java.util.ArrayList; |
52 |
import java.util.HashMap; |
|
53 | 49 |
import java.util.Hashtable; |
54 | 50 |
import java.util.StringTokenizer; |
55 |
import java.util.Vector; |
|
56 | 51 |
|
52 |
import org.kxml2.io.KXmlParser; |
|
53 |
import org.xmlpull.v1.XmlPullParserException; |
|
54 |
|
|
55 |
import org.gvsig.compat.CompatLocator; |
|
56 |
import org.gvsig.compat.lang.StringUtils; |
|
57 |
import org.gvsig.compat.net.ICancellable; |
|
57 | 58 |
import org.gvsig.remoteclient.exceptions.ServerErrorException; |
58 | 59 |
import org.gvsig.remoteclient.exceptions.WCSException; |
59 | 60 |
import org.gvsig.remoteclient.ogc.OGCProtocolHandler; |
... | ... | |
62 | 63 |
import org.gvsig.remoteclient.utils.Utilities; |
63 | 64 |
import org.gvsig.remoteclient.wcs.request.WCSDescribeCoverageRequest; |
64 | 65 |
import org.gvsig.remoteclient.wcs.request.WCSGetCoverageRequest; |
65 |
import org.gvsig.remoteclient.wms.ICancellable; |
|
66 |
import org.kxml2.io.KXmlParser; |
|
67 |
import org.xmlpull.v1.XmlPullParserException; |
|
68 | 66 |
/** |
69 | 67 |
* |
70 | 68 |
* @author jaume |
... | ... | |
81 | 79 |
* WCS metadata |
82 | 80 |
*/ |
83 | 81 |
protected WCSServiceInformation serviceInfo = new WCSServiceInformation(); |
82 |
|
|
83 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
84 | 84 |
|
85 | 85 |
/* |
86 | 86 |
* (non-Javadoc) |
... | ... | |
122 | 122 |
} |
123 | 123 |
try { |
124 | 124 |
if (override) |
125 |
Utilities.removeURL(request);
|
|
126 |
File f = Utilities.downloadFile(request,"wcs_capabilities.xml", cancel);
|
|
125 |
downloader.removeURL(request);
|
|
126 |
File f = downloader.downloadFile(request,"wcs_capabilities.xml", cancel);
|
|
127 | 127 |
if (f!=null) |
128 | 128 |
parseCapabilities(f); |
129 | 129 |
} catch(Exception e) { |
... | ... | |
188 | 188 |
File f = request.sendRequest(); |
189 | 189 |
|
190 | 190 |
if (f!=null && Utilities.isTextFile(f)) { |
191 |
FileInputStream fis = new FileInputStream(f); |
|
192 |
FileChannel fc = fis.getChannel(); |
|
193 |
byte[] data = new byte[(int)fc.size()]; // fc.size returns the size of the file which backs the channel |
|
194 |
ByteBuffer bb = ByteBuffer.wrap(data); |
|
195 |
fc.read(bb); |
|
191 |
byte[] data = fileToBytes(f); |
|
196 | 192 |
|
197 | 193 |
WCSException wcsEx = null; |
198 | 194 |
|
... | ... | |
214 | 210 |
wcsEx.setWCSMessage(new String(data)); |
215 | 211 |
|
216 | 212 |
// Since it is an error file, It must be deleted from the cache |
217 |
Utilities.removeURL(request);
|
|
213 |
downloader.removeURL(request);
|
|
218 | 214 |
throw wcsEx; |
219 | 215 |
} |
220 | 216 |
return f; |
... | ... | |
325 | 321 |
else |
326 | 322 |
_host += "REQUEST=GetCapabilities&SERVICE=WCS&EXCEPTIONS=XML"; |
327 | 323 |
|
328 |
return _host.replaceAll(" ", "%20");
|
|
324 |
return stringUtils.replaceAll(_host, " ", "%20");
|
|
329 | 325 |
} |
330 | 326 |
|
331 | 327 |
public ArrayList getFormats() { |
... | ... | |
342 | 338 |
|
343 | 339 |
/* (non-Javadoc) |
344 | 340 |
* @see org.gvsig.remoteclient.ogc.OGCProtocolHandler#getServiceInformation() |
345 |
*/ |
|
346 |
@Override |
|
341 |
*/ |
|
347 | 342 |
public OGCServiceInformation getServiceInformation() { |
348 | 343 |
return serviceInfo; |
349 | 344 |
} |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wcs/CoverageOfferingBrief.java | ||
---|---|---|
52 | 52 |
|
53 | 53 |
import java.io.IOException; |
54 | 54 |
|
55 |
import org.kxml2.io.KXmlParser; |
|
56 |
import org.xmlpull.v1.XmlPullParserException; |
|
57 |
|
|
58 |
import org.gvsig.compat.CompatLocator; |
|
59 |
import org.gvsig.compat.lang.StringUtils; |
|
55 | 60 |
import org.gvsig.remoteclient.utils.BoundaryBox; |
56 | 61 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
57 | 62 |
import org.gvsig.remoteclient.utils.DescribeCoverageTags; |
58 |
import org.kxml2.io.KXmlParser; |
|
59 |
import org.xmlpull.v1.XmlPullParserException; |
|
60 | 63 |
|
61 | 64 |
public class CoverageOfferingBrief { |
62 | 65 |
private String name; |
63 | 66 |
private String label; |
64 | 67 |
private BoundaryBox lonLatBbox; |
65 |
|
|
68 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
69 |
|
|
66 | 70 |
public String getLabel() { |
67 | 71 |
return label; |
68 | 72 |
} |
... | ... | |
106 | 110 |
this.lonLatBbox.setSrs(DescribeCoverageTags.WGS84); |
107 | 111 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.GML_POS); |
108 | 112 |
String[][] coord = new String[2][2]; |
109 |
coord[0] = parser.nextText().split(WCSCoverage.SEPARATOR);
|
|
113 |
coord[0] = stringUtils.split(parser.nextText(), WCSCoverage.SEPARATOR);
|
|
110 | 114 |
parser.nextTag(); |
111 | 115 |
parser.require(KXmlParser.START_TAG, null, DescribeCoverageTags.GML_POS); |
112 |
coord[1] = parser.nextText().split(WCSCoverage.SEPARATOR);
|
|
116 |
coord[1] = stringUtils.split(parser.nextText(), WCSCoverage.SEPARATOR);
|
|
113 | 117 |
this.lonLatBbox.setXmin(Double.parseDouble(coord[0][0])); |
114 | 118 |
this.lonLatBbox.setYmin(Double.parseDouble(coord[0][1])); |
115 | 119 |
this.lonLatBbox.setXmax(Double.parseDouble(coord[1][0])); |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wcs/WCSServiceInformation.java | ||
---|---|---|
86 | 86 |
operations = new HashMap(); |
87 | 87 |
} |
88 | 88 |
|
89 |
@Override |
|
90 | 89 |
public OGCClientOperation createOperation(String name) { |
91 | 90 |
return new WCSOperation(name); |
92 | 91 |
} |
93 | 92 |
|
94 |
@Override |
|
95 | 93 |
public OGCClientOperation createOperation(String name, String onlineResource) { |
96 | 94 |
return new WCSOperation(name, onlineResource); |
97 | 95 |
} |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wcs/WCSProtocolHandlerFactory.java | ||
---|---|---|
67 | 67 |
import java.util.ArrayList; |
68 | 68 |
import java.util.Iterator; |
69 | 69 |
|
70 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
|
71 | 70 |
import org.kxml2.io.KXmlParser; |
72 | 71 |
import org.xmlpull.v1.XmlPullParserException; |
73 | 72 |
|
73 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
|
74 |
|
|
74 | 75 |
/** |
75 | 76 |
* |
76 | 77 |
* @author jaume dominguez faus |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/WFSClient.java | ||
---|---|---|
6 | 6 |
import java.util.ArrayList; |
7 | 7 |
import java.util.Hashtable; |
8 | 8 |
|
9 |
import org.gvsig.compat.net.ICancellable; |
|
9 | 10 |
import org.gvsig.remoteclient.RemoteClient; |
10 | 11 |
import org.gvsig.remoteclient.wfs.exceptions.WFSException; |
11 |
import org.gvsig.remoteclient.wms.ICancellable; |
|
12 | 12 |
|
13 | 13 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
14 | 14 |
* |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/wfs_1_1_0/WFSProtocolHandler1_1_0.java | ||
---|---|---|
5 | 5 |
import java.io.IOException; |
6 | 6 |
import java.util.Vector; |
7 | 7 |
|
8 |
import org.kxml2.io.KXmlParser; |
|
9 |
import org.xmlpull.v1.XmlPullParserException; |
|
10 |
|
|
11 |
import org.gvsig.compat.CompatLocator; |
|
12 |
import org.gvsig.compat.lang.StringUtils; |
|
8 | 13 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
9 | 14 |
import org.gvsig.remoteclient.wfs.WFSOperation; |
10 | 15 |
import org.gvsig.remoteclient.wfs.WFSProtocolHandler; |
... | ... | |
24 | 29 |
import org.gvsig.remoteclient.wfs.wfs_1_1_0.request.WFSDescribeFeatureTypeRequest1_1_0; |
25 | 30 |
import org.gvsig.remoteclient.wfs.wfs_1_1_0.request.WFSGetFeatureRequest1_1_0; |
26 | 31 |
import org.gvsig.remoteclient.wfs.wfs_1_1_0.request.WFSTLockFeatureRequest1_1_0; |
27 |
import org.kxml2.io.KXmlParser; |
|
28 |
import org.xmlpull.v1.XmlPullParserException; |
|
29 | 32 |
|
30 | 33 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
31 | 34 |
* |
... | ... | |
81 | 84 |
*/ |
82 | 85 |
public class WFSProtocolHandler1_1_0 extends WFSProtocolHandler{ |
83 | 86 |
|
87 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
88 |
|
|
84 | 89 |
public WFSProtocolHandler1_1_0(){ |
85 | 90 |
this.version = "1.1.0"; |
86 | 91 |
this.name = "WFS1.1.0"; |
... | ... | |
356 | 361 |
} |
357 | 362 |
|
358 | 363 |
String layerName = getCurrentFeature(); |
359 |
if (getCurrentFeature().split(":").length>1){
|
|
360 |
layerName = getCurrentFeature().split(":")[1];
|
|
364 |
if (stringUtils.split(getCurrentFeature(), ":").length>1){
|
|
365 |
layerName = stringUtils.split(getCurrentFeature(), ":")[1];
|
|
361 | 366 |
} |
362 | 367 |
XMLElement entity = XMLElementsFactory.getElement(layerName); |
363 | 368 |
if (entity != null){ |
... | ... | |
388 | 393 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
389 | 394 |
String attName = parser.getAttributeName(i); |
390 | 395 |
if (WFSTTags.WFS_NUMBER_OF_FEATURES.equals(attName)){ |
391 |
requestInformation.setNumberOfFeatures(new Integer(parser.getAttributeValue(i))); |
|
396 |
requestInformation.setNumberOfFeatures(new Integer(parser.getAttributeValue(i)).intValue());
|
|
392 | 397 |
}else if (WFSTTags.WFS_TIME_STAMP.equals(attName)){ |
393 | 398 |
requestInformation.setTimeStamp(parser.getAttributeValue(i)); |
394 | 399 |
} |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/wfs_1_1_0/WFSFeature1_1_0.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.io.IOException; |
4 | 4 |
|
5 |
import org.kxml2.io.KXmlParser; |
|
6 |
import org.xmlpull.v1.XmlPullParserException; |
|
7 |
|
|
8 |
import org.gvsig.compat.CompatLocator; |
|
9 |
import org.gvsig.compat.lang.StringUtils; |
|
5 | 10 |
import org.gvsig.remoteclient.utils.BoundaryBox; |
6 | 11 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
7 | 12 |
import org.gvsig.remoteclient.utils.Utilities; |
8 | 13 |
import org.gvsig.remoteclient.wfs.WFSFeature; |
9 | 14 |
import org.gvsig.remoteclient.wfs.schema.GMLTags; |
10 | 15 |
import org.gvsig.remoteclient.wfs.schema.XMLNameSpace; |
11 |
import org.kxml2.io.KXmlParser; |
|
12 |
import org.xmlpull.v1.XmlPullParserException; |
|
13 | 16 |
|
14 | 17 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
15 | 18 |
* |
... | ... | |
64 | 67 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
65 | 68 |
*/ |
66 | 69 |
public class WFSFeature1_1_0 extends WFSFeature{ |
67 |
|
|
70 |
|
|
71 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
72 |
|
|
68 | 73 |
public WFSFeature1_1_0() { |
69 | 74 |
|
70 | 75 |
} |
... | ... | |
87 | 92 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.WFS_FEATURETYPE); |
88 | 93 |
|
89 | 94 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
90 |
String[] attName = parser.getAttributeName(i).split(":");
|
|
95 |
String[] attName = stringUtils.split(parser.getAttributeName(i), ":");
|
|
91 | 96 |
if (attName.length == 2){ |
92 | 97 |
if (attName[0].compareTo(GMLTags.XML_NAMESPACE)==0){ |
93 | 98 |
XMLNameSpace nameSpace = new XMLNameSpace(attName[1],parser.getAttributeValue(i)); |
... | ... | |
127 | 132 |
} else if (parser.getName().compareToIgnoreCase(CapabilitiesTags.SRS)==0){ |
128 | 133 |
String value = parser.nextText(); |
129 | 134 |
if (value != null){ |
130 |
String[] mySRSs = value.split(" ");
|
|
135 |
String[] mySRSs = stringUtils.split(value, " ");
|
|
131 | 136 |
for (int i = 0; i < mySRSs.length; i++) { |
132 | 137 |
this.addSRS(mySRSs[i]); |
133 | 138 |
} |
... | ... | |
193 | 198 |
if ((lowerCorner != null) && (upperCorner != null)){ |
194 | 199 |
BoundaryBox bbox = new BoundaryBox(); |
195 | 200 |
bbox.setSrs("EPSG:4326"); |
196 |
String[] lowerCoordinates = lowerCorner.split("[! \t\r\n]");
|
|
201 |
String[] lowerCoordinates = stringUtils.split(lowerCorner, "[! \t\r\n]");
|
|
197 | 202 |
if (lowerCoordinates.length >= 2){ |
198 | 203 |
try{ |
199 |
bbox.setXmin(Double.valueOf(lowerCoordinates[0])); |
|
200 |
bbox.setYmin(Double.valueOf(lowerCoordinates[1])); |
|
204 |
bbox.setXmin(Double.valueOf(lowerCoordinates[0]).doubleValue());
|
|
205 |
bbox.setYmin(Double.valueOf(lowerCoordinates[1]).doubleValue());
|
|
201 | 206 |
}catch(NumberFormatException e){ |
202 | 207 |
//Is not a number |
203 | 208 |
} |
204 | 209 |
} |
205 |
String[] upperCoordinates = upperCorner.split("[! \t\r\n]");
|
|
210 |
String[] upperCoordinates = stringUtils.split(upperCorner, "[! \t\r\n]");
|
|
206 | 211 |
if (upperCoordinates.length >= 2){ |
207 | 212 |
try{ |
208 |
bbox.setXmax(Double.valueOf(upperCoordinates[0])); |
|
209 |
bbox.setYmax(Double.valueOf(upperCoordinates[1])); |
|
213 |
bbox.setXmax(Double.valueOf(upperCoordinates[0]).doubleValue());
|
|
214 |
bbox.setYmax(Double.valueOf(upperCoordinates[1]).doubleValue());
|
|
210 | 215 |
}catch(NumberFormatException e){ |
211 | 216 |
//Is not a number |
212 | 217 |
} |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/exceptions/ExceptionsFactory.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.io.IOException; |
4 | 4 |
|
5 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
|
6 | 5 |
import org.kxml2.io.KXmlParser; |
7 | 6 |
import org.xmlpull.v1.XmlPullParserException; |
8 | 7 |
|
8 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
|
9 |
|
|
9 | 10 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
10 | 11 |
* |
11 | 12 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/WFSStatus.java | ||
---|---|---|
3 | 3 |
import java.awt.geom.Rectangle2D; |
4 | 4 |
import java.util.ArrayList; |
5 | 5 |
|
6 |
import org.gvsig.compat.CompatLocator; |
|
7 |
import org.gvsig.compat.lang.StringUtils; |
|
6 | 8 |
import org.gvsig.fmap.geom.Geometry; |
7 | 9 |
import org.gvsig.fmap.geom.GeometryLocator; |
8 | 10 |
import org.gvsig.fmap.geom.GeometryManager; |
... | ... | |
93 | 95 |
* @see <a href="http://www.opengeospatial.org/standards/wfs">OpenGIS Web Feature Service (WFS) Implementation Specification</a> |
94 | 96 |
*/ |
95 | 97 |
public class WFSStatus extends RemoteClientStatus{ |
96 |
/** |
|
98 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
99 |
|
|
100 |
/** |
|
97 | 101 |
* The optional resultType attribute is used to control how |
98 | 102 |
* a web feature service responds to a GetFeature request. |
99 | 103 |
* The possible values for the attribute are defined in |
... | ... | |
124 | 128 |
private String namespace = null; |
125 | 129 |
private String[] fields = null; |
126 | 130 |
private String onlineResource = null; |
127 |
private Integer timeout = 10000;
|
|
128 |
private Integer buffer = 100;
|
|
131 |
private Integer timeout = new Integer(10000);
|
|
132 |
private Integer buffer = new Integer(100);
|
|
129 | 133 |
private String filterByAttribute = null; |
130 | 134 |
private WFSSpatialFilterOperation filterByArea = null; |
131 | 135 |
|
... | ... | |
223 | 227 |
if (fields == null){ |
224 | 228 |
return; |
225 | 229 |
} |
226 |
this.fields = fields.split(",");
|
|
230 |
this.fields = stringUtils.split(fields, ",");
|
|
227 | 231 |
} |
228 | 232 |
|
229 | 233 |
|
... | ... | |
314 | 318 |
attributeName = "the_geom"; |
315 | 319 |
} |
316 | 320 |
if (operation == null){ |
317 |
operation = AbstractFilter.GEOMETRIC_OPERATOR_INTERSECT;
|
|
321 |
operation = new Integer(AbstractFilter.GEOMETRIC_OPERATOR_INTERSECT);
|
|
318 | 322 |
} |
319 | 323 |
this.filterByArea = new WFSGeometryFilterOperation(geometry, |
320 |
operation, |
|
324 |
operation.intValue(),
|
|
321 | 325 |
attributeName, |
322 | 326 |
srs); |
323 | 327 |
} |
... | ... | |
337 | 341 |
attributeName = "the_geom"; |
338 | 342 |
} |
339 | 343 |
if (operation == null){ |
340 |
operation = AbstractFilter.GEOMETRIC_OPERATOR_INTERSECT;
|
|
344 |
operation = new Integer(AbstractFilter.GEOMETRIC_OPERATOR_INTERSECT);
|
|
341 | 345 |
} |
342 | 346 |
this.filterByArea = new WFSEnvelopeFilterOperation(envelope, |
343 |
operation, |
|
347 |
operation.intValue(),
|
|
344 | 348 |
attributeName, |
345 | 349 |
srs); |
346 | 350 |
} |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/WFSProtocolHandlerFactory.java | ||
---|---|---|
9 | 9 |
import java.util.ArrayList; |
10 | 10 |
import java.util.Iterator; |
11 | 11 |
|
12 |
import org.kxml2.io.KXmlParser; |
|
13 |
import org.xmlpull.v1.XmlPullParserException; |
|
14 |
|
|
15 |
import org.gvsig.compat.CompatLocator; |
|
16 |
import org.gvsig.compat.lang.StringUtils; |
|
12 | 17 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
13 | 18 |
import org.gvsig.remoteclient.utils.EncodingXMLParser; |
14 | 19 |
import org.gvsig.remoteclient.utils.Utilities; |
15 |
import org.kxml2.io.KXmlParser; |
|
16 |
import org.xmlpull.v1.XmlPullParserException; |
|
17 | 20 |
|
18 | 21 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
19 | 22 |
* |
... | ... | |
72 | 75 |
*/ |
73 | 76 |
public class WFSProtocolHandlerFactory { |
74 | 77 |
public WFSProtocolHandler wFSProtocolHandler; |
75 |
|
|
78 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
76 | 79 |
private static ArrayList supportedVersions = new ArrayList(); |
77 | 80 |
|
78 | 81 |
static { |
... | ... | |
203 | 206 |
kxmlParser.nextTag(); |
204 | 207 |
if ( kxmlParser.getEventType() != KXmlParser.END_DOCUMENT ) { |
205 | 208 |
String tag = kxmlParser.getName(); |
206 |
if (tag.split(":").length == 2){
|
|
207 |
tag = tag.split(":")[1];
|
|
209 |
if (stringUtils.split(tag, ":").length == 2){
|
|
210 |
tag = stringUtils.split(tag, ":")[1];
|
|
208 | 211 |
} |
209 | 212 |
if ((tag.compareTo(CapabilitiesTags.WFS_CAPABILITIES_ROOT1_0_0)==0)) { |
210 | 213 |
version = kxmlParser.getAttributeValue("", CapabilitiesTags.VERSION); |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/WFSProtocolHandler.java | ||
---|---|---|
8 | 8 |
import java.util.StringTokenizer; |
9 | 9 |
import java.util.Vector; |
10 | 10 |
|
11 |
import org.kxml2.io.KXmlParser; |
|
12 |
|
|
13 |
import org.gvsig.compat.net.ICancellable; |
|
11 | 14 |
import org.gvsig.remoteclient.ogc.OGCProtocolHandler; |
12 | 15 |
import org.gvsig.remoteclient.ogc.OGCServiceInformation; |
13 | 16 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
14 |
import org.gvsig.remoteclient.utils.Utilities; |
|
15 | 17 |
import org.gvsig.remoteclient.wfs.edition.WFSTTransaction; |
16 | 18 |
import org.gvsig.remoteclient.wfs.exceptions.WFSException; |
17 | 19 |
import org.gvsig.remoteclient.wfs.request.WFSDescribeFeatureTypeRequest; |
18 | 20 |
import org.gvsig.remoteclient.wfs.request.WFSGetFeatureRequest; |
19 | 21 |
import org.gvsig.remoteclient.wfs.request.WFSTLockFeatureRequest; |
20 | 22 |
import org.gvsig.remoteclient.wfs.schema.GMLTags; |
21 |
import org.gvsig.remoteclient.wms.ICancellable; |
|
22 |
import org.kxml2.io.KXmlParser; |
|
23 | 23 |
|
24 | 24 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
25 | 25 |
* |
... | ... | |
136 | 136 |
try { |
137 | 137 |
request = new URL(buildCapabilitiesRequest(status)); |
138 | 138 |
if (override){ |
139 |
Utilities.removeURL(request);
|
|
139 |
downloader.removeURL(request);
|
|
140 | 140 |
} |
141 |
File f = Utilities.downloadFile(request,"wfs_capabilities.xml", cancel);
|
|
141 |
File f = downloader.downloadFile(request,"wfs_capabilities.xml", cancel);
|
|
142 | 142 |
if (f == null) |
143 | 143 |
return; |
144 | 144 |
clear(); |
... | ... | |
295 | 295 |
WFSTTransaction transaction = status.getTransactionAt(i); |
296 | 296 |
if (transaction.getStatus() == WFSTTransaction.STATUS_NO_EXECUTED){ |
297 | 297 |
System.out.println(transaction.getWFSTRequest()); |
298 |
File f = Utilities.downloadFile(request,
|
|
298 |
File f = downloader.downloadFile(request,
|
|
299 | 299 |
transaction.getWFSTRequest(), |
300 | 300 |
"wfs_transaction.xml", null); |
301 | 301 |
parseTransaction(f,status.getNamespacePrefix(),transaction); |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/schema/XMLElement.java | ||
---|---|---|
3 | 3 |
import java.io.IOException; |
4 | 4 |
import java.util.Vector; |
5 | 5 |
|
6 |
import org.kxml2.io.KXmlParser; |
|
7 |
import org.xmlpull.v1.XmlPullParserException; |
|
8 |
|
|
9 |
import org.gvsig.compat.CompatLocator; |
|
10 |
import org.gvsig.compat.lang.StringUtils; |
|
6 | 11 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
7 | 12 |
import org.gvsig.remoteclient.wfs.schema.type.IXMLType; |
8 | 13 |
import org.gvsig.remoteclient.wfs.schema.type.XMLComplexType; |
9 |
import org.kxml2.io.KXmlParser; |
|
10 |
import org.xmlpull.v1.XmlPullParserException; |
|
11 | 14 |
|
12 | 15 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
13 | 16 |
* |
... | ... | |
105 | 108 |
//Only used if is a part of a complex type |
106 | 109 |
private XMLElement parentElement = null; |
107 | 110 |
|
111 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
112 |
|
|
108 | 113 |
public XMLElement(XMLSchemaParser parser) throws XmlPullParserException, IOException { |
109 | 114 |
super(); |
110 | 115 |
parse(parser); |
... | ... | |
162 | 167 |
this.type = XMLTypesFactory.getType(typeUnknown); |
163 | 168 |
} |
164 | 169 |
if ((type == null) && (typeUnknown != null)){ |
165 |
if (typeUnknown.split(":").length > 1){
|
|
166 |
this.type = XMLTypesFactory.getType(null + ":" + typeUnknown.split(":")[1]);
|
|
170 |
if (stringUtils.split(typeUnknown, ":").length > 1){
|
|
171 |
this.type = XMLTypesFactory.getType(null + ":" + stringUtils.split(typeUnknown, ":")[1]);
|
|
167 | 172 |
if (type == null){ |
168 |
this.type = XMLTypesFactory.getType(typeUnknown.split(":")[1]);
|
|
173 |
this.type = XMLTypesFactory.getType(stringUtils.split(typeUnknown, ":")[1]);
|
|
169 | 174 |
} |
170 | 175 |
} |
171 | 176 |
} |
... | ... | |
178 | 183 |
public void setEntityType(String type) { |
179 | 184 |
IXMLType xmlType = XMLTypesFactory.getType(type); |
180 | 185 |
if (xmlType == null){ |
181 |
String[] types = type.split(":");
|
|
186 |
String[] types = stringUtils.split(type, ":");
|
|
182 | 187 |
if (types.length == 1){ |
183 | 188 |
xmlType = XMLTypesFactory.getType("XS:" + type); |
184 | 189 |
} |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/schema/XMLTypesFactory.java | ||
---|---|---|
4 | 4 |
import java.util.Iterator; |
5 | 5 |
import java.util.Set; |
6 | 6 |
|
7 |
import org.gvsig.compat.CompatLocator; |
|
8 |
import org.gvsig.compat.lang.StringUtils; |
|
7 | 9 |
import org.gvsig.remoteclient.wfs.schema.type.GMLGeometryType; |
8 | 10 |
import org.gvsig.remoteclient.wfs.schema.type.IXMLType; |
9 | 11 |
import org.gvsig.remoteclient.wfs.schema.type.XMLComplexType; |
... | ... | |
92 | 94 |
*/ |
93 | 95 |
public class XMLTypesFactory { |
94 | 96 |
private static Hashtable types = new Hashtable(); |
95 |
|
|
97 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
98 |
|
|
96 | 99 |
static{ |
97 | 100 |
types.put(XMLSimpleType.STRING.toUpperCase(),new XMLSimpleType(XMLSimpleType.STRING)); |
98 | 101 |
types.put(XMLSimpleType.INTEGER.toUpperCase(),new XMLSimpleType(XMLSimpleType.INTEGER)); |
... | ... | |
137 | 140 |
public static IXMLType getTypeWithOutNameSpace(String type){ |
138 | 141 |
Set keys = types.keySet(); |
139 | 142 |
Iterator it = keys.iterator(); |
140 |
String[] typeParts = type.split(":");
|
|
143 |
String[] typeParts = stringUtils.split(type, ":");
|
|
141 | 144 |
String typeAux = type; |
142 | 145 |
if (typeParts.length > 1){ |
143 | 146 |
typeAux = typeParts[1]; |
144 | 147 |
} |
145 | 148 |
while(it.hasNext()){ |
146 | 149 |
String key = (String)it.next(); |
147 |
String[] parts = key.split(":");
|
|
150 |
String[] parts = stringUtils.split(key, ":");
|
|
148 | 151 |
if (parts.length == 1){ |
149 | 152 |
if (parts[0].compareTo(typeAux.toUpperCase())==0){ |
150 | 153 |
return (IXMLType)types.get(key); |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/schema/XMLSchemaParser.java | ||
---|---|---|
4 | 4 |
import java.io.FileReader; |
5 | 5 |
import java.io.IOException; |
6 | 6 |
|
7 |
import org.kxml2.io.KXmlParser; |
|
8 |
import org.xmlpull.v1.XmlPullParserException; |
|
9 |
|
|
10 |
import org.gvsig.compat.CompatLocator; |
|
11 |
import org.gvsig.compat.lang.StringUtils; |
|
7 | 12 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
8 | 13 |
import org.gvsig.remoteclient.utils.EncodingXMLParser; |
9 | 14 |
import org.gvsig.remoteclient.wfs.schema.type.XMLComplexType; |
10 |
import org.kxml2.io.KXmlParser; |
|
11 |
import org.xmlpull.v1.XmlPullParserException; |
|
12 | 15 |
|
13 | 16 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
14 | 17 |
* |
... | ... | |
97 | 100 |
private String nameSpace = ""; |
98 | 101 |
private String version = null; |
99 | 102 |
|
103 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
100 | 104 |
|
101 | 105 |
public XMLSchemaParser(){ |
102 | 106 |
super(); |
... | ... | |
185 | 189 |
public String getNameSpace(){ |
186 | 190 |
try{ |
187 | 191 |
String name = super.getName(); |
188 |
if ((name!=null)&&(name.split(":").length > 1)){
|
|
189 |
return name.split(":")[0];
|
|
192 |
if ((name!=null)&&(stringUtils.split(name, ":").length > 1)){
|
|
193 |
return stringUtils.split(name, ":")[0];
|
|
190 | 194 |
} |
191 | 195 |
return ""; |
192 | 196 |
}catch (NullPointerException e){ |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/schema/XMLElementsFactory.java | ||
---|---|---|
6 | 6 |
import java.util.Map; |
7 | 7 |
import java.util.Set; |
8 | 8 |
|
9 |
import org.xmlpull.v1.XmlPullParserException; |
|
10 |
|
|
9 | 11 |
import org.gvsig.remoteclient.wfs.schema.type.IXMLType; |
10 | 12 |
import org.gvsig.remoteclient.wfs.schema.type.XMLComplexType; |
11 |
import org.xmlpull.v1.XmlPullParserException; |
|
12 | 13 |
|
13 | 14 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
14 | 15 |
* |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/filters/operations/WFSEnvelopeFilterOperation.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
package org.gvsig.remoteclient.wfs.filters.operations; |
29 | 29 |
|
30 |
import org.gvsig.fmap.geom.Geometry; |
|
31 | 30 |
import org.gvsig.fmap.geom.primitive.Envelope; |
32 | 31 |
|
33 | 32 |
/** |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/filters/operations/WFSSpatialFilterOperation.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
package org.gvsig.remoteclient.wfs.filters.operations; |
29 | 29 |
|
30 |
import org.gvsig.fmap.geom.Geometry; |
|
31 | 30 |
import org.gvsig.remoteclient.wfs.filters.AbstractFilter; |
32 | 31 |
|
33 | 32 |
/** |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/filters/operations/WFSGeometryFilterOperation.java | ||
---|---|---|
28 | 28 |
package org.gvsig.remoteclient.wfs.filters.operations; |
29 | 29 |
|
30 | 30 |
import org.gvsig.fmap.geom.Geometry; |
31 |
import org.gvsig.remoteclient.wfs.filters.AbstractFilter; |
|
32 | 31 |
|
33 | 32 |
/** |
34 | 33 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/filters/filterencoding/FilterEncoding.java | ||
---|---|---|
45 | 45 |
import java.util.Iterator; |
46 | 46 |
import java.util.Set; |
47 | 47 |
|
48 |
import org.gvsig.compat.CompatLocator; |
|
49 |
import org.gvsig.compat.lang.StringUtils; |
|
48 | 50 |
import org.gvsig.remoteclient.wfs.WFSStatus; |
49 | 51 |
import org.gvsig.remoteclient.wfs.filters.AbstractFilter; |
50 | 52 |
import org.gvsig.remoteclient.wfs.filters.BinaryTree; |
... | ... | |
99 | 101 |
*/ |
100 | 102 |
private boolean isQualified = false; |
101 | 103 |
|
104 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
105 |
|
|
102 | 106 |
/** |
103 | 107 |
* Create a new Filter Encoding Parser |
104 | 108 |
* |
... | ... | |
236 | 240 |
* @return |
237 | 241 |
*/ |
238 | 242 |
private String getExpression(String expression){ |
239 |
String[] words = expression.split(" ");
|
|
243 |
String[] words = stringUtils.split(expression, " ");
|
|
240 | 244 |
//Param |
241 | 245 |
String param = words[0]; |
242 | 246 |
if (param.charAt(0) == '"'){ |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/filters/filterencoding/EnvelopeFEQuery.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
package org.gvsig.remoteclient.wfs.filters.filterencoding; |
29 | 29 |
|
30 |
import java.awt.geom.PathIterator; |
|
31 |
|
|
32 |
import org.gvsig.fmap.geom.Geometry; |
|
33 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
|
34 | 30 |
import org.gvsig.fmap.geom.primitive.Envelope; |
35 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
|
36 |
import org.gvsig.fmap.geom.primitive.Surface; |
|
37 | 31 |
import org.gvsig.remoteclient.wfs.filters.operations.WFSEnvelopeFilterOperation; |
38 |
import org.gvsig.remoteclient.wfs.filters.operations.WFSGeometryFilterOperation; |
|
39 | 32 |
|
40 | 33 |
/** |
41 | 34 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a> |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/filters/filterencoding/SpatialFEQuery.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
package org.gvsig.remoteclient.wfs.filters.filterencoding; |
29 | 29 |
|
30 |
import org.gvsig.fmap.geom.Geometry; |
|
31 |
import org.gvsig.remoteclient.wfs.filters.operations.WFSGeometryFilterOperation; |
|
32 | 30 |
import org.gvsig.remoteclient.wfs.filters.operations.WFSSpatialFilterOperation; |
33 | 31 |
|
34 | 32 |
/** |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/wfs_1_0_0/request/WFSDescribeFeatureTypeRequest1_0_0.java | ||
---|---|---|
1 | 1 |
package org.gvsig.remoteclient.wfs.wfs_1_0_0.request; |
2 | 2 |
|
3 |
import org.gvsig.compat.CompatLocator; |
|
4 |
import org.gvsig.compat.lang.StringUtils; |
|
3 | 5 |
import org.gvsig.remoteclient.wfs.WFSProtocolHandler; |
4 | 6 |
import org.gvsig.remoteclient.wfs.WFSStatus; |
5 | 7 |
import org.gvsig.remoteclient.wfs.request.WFSDescribeFeatureTypeRequest; |
... | ... | |
55 | 57 |
*/ |
56 | 58 |
public class WFSDescribeFeatureTypeRequest1_0_0 extends WFSDescribeFeatureTypeRequest { |
57 | 59 |
|
60 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
61 |
|
|
58 | 62 |
public WFSDescribeFeatureTypeRequest1_0_0(WFSStatus status, |
59 | 63 |
WFSProtocolHandler protocolHandler) { |
60 | 64 |
super(status, protocolHandler); |
... | ... | |
79 | 83 |
} |
80 | 84 |
req.append("TYPENAME=").append(typeName).append("&"); |
81 | 85 |
req.append("VERSION=").append(protocolHandler.getVersion()).append("&EXCEPTIONS=XML"); |
82 |
String request = req.toString().replace("UEeRtKxB+ROJTlqYiWB3XQ==", "UEeRtKxB%2bROJTlqYiWB3XQ%3d%3d");
|
|
86 |
String request = stringUtils.replaceAll(req.toString(), "UEeRtKxB+ROJTlqYiWB3XQ==", "UEeRtKxB%2bROJTlqYiWB3XQ%3d%3d");
|
|
83 | 87 |
return request; |
84 | 88 |
} |
85 | 89 |
|
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/wfs_1_0_0/WFSFeature1_0_0.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.io.IOException; |
4 | 4 |
|
5 |
import org.kxml2.io.KXmlParser; |
|
6 |
import org.xmlpull.v1.XmlPullParserException; |
|
7 |
|
|
8 |
import org.gvsig.compat.CompatLocator; |
|
9 |
import org.gvsig.compat.lang.StringUtils; |
|
5 | 10 |
import org.gvsig.remoteclient.utils.BoundaryBox; |
6 | 11 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
7 | 12 |
import org.gvsig.remoteclient.utils.Utilities; |
8 | 13 |
import org.gvsig.remoteclient.wfs.WFSFeature; |
9 | 14 |
import org.gvsig.remoteclient.wfs.schema.GMLTags; |
10 | 15 |
import org.gvsig.remoteclient.wfs.schema.XMLNameSpace; |
11 |
import org.kxml2.io.KXmlParser; |
|
12 |
import org.xmlpull.v1.XmlPullParserException; |
|
13 | 16 |
|
14 | 17 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
15 | 18 |
* |
... | ... | |
82 | 85 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
83 | 86 |
*/ |
84 | 87 |
public class WFSFeature1_0_0 extends WFSFeature{ |
85 |
|
|
88 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
89 |
|
|
86 | 90 |
public WFSFeature1_0_0() { |
87 | 91 |
|
88 | 92 |
} |
... | ... | |
105 | 109 |
parser.require(KXmlParser.START_TAG, null, CapabilitiesTags.WFS_FEATURETYPE); |
106 | 110 |
|
107 | 111 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
108 |
String[] attName = parser.getAttributeName(i).split(":");
|
|
112 |
String[] attName = stringUtils.split(parser.getAttributeName(i), ":");
|
|
109 | 113 |
if (attName.length == 2){ |
110 | 114 |
if (attName[0].compareTo(GMLTags.XML_NAMESPACE)==0){ |
111 | 115 |
XMLNameSpace nameSpace = new XMLNameSpace(attName[1],parser.getAttributeValue(i)); |
... | ... | |
143 | 147 |
{ |
144 | 148 |
String value = parser.nextText(); |
145 | 149 |
if (value != null){ |
146 |
String[] mySRSs = value.split(" ");
|
|
150 |
String[] mySRSs = stringUtils.split(value, " ");
|
|
147 | 151 |
for (int i = 0; i < mySRSs.length; i++) { |
148 | 152 |
this.addSRS(mySRSs[i]); |
149 | 153 |
} |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/wfs_1_0_0/WFSProtocolHandler1_0_0.java | ||
---|---|---|
5 | 5 |
import java.io.IOException; |
6 | 6 |
import java.util.Vector; |
7 | 7 |
|
8 |
import org.gvsig.compat.CompatLocator; |
|
9 |
import org.gvsig.compat.lang.StringUtils; |
|
8 | 10 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
9 | 11 |
import org.gvsig.remoteclient.wfs.WFSProtocolHandler; |
10 | 12 |
import org.gvsig.remoteclient.wfs.WFSStatus; |
... | ... | |
108 | 110 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
109 | 111 |
*/ |
110 | 112 |
public class WFSProtocolHandler1_0_0 extends WFSProtocolHandler{ |
111 |
public WFSProtocolHandler1_0_0(){ |
|
113 |
|
|
114 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
115 |
|
|
116 |
public WFSProtocolHandler1_0_0(){ |
|
112 | 117 |
this.version = "1.0.0"; |
113 | 118 |
this.name = "WFS1.0.0"; |
114 | 119 |
} |
... | ... | |
357 | 362 |
} |
358 | 363 |
|
359 | 364 |
String layerName = getCurrentFeature(); |
360 |
if (getCurrentFeature().split(":").length>1){
|
|
361 |
layerName = getCurrentFeature().split(":")[1];
|
|
365 |
if (stringUtils.split(getCurrentFeature(), ":").length>1){
|
|
366 |
layerName = stringUtils.split(getCurrentFeature(), ":")[1];
|
|
362 | 367 |
} |
363 | 368 |
XMLElement entity = XMLElementsFactory.getElement(layerName); |
364 | 369 |
if (entity != null){ |
branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/utils/Utilities.java | ||
---|---|---|
41 | 41 |
*/ |
42 | 42 |
|
43 | 43 |
import java.io.BufferedOutputStream; |
44 |
import java.io.DataInputStream; |
|
45 | 44 |
import java.io.DataOutputStream; |
46 | 45 |
import java.io.File; |
47 | 46 |
import java.io.FileNotFoundException; |
... | ... | |
50 | 49 |
import java.io.IOException; |
51 | 50 |
import java.io.InputStream; |
52 | 51 |
import java.io.OutputStream; |
53 |
import java.io.OutputStreamWriter; |
|
54 | 52 |
import java.net.ConnectException; |
55 |
import java.net.HttpURLConnection; |
|
56 | 53 |
import java.net.URL; |
57 | 54 |
import java.net.UnknownHostException; |
58 |
import java.rmi.NoSuchObjectException; |
|
59 |
import java.security.KeyManagementException; |
|
60 |
import java.security.NoSuchAlgorithmException; |
|
61 | 55 |
import java.util.Hashtable; |
62 | 56 |
import java.util.StringTokenizer; |
63 | 57 |
import java.util.Vector; |
64 | 58 |
|
65 |
import javax.net.ssl.HttpsURLConnection; |
|
66 |
import javax.net.ssl.SSLContext; |
|
67 |
import javax.net.ssl.TrustManager; |
|
68 |
import javax.net.ssl.X509TrustManager; |
|
69 |
|
|
59 |
import org.gvsig.compat.CompatLocator; |
|
60 |
import org.gvsig.compat.net.Downloader; |
|
70 | 61 |
import org.gvsig.remoteclient.wms.ICancellable; |
71 | 62 |
|
72 | 63 |
|
... | ... | |
78 | 69 |
* @authors Laura D?az, jaume dominguez faus |
79 | 70 |
*/ |
80 | 71 |
public class Utilities { |
81 |
private static String characters; |
|
72 |
private static final Downloader downloader = CompatLocator.getDownloader(); |
|
73 |
private static String characters; |
|
82 | 74 |
static boolean canceled; |
83 | 75 |
static final long latency = 500; |
84 | 76 |
/** |
... | ... | |
227 | 219 |
|
228 | 220 |
try { |
229 | 221 |
index2 = findBeginIndex(bytes, startTag); |
230 |
} catch (NoSuchObjectException e) {
|
|
222 |
} catch (Exception e) { |
|
231 | 223 |
return bytes; |
232 | 224 |
} |
233 | 225 |
|
... | ... | |
246 | 238 |
* |
247 | 239 |
* @return ?ndice donde empieza el tag raiz |
248 | 240 |
* |
249 |
* @throws NoSuchObjectException Si no se encuentra el tag
|
|
241 |
* @throws Exception Si no se encuentra el tag |
|
250 | 242 |
*/ |
251 | 243 |
private static int findBeginIndex(byte[] bytes, String tagRaiz) |
252 |
throws NoSuchObjectException {
|
|
244 |
throws Exception { |
|
253 | 245 |
try { |
254 | 246 |
int nodo = 0; |
255 | 247 |
int ret = -1; |
... | ... | |
294 | 286 |
i++; |
295 | 287 |
} |
296 | 288 |
} catch (Exception e) { |
297 |
throw new NoSuchObjectException("No se pudo parsear el xml");
|
|
289 |
throw new Exception("No se pudo parsear el xml", e);
|
|
298 | 290 |
} |
299 | 291 |
} |
300 | 292 |
|
... | ... | |
421 | 413 |
} |
422 | 414 |
return s; |
423 | 415 |
} |
424 |
|
|
416 |
|
|
425 | 417 |
/** |
426 |
* Return the content of a file that has been created |
|
427 |
* from a URL using the HTTP GET protocol |
|
428 |
* @param url |
|
429 |
* The URL |
|
430 |
* @return |
|
431 |
* File containing this URL's content or null if no file was found. |
|
432 |
*/ |
|
433 |
private static File getPreviousDownloadedURL(URL url){ |
|
434 |
return getPreviousDownloaded(url); |
|
435 |
} |
|
436 |
|
|
437 |
/** |
|
438 |
* Return the content of a file that has been created |
|
439 |
* from a URL using the HTTP POST protocol |
|
440 |
* @param url |
|
441 |
* The URL |
|
442 |
* @param data |
|
443 |
* The data to send on the query |
|
444 |
* @return |
|
445 |
* File containing this URL's content or null if no file was found. |
|
446 |
*/ |
|
447 |
private static File getPreviousDownloadedURL(URL url, String data){ |
|
448 |
return getPreviousDownloaded(url+data); |
|
449 |
} |
|
450 |
|
|
451 |
/** |
|
452 |
* Returns the content of a URL as a file from the file system.<br> |
|
453 |
* <p> |
|
454 |
* If the URL has been already downloaded in this session and notified |
|
455 |
* to the system using the static <b>Utilities.addDownloadedURL(URL)</b> |
|
456 |
* method, it can be restored faster from the file system avoiding to |
|
457 |
* download it again. |
|
458 |
* </p> |
|
459 |
* @param url |
|
460 |
* @return File containing this URL's content or null if no file was found. |
|
461 |
*/ |
|
462 |
private static File getPreviousDownloaded(Object object){ |
|
463 |
File f = null; |
|
464 |
if (downloadedFiles!=null && downloadedFiles.containsKey(object)){ |
|
465 |
String filePath = (String) downloadedFiles.get(object); |
|
466 |
f = new File(filePath); |
|
467 |
if (!f.exists()) |
|
468 |
return null; |
|
469 |
} |
|
470 |
return f; |
|
471 |
} |
|
472 |
|
|
473 |
/** |
|
474 |
* Adds an URL to the table of downloaded files for further uses. If the URL |
|
475 |
* already exists in the table its filePath value is updated to the new one and |
|
476 |
* the old file itself is removed from the file system. |
|
477 |
* |
|
478 |
* @param url |
|
479 |
* @param filePath |
|
480 |
*/ |
|
481 |
static void addDownloadedURL(URL url, String filePath){ |
|
482 |
if (downloadedFiles==null) |
|
483 |
downloadedFiles = new Hashtable(); |
|
484 |
String fileName = (String) downloadedFiles.put(url, filePath); |
|
485 |
//JMV: No se puede eliminar el anterior porque puede que alguien lo |
|
486 |
// este usando |
|
487 |
/* |
|
488 |
if (fileName!=null){ |
|
489 |
File f = new File(fileName); |
|
490 |
if (f.exists()) |
|
491 |
f.delete(); |
|
492 |
} |
|
493 |
*/ |
|
494 |
} |
|
495 |
|
|
496 |
/** |
|
497 | 418 |
* Downloads an URL into a temporary file that is removed the next time the |
498 | 419 |
* tempFileManager class is called, which means the next time gvSIG is launched. |
499 | 420 |
* |
... | ... | |
506 | 427 |
* @throws UnknownHostException |
507 | 428 |
*/ |
508 | 429 |
public static synchronized File downloadFile(URL url, String name, ICancellable cancel) throws IOException,ConnectException, UnknownHostException{ |
509 |
File f = null; |
|
510 |
|
|
511 |
if ((f=getPreviousDownloadedURL(url))==null){ |
|
512 |
File tempDirectory = new File(tempDirectoryPath); |
|
513 |
if (!tempDirectory.exists()) |
|
514 |
tempDirectory.mkdir(); |
|
515 |
|
|
516 |
f = new File(calculateFileName(name)); |
|
517 |
|
|
518 |
if (cancel == null) { |
|
519 |
cancel = new ICancellable() { |
|
520 |
public boolean isCanceled() { |
|
521 |
return false; |
|
522 |
} |
|
523 |
public Object getID(){ |
|
524 |
return Utilities.class.getName(); |
|
525 |
} |
|
526 |
}; |
|
527 |
} |
|
528 |
Thread downloader = new Thread(new Downloader(url, f, cancel.getID())); |
|
529 |
Thread monitor = new Thread(new Monitor(cancel)); |
|
530 |
monitor.start(); |
|
531 |
downloader.start(); |
|
532 |
while(!getCanceled(cancel.getID()) && downloader.isAlive()) { |
|
533 |
try { |
|
534 |
Thread.sleep(latency); |
|
535 |
} catch (InterruptedException e) { |
|
536 |
// TODO Auto-generated catch block |
|
537 |
e.printStackTrace(); |
|
538 |
} |
|
539 |
} |
|
540 |
|
|
541 |
if (getCanceled(cancel.getID())) |
|
542 |
return null; |
|
543 |
downloader = null; |
|
544 |
monitor = null; |
|
545 |
if (Utilities.downloadException!=null) { |
|
546 |
Exception e = Utilities.downloadException; |
|
547 |
if (e instanceof FileNotFoundException) |
|
548 |
throw (IOException) e; |
|
549 |
else if (e instanceof IOException) |
|
550 |
throw (IOException) e; |
|
551 |
else if (e instanceof ConnectException) |
|
552 |
throw (ConnectException) e; |
|
553 |
else if (e instanceof UnknownHostException) |
|
554 |
throw (UnknownHostException) e; |
|
555 |
} |
|
556 |
} else { |
|
557 |
System.out.println(url.toString()+" cached at '"+f.getAbsolutePath()+"'"); |
|
558 |
} |
|
559 |
|
|
560 |
return f; |
|
430 |
return downloader.downloadFile(url, name, new CancellableAdapter(cancel)); |
|
561 | 431 |
} |
562 | 432 |
|
563 | 433 |
private static String calculateFileName(String name){ |
... | ... | |
586 | 456 |
* @throws UnknownHostException |
587 | 457 |
*/ |
588 | 458 |
public static synchronized File downloadFile(URL url, String data, String name, ICancellable cancel) throws IOException,ConnectException, UnknownHostException{ |
589 |
File f = null; |
|
590 |
|
|
591 |
if ((f=getPreviousDownloadedURL(url,data))==null){ |
|
592 |
File tempDirectory = new File(tempDirectoryPath); |
|
593 |
if (!tempDirectory.exists()) |
|
594 |
tempDirectory.mkdir(); |
|
595 |
|
|
596 |
f = new File(calculateFileName(name)); |
|
597 |
|
|
598 |
if (cancel == null) { |
|
599 |
cancel = new ICancellable() { |
|
600 |
public boolean isCanceled() { |
|
601 |
return false; |
|
602 |
} |
|
603 |
public Object getID(){ |
|
604 |
return Utilities.class.getName(); |
|
605 |
} |
|
606 |
}; |
|
607 |
} |
|
608 |
Thread downloader = new Thread(new Downloader(url, data, f, cancel.getID())); |
|
609 |
Thread monitor = new Thread(new Monitor(cancel)); |
|
610 |
monitor.start(); |
|
611 |
downloader.start(); |
|
612 |
while(!getCanceled(cancel.getID()) && downloader.isAlive()) { |
|
613 |
try { |
|
614 |
Thread.sleep(latency); |
|
615 |
} catch (InterruptedException e) { |
|
616 |
// TODO Auto-generated catch block |
|
617 |
e.printStackTrace(); |
|
618 |
} |
|
619 |
} |
|
620 |
|
|
621 |
if (getCanceled(cancel.getID())) |
|
622 |
return null; |
|
623 |
downloader = null; |
|
624 |
monitor = null; |
|
625 |
if (Utilities.downloadException!=null) { |
|
626 |
Exception e = Utilities.downloadException; |
|
627 |
if (e instanceof FileNotFoundException) |
|
628 |
throw (IOException) e; |
|
629 |
else if (e instanceof IOException) |
|
630 |
throw (IOException) e; |
|
631 |
else if (e instanceof ConnectException) |
|
632 |
throw (ConnectException) e; |
|
633 |
else if (e instanceof UnknownHostException) |
|
634 |
throw (UnknownHostException) e; |
|
635 |
} |
|
636 |
} else { |
|
637 |
System.out.println(url.toString()+" cached at '"+f.getAbsolutePath()+"'"); |
|
638 |
} |
|
639 |
|
|
640 |
return f; |
|
459 |
return downloader.downloadFile(url, data, name, new CancellableAdapter(cancel)); |
|
641 | 460 |
} |
642 | 461 |
|
643 | 462 |
/** |
644 |
* Try if a group of downloads has been canceled |
|
645 |
* @param groupId |
|
646 |
* Group id |
|
647 |
* @return |
|
648 |
* If the group has been canceled |
|
649 |
*/ |
|
650 |
protected static boolean getCanceled(Object groupId){ |
|
651 |
Object obj = canceledGroup.get(groupId); |
|
652 |
if (obj != null){ |
|
653 |
return ((Boolean)obj).booleanValue(); |
|
654 |
} |
|
655 |
return false; |
|
656 |
} |
|
657 |
|
|
658 |
/** |
|
659 |
* Cancel a group of downloads |
|
660 |
* @param groupId |
|
661 |
* Group id |
|
662 |
* @param isCanceled |
|
663 |
* if the group has to be canceled |
|
664 |
*/ |
|
665 |
protected static void setCanceled(Object groupId, boolean isCanceled){ |
|
666 |
if (groupId == null){ |
|
667 |
groupId = Utilities.class.getName(); |
|
668 |
} |
|
669 |
canceledGroup.put(groupId,new Boolean(isCanceled)); |
|
670 |
} |
|
671 |
|
|
672 |
/** |
|
673 | 463 |
* Cleans every temporal file previously downloaded. |
674 | 464 |
*/ |
675 | 465 |
public static void cleanUpTempFiles() { |
676 |
try{ |
|
677 |
File tempDirectory = new File(tempDirectoryPath); |
|
678 |
|
|
679 |
File[] files = tempDirectory.listFiles(); |
|
680 |
if (files!=null) { |
|
681 |
for (int i = 0; i < files.length; i++) { |
|
682 |
// s?lo por si en un futuro se necesitan crear directorios temporales |
|
683 |
if (files[i].isDirectory()) deleteDirectory(files[i]); |
|
684 |
files[i].delete(); |
|
685 |
} |
|
686 |
} |
|
687 |
tempDirectory.delete(); |
|
688 |
} catch (Exception e) { } |
|
689 |
|
|
466 |
downloader.cleanUpTempFiles(); |
|
690 | 467 |
} |
691 |
/** |
|
692 |
* Recursive directory delete. |
|
693 |
* @param f |
|
694 |
*/ |
|
695 |
private static void deleteDirectory(File f) { |
|
696 |
File[] files = f.listFiles(); |
|
697 |
for (int i = 0; i < files.length; i++) { |
|
698 |
if (files[i].isDirectory()) deleteDirectory(files[i]); |
|
699 |
files[i].delete(); |
|
700 |
} |
|
701 | 468 |
|
702 |
} |
|
703 | 469 |
|
704 |
|
|
705 | 470 |
/** |
706 | 471 |
* Remove an URL from the system cache. The file will remain in the file |
707 | 472 |
* system for further eventual uses. |
708 | 473 |
* @param request |
709 | 474 |
*/ |
710 | 475 |
public static void removeURL(URL url) { |
711 |
if (downloadedFiles != null && downloadedFiles.containsKey(url)) |
|
712 |
downloadedFiles.remove(url); |
|
476 |
downloader.removeURL(url); |
Also available in: Unified diff