Revision 34026 branches/v2_0_0_prep/libraries/libRemoteServices/src/org/gvsig/remoteclient/wfs/WFSClient.java

View differences:

WFSClient.java
5 5
import java.net.ConnectException;
6 6
import java.util.ArrayList;
7 7
import java.util.Hashtable;
8
import java.util.Iterator;
8 9

  
10
import org.slf4j.Logger;
11
import org.slf4j.LoggerFactory;
12

  
9 13
import org.gvsig.compat.net.ICancellable;
10 14
import org.gvsig.remoteclient.RemoteClient;
11 15
import org.gvsig.remoteclient.wfs.exceptions.WFSException;
......
84 88
 */
85 89
public class WFSClient extends RemoteClient{
86 90
	private WFSProtocolHandler handler;
87
		
91
	private Logger LOG = LoggerFactory.getLogger(WFSClient.class);
88 92
	
89 93
	/**
90 94
	 * Constructor.
......
98 102
		try {        	
99 103
			handler = WFSProtocolHandlerFactory.negotiate(host);
100 104
			handler.setHost(host);        
101
		} catch(ConnectException conE) {
102
			conE.printStackTrace();
103
			throw conE; 
104
		} catch(IOException ioE) {
105
			ioE.printStackTrace();
106
			throw ioE; 
107 105
		} catch(Exception e) {
108
			e.printStackTrace();       	
106
		    LOG.error("Error connecting with the server", e);
107
		    throw new ConnectException("Error connecting with the server");   	
109 108
		} 
110 109
	}
111 110
	
......
158 157
	 * WFS client status. Contains all the information to create
159 158
	 * the query
160 159
	 */
161
	public void describeFeatureType(WFSStatus status, boolean override, ICancellable cancel)throws WFSException {
162
		handler.describeFeatureType(status,override,cancel);		
160
	public File describeFeatureType(WFSStatus status, boolean override, ICancellable cancel)throws WFSException {
161
		return handler.describeFeatureType(status,override,cancel);		
163 162
	}
164 163
	
165 164
	/**
......
175 174
	 * GML File
176 175
	 */
177 176
	public File getFeature(WFSStatus status, boolean override, ICancellable cancel) throws WFSException{
178
		return handler.getFeature(status,override,cancel);
177
	    if ((status.getNamespaceLocation() != null) && (status.getNamespacePrefix() == null)){
178
	        String namespacePrefix = getServiceInformation().getNamespacePrefix(status.getNamespaceLocation());
179
	        if (namespacePrefix != null){
180
	            status.setNamespacePrefix(namespacePrefix);
181
	        }
182
        }
183
	    return handler.getFeature(status,override,cancel);
179 184
	}
180 185
	
181 186
	/**
......
292 297
        return handler.getFeatures();  
293 298
    }
294 299
    
300
    public WFSFeature getFeature(String nameSpace, String localName){
301
        Iterator it = handler.getFeatures().keySet().iterator();
302
        String fullName = localName;
303
        String prefix = getServiceInformation().getNamespacePrefix(nameSpace);
304
        if (prefix != null){
305
            fullName = prefix + ":" + localName;
306
        }
307
        while (it.hasNext()){
308
            String featureName = (String)it.next();
309
            if (localName.equals(featureName)){
310
                return (WFSFeature)handler.getFeatures().get(localName);
311
            }
312
            if (fullName.equals(featureName)){
313
                return (WFSFeature)handler.getFeatures().get(fullName);
314
            }
315
        }
316
        return null;
317
    }
318
    
295 319
	/**
296 320
	 * @return the lastWfsRequestInformation
297 321
	 */

Also available in: Unified diff