Revision 364
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.app/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<parent> |
|
4 |
<groupId>org.gvsig</groupId> |
|
5 |
<artifactId>org.gvsig.downloader</artifactId> |
|
6 |
<version>1.0.70</version> |
|
7 |
</parent> |
|
8 |
<artifactId>org.gvsig.downloader.app</artifactId> |
|
9 |
<packaging>pom</packaging> |
|
10 |
<name>org.gvsig.downloader.app</name> |
|
11 |
<modules> |
|
12 |
<module>org.gvsig.downloader.app.mainplugin</module> |
|
13 |
</modules> |
|
14 |
</project> |
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.app/org.gvsig.downloader.app.mainplugin/buildNumber.properties | ||
---|---|---|
1 |
#Tue Jan 22 11:24:57 CET 2019 |
|
2 |
buildNumber=74 |
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.app/org.gvsig.downloader.app.mainplugin/src/main/resources-plugin/plugin-persistence.def | ||
---|---|---|
1 |
<?xml version="1.0"?> |
|
2 |
<!-- |
|
3 |
Definitions of plugin persistence org.gvsig.downloader.app.mainplugin |
|
4 |
--> |
|
5 |
<definitions> |
|
6 |
<version>1.0.0</version> |
|
7 |
<classes> |
|
8 |
<class name="org.gvsig.downloader.app.mainplugin"> |
|
9 |
<description>Persistence for the downloader plugin</description> |
|
10 |
<fields> |
|
11 |
<field name="authentications" type="List" classOfItems="org.gvsig.downloader.lib.httpclient.HttpClientDownloaderAuthentication" mandatory="false"> |
|
12 |
<description>List of authentications</description> |
|
13 |
</field> |
|
14 |
</fields> |
|
15 |
</class> |
|
16 |
</classes> |
|
17 |
</definitions> |
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.app/org.gvsig.downloader.app.mainplugin/src/main/resources-plugin/i18n/text.properties | ||
---|---|---|
1 |
#Translations for language [es] |
|
2 |
#Thu Nov 20 10:10:09 CET 2014 |
|
3 |
add_authentication=A\u00f1adir autenticaci\u00f3n |
|
4 |
accept=Aceptar |
|
5 |
apply=Aplicar |
|
6 |
cancel=Cancelar |
|
7 |
downloader_authentication_preferences=Preferencias de autenticaci\u00f3n |
|
8 |
edit=Editar |
|
9 |
edit_authentication=Editar autenticaci\u00f3n |
|
10 |
host=Host |
|
11 |
password=Contrase\u00f1a |
|
12 |
preferences=Preferencias |
|
13 |
port=Puerto |
|
14 |
remove=Quitar |
|
15 |
user=Usuario |
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.app/org.gvsig.downloader.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties | ||
---|---|---|
1 |
#Translations for language [en] |
|
2 |
#Thu Nov 20 10:10:15 CET 2014 |
|
3 |
add_authentication=Add authentication |
|
4 |
accept=Accept |
|
5 |
apply=Apply |
|
6 |
cancel=Cancel |
|
7 |
downloader_authentication_preferences=Authentication preferences |
|
8 |
edit=Edit |
|
9 |
edit_authentication=Edit authentication |
|
10 |
host=Host |
|
11 |
password=Password |
|
12 |
preferences=Preferences |
|
13 |
port=Port |
|
14 |
remove=Remove |
|
15 |
user=User |
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.app/org.gvsig.downloader.app.mainplugin/src/main/resources-plugin/config.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<!-- gvSIG. Desktop Geographic Information System. Copyright (C) 2007-2014 gvSIG |
|
3 |
Association. This program is free software; you can redistribute it and/or modify |
|
4 |
it under the terms of the GNU General Public License as published by the Free Software |
|
5 |
Foundation; either version 3 of the License, or (at your option) any later version. |
|
6 |
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
|
7 |
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
8 |
PURPOSE. See the GNU General Public License for more details. You should have received |
|
9 |
a copy of the GNU General Public License along with this program; if not, write to |
|
10 |
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
|
11 |
USA. For any additional information, do not hesitate to contact us at info AT gvsig.com, |
|
12 |
or visit our website www.gvsig.com. --> |
|
13 |
<plugin-config> |
|
14 |
<depends plugin-name="org.gvsig.app.mainplugin" /> |
|
15 |
<resourceBundle name="text" /> |
|
16 |
<libraries library-dir="lib" /> |
|
17 |
<extensions> |
|
18 |
|
|
19 |
|
|
20 |
<extension class-name="org.gvsig.app.mainplugin.extension.DownloaderExtension" |
|
21 |
description="" active="true" priority="1"> |
|
22 |
</extension> |
|
23 |
|
|
24 |
|
|
25 |
</extensions> |
|
26 |
</plugin-config> |
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.app/org.gvsig.downloader.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<!-- |
|
2 |
|
|
3 |
gvSIG. Desktop Geographic Information System. |
|
4 |
|
|
5 |
Copyright (C) 2007-2013 gvSIG Association. |
|
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
|
8 |
modify it under the terms of the GNU General Public License |
|
9 |
as published by the Free Software Foundation; either version 3 |
|
10 |
of the License, or (at your option) any later version. |
|
11 |
|
|
12 |
This program is distributed in the hope that it will be useful, |
|
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15 |
GNU General Public License for more details. |
|
16 |
|
|
17 |
You should have received a copy of the GNU General Public License |
|
18 |
along with this program; if not, write to the Free Software |
|
19 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
20 |
MA 02110-1301, USA. |
|
21 |
|
|
22 |
For any additional information, do not hesitate to contact us |
|
23 |
at info AT gvsig.com, or visit our website www.gvsig.com. |
|
24 |
|
|
25 |
--> |
|
26 |
<assembly> |
|
27 |
<id>gvsig-plugin-package</id> |
|
28 |
<formats> |
|
29 |
<format>zip</format> |
|
30 |
</formats> |
|
31 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
32 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
33 |
<files> |
|
34 |
<file> |
|
35 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
36 |
<outputDirectory>lib</outputDirectory> |
|
37 |
</file> |
|
38 |
<file> |
|
39 |
<source>target/package.info</source> |
|
40 |
</file> |
|
41 |
</files> |
|
42 |
|
|
43 |
<fileSets> |
|
44 |
<fileSet> |
|
45 |
<directory>src/main/resources-plugin</directory> |
|
46 |
<outputDirectory>.</outputDirectory> |
|
47 |
</fileSet> |
|
48 |
</fileSets> |
|
49 |
|
|
50 |
|
|
51 |
<dependencySets> |
|
52 |
<dependencySet> |
|
53 |
<useProjectArtifact>false</useProjectArtifact> |
|
54 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
55 |
<outputDirectory>lib</outputDirectory> |
|
56 |
<includes> |
|
57 |
<include>org.gvsig:org.gvsig.downloader.lib.api</include> |
|
58 |
<include>org.gvsig:org.gvsig.downloader.swing.api</include> |
|
59 |
<include>org.gvsig:org.gvsig.downloader.lib.httpclient</include> |
|
60 |
<include>org.gvsig:org.gvsig.downloader.swing.impl</include> |
|
61 |
<include>org.apache.httpcomponents:httpclient</include> |
|
62 |
</includes> |
|
63 |
</dependencySet> |
|
64 |
</dependencySets> |
|
65 |
|
|
66 |
</assembly> |
|
67 |
|
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.app/org.gvsig.downloader.app.mainplugin/src/main/java/org/gvsig/app/mainplugin/extension/DownloaderAuthenticationPreferencePage.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2014 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 3 |
|
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 |
package org.gvsig.app.mainplugin.extension; |
|
25 |
|
|
26 |
import java.util.ArrayList; |
|
27 |
import java.util.List; |
|
28 |
|
|
29 |
import javax.swing.ImageIcon; |
|
30 |
import javax.swing.JPanel; |
|
31 |
|
|
32 |
import org.gvsig.andami.IconThemeHelper; |
|
33 |
import org.gvsig.andami.PluginServices; |
|
34 |
import org.gvsig.andami.PluginsLocator; |
|
35 |
import org.gvsig.andami.preferences.AbstractPreferencePage; |
|
36 |
import org.gvsig.andami.preferences.StoreException; |
|
37 |
import org.gvsig.downloader.lib.api.DownloaderAuthentication; |
|
38 |
import org.gvsig.downloader.lib.api.DownloaderLocator; |
|
39 |
import org.gvsig.downloader.lib.api.DownloaderManager; |
|
40 |
import org.gvsig.downloader.swing.api.DownloaderAuthenticationsPanel; |
|
41 |
import org.gvsig.downloader.swing.api.DownloaderSwingLocator; |
|
42 |
import org.gvsig.tools.dynobject.DynObject; |
|
43 |
|
|
44 |
/** |
|
45 |
* @author paco |
|
46 |
* |
|
47 |
*/ |
|
48 |
public class DownloaderAuthenticationPreferencePage extends |
|
49 |
AbstractPreferencePage { |
|
50 |
|
|
51 |
/** |
|
52 |
* |
|
53 |
*/ |
|
54 |
private static final long serialVersionUID = -5679710171255385559L; |
|
55 |
protected String id; |
|
56 |
private DownloaderManager downloaderManager = null; |
|
57 |
private List<DownloaderAuthentication> authentications; |
|
58 |
private DownloaderAuthenticationsPanel authenticationsPanel; |
|
59 |
|
|
60 |
public DownloaderAuthenticationPreferencePage() { |
|
61 |
super(); |
|
62 |
id = this.getClass().getName(); |
|
63 |
this.downloaderManager = DownloaderLocator.getDownloaderManager(); |
|
64 |
authenticationsPanel = getAuthenticationsPanel(); |
|
65 |
addComponent(authenticationsPanel.asJComponent()); |
|
66 |
|
|
67 |
} |
|
68 |
|
|
69 |
public String getID() { |
|
70 |
return id; |
|
71 |
} |
|
72 |
|
|
73 |
public ImageIcon getIcon() { |
|
74 |
return IconThemeHelper |
|
75 |
.getImageIcon("downloader-authentication-preferences"); |
|
76 |
|
|
77 |
} |
|
78 |
|
|
79 |
private DownloaderAuthenticationsPanel getAuthenticationsPanel() { |
|
80 |
if (authenticationsPanel == null) { |
|
81 |
authenticationsPanel = DownloaderSwingLocator.getSwingManager() |
|
82 |
.createAuthenticationsPanel(authentications); |
|
83 |
} |
|
84 |
return authenticationsPanel; |
|
85 |
|
|
86 |
} |
|
87 |
|
|
88 |
public JPanel getPanel() { |
|
89 |
return (JPanel) getAuthenticationsPanel().asJComponent(); |
|
90 |
} |
|
91 |
|
|
92 |
public String getTitle() { |
|
93 |
return PluginServices.getText(this, |
|
94 |
"downloader_authentication_preferences"); |
|
95 |
} |
|
96 |
|
|
97 |
public void initializeDefaults() { |
|
98 |
authentications = downloaderManager.getAuthentications(); |
|
99 |
} |
|
100 |
|
|
101 |
@SuppressWarnings("unchecked") |
|
102 |
public void initializeValues() { |
|
103 |
PluginServices ps = PluginServices.getPluginServices(this); |
|
104 |
DynObject props = ps.getPluginProperties(); |
|
105 |
|
|
106 |
// first defaults, then stored if not null |
|
107 |
initializeDefaults(); |
|
108 |
|
|
109 |
authentications = ((List<DownloaderAuthentication>) props.getDynValue("authentications")); |
|
110 |
if (authentications == null){ |
|
111 |
authentications = new ArrayList<DownloaderAuthentication>(); |
|
112 |
} |
|
113 |
getAuthenticationsPanel().setAuthentications(authentications); |
|
114 |
|
|
115 |
} |
|
116 |
|
|
117 |
public boolean isValueChanged() { |
|
118 |
return super.hasChanged(); |
|
119 |
} |
|
120 |
|
|
121 |
@Override |
|
122 |
public void setChangesApplied() { |
|
123 |
setChanged(false); |
|
124 |
} |
|
125 |
|
|
126 |
@Override |
|
127 |
public void storeValues() throws StoreException { |
|
128 |
|
|
129 |
DynObject preferences = PluginsLocator.getManager() |
|
130 |
.getPlugin("org.gvsig.downloader.app.mainplugin") |
|
131 |
.getPluginProperties(); |
|
132 |
preferences.setDynValue("authentications", authentications); |
|
133 |
} |
|
134 |
|
|
135 |
/** |
|
136 |
* Devuelve true si el Panel debe estar en un BorderLayout centrado o false |
|
137 |
* si tiene un tama?o fijo. |
|
138 |
* |
|
139 |
* @return |
|
140 |
*/ |
|
141 |
public boolean isResizeable() { |
|
142 |
return true; |
|
143 |
} |
|
144 |
|
|
145 |
} |
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.app/org.gvsig.downloader.app.mainplugin/src/main/java/org/gvsig/app/mainplugin/extension/DownloaderExtension.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2014 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 3 |
|
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 |
package org.gvsig.app.mainplugin.extension; |
|
25 |
|
|
26 |
import java.util.List; |
|
27 |
|
|
28 |
import org.gvsig.andami.IconThemeHelper; |
|
29 |
import org.gvsig.andami.plugins.Extension; |
|
30 |
import org.gvsig.downloader.lib.api.DownloaderAuthentication; |
|
31 |
import org.gvsig.downloader.lib.api.DownloaderLocator; |
|
32 |
import org.gvsig.tools.ToolsLocator; |
|
33 |
import org.gvsig.tools.dynobject.DynObject; |
|
34 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
|
35 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
|
36 |
|
|
37 |
/** |
|
38 |
* @author paco |
|
39 |
* |
|
40 |
*/ |
|
41 |
public class DownloaderExtension extends Extension { |
|
42 |
|
|
43 |
/* (non-Javadoc) |
|
44 |
* @see org.gvsig.andami.plugins.IExtension#initialize() |
|
45 |
*/ |
|
46 |
public void initialize() { |
|
47 |
|
|
48 |
ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
|
49 |
ExtensionPoint ep = extensionPoints.add("AplicationPreferences", ""); |
|
50 |
|
|
51 |
ep.append("DownloaderAuthenticationPreferencePage", "", new DownloaderAuthenticationPreferencePage()); |
|
52 |
|
|
53 |
IconThemeHelper.registerIcon("preferences", "downloader-authentication-preferences", this); |
|
54 |
|
|
55 |
DynObject properties = getPlugin().getPluginProperties(); |
|
56 |
@SuppressWarnings("unchecked") |
|
57 |
List<DownloaderAuthentication> authentications = (List<DownloaderAuthentication>) properties.getDynValue("authentications"); |
|
58 |
DownloaderLocator.getDownloaderManager().setAuthentications(authentications); |
|
59 |
} |
|
60 |
|
|
61 |
/* (non-Javadoc) |
|
62 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String) |
|
63 |
*/ |
|
64 |
public void execute(String actionCommand) { |
|
65 |
// TODO Auto-generated method stub |
|
66 |
|
|
67 |
} |
|
68 |
|
|
69 |
/* (non-Javadoc) |
|
70 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled() |
|
71 |
*/ |
|
72 |
public boolean isEnabled() { |
|
73 |
// TODO Auto-generated method stub |
|
74 |
return false; |
|
75 |
} |
|
76 |
|
|
77 |
/* (non-Javadoc) |
|
78 |
* @see org.gvsig.andami.plugins.IExtension#isVisible() |
|
79 |
*/ |
|
80 |
public boolean isVisible() { |
|
81 |
// TODO Auto-generated method stub |
|
82 |
return false; |
|
83 |
} |
|
84 |
|
|
85 |
} |
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.app/org.gvsig.downloader.app.mainplugin/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<parent> |
|
4 |
<groupId>org.gvsig</groupId> |
|
5 |
<artifactId>org.gvsig.downloader.app</artifactId> |
|
6 |
<version>1.0.70</version> |
|
7 |
</parent> |
|
8 |
<artifactId>org.gvsig.downloader.app.mainplugin</artifactId> |
|
9 |
<name>org.gvsig.downloader.app.mainplugin</name> |
|
10 |
<dependencies> |
|
11 |
<dependency> |
|
12 |
<groupId>org.gvsig</groupId> |
|
13 |
<artifactId>org.gvsig.app.mainplugin</artifactId> |
|
14 |
<scope>compile</scope> |
|
15 |
</dependency> |
|
16 |
<dependency> |
|
17 |
<groupId>org.gvsig</groupId> |
|
18 |
<artifactId>org.gvsig.downloader.lib.api</artifactId> |
|
19 |
</dependency> |
|
20 |
<dependency> |
|
21 |
<groupId>org.gvsig</groupId> |
|
22 |
<artifactId>org.gvsig.downloader.lib.httpclient</artifactId> |
|
23 |
</dependency> |
|
24 |
<dependency> |
|
25 |
<groupId>org.gvsig</groupId> |
|
26 |
<artifactId>org.gvsig.downloader.swing.api</artifactId> |
|
27 |
</dependency> |
|
28 |
<dependency> |
|
29 |
<groupId>org.gvsig</groupId> |
|
30 |
<artifactId>org.gvsig.downloader.swing.impl</artifactId> |
|
31 |
</dependency> |
|
32 |
<dependency> |
|
33 |
<groupId>org.apache.httpcomponents</groupId> |
|
34 |
<artifactId>httpclient</artifactId> |
|
35 |
</dependency> |
|
36 |
</dependencies> |
|
37 |
|
|
38 |
<properties> |
|
39 |
<gvsig.package.info.state>testing</gvsig.package.info.state> |
|
40 |
<gvsig.package.info.official>true</gvsig.package.info.official> |
|
41 |
<gvsig.package.info.dependencies>required: org.gvsig.app -ge 2.2.0</gvsig.package.info.dependencies> |
|
42 |
<gvsig.package.info.categories>Remote Services</gvsig.package.info.categories> |
|
43 |
<gvsig.package.info.name>downloader</gvsig.package.info.name> |
|
44 |
<gvsig.package.info.description>Downloader: Provides support for connecting to web services with Basic authentication and trusted SSL Certificate.</gvsig.package.info.description> |
|
45 |
<gvsig.package.info.owner>gvSIG Association</gvsig.package.info.owner> |
|
46 |
<gvsig.package.info.javaVM>j1_6</gvsig.package.info.javaVM> |
|
47 |
<gvsig.package.info.sourcesURL>${project.scm.url}</gvsig.package.info.sourcesURL> |
|
48 |
<gvsig.package.info.poolURL>https://devel.gvsig.org/download/projects/gvsig-downloader/pool</gvsig.package.info.poolURL> |
|
49 |
</properties> |
|
50 |
|
|
51 |
</project> |
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.main/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<parent> |
|
4 |
<groupId>org.gvsig</groupId> |
|
5 |
<artifactId>org.gvsig.downloader</artifactId> |
|
6 |
<version>1.0.70</version> |
|
7 |
</parent> |
|
8 |
<artifactId>org.gvsig.downloader.main</artifactId> |
|
9 |
<name>org.gvsig.downloader.main</name> |
|
10 |
</project> |
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.lib/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<parent> |
|
4 |
<groupId>org.gvsig</groupId> |
|
5 |
<artifactId>org.gvsig.downloader</artifactId> |
|
6 |
<version>1.0.70</version> |
|
7 |
</parent> |
|
8 |
<artifactId>org.gvsig.downloader.lib</artifactId> |
|
9 |
<packaging>pom</packaging> |
|
10 |
<name>org.gvsig.downloader.lib</name> |
|
11 |
<modules> |
|
12 |
<module>org.gvsig.downloader.lib.api</module> |
|
13 |
<module>org.gvsig.downloader.lib.httpclient</module> |
|
14 |
</modules> |
|
15 |
</project> |
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.lib/org.gvsig.downloader.lib.api/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<parent> |
|
4 |
<groupId>org.gvsig</groupId> |
|
5 |
<artifactId>org.gvsig.downloader.lib</artifactId> |
|
6 |
<version>1.0.70</version> |
|
7 |
</parent> |
|
8 |
<artifactId>org.gvsig.downloader.lib.api</artifactId> |
|
9 |
<name>org.gvsig.downloader.lib.api</name> |
|
10 |
<dependencies> |
|
11 |
<dependency> |
|
12 |
<groupId>org.gvsig</groupId> |
|
13 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
14 |
</dependency> |
|
15 |
<dependency> |
|
16 |
<groupId>org.apache.httpcomponents</groupId> |
|
17 |
<artifactId>httpclient</artifactId> |
|
18 |
</dependency> |
|
19 |
</dependencies> |
|
20 |
<dependencyManagement> |
|
21 |
<dependencies> |
|
22 |
</dependencies> |
|
23 |
</dependencyManagement> |
|
24 |
</project> |
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.lib/org.gvsig.downloader.lib.api/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.downloader.lib.api.DownloaderLibrary |
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.lib/org.gvsig.downloader.lib.api/src/main/java/org/gvsig/downloader/lib/api/DownloaderLocator.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2014 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 3 |
|
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 |
package org.gvsig.downloader.lib.api; |
|
25 |
|
|
26 |
import org.gvsig.tools.locator.BaseLocator; |
|
27 |
import org.gvsig.tools.locator.LocatorException; |
|
28 |
/** |
|
29 |
* @author miguel |
|
30 |
*/ |
|
31 |
public class DownloaderLocator extends BaseLocator { |
|
32 |
|
|
33 |
/** |
|
34 |
* The name and the description for the {@link Downloader manager} reference. |
|
35 |
*/ |
|
36 |
public static final String MANAGER_NAME = "Downloader.manager"; |
|
37 |
|
|
38 |
public static final String DOWNLOADER_MANAGER_DESCRIPTION = "Downloader manager description"; |
|
39 |
|
|
40 |
/** |
|
41 |
* Unique instance. |
|
42 |
*/ |
|
43 |
private static final DownloaderLocator instance = new DownloaderLocator(); |
|
44 |
|
|
45 |
/** |
|
46 |
* Return the singleton instance. |
|
47 |
* |
|
48 |
* @return the singleton instance |
|
49 |
*/ |
|
50 |
public static DownloaderLocator getInstance() { |
|
51 |
return instance; |
|
52 |
} |
|
53 |
|
|
54 |
/** |
|
55 |
* Return a reference to Downloader manager. |
|
56 |
* |
|
57 |
* @return a reference to Downloader manager |
|
58 |
* @throws LocatorException if there is no access to the class or the class |
|
59 |
* cannot be instantiated |
|
60 |
* @see Locator#get(String) |
|
61 |
*/ |
|
62 |
public static DownloaderManager getDownloaderManager() throws LocatorException { |
|
63 |
return (DownloaderManager) getInstance().get(MANAGER_NAME); |
|
64 |
} |
|
65 |
|
|
66 |
/** |
|
67 |
* Registers the Class implementing the Downloader manager interface. |
|
68 |
* |
|
69 |
* @param clazz implementing the Downloader manager interface |
|
70 |
*/ |
|
71 |
public static void registerDownloaderManager(Class clazz) { |
|
72 |
getInstance().register(MANAGER_NAME, DOWNLOADER_MANAGER_DESCRIPTION, clazz); |
|
73 |
} |
|
74 |
} |
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.lib/org.gvsig.downloader.lib.api/src/main/java/org/gvsig/downloader/lib/api/DownloaderLibrary.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2014 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 3 |
|
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 |
package org.gvsig.downloader.lib.api; |
|
25 |
|
|
26 |
import org.gvsig.tools.library.AbstractLibrary; |
|
27 |
import org.gvsig.tools.library.LibraryException; |
|
28 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
|
29 |
|
|
30 |
|
|
31 |
/** |
|
32 |
* @author miguel |
|
33 |
*/ |
|
34 |
public class DownloaderLibrary extends AbstractLibrary { |
|
35 |
|
|
36 |
public void doRegistration() { |
|
37 |
registerAsAPI(DownloaderLibrary.class); |
|
38 |
} |
|
39 |
|
|
40 |
@Override |
|
41 |
protected void doInitialize() throws LibraryException { |
|
42 |
|
|
43 |
} |
|
44 |
|
|
45 |
@Override |
|
46 |
protected void doPostInitialize() throws LibraryException { |
|
47 |
// Validate there is any implementation registered for the DownloaderManager. |
|
48 |
DownloaderManager downloaderManager = DownloaderLocator.getDownloaderManager(); |
|
49 |
|
|
50 |
if (downloaderManager == null) { |
|
51 |
throw new ReferenceNotRegisteredException(DownloaderLocator.MANAGER_NAME, |
|
52 |
DownloaderLocator.getInstance()); |
|
53 |
} |
|
54 |
|
|
55 |
|
|
56 |
} |
|
57 |
} |
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.lib/org.gvsig.downloader.lib.api/src/main/java/org/gvsig/downloader/lib/api/DownloaderManager.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2014 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 3 |
|
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 |
package org.gvsig.downloader.lib.api; |
|
25 |
|
|
26 |
import java.io.File; |
|
27 |
import java.net.URL; |
|
28 |
import java.util.List; |
|
29 |
|
|
30 |
import org.apache.http.client.CredentialsProvider; |
|
31 |
|
|
32 |
/** |
|
33 |
* @author miguel |
|
34 |
*/ |
|
35 |
public interface DownloaderManager { |
|
36 |
|
|
37 |
public DownloaderProcess download(File target, URL url, String postdata) |
|
38 |
throws UnsupportedOperationException; |
|
39 |
|
|
40 |
public DownloaderAuthentication createAuthentication(String host, int port, String user, String password); |
|
41 |
|
|
42 |
public void createDownloader(File target, URL url, String postdata) |
|
43 |
throws UnsupportedOperationException; |
|
44 |
|
|
45 |
public List<DownloaderAuthentication> getAuthentications(); |
|
46 |
|
|
47 |
public void setAuthentications(List<DownloaderAuthentication> authentications); |
|
48 |
|
|
49 |
public List<DownloaderProcess> getDownloads() |
|
50 |
throws UnsupportedOperationException; |
|
51 |
|
|
52 |
public CredentialsProvider getCredentialsProvider(String host); |
|
53 |
} |
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.lib/org.gvsig.downloader.lib.api/src/main/java/org/gvsig/downloader/lib/api/DownloaderProcess.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2014 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 3 |
|
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 |
package org.gvsig.downloader.lib.api; |
|
25 |
|
|
26 |
import java.io.File; |
|
27 |
import java.net.URL; |
|
28 |
|
|
29 |
import org.gvsig.tools.observer.Observable; |
|
30 |
import org.gvsig.tools.task.MonitorableTask; |
|
31 |
|
|
32 |
/** |
|
33 |
* @author miguel |
|
34 |
*/ |
|
35 |
public interface DownloaderProcess extends MonitorableTask, Observable { |
|
36 |
|
|
37 |
/** |
|
38 |
* join() start() requestCancel() File getFile() URL getURL() String getID() |
|
39 |
* isTerminated isCanceled |
|
40 |
**/ |
|
41 |
|
|
42 |
public File getFile(); |
|
43 |
|
|
44 |
public URL getUrl(); |
|
45 |
|
|
46 |
public String getID(); |
|
47 |
|
|
48 |
} |
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.lib/org.gvsig.downloader.lib.api/src/main/java/org/gvsig/downloader/lib/api/DownloaderAuthentication.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2014 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 3 |
|
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 |
package org.gvsig.downloader.lib.api; |
|
25 |
|
|
26 |
import org.gvsig.tools.persistence.Persistent; |
|
27 |
|
|
28 |
/** |
|
29 |
* @author miguel |
|
30 |
*/ |
|
31 |
public interface DownloaderAuthentication extends Persistent { |
|
32 |
|
|
33 |
public String getHost(); |
|
34 |
|
|
35 |
public int getPort(); |
|
36 |
|
|
37 |
public String getUser(); |
|
38 |
|
|
39 |
public String getPassword(); |
|
40 |
|
|
41 |
public void setHost(String host); |
|
42 |
|
|
43 |
public void setPort(int port); |
|
44 |
|
|
45 |
public void setUser(String user); |
|
46 |
|
|
47 |
public void setPassword(String password); |
|
48 |
} |
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.lib/org.gvsig.downloader.lib.httpclient/pom.xml | ||
---|---|---|
1 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|
2 |
<modelVersion>4.0.0</modelVersion> |
|
3 |
<parent> |
|
4 |
<groupId>org.gvsig</groupId> |
|
5 |
<artifactId>org.gvsig.downloader.lib</artifactId> |
|
6 |
<version>1.0.70</version> |
|
7 |
</parent> |
|
8 |
<artifactId>org.gvsig.downloader.lib.httpclient</artifactId> |
|
9 |
<name>org.gvsig.downloader.lib.httpclient</name> |
|
10 |
<dependencies> |
|
11 |
<dependency> |
|
12 |
<groupId>org.gvsig</groupId> |
|
13 |
<artifactId>org.gvsig.downloader.lib.api</artifactId> |
|
14 |
</dependency> |
|
15 |
<dependency> |
|
16 |
<groupId>org.gvsig</groupId> |
|
17 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
18 |
</dependency> |
|
19 |
<dependency> |
|
20 |
<groupId>org.gvsig</groupId> |
|
21 |
<artifactId>org.gvsig.compat.api</artifactId> |
|
22 |
</dependency> |
|
23 |
<dependency> |
|
24 |
<groupId>org.gvsig</groupId> |
|
25 |
<artifactId>org.gvsig.compat.se</artifactId> |
|
26 |
</dependency> |
|
27 |
<dependency> |
|
28 |
<groupId>org.apache.httpcomponents</groupId> |
|
29 |
<artifactId>httpclient</artifactId> |
|
30 |
</dependency> |
|
31 |
</dependencies> |
|
32 |
</project> |
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.lib/org.gvsig.downloader.lib.httpclient/src/main/resources/META-INF/services/org.gvsig.tools.library.Library | ||
---|---|---|
1 |
org.gvsig.downloader.lib.httpclient.HttpClientDownloaderLibrary |
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.lib/org.gvsig.downloader.lib.httpclient/src/main/java/org/gvsig/downloader/lib/httpclient/HttpClientDownloaderProcess.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2014 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 3 |
|
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 |
package org.gvsig.downloader.lib.httpclient; |
|
25 |
|
|
26 |
import java.io.File; |
|
27 |
import java.net.URL; |
|
28 |
|
|
29 |
import org.gvsig.downloader.lib.api.DownloaderProcess; |
|
30 |
import org.gvsig.tools.observer.Observer; |
|
31 |
import org.gvsig.tools.task.TaskStatus; |
|
32 |
|
|
33 |
/** |
|
34 |
* @author miguel |
|
35 |
*/ |
|
36 |
public class HttpClientDownloaderProcess implements DownloaderProcess { |
|
37 |
|
|
38 |
/* |
|
39 |
* (non-Javadoc) |
|
40 |
* @see org.gvsig.tools.task.MonitorableTask#getTaskStatus() |
|
41 |
*/ |
|
42 |
public TaskStatus getTaskStatus() { |
|
43 |
// TODO Auto-generated method stub |
|
44 |
return null; |
|
45 |
} |
|
46 |
|
|
47 |
/* |
|
48 |
* (non-Javadoc) |
|
49 |
* @see org.gvsig.tools.task.CancellableTask#isCancellationRequested() |
|
50 |
*/ |
|
51 |
public boolean isCancellationRequested() { |
|
52 |
// TODO Auto-generated method stub |
|
53 |
return false; |
|
54 |
} |
|
55 |
|
|
56 |
/* |
|
57 |
* (non-Javadoc) |
|
58 |
* @see org.gvsig.tools.task.CancellableTask#cancelRequest() |
|
59 |
*/ |
|
60 |
public void cancelRequest() { |
|
61 |
// TODO Auto-generated method stub |
|
62 |
|
|
63 |
} |
|
64 |
|
|
65 |
/* |
|
66 |
* (non-Javadoc) |
|
67 |
* @see |
|
68 |
* org.gvsig.tools.observer.Observable#addObserver(org.gvsig.tools.observer |
|
69 |
* .Observer) |
|
70 |
*/ |
|
71 |
public void addObserver(Observer o) { |
|
72 |
// TODO Auto-generated method stub |
|
73 |
|
|
74 |
} |
|
75 |
|
|
76 |
/* |
|
77 |
* (non-Javadoc) |
|
78 |
* @see |
|
79 |
* org.gvsig.tools.observer.Observable#deleteObserver(org.gvsig.tools.observer |
|
80 |
* .Observer) |
|
81 |
*/ |
|
82 |
public void deleteObserver(Observer o) { |
|
83 |
// TODO Auto-generated method stub |
|
84 |
|
|
85 |
} |
|
86 |
|
|
87 |
/* |
|
88 |
* (non-Javadoc) |
|
89 |
* @see org.gvsig.tools.observer.Observable#deleteObservers() |
|
90 |
*/ |
|
91 |
public void deleteObservers() { |
|
92 |
// TODO Auto-generated method stub |
|
93 |
|
|
94 |
} |
|
95 |
|
|
96 |
/* |
|
97 |
* (non-Javadoc) |
|
98 |
* @see org.gvsig.downloader.lib.api.DownloaderProcess#getFile() |
|
99 |
*/ |
|
100 |
public File getFile() { |
|
101 |
// TODO Auto-generated method stub |
|
102 |
return null; |
|
103 |
} |
|
104 |
|
|
105 |
/* |
|
106 |
* (non-Javadoc) |
|
107 |
* @see org.gvsig.downloader.lib.api.DownloaderProcess#getUrl() |
|
108 |
*/ |
|
109 |
public URL getUrl() { |
|
110 |
// TODO Auto-generated method stub |
|
111 |
return null; |
|
112 |
} |
|
113 |
|
|
114 |
/* |
|
115 |
* (non-Javadoc) |
|
116 |
* @see org.gvsig.downloader.lib.api.DownloaderProcess#getID() |
|
117 |
*/ |
|
118 |
public String getID() { |
|
119 |
// TODO Auto-generated method stub |
|
120 |
return null; |
|
121 |
} |
|
122 |
|
|
123 |
} |
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.lib/org.gvsig.downloader.lib.httpclient/src/main/java/org/gvsig/downloader/lib/httpclient/HttpClientDownloader.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2014 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 3 |
|
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 |
package org.gvsig.downloader.lib.httpclient; |
|
25 |
|
|
26 |
import java.io.File; |
|
27 |
import java.net.URL; |
|
28 |
import org.gvsig.compat.se.net.downloader.Downloader; |
|
29 |
import org.gvsig.compat.se.net.downloader.se.SEDownloader; |
|
30 |
|
|
31 |
public class HttpClientDownloader extends SEDownloader { |
|
32 |
|
|
33 |
public HttpClientDownloader() { |
|
34 |
super(); |
|
35 |
} |
|
36 |
|
|
37 |
protected Runnable createDownloaderTask(Downloader downloader, URL url, String data, File target, Object groupID) { |
|
38 |
return new HttpClientDownloaderTask(downloader, url, data, target, groupID); |
|
39 |
} |
|
40 |
|
|
41 |
} |
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.lib/org.gvsig.downloader.lib.httpclient/src/main/java/org/gvsig/downloader/lib/httpclient/HttpClientDownloaderAuthentication.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2014 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 3 |
|
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 |
package org.gvsig.downloader.lib.httpclient; |
|
25 |
|
|
26 |
import org.gvsig.downloader.lib.api.DownloaderAuthentication; |
|
27 |
import org.gvsig.tools.ToolsLocator; |
|
28 |
import org.gvsig.tools.dynobject.DynStruct; |
|
29 |
import org.gvsig.tools.persistence.PersistenceManager; |
|
30 |
import org.gvsig.tools.persistence.PersistentState; |
|
31 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
|
32 |
|
|
33 |
/** |
|
34 |
* @author miguel |
|
35 |
*/ |
|
36 |
public class HttpClientDownloaderAuthentication implements |
|
37 |
DownloaderAuthentication { |
|
38 |
|
|
39 |
public static final String PERSISTENT_NAME = "org.gvsig.downloader.lib.httpclient.HttpClientDownloaderAuthentication"; |
|
40 |
|
|
41 |
public static final String PERSISTENT_DESCRIPTION = "HttpClientDownloader Persistent"; |
|
42 |
|
|
43 |
private String host; |
|
44 |
|
|
45 |
private int port; |
|
46 |
|
|
47 |
private String user; |
|
48 |
|
|
49 |
private String password; |
|
50 |
|
|
51 |
public HttpClientDownloaderAuthentication(String host, int port, String user, |
|
52 |
String password) { |
|
53 |
this.host = host; |
|
54 |
this.port = port; |
|
55 |
this.user = user; |
|
56 |
this.password = password; |
|
57 |
} |
|
58 |
|
|
59 |
public HttpClientDownloaderAuthentication() { |
|
60 |
this.host = ""; |
|
61 |
this.port = 443; |
|
62 |
this.user = ""; |
|
63 |
this.password = ""; |
|
64 |
} |
|
65 |
|
|
66 |
public String getHost() { |
|
67 |
return this.host; |
|
68 |
} |
|
69 |
|
|
70 |
public String getUser() { |
|
71 |
return this.user; |
|
72 |
} |
|
73 |
|
|
74 |
public int getPort() { |
|
75 |
return this.port; |
|
76 |
} |
|
77 |
|
|
78 |
public void setPort(int port) { |
|
79 |
this.port = port; |
|
80 |
} |
|
81 |
|
|
82 |
public String getPassword() { |
|
83 |
return this.password; |
|
84 |
} |
|
85 |
|
|
86 |
public void setHost(String host) { |
|
87 |
this.host = host; |
|
88 |
} |
|
89 |
|
|
90 |
public void setUser(String user) { |
|
91 |
this.user = user; |
|
92 |
} |
|
93 |
|
|
94 |
public void setPassword(String password) { |
|
95 |
this.password = password; |
|
96 |
} |
|
97 |
|
|
98 |
public void saveToState(PersistentState state) throws PersistenceException { |
|
99 |
state.set("host", this.host); |
|
100 |
state.set("port", this.port); |
|
101 |
state.set("user", this.user); |
|
102 |
state.set("password", this.password); |
|
103 |
} |
|
104 |
|
|
105 |
public void loadFromState(PersistentState state) throws PersistenceException { |
|
106 |
this.host = state.getString("host"); |
|
107 |
this.port = state.getInt("port"); |
|
108 |
this.user = state.getString("user"); |
|
109 |
this.password = state.getString("password"); |
|
110 |
} |
|
111 |
|
|
112 |
public static void registerPersistence() { |
|
113 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
|
114 |
DynStruct definition = manager.getDefinition(PERSISTENT_NAME); |
|
115 |
if (definition == null) { |
|
116 |
definition = manager.addDefinition( |
|
117 |
HttpClientDownloaderAuthentication.class, PERSISTENT_NAME, |
|
118 |
PERSISTENT_DESCRIPTION, null, null); |
|
119 |
definition.addDynFieldString("host").setMandatory(false); |
|
120 |
definition.addDynFieldInt("port").setMandatory(false); |
|
121 |
definition.addDynFieldString("user").setMandatory(false); |
|
122 |
definition.addDynFieldString("password").setMandatory(false); |
|
123 |
} |
|
124 |
} |
|
125 |
} |
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.lib/org.gvsig.downloader.lib.httpclient/src/main/java/org/gvsig/downloader/lib/httpclient/HttpClientDownloaderTask.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2014 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 3 |
|
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 |
package org.gvsig.downloader.lib.httpclient; |
|
25 |
|
|
26 |
import java.io.*; |
|
27 |
import java.net.URL; |
|
28 |
import java.security.*; |
|
29 |
|
|
30 |
import org.apache.commons.lang3.StringUtils; |
|
31 |
import org.apache.http.HttpEntity; |
|
32 |
import org.apache.http.HttpHost; |
|
33 |
import org.apache.http.client.*; |
|
34 |
import org.apache.http.client.entity.EntityBuilder; |
|
35 |
import org.apache.http.client.methods.*; |
|
36 |
import org.apache.http.client.protocol.HttpClientContext; |
|
37 |
import org.apache.http.conn.ssl.*; |
|
38 |
import org.apache.http.impl.auth.BasicScheme; |
|
39 |
import org.apache.http.impl.client.*; |
|
40 |
import org.gvsig.compat.se.net.downloader.Downloader; |
|
41 |
import org.gvsig.downloader.lib.api.DownloaderLocator; |
|
42 |
import org.slf4j.Logger; |
|
43 |
import org.slf4j.LoggerFactory; |
|
44 |
|
|
45 |
final class HttpClientDownloaderTask implements Runnable { |
|
46 |
|
|
47 |
private URL url = null; |
|
48 |
|
|
49 |
private File dstFile = null; |
|
50 |
|
|
51 |
private Object groupID = null; |
|
52 |
|
|
53 |
private String data = null; |
|
54 |
|
|
55 |
private Downloader downloader = null; |
|
56 |
|
|
57 |
private static Logger LOG = LoggerFactory |
|
58 |
.getLogger(HttpClientDownloaderTask.class); |
|
59 |
|
|
60 |
public HttpClientDownloaderTask(Downloader downloader, URL url, |
|
61 |
String data, File dstFile, Object groupID) { |
|
62 |
this.url = url; |
|
63 |
this.data = data; |
|
64 |
this.dstFile = dstFile; |
|
65 |
this.groupID = groupID; |
|
66 |
this.downloader = downloader; |
|
67 |
downloader.setDownloadException(null); |
|
68 |
} |
|
69 |
|
|
70 |
public void run() { |
|
71 |
|
|
72 |
LOG.info("Downloading '" + url.toString() + "' to: " |
|
73 |
+ dstFile.getAbsolutePath()); |
|
74 |
|
|
75 |
if (data != null) { |
|
76 |
LOG.info("using POST, request = " + data); |
|
77 |
} |
|
78 |
|
|
79 |
HttpClientDownloaderManager manager = |
|
80 |
(HttpClientDownloaderManager) DownloaderLocator |
|
81 |
.getDownloaderManager(); |
|
82 |
CredentialsProvider credsProvider = |
|
83 |
manager.getCredentialsProvider(url.getHost()); |
|
84 |
|
|
85 |
HttpHost targetHost = |
|
86 |
new HttpHost(url.getHost(), url.getPort(), url.getProtocol()); |
|
87 |
|
|
88 |
// MOVIDO A DownloaderManager |
|
89 |
// CredentialsProvider credsProvider = new BasicCredentialsProvider(); |
|
90 |
// credsProvider.setCredentials(AuthScope.ANY, |
|
91 |
// new UsernamePasswordCredentials("prueba", "prueba")); |
|
92 |
|
|
93 |
AuthCache authCache = new BasicAuthCache(); |
|
94 |
authCache.put(targetHost, new BasicScheme()); |
|
95 |
|
|
96 |
// Add AuthCache to the execution context |
|
97 |
final HttpClientContext context = HttpClientContext.create(); |
|
98 |
context.setCredentialsProvider(credsProvider); |
|
99 |
context.setAuthCache(authCache); |
|
100 |
|
|
101 |
HttpClient client = null; |
|
102 |
|
|
103 |
try { |
|
104 |
client = getHttpClient(url.getProtocol()); |
|
105 |
} catch (Exception e) { |
|
106 |
LOG.info("Error handling certificate.", e); |
|
107 |
downloader.setDownloadException(e); |
|
108 |
return; |
|
109 |
} |
|
110 |
|
|
111 |
HttpEntity entity = null; |
|
112 |
HttpRequestBase request = null; |
|
113 |
if (StringUtils.isEmpty(data)) { |
|
114 |
HttpGet httpget = new HttpGet(url.getFile()); |
|
115 |
request = httpget; |
|
116 |
} else { |
|
117 |
EntityBuilder builder = EntityBuilder.create(); |
|
118 |
builder.setText(data); |
|
119 |
HttpPost postRequest = new HttpPost(url.getFile()); |
|
120 |
HttpEntity postRequestEntity = builder.build(); |
|
121 |
postRequest.setEntity(postRequestEntity); |
|
122 |
request = postRequest; |
|
123 |
} |
|
124 |
|
|
125 |
CloseableHttpResponse closeableHttpResponse = null; |
|
126 |
InputStream is = null; |
|
127 |
OutputStream os = null; |
|
128 |
try { |
|
129 |
closeableHttpResponse = |
|
130 |
(CloseableHttpResponse) client.execute(targetHost, request, |
|
131 |
context); |
|
132 |
|
|
133 |
entity = closeableHttpResponse.getEntity(); |
|
134 |
|
|
135 |
if (entity != null) { |
|
136 |
try { |
|
137 |
os = new FileOutputStream(dstFile); |
|
138 |
is = entity.getContent(); |
|
139 |
byte[] buffer = new byte[4096]; |
|
140 |
try { |
|
141 |
int n = is.read(buffer); |
|
142 |
while (n != -1) { |
|
143 |
os.write(buffer, 0, n); |
|
144 |
n = is.read(buffer); |
|
145 |
} |
|
146 |
} finally { |
|
147 |
if (os != null) { |
|
148 |
os.close(); |
|
149 |
} |
|
150 |
} |
|
151 |
} catch (FileNotFoundException e) { |
|
152 |
throw e; |
|
153 |
|
|
154 |
} catch (IllegalStateException e) { |
|
155 |
throw e; |
|
156 |
|
|
157 |
} catch (IOException e) { |
|
158 |
throw e; |
|
159 |
|
|
160 |
} finally { |
|
161 |
if (is != null) { |
|
162 |
is.close(); |
|
163 |
} |
|
164 |
} |
|
165 |
} |
|
166 |
if (closeableHttpResponse != null) { |
|
167 |
closeableHttpResponse.close(); |
|
168 |
} |
|
169 |
} catch (Exception e) { |
|
170 |
LOG.info("Error downloading", e); |
|
171 |
downloader.setDownloadException(e); |
|
172 |
} |
|
173 |
} |
|
174 |
|
|
175 |
private HttpClient getHttpClient(String protocol) |
|
176 |
throws NoSuchAlgorithmException, KeyStoreException, |
|
177 |
KeyManagementException { |
|
178 |
|
|
179 |
CloseableHttpClient httpclient; |
|
180 |
|
|
181 |
if (protocol.equalsIgnoreCase("https")) { |
|
182 |
SSLContextBuilder builder = new SSLContextBuilder(); |
|
183 |
builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); |
|
184 |
SSLConnectionSocketFactory sslsf = |
|
185 |
new SSLConnectionSocketFactory(builder.build()); |
|
186 |
httpclient = |
|
187 |
HttpClients.custom().setSSLSocketFactory(sslsf).build(); |
|
188 |
} else { |
|
189 |
httpclient = HttpClientBuilder.create().build(); |
|
190 |
} |
|
191 |
return httpclient; |
|
192 |
} |
|
193 |
} |
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.lib/org.gvsig.downloader.lib.httpclient/src/main/java/org/gvsig/downloader/lib/httpclient/HttpClientDownloaderLibrary.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2014 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 3 |
|
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 |
package org.gvsig.downloader.lib.httpclient; |
|
25 |
|
|
26 |
import org.gvsig.compat.CompatLibrary; |
|
27 |
import org.gvsig.compat.CompatLocator; |
|
28 |
import org.gvsig.downloader.lib.api.DownloaderLibrary; |
|
29 |
import org.gvsig.downloader.lib.api.DownloaderLocator; |
|
30 |
import org.gvsig.tools.library.AbstractLibrary; |
|
31 |
import org.gvsig.tools.library.LibraryException; |
|
32 |
|
|
33 |
/** |
|
34 |
* @author miguel |
|
35 |
*/ |
|
36 |
public class HttpClientDownloaderLibrary extends AbstractLibrary { |
|
37 |
|
|
38 |
@Override |
|
39 |
public void doRegistration() { |
|
40 |
super.doRegistration(); |
|
41 |
registerAsImplementationOf(CompatLibrary.class); |
|
42 |
registerAsImplementationOf(DownloaderLibrary.class); |
|
43 |
} |
|
44 |
|
|
45 |
@Override |
|
46 |
protected void doInitialize() throws LibraryException { |
|
47 |
CompatLocator.registerDownloader(HttpClientDownloader.class); |
|
48 |
DownloaderLocator.registerDownloaderManager(HttpClientDownloaderManager.class); |
|
49 |
} |
|
50 |
|
|
51 |
@Override |
|
52 |
protected void doPostInitialize() throws LibraryException { |
|
53 |
HttpClientDownloaderAuthentication.registerPersistence(); |
|
54 |
} |
|
55 |
} |
org.gvsig.downloader/tags/org.gvsig.downloader-1.0.70/org.gvsig.downloader.lib/org.gvsig.downloader.lib.httpclient/src/main/java/org/gvsig/downloader/lib/httpclient/HttpClientDownloaderManager.java | ||
---|---|---|
1 |
/** |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2014 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 3 |
|
9 |
* of the License, or (at your option) any later version. |
Also available in: Unified diff