Revision 37652
tags/v_2_0_0_Build_2043/libraries/libRemoteServices/src/org/gvsig/remoteclient/RemoteClientStatus.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.remoteclient; |
|
3 |
|
|
4 |
import org.gvsig.remoteclient.ogc.OGCClientOperation; |
|
5 |
|
|
6 |
/** |
|
7 |
* This class represents the client status at a certain moment |
|
8 |
* it describes the "graphic" situation or the requirements of the data |
|
9 |
* to be retrieved. |
|
10 |
* |
|
11 |
*/ |
|
12 |
public abstract class RemoteClientStatus { |
|
13 |
|
|
14 |
// width and heigh of the map |
|
15 |
private int width; |
|
16 |
private int height; |
|
17 |
|
|
18 |
//format of the image to be retrieved |
|
19 |
private String format; |
|
20 |
private String infoFormat; |
|
21 |
// spatial reference system of the image to be retrieved |
|
22 |
private String srs; |
|
23 |
// exception format, to be retrieved in case of error |
|
24 |
private String exceptionFormat; |
|
25 |
|
|
26 |
//To set if the client has to use GET or POST |
|
27 |
private int protocol = OGCClientOperation.PROTOCOL_UNDEFINED; |
|
28 |
|
|
29 |
public int getWidth() { |
|
30 |
return width; |
|
31 |
} |
|
32 |
|
|
33 |
public void setWidth(int _width) { |
|
34 |
width = _width; |
|
35 |
} |
|
36 |
|
|
37 |
public int getHeight() { |
|
38 |
return height; |
|
39 |
} |
|
40 |
public void setHeight(int _height) { |
|
41 |
height = _height; |
|
42 |
} |
|
43 |
|
|
44 |
public String getFormat() { |
|
45 |
return format; |
|
46 |
} |
|
47 |
|
|
48 |
public void setFormat(String _format) { |
|
49 |
format = _format; |
|
50 |
} |
|
51 |
|
|
52 |
public String getInfoFormat() { |
|
53 |
return infoFormat; |
|
54 |
} |
|
55 |
|
|
56 |
public void setInfoFormat(String _format) { |
|
57 |
infoFormat = _format; |
|
58 |
} |
|
59 |
|
|
60 |
public String getSrs() { |
|
61 |
return srs; |
|
62 |
} |
|
63 |
|
|
64 |
public void setSrs(String _srs) { |
|
65 |
srs = _srs; |
|
66 |
} |
|
67 |
|
|
68 |
public void setExceptionFormat(String _format) { |
|
69 |
exceptionFormat = _format; |
|
70 |
} |
|
71 |
|
|
72 |
public String getExceptionFormat() { |
|
73 |
return exceptionFormat; |
|
74 |
} |
|
75 |
|
|
76 |
/** |
|
77 |
* @return the protocol |
|
78 |
*/ |
|
79 |
public int getProtocol() { |
|
80 |
return protocol; |
|
81 |
} |
|
82 |
|
|
83 |
/** |
|
84 |
* @param protocol the protocol to set |
|
85 |
*/ |
|
86 |
public void setProtocol(int protocol) { |
|
87 |
this.protocol = protocol; |
|
88 |
} |
|
89 |
|
|
90 |
} |
|
0 | 91 |
tags/v_2_0_0_Build_2043/libraries/libRemoteServices/src/org/gvsig/remoteclient/RasterClient.java | ||
---|---|---|
1 |
|
|
2 |
package org.gvsig.remoteclient; |
|
3 |
|
|
4 |
/** |
|
5 |
* <p></p> |
|
6 |
* |
|
7 |
*/ |
|
8 |
public abstract class RasterClient extends org.gvsig.remoteclient.RemoteClient implements org.gvsig.remoteclient.IRasterClient { |
|
9 |
} |
|
0 | 10 |
tags/v_2_0_0_Build_2043/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/exceptions/WFSGetFeatureException.java | ||
---|---|---|
1 |
package org.gvsig.remoteclient.wfs.exceptions; |
|
2 |
|
|
3 |
import java.util.HashMap; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
7 |
* |
|
8 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
9 |
* |
|
10 |
* This program is free software; you can redistribute it and/or |
|
11 |
* modify it under the terms of the GNU General Public License |
|
12 |
* as published by the Free Software Foundation; either version 2 |
|
13 |
* of the License, or (at your option) any later version. |
|
14 |
* |
|
15 |
* This program is distributed in the hope that it will be useful, |
|
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
* GNU General Public License for more details. |
|
19 |
* |
|
20 |
* You should have received a copy of the GNU General Public License |
|
21 |
* along with this program; if not, write to the Free Software |
|
22 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
23 |
* |
|
24 |
* For more information, contact: |
|
25 |
* |
|
26 |
* Generalitat Valenciana |
|
27 |
* Conselleria d'Infraestructures i Transport |
|
28 |
* Av. Blasco Ib??ez, 50 |
|
29 |
* 46010 VALENCIA |
|
30 |
* SPAIN |
|
31 |
* |
|
32 |
* +34 963862235 |
|
33 |
* gvsig@gva.es |
|
34 |
* www.gvsig.gva.es |
|
35 |
* |
|
36 |
* or |
|
37 |
* |
|
38 |
* IVER T.I. S.A |
|
39 |
* Salamanca 50 |
|
40 |
* 46005 Valencia |
|
41 |
* Spain |
|
42 |
* |
|
43 |
* +34 963163400 |
|
44 |
* dac@iver.es |
|
45 |
*/ |
|
46 |
/* CVS MESSAGES: |
|
47 |
* |
|
48 |
* $Id$ |
|
49 |
* $Log$ |
|
50 |
* |
|
51 |
*/ |
|
52 |
/** |
|
53 |
* This exception is thrown when there is a problem |
|
54 |
* with the GetFeature operation |
|
55 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
56 |
*/ |
|
57 |
public class WFSGetFeatureException extends WFSException{ |
|
58 |
private static final long serialVersionUID = 1L; |
|
59 |
|
|
60 |
public WFSGetFeatureException(Throwable e){ |
|
61 |
initCause(e); |
|
62 |
initialize(); |
|
63 |
} |
|
64 |
|
|
65 |
/* |
|
66 |
* (non-Javadoc) |
|
67 |
* @see com.iver.gvsig.crstoslr.exceptions.LRSToCRSBaseException#initialize() |
|
68 |
*/ |
|
69 |
protected void initialize() { |
|
70 |
messageKey = "wfs_getFeature_excpetion"; |
|
71 |
formatString = "Exception with the GetFeature operation"; |
|
72 |
code = serialVersionUID; |
|
73 |
} |
|
74 |
|
|
75 |
/* |
|
76 |
* (non-Javadoc) |
|
77 |
* @see org.gvsig.exceptions.BaseException#values() |
|
78 |
*/ |
|
79 |
protected Map values() { |
|
80 |
return new HashMap(); |
|
81 |
} |
|
82 |
} |
tags/v_2_0_0_Build_2043/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/exceptions/InvalidFormatException.java | ||
---|---|---|
1 |
package org.gvsig.remoteclient.wfs.exceptions; |
|
2 |
|
|
3 |
import java.util.Hashtable; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
7 |
* |
|
8 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
9 |
* |
|
10 |
* This program is free software; you can redistribute it and/or |
|
11 |
* modify it under the terms of the GNU General Public License |
|
12 |
* as published by the Free Software Foundation; either version 2 |
|
13 |
* of the License, or (at your option) any later version. |
|
14 |
* |
|
15 |
* This program is distributed in the hope that it will be useful, |
|
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
* GNU General Public License for more details. |
|
19 |
* |
|
20 |
* You should have received a copy of the GNU General Public License |
|
21 |
* along with this program; if not, write to the Free Software |
|
22 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
23 |
* |
|
24 |
* For more information, contact: |
|
25 |
* |
|
26 |
* Generalitat Valenciana |
|
27 |
* Conselleria d'Infraestructures i Transport |
|
28 |
* Av. Blasco Ib??ez, 50 |
|
29 |
* 46010 VALENCIA |
|
30 |
* SPAIN |
|
31 |
* |
|
32 |
* +34 963862235 |
|
33 |
* gvsig@gva.es |
|
34 |
* www.gvsig.gva.es |
|
35 |
* |
|
36 |
* or |
|
37 |
* |
|
38 |
* IVER T.I. S.A |
|
39 |
* Salamanca 50 |
|
40 |
* 46005 Valencia |
|
41 |
* Spain |
|
42 |
* |
|
43 |
* +34 963163400 |
|
44 |
* dac@iver.es |
|
45 |
*/ |
|
46 |
/* CVS MESSAGES: |
|
47 |
* |
|
48 |
* $Id$ |
|
49 |
* $Log$ |
|
50 |
* Revision 1.1 2007-02-09 14:11:01 jorpiell |
|
51 |
* Primer piloto del soporte para WFS 1.1 y para WFS-T |
|
52 |
* |
|
53 |
* |
|
54 |
*/ |
|
55 |
/** |
|
56 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
57 |
*/ |
|
58 |
public class InvalidFormatException extends WFSException { |
|
59 |
private static final long serialVersionUID = 8833249742771533911L; |
|
60 |
private String msg = null; |
|
61 |
|
|
62 |
public InvalidFormatException(String msg) { |
|
63 |
this.msg = msg; |
|
64 |
init(); |
|
65 |
} |
|
66 |
|
|
67 |
protected Map values() { |
|
68 |
Hashtable params; |
|
69 |
params = new Hashtable(); |
|
70 |
return params; |
|
71 |
} |
|
72 |
|
|
73 |
public void init() { |
|
74 |
messageKey = "wfs_invalidFormat"; |
|
75 |
formatString = msg; |
|
76 |
code = serialVersionUID; |
|
77 |
} |
|
78 |
} |
|
0 | 79 |
tags/v_2_0_0_Build_2043/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/exceptions/WFSException.java | ||
---|---|---|
1 |
package org.gvsig.remoteclient.wfs.exceptions; |
|
2 |
|
|
3 |
import java.util.Hashtable; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
7 |
* |
|
8 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
9 |
* |
|
10 |
* This program is free software; you can redistribute it and/or |
|
11 |
* modify it under the terms of the GNU General Public License |
|
12 |
* as published by the Free Software Foundation; either version 2 |
|
13 |
* of the License, or (at your option) any later version. |
|
14 |
* |
|
15 |
* This program is distributed in the hope that it will be useful, |
|
16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
18 |
* GNU General Public License for more details. |
|
19 |
* |
|
20 |
* You should have received a copy of the GNU General Public License |
|
21 |
* along with this program; if not, write to the Free Software |
|
22 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
23 |
* |
|
24 |
* For more information, contact: |
|
25 |
* |
|
26 |
* Generalitat Valenciana |
|
27 |
* Conselleria d'Infraestructures i Transport |
|
28 |
* Av. Blasco Ib??ez, 50 |
|
29 |
* 46010 VALENCIA |
|
30 |
* SPAIN |
|
31 |
* |
|
32 |
* +34 963862235 |
|
33 |
* gvsig@gva.es |
|
34 |
* www.gvsig.gva.es |
|
35 |
* |
|
36 |
* or |
|
37 |
* |
|
38 |
* IVER T.I. S.A |
|
39 |
* Salamanca 50 |
|
40 |
* 46005 Valencia |
|
41 |
* Spain |
|
42 |
* |
|
43 |
* +34 963163400 |
|
44 |
* dac@iver.es |
|
45 |
*/ |
|
46 |
/* CVS MESSAGES: |
|
47 |
* |
|
48 |
* $Id$ |
|
49 |
* $Log$ |
|
50 |
* Revision 1.1 2007-02-09 14:11:01 jorpiell |
|
51 |
* Primer piloto del soporte para WFS 1.1 y para WFS-T |
|
52 |
* |
|
53 |
* |
|
54 |
*/ |
|
55 |
/** |
|
56 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
57 |
*/ |
|
58 |
public class WFSException extends Exception { |
|
59 |
private static final long serialVersionUID = 1476084093500156070L; |
|
60 |
private String wfsCode = null; |
|
61 |
protected String formatString; |
|
62 |
protected String messageKey; |
|
63 |
protected long code; |
|
64 |
|
|
65 |
public WFSException() { |
|
66 |
init(); |
|
67 |
} |
|
68 |
|
|
69 |
public WFSException(Throwable cause) { |
|
70 |
init(); |
|
71 |
initCause(cause); |
|
72 |
} |
|
73 |
|
|
74 |
public WFSException(String wfsCode,String message) { |
|
75 |
init(); |
|
76 |
formatString = message; |
|
77 |
this.wfsCode = wfsCode; |
|
78 |
} |
|
79 |
|
|
80 |
public WFSException(String message) { |
|
81 |
init(); |
|
82 |
formatString = message; |
|
83 |
} |
|
84 |
|
|
85 |
protected Map values() { |
|
86 |
Hashtable params; |
|
87 |
params = new Hashtable(); |
|
88 |
return params; |
|
89 |
} |
|
90 |
|
|
91 |
public void init() { |
|
92 |
messageKey = "wfs_exception"; |
|
93 |
formatString = "WFS Exception"; |
|
94 |
code = serialVersionUID; |
|
95 |
} |
|
96 |
|
|
97 |
/** |
|
98 |
* @return Returns the wfsCode. |
|
99 |
*/ |
|
100 |
public String getWfsCode() { |
|
101 |
return wfsCode; |
|
102 |
} |
|
103 |
} |
|
0 | 104 |
tags/v_2_0_0_Build_2043/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/exceptions/ExceptionsFactory.java | ||
---|---|---|
1 |
package org.gvsig.remoteclient.wfs.exceptions; |
|
2 |
|
|
3 |
import java.io.IOException; |
|
4 |
|
|
5 |
import org.kxml2.io.KXmlParser; |
|
6 |
import org.xmlpull.v1.XmlPullParserException; |
|
7 |
|
|
8 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
|
9 |
|
|
10 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
11 |
* |
|
12 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
13 |
* |
|
14 |
* This program is free software; you can redistribute it and/or |
|
15 |
* modify it under the terms of the GNU General Public License |
|
16 |
* as published by the Free Software Foundation; either version 2 |
|
17 |
* of the License, or (at your option) any later version. |
|
18 |
* |
|
19 |
* This program is distributed in the hope that it will be useful, |
|
20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
22 |
* GNU General Public License for more details. |
|
23 |
* |
|
24 |
* You should have received a copy of the GNU General Public License |
|
25 |
* along with this program; if not, write to the Free Software |
|
26 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
27 |
* |
|
28 |
* For more information, contact: |
|
29 |
* |
|
30 |
* Generalitat Valenciana |
|
31 |
* Conselleria d'Infraestructures i Transport |
|
32 |
* Av. Blasco Ib??ez, 50 |
|
33 |
* 46010 VALENCIA |
|
34 |
* SPAIN |
|
35 |
* |
|
36 |
* +34 963862235 |
|
37 |
* gvsig@gva.es |
|
38 |
* www.gvsig.gva.es |
|
39 |
* |
|
40 |
* or |
|
41 |
* |
|
42 |
* IVER T.I. S.A |
|
43 |
* Salamanca 50 |
|
44 |
* 46005 Valencia |
|
45 |
* Spain |
|
46 |
* |
|
47 |
* +34 963163400 |
|
48 |
* dac@iver.es |
|
49 |
*/ |
|
50 |
/* CVS MESSAGES: |
|
51 |
* |
|
52 |
* $Id$ |
|
53 |
* $Log$ |
|
54 |
* Revision 1.1 2007-02-09 14:11:01 jorpiell |
|
55 |
* Primer piloto del soporte para WFS 1.1 y para WFS-T |
|
56 |
* |
|
57 |
* |
|
58 |
*/ |
|
59 |
/** |
|
60 |
* This class parses an exception and returns it |
|
61 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
62 |
*/ |
|
63 |
public class ExceptionsFactory { |
|
64 |
|
|
65 |
public static WFSException parseServiceExceptionReport(KXmlParser parser) throws XmlPullParserException, IOException { |
|
66 |
int currentTag; |
|
67 |
boolean end = false; |
|
68 |
|
|
69 |
currentTag = parser.next(); |
|
70 |
|
|
71 |
while (!end) |
|
72 |
{ |
|
73 |
switch(currentTag) |
|
74 |
{ |
|
75 |
case KXmlParser.START_TAG: |
|
76 |
if (parser.getName().compareToIgnoreCase(CapabilitiesTags.SERVICE_EXCEPTION)==0) |
|
77 |
{ |
|
78 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
|
79 |
String attName = parser.getAttributeName(i); |
|
80 |
String code = null; |
|
81 |
if (attName.compareTo(CapabilitiesTags.CODE)==0){ |
|
82 |
code = parser.getAttributeValue(i); |
|
83 |
} |
|
84 |
if (code != null){ |
|
85 |
if (code.compareTo(CapabilitiesTags.INVALID_FORMAT)==0){ |
|
86 |
parser.next(); |
|
87 |
return new InvalidFormatException(parser.getText()); |
|
88 |
} |
|
89 |
//Code unspecified |
|
90 |
parser.next(); |
|
91 |
return new WFSException(code,parser.getText()); |
|
92 |
} |
|
93 |
} |
|
94 |
} |
|
95 |
break; |
|
96 |
case KXmlParser.END_TAG: |
|
97 |
if (parser.getName().compareTo(CapabilitiesTags.SERVICE_EXCEPTION_REPORT) == 0) |
|
98 |
end = true; |
|
99 |
break; |
|
100 |
case KXmlParser.TEXT: |
|
101 |
break; |
|
102 |
} |
|
103 |
if (!end){ |
|
104 |
currentTag = parser.next(); |
|
105 |
} |
|
106 |
} |
|
107 |
return new WFSException(); |
|
108 |
} |
|
109 |
|
|
110 |
public static WFSException parseExceptionReport(KXmlParser parser) throws XmlPullParserException, IOException { |
|
111 |
int currentTag; |
|
112 |
boolean end = false; |
|
113 |
|
|
114 |
currentTag = parser.next(); |
|
115 |
|
|
116 |
String code = null; |
|
117 |
|
|
118 |
while (!end) |
|
119 |
{ |
|
120 |
switch(currentTag) |
|
121 |
{ |
|
122 |
case KXmlParser.START_TAG: |
|
123 |
if (CapabilitiesTags.EXCEPTION.equals(parser.getName())) |
|
124 |
{ |
|
125 |
for (int i=0 ; i<parser.getAttributeCount() ; i++){ |
|
126 |
String attName = parser.getAttributeName(i); |
|
127 |
if (CapabilitiesTags.EXCEPTION_CODE.equals(attName)){ |
|
128 |
code = parser.getAttributeValue(i); |
|
129 |
} |
|
130 |
} |
|
131 |
} else if (CapabilitiesTags.EXCEPTION_TEXT.equals(parser.getName())){ |
|
132 |
parser.next(); |
|
133 |
return new WFSException(code, parser.getText()); |
|
134 |
} |
|
135 |
break; |
|
136 |
case KXmlParser.END_TAG: |
|
137 |
if (CapabilitiesTags.EXCEPTION_REPORT.equals(parser.getName())) |
|
138 |
end = true; |
|
139 |
break; |
|
140 |
case KXmlParser.TEXT: |
|
141 |
break; |
|
142 |
} |
|
143 |
if (!end){ |
|
144 |
currentTag = parser.next(); |
|
145 |
} |
|
146 |
} |
|
147 |
return new WFSException(); |
|
148 |
} |
|
149 |
} |
|
0 | 150 |
tags/v_2_0_0_Build_2043/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/WFSStatus.java | ||
---|---|---|
1 |
package org.gvsig.remoteclient.wfs; |
|
2 |
|
|
3 |
import java.awt.geom.Rectangle2D; |
|
4 |
import java.util.ArrayList; |
|
5 |
|
|
6 |
import org.gvsig.compat.CompatLocator; |
|
7 |
import org.gvsig.compat.lang.StringUtils; |
|
8 |
import org.gvsig.fmap.geom.Geometry; |
|
9 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
10 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
11 |
import org.gvsig.fmap.geom.GeometryManager; |
|
12 |
import org.gvsig.fmap.geom.exception.CreateGeometryException; |
|
13 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
14 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
|
15 |
import org.gvsig.remoteclient.RemoteClientStatus; |
|
16 |
import org.gvsig.remoteclient.wfs.edition.WFSTTransaction; |
|
17 |
import org.gvsig.remoteclient.wfs.filters.AbstractFilter; |
|
18 |
import org.gvsig.remoteclient.wfs.filters.filterencoding.FilterEncoding; |
|
19 |
import org.gvsig.remoteclient.wfs.filters.operations.WFSEnvelopeFilterOperation; |
|
20 |
import org.gvsig.remoteclient.wfs.filters.operations.WFSGeometryFilterOperation; |
|
21 |
import org.gvsig.remoteclient.wfs.filters.operations.WFSSpatialFilterOperation; |
|
22 |
|
|
23 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
24 |
* |
|
25 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
26 |
* |
|
27 |
* This program is free software; you can redistribute it and/or |
|
28 |
* modify it under the terms of the GNU General Public License |
|
29 |
* as published by the Free Software Foundation; either version 2 |
|
30 |
* of the License, or (at your option) any later version. |
|
31 |
* |
|
32 |
* This program is distributed in the hope that it will be useful, |
|
33 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
34 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
35 |
* GNU General Public License for more details. |
|
36 |
* |
|
37 |
* You should have received a copy of the GNU General Public License |
|
38 |
* along with this program; if not, write to the Free Software |
|
39 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
40 |
* |
|
41 |
* For more information, contact: |
|
42 |
* |
|
43 |
* Generalitat Valenciana |
|
44 |
* Conselleria d'Infraestructures i Transport |
|
45 |
* Av. Blasco Ib??ez, 50 |
|
46 |
* 46010 VALENCIA |
|
47 |
* SPAIN |
|
48 |
* |
|
49 |
* +34 963862235 |
|
50 |
* gvsig@gva.es |
|
51 |
* www.gvsig.gva.es |
|
52 |
* |
|
53 |
* or |
|
54 |
* |
|
55 |
* IVER T.I. S.A |
|
56 |
* Salamanca 50 |
|
57 |
* 46005 Valencia |
|
58 |
* Spain |
|
59 |
* |
|
60 |
* +34 963163400 |
|
61 |
* dac@iver.es |
|
62 |
*/ |
|
63 |
/* CVS MESSAGES: |
|
64 |
* |
|
65 |
* $Id$ |
|
66 |
* $Log$ |
|
67 |
* Revision 1.7 2007-09-20 09:30:12 jaume |
|
68 |
* removed unnecessary imports |
|
69 |
* |
|
70 |
* Revision 1.6 2007/02/09 14:11:01 jorpiell |
|
71 |
* Primer piloto del soporte para WFS 1.1 y para WFS-T |
|
72 |
* |
|
73 |
* Revision 1.5 2006/12/11 11:02:24 ppiqueras |
|
74 |
* Corregido bug -> que se mantenga la frase de filtrado |
|
75 |
* |
|
76 |
* Revision 1.4 2006/10/10 12:52:28 jorpiell |
|
77 |
* Soporte para features complejas. |
|
78 |
* |
|
79 |
* Revision 1.3 2006/06/14 07:54:18 jorpiell |
|
80 |
* Se parsea el online resource que antes se ignoraba |
|
81 |
* |
|
82 |
* Revision 1.2 2006/05/23 13:23:13 jorpiell |
|
83 |
* Se ha cambiado el final del bucle de parseado y se tiene en cuenta el online resource |
|
84 |
* |
|
85 |
* Revision 1.1 2006/04/19 12:51:35 jorpiell |
|
86 |
* A?adidas algunas de las clases del servicio WFS |
|
87 |
* |
|
88 |
* |
|
89 |
*/ |
|
90 |
/** |
|
91 |
* The status of the current WFS connection |
|
92 |
* |
|
93 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
94 |
* @see <a href="http://www.opengeospatial.org/standards/wfs">OpenGIS Web Feature Service (WFS) Implementation Specification</a> |
|
95 |
*/ |
|
96 |
public class WFSStatus extends RemoteClientStatus{ |
|
97 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
98 |
|
|
99 |
/** |
|
100 |
* The optional resultType attribute is used to control how |
|
101 |
* a web feature service responds to a GetFeature request. |
|
102 |
* The possible values for the attribute are defined in |
|
103 |
* some constants in this class. |
|
104 |
*/ |
|
105 |
private int resultType = RESULTYPE_RESULTS; |
|
106 |
|
|
107 |
/** |
|
108 |
* The default value results indicates that a web feature |
|
109 |
* service should generate a complete response that |
|
110 |
* contains all the features that satisfy the request. |
|
111 |
*/ |
|
112 |
public static final int RESULTYPE_RESULTS = 0; |
|
113 |
|
|
114 |
/** |
|
115 |
* The value hits indicates that a web feature service should process the |
|
116 |
* GetFeature request and rather than return the entire result set, |
|
117 |
* it should simply indicate the number of feature instance of |
|
118 |
* the requested feature type(s) that satisfy the request. |
|
119 |
*/ |
|
120 |
public static final int RESULTYPE_HITS = 1; |
|
121 |
|
|
122 |
static final String LOCKACTION_ALL = "ALL"; |
|
123 |
static final String LOCKACTION_SOME = "SOME"; |
|
124 |
//WFS attributes |
|
125 |
private String featureName = null; |
|
126 |
private String namespacePrefix = null; |
|
127 |
private String namespaceLocation = null; |
|
128 |
private String[] fields = null; |
|
129 |
private String onlineResource = null; |
|
130 |
private Integer timeout = new Integer(10000); |
|
131 |
private Integer maxFeatures = new Integer(100); |
|
132 |
private String filterByAttribute = null; |
|
133 |
private WFSSpatialFilterOperation filterByArea = null; |
|
134 |
|
|
135 |
|
|
136 |
//Geometry manager |
|
137 |
private static GeometryManager geometryManager = GeometryLocator.getGeometryManager(); |
|
138 |
|
|
139 |
//WFS-T LockFeature attributes |
|
140 |
private String userName = null; |
|
141 |
private String password = null; |
|
142 |
private ArrayList featuresToLock = new ArrayList(); |
|
143 |
private ArrayList featuresToLockPropertieName = new ArrayList(); |
|
144 |
private ArrayList featuresToLockPropertieValue = new ArrayList(); |
|
145 |
private ArrayList featuresLocked = new ArrayList(); |
|
146 |
private int expiry = -1; |
|
147 |
private String lockAction = null; |
|
148 |
private Rectangle2D lockedArea = null; |
|
149 |
private String lockedAreaProperty = null; |
|
150 |
|
|
151 |
//WFS-T Transaction |
|
152 |
private WFSTTransaction transaction = null; |
|
153 |
|
|
154 |
public WFSStatus(String featureName){ |
|
155 |
this(featureName, null); |
|
156 |
} |
|
157 |
|
|
158 |
public WFSStatus(String featureName, String namespace){ |
|
159 |
this.featureName = featureName; |
|
160 |
this.namespaceLocation = namespace; |
|
161 |
setFeatureName(featureName); |
|
162 |
lockAction = LOCKACTION_ALL; |
|
163 |
featuresLocked = new ArrayList(); |
|
164 |
featuresLocked = new ArrayList(); |
|
165 |
featuresToLockPropertieName = new ArrayList(); |
|
166 |
featuresToLockPropertieValue = new ArrayList(); |
|
167 |
} |
|
168 |
|
|
169 |
/** |
|
170 |
* @return Returns the buffer. |
|
171 |
*/ |
|
172 |
public Integer getMaxFeatures() { |
|
173 |
return maxFeatures; |
|
174 |
} |
|
175 |
|
|
176 |
|
|
177 |
/** |
|
178 |
* @param buffer The buffer to set. |
|
179 |
*/ |
|
180 |
public void setMaxFeatures(Integer buffer) { |
|
181 |
if (buffer != null){ |
|
182 |
this.maxFeatures = buffer; |
|
183 |
} |
|
184 |
} |
|
185 |
|
|
186 |
|
|
187 |
/** |
|
188 |
* @return Returns the featureName. |
|
189 |
*/ |
|
190 |
public String getFeatureName() { |
|
191 |
return featureName; |
|
192 |
} |
|
193 |
|
|
194 |
public String getFeatureFullName(){ |
|
195 |
if (namespacePrefix == null){ |
|
196 |
return featureName; |
|
197 |
}else{ |
|
198 |
return namespacePrefix + ":" + featureName; |
|
199 |
} |
|
200 |
} |
|
201 |
|
|
202 |
|
|
203 |
/** |
|
204 |
* @param featureName The featureName to set. |
|
205 |
*/ |
|
206 |
public void setFeatureName(String featureName) { |
|
207 |
if (featureName != null){ |
|
208 |
int index = featureName.indexOf(":"); |
|
209 |
if (index>0){ |
|
210 |
this.featureName = featureName.substring(index+1, featureName.length()); |
|
211 |
namespacePrefix = featureName.substring(0, index); |
|
212 |
}else{ |
|
213 |
this.featureName = featureName; |
|
214 |
} |
|
215 |
} |
|
216 |
} |
|
217 |
|
|
218 |
/** |
|
219 |
* @return Returns the fields. |
|
220 |
*/ |
|
221 |
public String[] getFields() { |
|
222 |
if (fields == null){ |
|
223 |
fields = new String[0]; |
|
224 |
} |
|
225 |
return fields; |
|
226 |
} |
|
227 |
|
|
228 |
|
|
229 |
/** |
|
230 |
* @param fields The fields to set. |
|
231 |
*/ |
|
232 |
public void setFields(String[] fields) { |
|
233 |
this.fields = fields; |
|
234 |
} |
|
235 |
|
|
236 |
public void setFields(String fields) { |
|
237 |
if (fields == null){ |
|
238 |
return; |
|
239 |
} |
|
240 |
this.fields = stringUtils.split(fields, ","); |
|
241 |
} |
|
242 |
|
|
243 |
|
|
244 |
/** |
|
245 |
* @return Returns the password. |
|
246 |
*/ |
|
247 |
public String getPassword() { |
|
248 |
return password; |
|
249 |
} |
|
250 |
|
|
251 |
|
|
252 |
/** |
|
253 |
* @param password The password to set. |
|
254 |
*/ |
|
255 |
public void setPassword(String password) { |
|
256 |
this.password = password; |
|
257 |
} |
|
258 |
|
|
259 |
|
|
260 |
/** |
|
261 |
* @return Returns the timeout. |
|
262 |
*/ |
|
263 |
public Integer getTimeout() { |
|
264 |
return timeout; |
|
265 |
} |
|
266 |
|
|
267 |
|
|
268 |
/** |
|
269 |
* @param timeout The timeout to set. |
|
270 |
*/ |
|
271 |
public void setTimeout(Integer timeout) { |
|
272 |
if (timeout != null){ |
|
273 |
this.timeout = timeout; |
|
274 |
} |
|
275 |
} |
|
276 |
|
|
277 |
|
|
278 |
/** |
|
279 |
* @return Returns the userName. |
|
280 |
*/ |
|
281 |
public String getUserName() { |
|
282 |
return userName; |
|
283 |
} |
|
284 |
|
|
285 |
|
|
286 |
/** |
|
287 |
* @param userName The userName to set. |
|
288 |
*/ |
|
289 |
public void setUserName(String userName) { |
|
290 |
this.userName = userName; |
|
291 |
} |
|
292 |
|
|
293 |
public String getOnlineResource() { |
|
294 |
return onlineResource; |
|
295 |
} |
|
296 |
|
|
297 |
|
|
298 |
public void setOnlineResource(String url) { |
|
299 |
onlineResource = url; |
|
300 |
} |
|
301 |
|
|
302 |
/** |
|
303 |
* @return Returns the filterQuery. |
|
304 |
*/ |
|
305 |
public String getFilterByAttribute() { |
|
306 |
return filterByAttribute; |
|
307 |
} |
|
308 |
|
|
309 |
/** |
|
310 |
* @param filterQuery The filterQuery to set. |
|
311 |
*/ |
|
312 |
public void setFilterByAttribute(String filterQuery) { |
|
313 |
this.filterByAttribute = filterQuery; |
|
314 |
} |
|
315 |
|
|
316 |
/** |
|
317 |
* @param filterByArea |
|
318 |
* the filterByArea to set |
|
319 |
* @param operation |
|
320 |
* The geometric operation to apply. It has to be a value from |
|
321 |
* {@link AbstractFilter} |
|
322 |
*/ |
|
323 |
public void setFilterByArea(Geometry geometry, String attributeName, String srs, Integer operation) { |
|
324 |
if (geometry == null){ |
|
325 |
return; |
|
326 |
} |
|
327 |
if (attributeName == null){ |
|
328 |
attributeName = "the_geom"; |
|
329 |
} |
|
330 |
if (operation == null){ |
|
331 |
operation = new Integer(AbstractFilter.GEOMETRIC_OPERATOR_INTERSECT); |
|
332 |
} |
|
333 |
//TODO add a manager to register this |
|
334 |
this.filterByArea = new WFSGeometryFilterOperation(geometry, |
|
335 |
operation.intValue(), |
|
336 |
attributeName, |
|
337 |
getNamespacePrefix(), |
|
338 |
getNamespaceLocation(), |
|
339 |
srs); |
|
340 |
} |
|
341 |
|
|
342 |
public void removeFilterByArea(){ |
|
343 |
this.filterByArea = null; |
|
344 |
} |
|
345 |
|
|
346 |
public void removeFilterByAttribute(){ |
|
347 |
this.filterByAttribute = null; |
|
348 |
} |
|
349 |
|
|
350 |
public void removeAllFilters(){ |
|
351 |
removeFilterByArea(); |
|
352 |
removeFilterByAttribute(); |
|
353 |
} |
|
354 |
|
|
355 |
/** |
|
356 |
* @param filterByArea |
|
357 |
* the filterByArea to set |
|
358 |
* @param operation |
|
359 |
* The geometric operation to apply. It has to be a value from |
|
360 |
* {@link AbstractFilter} |
|
361 |
*/ |
|
362 |
public void setFilterByArea(Envelope envelope, String attributeName, String srs, Integer operation) { |
|
363 |
if (envelope == null){ |
|
364 |
return; |
|
365 |
} |
|
366 |
if (attributeName == null){ |
|
367 |
attributeName = "the_geom"; |
|
368 |
} |
|
369 |
if (operation == null){ |
|
370 |
operation = new Integer(AbstractFilter.GEOMETRIC_OPERATOR_INTERSECT); |
|
371 |
} |
|
372 |
this.filterByArea = new WFSEnvelopeFilterOperation(envelope, |
|
373 |
operation.intValue(), |
|
374 |
attributeName, |
|
375 |
getNamespacePrefix(), |
|
376 |
getNamespaceLocation(), |
|
377 |
srs); |
|
378 |
} |
|
379 |
|
|
380 |
/** |
|
381 |
* @return the filterByArea |
|
382 |
*/ |
|
383 |
public WFSSpatialFilterOperation getFilterByArea() { |
|
384 |
return filterByArea; |
|
385 |
} |
|
386 |
|
|
387 |
/** |
|
388 |
* @return the filterQueryLocked |
|
389 |
*/ |
|
390 |
public String getFilterQueryLocked() { |
|
391 |
FilterEncoding filter = new FilterEncoding(this); |
|
392 |
filter.setQualified(true); |
|
393 |
filter.setNamepacePrefix(null); |
|
394 |
filter.setHasBlankSpaces(false); |
|
395 |
return getFilterQueryLocked(filter); |
|
396 |
} |
|
397 |
|
|
398 |
/** |
|
399 |
* @return the filterQueryLocked |
|
400 |
*/ |
|
401 |
public String getFilterQueryLockedPost() { |
|
402 |
FilterEncoding filter = new FilterEncoding(this); |
|
403 |
filter.setQualified(true); |
|
404 |
return getFilterQueryLocked(filter); |
|
405 |
} |
|
406 |
|
|
407 |
/** |
|
408 |
* Create a filter encoding request |
|
409 |
* @param filter |
|
410 |
* @return |
|
411 |
*/ |
|
412 |
private String getFilterQueryLocked(FilterEncoding filter){ |
|
413 |
if ((featuresToLock.size() == 0) && |
|
414 |
(getLockedArea() == null) && |
|
415 |
(featuresToLockPropertieName.size() == 0)){ |
|
416 |
return null; |
|
417 |
} |
|
418 |
for (int i=0 ; i<featuresToLock.size() ; i++){ |
|
419 |
filter.addFeatureById(featuresToLock.get(i)); |
|
420 |
} |
|
421 |
if (featuresToLockPropertieName.size() > 0){ |
|
422 |
for (int i=0 ; i<featuresToLockPropertieName.size() ; i++){ |
|
423 |
filter.addAndClause((String)featuresToLockPropertieName.get(i), |
|
424 |
(String)featuresToLockPropertieValue.get(i)); |
|
425 |
} |
|
426 |
} |
|
427 |
if (lockedArea != null){ |
|
428 |
GeneralPathX generalPath = new GeneralPathX(); |
|
429 |
generalPath.moveTo(lockedArea.getMinX(), lockedArea.getMinY()); |
|
430 |
generalPath.lineTo(lockedArea.getMaxX(), lockedArea.getMinY()); |
|
431 |
generalPath.lineTo(lockedArea.getMaxX(), lockedArea.getMaxY()); |
|
432 |
generalPath.lineTo(lockedArea.getMinX(), lockedArea.getMaxY()); |
|
433 |
generalPath.lineTo(lockedArea.getMinX(), lockedArea.getMinY()); |
|
434 |
try { |
|
435 |
filter.clearSpatialFilters(); |
|
436 |
filter.addSpatialFilter(geometryManager.createSurface(generalPath, SUBTYPES.GEOM2D), |
|
437 |
lockedAreaProperty, |
|
438 |
getNamespacePrefix(), |
|
439 |
getNamespaceLocation(), |
|
440 |
getSrs(), |
|
441 |
AbstractFilter.BBOX_ENCLOSES); |
|
442 |
} catch (CreateGeometryException e) { |
|
443 |
return null; |
|
444 |
} |
|
445 |
|
|
446 |
} |
|
447 |
return filter.toString(); |
|
448 |
} |
|
449 |
|
|
450 |
/** |
|
451 |
* @return the expiry |
|
452 |
*/ |
|
453 |
public int getExpiry() { |
|
454 |
return expiry; |
|
455 |
} |
|
456 |
|
|
457 |
/** |
|
458 |
* @param expiry the expiry to set |
|
459 |
*/ |
|
460 |
public void setExpiry(int expiry) { |
|
461 |
this.expiry = expiry; |
|
462 |
} |
|
463 |
|
|
464 |
/** |
|
465 |
* @return the lockAction |
|
466 |
*/ |
|
467 |
public String getLockAction() { |
|
468 |
return lockAction; |
|
469 |
} |
|
470 |
|
|
471 |
/** |
|
472 |
* Set the lock action to all |
|
473 |
*/ |
|
474 |
public void setLockActionToAll() { |
|
475 |
lockAction = LOCKACTION_ALL; |
|
476 |
} |
|
477 |
|
|
478 |
/** |
|
479 |
* Set teh lock action to some |
|
480 |
*/ |
|
481 |
public void setLockActionToSome() { |
|
482 |
lockAction = LOCKACTION_SOME; |
|
483 |
} |
|
484 |
|
|
485 |
public WFSTTransaction createNewTransaction(){ |
|
486 |
transaction = new WFSTTransaction(this); |
|
487 |
return transaction; |
|
488 |
} |
|
489 |
|
|
490 |
public WFSTTransaction getTransaction(){ |
|
491 |
return transaction; |
|
492 |
} |
|
493 |
|
|
494 |
/** |
|
495 |
* @return the neumber of features blocked |
|
496 |
*/ |
|
497 |
public int getFeaturesToLockSize() { |
|
498 |
return featuresToLock.size(); |
|
499 |
} |
|
500 |
|
|
501 |
/** |
|
502 |
* Gets an identifier of a feature that is blocked |
|
503 |
* @param i |
|
504 |
* The id position |
|
505 |
* @return |
|
506 |
* The Id |
|
507 |
*/ |
|
508 |
public String getFeatureToLockAt(int i){ |
|
509 |
if (i>featuresToLock.size()){ |
|
510 |
return null; |
|
511 |
} |
|
512 |
return (String)featuresToLock.get(i); |
|
513 |
} |
|
514 |
|
|
515 |
/** |
|
516 |
* Remove all the features to lock |
|
517 |
*/ |
|
518 |
public void removeFeaturesToLock() { |
|
519 |
featuresToLock.clear(); |
|
520 |
featuresLocked.clear(); |
|
521 |
featuresToLockPropertieName.clear(); |
|
522 |
featuresToLockPropertieValue.clear(); |
|
523 |
} |
|
524 |
|
|
525 |
/** |
|
526 |
* Adds a new feature locked |
|
527 |
* @param idFeature |
|
528 |
* the feature id |
|
529 |
*/ |
|
530 |
public void addFeatureToLock(String idFeature) { |
|
531 |
featuresToLock.add(idFeature); |
|
532 |
} |
|
533 |
|
|
534 |
/** |
|
535 |
* Adds a new feature locked |
|
536 |
* @param idFeature |
|
537 |
* the feature id |
|
538 |
*/ |
|
539 |
public void addFeatureToLock(String propertyName, String propertyValue){ |
|
540 |
featuresToLockPropertieName.add(propertyName); |
|
541 |
featuresToLockPropertieValue.add(propertyValue); |
|
542 |
} |
|
543 |
|
|
544 |
/** |
|
545 |
* @return the idsLocked size |
|
546 |
*/ |
|
547 |
public int getFeaturesLocked() { |
|
548 |
return featuresLocked.size(); |
|
549 |
} |
|
550 |
|
|
551 |
/** |
|
552 |
* Gets an identifier tha is blocked |
|
553 |
* @param i |
|
554 |
* The id position |
|
555 |
* @return |
|
556 |
* The Id |
|
557 |
*/ |
|
558 |
public String getFeatureLockedAt(int i){ |
|
559 |
if (i>featuresLocked.size()){ |
|
560 |
return null; |
|
561 |
} |
|
562 |
return (String)featuresLocked.get(i); |
|
563 |
} |
|
564 |
|
|
565 |
/** |
|
566 |
* Adds a new Id |
|
567 |
* @param idLocked |
|
568 |
* the idLocked to add |
|
569 |
*/ |
|
570 |
public void addFeatureLocked(String lockId) { |
|
571 |
featuresLocked.add(lockId); |
|
572 |
} |
|
573 |
|
|
574 |
/** |
|
575 |
* @return the lockedArea |
|
576 |
*/ |
|
577 |
public Rectangle2D getLockedArea() { |
|
578 |
return lockedArea; |
|
579 |
} |
|
580 |
|
|
581 |
/** |
|
582 |
* @param lockedArea the lockedArea to set |
|
583 |
*/ |
|
584 |
public void setLockedArea(Rectangle2D lockedArea, String lockedAreaProperty) { |
|
585 |
this.lockedArea = lockedArea; |
|
586 |
this.lockedAreaProperty = lockedAreaProperty; |
|
587 |
} |
|
588 |
|
|
589 |
/** |
|
590 |
* @return the namespace prefix |
|
591 |
*/ |
|
592 |
public String getNamespacePrefix(){ |
|
593 |
return namespacePrefix; |
|
594 |
} |
|
595 |
|
|
596 |
/** |
|
597 |
* @return the namespace URL |
|
598 |
*/ |
|
599 |
public String getNamespaceLocation(){ |
|
600 |
return namespaceLocation; |
|
601 |
} |
|
602 |
|
|
603 |
/** |
|
604 |
* @param namespaceprefix the namespaceprefix to set |
|
605 |
*/ |
|
606 |
public void setNamespacePrefix(String namespacePrefix) { |
|
607 |
this.namespacePrefix = namespacePrefix; |
|
608 |
} |
|
609 |
|
|
610 |
/** |
|
611 |
* @param namespace the namespace to set |
|
612 |
*/ |
|
613 |
public void setNamespaceLocation(String namespaceLocation) { |
|
614 |
this.namespaceLocation = namespaceLocation; |
|
615 |
} |
|
616 |
|
|
617 |
/** |
|
618 |
* @return the resultType |
|
619 |
*/ |
|
620 |
public int getResultType() { |
|
621 |
return resultType; |
|
622 |
} |
|
623 |
|
|
624 |
/** |
|
625 |
* @param resultType the resultType to set |
|
626 |
*/ |
|
627 |
public void setResultType(int resultType) { |
|
628 |
this.resultType = resultType; |
|
629 |
} |
|
630 |
} |
|
0 | 631 |
tags/v_2_0_0_Build_2043/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/WFSProtocolHandlerFactory.java | ||
---|---|---|
1 |
package org.gvsig.remoteclient.wfs; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.io.FileReader; |
|
5 |
import java.io.IOException; |
|
6 |
import java.io.Reader; |
|
7 |
import java.net.ConnectException; |
|
8 |
import java.net.URL; |
|
9 |
import java.util.ArrayList; |
|
10 |
import java.util.Iterator; |
|
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; |
|
17 |
import org.gvsig.remoteclient.utils.CapabilitiesTags; |
|
18 |
import org.gvsig.remoteclient.utils.EncodingXMLParser; |
|
19 |
import org.gvsig.remoteclient.utils.Utilities; |
|
20 |
|
|
21 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
22 |
* |
|
23 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
24 |
* |
|
25 |
* This program is free software; you can redistribute it and/or |
|
26 |
* modify it under the terms of the GNU General Public License |
|
27 |
* as published by the Free Software Foundation; either version 2 |
|
28 |
* of the License, or (at your option) any later version. |
|
29 |
* |
|
30 |
* This program is distributed in the hope that it will be useful, |
|
31 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
32 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
33 |
* GNU General Public License for more details. |
|
34 |
* |
|
35 |
* You should have received a copy of the GNU General Public License |
|
36 |
* along with this program; if not, write to the Free Software |
|
37 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
38 |
* |
|
39 |
* For more information, contact: |
|
40 |
* |
|
41 |
* Generalitat Valenciana |
|
42 |
* Conselleria d'Infraestructures i Transport |
|
43 |
* Av. Blasco Ib??ez, 50 |
|
44 |
* 46010 VALENCIA |
|
45 |
* SPAIN |
|
46 |
* |
|
47 |
* +34 963862235 |
|
48 |
* gvsig@gva.es |
|
49 |
* www.gvsig.gva.es |
|
50 |
* |
|
51 |
* or |
|
52 |
* |
|
53 |
* IVER T.I. S.A |
|
54 |
* Salamanca 50 |
|
55 |
* 46005 Valencia |
|
56 |
* Spain |
|
57 |
* |
|
58 |
* +34 963163400 |
|
59 |
* dac@iver.es |
|
60 |
*/ |
|
61 |
/* CVS MESSAGES: |
|
62 |
* |
|
63 |
* $Id$ |
|
64 |
* $Log$ |
|
65 |
* Revision 1.2 2007-02-09 14:11:01 jorpiell |
|
66 |
* Primer piloto del soporte para WFS 1.1 y para WFS-T |
|
67 |
* |
|
68 |
* Revision 1.1 2006/04/19 12:51:35 jorpiell |
|
69 |
* A?adidas algunas de las clases del servicio WFS |
|
70 |
* |
|
71 |
* |
|
72 |
*/ |
|
73 |
/** |
|
74 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
75 |
*/ |
|
76 |
public class WFSProtocolHandlerFactory { |
|
77 |
public WFSProtocolHandler wFSProtocolHandler; |
|
78 |
private static final StringUtils stringUtils = CompatLocator.getStringUtils(); |
|
79 |
private static ArrayList supportedVersions = new ArrayList(); |
|
80 |
|
|
81 |
static { |
|
82 |
supportedVersions.add("1.0.0"); |
|
83 |
supportedVersions.add("1.1.0"); |
|
84 |
} |
|
85 |
|
|
86 |
/** |
|
87 |
* M?todo que dada una respuesta de getCapabilities y un iterador sobre una |
|
88 |
* coleccion de WFSClient's ordenada descendentemente devuelve el cliente |
|
89 |
* cuya version es igual o inmediatamente inferior |
|
90 |
* |
|
91 |
* @param caps Capabilities con la respuesta del servidor |
|
92 |
* @param clients Iterador de conjunto ordenado descendientemente |
|
93 |
* |
|
94 |
* @return cliente cuya version es igual o inmediatamente inferior |
|
95 |
* @throws IllegalAccessException |
|
96 |
* @throws InstantiationException |
|
97 |
* |
|
98 |
*/ |
|
99 |
private static String getDriverVersion(String version, Iterator clients) throws InstantiationException, IllegalAccessException { |
|
100 |
while (clients.hasNext()) { |
|
101 |
String clientVersion = (String)clients.next(); |
|
102 |
int ret = version.compareTo(clientVersion); |
|
103 |
|
|
104 |
if (ret >= 0) { |
|
105 |
return clientVersion; |
|
106 |
} |
|
107 |
} |
|
108 |
return null; |
|
109 |
} |
|
110 |
|
|
111 |
/** |
|
112 |
* Establece la versi?n con la que se comunicar? con el servidor y devuelve |
|
113 |
* el objeto Capabilities obtenido con dicha versi?n |
|
114 |
* |
|
115 |
* @param host maquina con la que se negocia |
|
116 |
* |
|
117 |
* @return instancia de un cliente capaz de negociar con el host que se |
|
118 |
* pasa como par?metro |
|
119 |
*/ |
|
120 |
public static WFSProtocolHandler negotiate(String host) throws ConnectException, IOException { |
|
121 |
|
|
122 |
if (supportedVersions.size() == 0){ |
|
123 |
return null; |
|
124 |
} |
|
125 |
|
|
126 |
try { |
|
127 |
String highestVersionSupportedByServer = getSuitableWFSVersion(host,""); |
|
128 |
if (supportedVersions.contains(highestVersionSupportedByServer)) |
|
129 |
{ |
|
130 |
// we support the highest version supported by the server |
|
131 |
// this is the best case |
|
132 |
return createVersionDriver(highestVersionSupportedByServer); |
|
133 |
} |
|
134 |
else |
|
135 |
{ |
|
136 |
// in case we dont support the highest version from the server |
|
137 |
// we start the negotiation process in which we have to get the higest version |
|
138 |
// the WFS supports and we are able to read. |
|
139 |
Iterator iVersion = supportedVersions.iterator(); |
|
140 |
String wfsVersion; |
|
141 |
String gvSIGVersion; |
|
142 |
|
|
143 |
while (iVersion.hasNext()) { |
|
144 |
gvSIGVersion = (String)iVersion.next(); |
|
145 |
wfsVersion = getSuitableWFSVersion(host,gvSIGVersion); |
|
146 |
//TODO: |
|
147 |
//compare with the version returned by the WMS!!!!! |
|
148 |
// send GetCapabilities and read the version to compare. |
|
149 |
int res = wfsVersion.compareTo(gvSIGVersion); |
|
150 |
|
|
151 |
if (res == 0) { //Si es la misma que nuestra version |
|
152 |
return createVersionDriver(gvSIGVersion); |
|
153 |
} else if (res > 0) { //Si es mayor que nuestra version |
|
154 |
throw new Exception("Server Version too high: " + wfsVersion); |
|
155 |
} else { //Si es menor que nuestra version |
|
156 |
//Obtenemos la primera version menor o igual que tengamos |
|
157 |
String lowerVersion = WFSProtocolHandlerFactory.getDriverVersion(wfsVersion, iVersion); |
|
158 |
|
|
159 |
if (lowerVersion == null) { //Si no hay ninguna |
|
160 |
throw new Exception("Lowest server version is " + wfsVersion); |
|
161 |
} else { |
|
162 |
if (lowerVersion.equals(wfsVersion)) { |
|
163 |
return createVersionDriver(lowerVersion); |
|
164 |
} else { //Si hay una version menor que la que retorno el servidor |
|
165 |
//iV = lower; |
|
166 |
} |
|
167 |
} |
|
168 |
} |
|
169 |
} |
|
170 |
}//case we had to start the negotiation process. |
|
171 |
return null; // if it did not find any suitable version. |
|
172 |
} |
|
173 |
catch(ConnectException conEx) |
|
174 |
{ |
|
175 |
throw conEx; |
|
176 |
} |
|
177 |
catch(IOException ioEx) |
|
178 |
{ |
|
179 |
throw ioEx; |
|
180 |
} |
|
181 |
catch(Exception e) |
|
182 |
{ |
|
183 |
e.printStackTrace(); |
|
184 |
return null; |
|
185 |
} |
|
186 |
} |
|
187 |
|
|
188 |
/** |
|
189 |
* Sends a GetCapabilities to the WFS server to get the version |
|
190 |
* if the version parameter is null, the WFS will return the highest version supported |
|
191 |
* if not it will return the lower highest version than the one requested. |
|
192 |
* @param host |
|
193 |
* @param version |
|
194 |
* @return suitable version supported by the server |
|
195 |
*/ |
|
196 |
private static String getSuitableWFSVersion(String host, String _version) throws ConnectException, IOException { |
|
197 |
String request = WFSProtocolHandler.buildCapabilitiesSuitableVersionRequest(host, _version); |
|
198 |
String version = new String(); |
|
199 |
Reader reader = null; |
|
200 |
try { |
|
201 |
File file = Utilities.downloadFile(new URL(request), "wfs-suitable-version", null); |
|
202 |
|
|
203 |
reader = new FileReader(file); |
|
204 |
EncodingXMLParser kxmlParser = new EncodingXMLParser(); |
|
205 |
kxmlParser.setInput(reader); |
|
206 |
kxmlParser.nextTag(); |
|
207 |
if ( kxmlParser.getEventType() != KXmlParser.END_DOCUMENT ) { |
|
208 |
String tag = kxmlParser.getName(); |
|
209 |
if (stringUtils.split(tag, ":").length == 2){ |
|
210 |
tag = stringUtils.split(tag, ":")[1]; |
|
211 |
} |
|
212 |
if ((tag.compareTo(CapabilitiesTags.WFS_CAPABILITIES_ROOT1_0_0)==0)) { |
|
213 |
version = kxmlParser.getAttributeValue("", CapabilitiesTags.VERSION); |
|
214 |
} |
|
215 |
} |
|
216 |
// do not forget to close the Stream. |
|
217 |
reader.close(); |
|
218 |
return version; |
|
219 |
} catch(ConnectException conEx) { |
|
220 |
throw new ConnectException(conEx.getMessage()); |
|
221 |
} catch(IOException ioEx) { |
|
222 |
throw new IOException(ioEx.getMessage()); |
|
223 |
} catch(XmlPullParserException xmlEx) { |
|
224 |
xmlEx.printStackTrace(); |
|
225 |
return ""; |
|
226 |
} finally { |
|
227 |
if (reader != null) { |
|
228 |
try { |
|
229 |
reader.close(); |
|
230 |
} catch(Exception ex) { |
|
231 |
ex.printStackTrace(); |
|
232 |
} |
|
233 |
} |
|
234 |
} |
|
235 |
} |
|
236 |
|
|
237 |
/** |
|
238 |
* It creates an instance of a WFSDriver class. |
|
239 |
* |
|
240 |
* @param String, with the version of the driver to be created |
|
241 |
* @return WFSDriver. |
|
242 |
*/ |
|
243 |
public static WFSProtocolHandler createVersionDriver(String version) { |
|
244 |
try { |
|
245 |
Class driver; |
|
246 |
version = version.replace('.', '_'); |
|
247 |
driver = Class.forName("org.gvsig.remoteclient.wfs.wfs_"+version+".WFSProtocolHandler" + version); |
|
248 |
return (WFSProtocolHandler)driver.newInstance(); |
|
249 |
} catch (Exception e) { |
|
250 |
e.printStackTrace(); |
|
251 |
//throw new Exception("WFSDriverFactory. Unknown driver version " + e); |
|
252 |
return null; |
|
253 |
} |
|
254 |
} |
|
255 |
|
|
256 |
|
|
257 |
|
|
258 |
} |
|
0 | 259 |
Also available in: Unified diff