Revision 47843

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.downloader/org.gvsig.downloader.lib/org.gvsig.downloader.lib.impl/src/main/java/org/gvsig/downloader/lib/impl/DownloaderManagerImpl.java
24 24
package org.gvsig.downloader.lib.impl;
25 25

  
26 26
import java.io.File;
27
import java.io.IOException;
28
import java.net.ConnectException;
27 29
import java.net.URL;
30
import java.net.UnknownHostException;
28 31
import java.util.ArrayList;
29 32
import java.util.Collection;
30 33
import java.util.HashMap;
......
33 36
import java.util.Map;
34 37
import org.apache.commons.lang3.StringUtils;
35 38
import org.apache.http.entity.ContentType;
39
import org.gvsig.compat.net.ICancellable;
36 40
import org.gvsig.compat.se.net.downloader.se.SEDownloader;
37 41
import org.gvsig.downloader.DownloaderAuthenticationConfig;
38 42
import org.gvsig.downloader.DownloaderAuthenticationFactory;
......
231 235
        return this.authenticationTypes.get(providerName.toLowerCase());
232 236
    }
233 237
    
238
    @Override
234 239
    public void registerAuthenticationConfigurationService(String config) {
235 240
        if(StringUtils.isNotBlank(config)) {
236 241
            DownloaderAuthenticationConfig downloaderConfig = (DownloaderAuthenticationConfig) Json.toObject(config);
......
240 245
        }
241 246
    }
242 247

  
248
    @Override
243 249
    public String getAuthenticationConfigurationServiceAsString(String baseUrl) {
244 250
        DownloaderAuthenticationConfig downloaderConfig = this.getAuthenticationConfigurationService(baseUrl);
245 251
        if(downloaderConfig != null){
......
247 253
        }
248 254
        return null;
249 255
    }
256

  
257
    @Override
258
    public synchronized File downloadFile(URL url, String method, ContentType contenttype, String data, String name, ICancellable cancel, int maxbytes) throws IOException, ConnectException, UnknownHostException {
259
//        File target = getPreviousDownloadedURL(url, data);
260
//        if(target != null){
261
//            return target;
262
//        }
263
        File target = new File(name);
264
        if (!target.isAbsolute()){
265
            target = getUniqueTemporaryFile(name);
266
        }
267
        if(cancel == null) {
268
            cancel = ICancellable.DUMB;
269
        }
270
        Runnable task = this.createDownloaderTask(this, url, method, contenttype, data, target, cancel.getID(), maxbytes);
271
        task.run();
272
        
273
        return target;
274
    }
275
    
276
    
250 277
}
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.downloader/org.gvsig.downloader.lib/org.gvsig.downloader.lib.impl/src/main/java/org/gvsig/downloader/lib/impl/SEAuthDownloaderTask.java
1 1
package org.gvsig.downloader.lib.impl;
2 2

  
3
import org.gvsig.downloader.IOExceptionWithStatus;
4 3
import java.io.File;
5 4
import java.io.IOException;
6 5
import java.io.InputStream;
7
import java.io.OutputStreamWriter;
8
import java.net.HttpURLConnection;
9 6
import java.net.SocketTimeoutException;
10 7
import java.net.URL;
11 8
import java.util.Objects;
......
37 34
import org.gvsig.downloader.DownloaderAuthenticationRequester;
38 35
import org.gvsig.downloader.DownloaderCredentials;
39 36
import org.gvsig.downloader.DownloaderManager;
37
import org.gvsig.downloader.IOExceptionWithStatus;
40 38

  
41 39
@SuppressWarnings("UseSpecificCatch")
42 40
final class SEAuthDownloaderTask
......
276 274
                        break;
277 275
                    case DownloaderManager.METHOD_PUT:
278 276
                        request = new HttpPut(theUrl.toURI());
277
                        request.setHeader("Content-type", contentType.toString());
279 278
                        ((HttpPut)request).setEntity(new StringEntity(data, contentType));
280 279
                        break;
281 280
                    case DownloaderManager.METHOD_POST:
282 281
                        request = new HttpPost(theUrl.toURI());
283 282
                        request.setHeader("SOAPAction", "post");                
283
                        request.setHeader("Content-type", contentType.toString());
284 284
                        ((HttpPost)request).setEntity(new StringEntity(data, contentType));
285 285
                        break;
286 286
                    case DownloaderManager.METHOD_GET:
......
291 291
//                request.setHeader("User-Agent","Mozilla/5.0 (gvSIG) like Gecko");
292 292
                request.setHeader("User-Agent","gvSIG-desktop");
293 293
                request.setHeader("Referer","http://www.gvsig.com");
294
                request.setHeader("Content-type", contentType.toString());                
295 294
                DownloaderResponseHandler responseHandler = executeRequest(request);
296 295
                status = responseHandler.getStatus();
297 296
                if(status >= 200 && status < 300) {

Also available in: Unified diff