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 |
/**
|
---|---|
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 |
package org.gvsig.downloader; |
26 |
|
27 |
import java.net.MalformedURLException; |
28 |
import java.net.URL; |
29 |
import java.util.Collection; |
30 |
import java.util.List; |
31 |
import org.apache.commons.lang3.StringUtils; |
32 |
import org.gvsig.compat.net.Downloader; |
33 |
|
34 |
/**
|
35 |
* Main class that defines the available Downlader services.
|
36 |
*
|
37 |
*/
|
38 |
public interface DownloaderManager extends Downloader { |
39 |
|
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 |
/**
|
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 |
|
68 |
/**
|
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 |
public void addOrReplaceCredentials(DownloaderCredentials credentials); |
93 |
|
94 |
public DownloaderAuthenticationConfig getAuthenticationConfigurationService(String baseUrl); |
95 |
|
96 |
public Collection<DownloaderAuthenticationConfig> getAuthenticationConfigurationServices(); |
97 |
|
98 |
public DownloaderAuthenticationFactory getDownloaderAuthenticationFactory(String providerName); |
99 |
|
100 |
public Collection<DownloaderAuthenticationFactory> getAuthenticationTypes(); |
101 |
|
102 |
public Collection<DownloaderCredentials> getCredentials(); |
103 |
|
104 |
public DownloaderCredentials getCredentials(URL url); |
105 |
|
106 |
public DownloaderCredentials getCredentials(String url); |
107 |
|
108 |
public void removeCredentials(DownloaderCredentials credentials); |
109 |
|
110 |
public void removeCredentials(String serviceURL); |
111 |
|
112 |
public void removeAuthenticationConfigurationService(DownloaderAuthenticationConfig config); |
113 |
|
114 |
public void registerAuthenticationConfigurationService(DownloaderAuthenticationConfig config); |
115 |
|
116 |
public void registerAuthenticationType(DownloaderAuthenticationFactory factory); |
117 |
|
118 |
public void registerAuthenticationConfigurationService(String config); |
119 |
|
120 |
public String getAuthenticationConfigurationServiceAsString(String url); |
121 |
|
122 |
public void propagateCredentials(String sourceServiceUrl, Collection<String> targetServicesUrls); |
123 |
|
124 |
} |