Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.downloader / org.gvsig.downloader.lib / org.gvsig.downloader.lib.api / src / main / java / org / gvsig / downloader / DownloaderManager.java @ 47845

History | View | Annotate | Download (4.15 KB)

1 47092 jjdelcerro
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright ? 2007-2023 gvSIG Association
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
25 47821 jjdelcerro
package org.gvsig.downloader;
26 47092 jjdelcerro
27 47833 fdiaz
import java.net.MalformedURLException;
28 47821 jjdelcerro
import java.net.URL;
29
import java.util.Collection;
30 47845 fdiaz
import java.util.List;
31 47833 fdiaz
import org.apache.commons.lang3.StringUtils;
32 47821 jjdelcerro
import org.gvsig.compat.net.Downloader;
33 47092 jjdelcerro
34
/**
35 47821 jjdelcerro
 * Main class that defines the available Downlader services.
36 47092 jjdelcerro
 *
37
 */
38 47821 jjdelcerro
public interface DownloaderManager extends Downloader {
39 47840 jjdelcerro
40
    public static final String METHOD_PUT = "PUT";
41
    public static final String METHOD_POST = "POST";
42
    public static final String METHOD_GET = "GET";
43
    public static final String METHOD_DELETE = "DELETE";
44
45 47833 fdiaz
    /**
46
     * Comprueba si la URL url_s comienza por la URL prefix ignorando el protocolo y la query
47
     *
48
     * @param prefix
49
     * @param url_s
50
     * @return
51
     */
52
    public static boolean urlStartsWith(String url_s, String prefix) {
53
        try {
54
            URL baseUrl = new URL(prefix);
55
            URL url = new URL(url_s);
56
            if(!StringUtils.equals(baseUrl.getHost(), url.getHost())){
57
                return false;
58
            }
59
            if(!StringUtils.startsWith(url.getPath(), baseUrl.getPath())){
60
                return false;
61
            }
62
            return true;
63
        } catch (MalformedURLException ex) {
64
            return StringUtils.startsWith(url_s, prefix);
65
        }
66
    }
67 47092 jjdelcerro
68 47833 fdiaz
    /**
69
     * Compara dos URL ignorando el protocolo y la query
70
     *
71
     * @param url1_s
72
     * @param url2_s
73
     * @return
74
     */
75
    public static boolean areSameURLs(String url1_s, String url2_s) {
76
        try {
77
            URL url1 = new URL(url1_s);
78
            URL url2 = new URL(url2_s);
79
            if(!StringUtils.equals(url1.getHost(), url2.getHost())){
80
                return false;
81
            }
82
            if(!StringUtils.equals(url1.getPath(), url2.getPath())){
83
                return false;
84
            }
85
            return true;
86
        } catch (MalformedURLException ex) {
87
            return StringUtils.equals(url1_s, url2_s);
88
        }
89
    }
90
91
92 47821 jjdelcerro
    public void addOrReplaceCredentials(DownloaderCredentials credentials);
93 47092 jjdelcerro
94 47821 jjdelcerro
    public DownloaderAuthenticationConfig getAuthenticationConfigurationService(String baseUrl);
95
96
    public Collection<DownloaderAuthenticationConfig> getAuthenticationConfigurationServices();
97
98 47828 jjdelcerro
    public DownloaderAuthenticationFactory getDownloaderAuthenticationFactory(String providerName);
99
100 47821 jjdelcerro
    public Collection<DownloaderAuthenticationFactory> getAuthenticationTypes();
101
102
    public Collection<DownloaderCredentials> getCredentials();
103 47347 fdiaz
104 47821 jjdelcerro
    public DownloaderCredentials getCredentials(URL url);
105 47347 fdiaz
106 47828 jjdelcerro
    public DownloaderCredentials getCredentials(String url);
107
108 47821 jjdelcerro
    public void removeCredentials(DownloaderCredentials credentials);
109 47838 fdiaz
110
    public void removeCredentials(String serviceURL);
111 47347 fdiaz
112 47821 jjdelcerro
    public void removeAuthenticationConfigurationService(DownloaderAuthenticationConfig config);
113
114
    public void registerAuthenticationConfigurationService(DownloaderAuthenticationConfig config);
115
116
    public void registerAuthenticationType(DownloaderAuthenticationFactory factory);
117 47841 fdiaz
118
    public void registerAuthenticationConfigurationService(String config);
119
120
    public String getAuthenticationConfigurationServiceAsString(String url);
121 47821 jjdelcerro
122 47845 fdiaz
    public void propagateCredentials(String sourceServiceUrl, Collection<String> targetServicesUrls);
123
124 47092 jjdelcerro
}