Revision 41916
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.api/src/main/java/org/gvsig/installer/lib/api/InstallerManager.java | ||
---|---|---|
536 | 536 |
// public PackageInfoFiles getPackageInfoFiles(PackageInfo packageInfo); |
537 | 537 |
|
538 | 538 |
public boolean hasProviderToThisPackage(PackageInfo packageInfo); |
539 |
|
|
540 |
public boolean needAdminRights(); |
|
539 | 541 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.impl/src/main/java/org/gvsig/installer/lib/impl/DefaultInstallerManager.java | ||
---|---|---|
489 | 489 |
return this.getDefaultLocalAddonRepository(packageType,ACCESS_READ); |
490 | 490 |
} |
491 | 491 |
|
492 |
public boolean needAdminRights() { |
|
493 |
List<File> folders = getLocalAddonRepositories(); |
|
494 |
for( File folder : folders) { |
|
495 |
if( !canWrite(folder) ) { |
|
496 |
return true; |
|
497 |
} |
|
498 |
} |
|
499 |
return false; |
|
500 |
} |
|
501 |
|
|
492 | 502 |
private boolean canWrite(File f) { |
493 | 503 |
if( !f.canWrite() ) { |
494 | 504 |
return false; |
trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/Launcher.java | ||
---|---|---|
535 | 535 |
splashWindow.process(translate("SplashWindow.load_plugins_configuration")); |
536 | 536 |
try { |
537 | 537 |
logger.info("Load plugins information"); |
538 |
this.loadPlugins(); |
|
538 |
this.loadPluginConfigs(); |
|
539 |
if ( pluginsConfig.isEmpty() ) { |
|
540 |
logger.warn("No valid plugin was found."); |
|
541 |
System.exit(-1); |
|
542 |
} |
|
539 | 543 |
} catch (Throwable ex) { |
540 | 544 |
this.addError("Can't load plugins", ex); |
541 | 545 |
} |
... | ... | |
547 | 551 |
// Se configura el classloader del plugin |
548 | 552 |
splashWindow.process(translate("SplashWindow.setup_plugins_configuration")); |
549 | 553 |
try { |
550 |
logger.info("Configure plugins class loader");
|
|
551 |
this.pluginsClassLoaders();
|
|
554 |
logger.info("Configure plugins class loader");
|
|
555 |
this.loadPluginServices();
|
|
552 | 556 |
} catch (Throwable ex) { |
553 |
this.addError("Can't initialize plugin's classloaders ", ex);
|
|
557 |
logger.warn("Can't initialize plugin's classloaders ", ex);
|
|
554 | 558 |
} |
559 |
try { |
|
560 |
registerActions(); |
|
561 |
} catch (Throwable ex) { |
|
562 |
logger.warn("Can't register actions of plugins", ex); |
|
563 |
} |
|
555 | 564 |
|
556 | 565 |
initializeIdentityManagement(new File(andamiConfig.getPluginsDirectory()).getAbsoluteFile()); |
557 | 566 |
|
... | ... | |
838 | 847 |
*/ |
839 | 848 |
private void loadAndamiConfig(String pluginFolder) |
840 | 849 |
throws ConfigurationException { |
841 |
// Leer el fichero de configuraci�n de andami (andami-config.xsd) |
|
842 |
// locale |
|
843 |
// Buscar actualizaci�nes al comenzar |
|
844 |
// Andami |
|
845 |
// Plugins |
|
846 |
// Directorio de las extensiones |
|
847 | 850 |
andamiConfigPath = appHomeDir + File.separator + "andami-config.xml"; |
848 | 851 |
andamiConfigFromXML(andamiConfigPath); |
849 | 852 |
andamiConfig.setPluginsDirectory(pluginFolder); |
... | ... | |
2173 | 2176 |
return urls; |
2174 | 2177 |
} |
2175 | 2178 |
|
2176 |
private void pluginsClassLoaders() {
|
|
2179 |
private void loadPluginServices() {
|
|
2177 | 2180 |
Set<String> installed = new HashSet<String>(); |
2178 | 2181 |
|
2179 | 2182 |
// Se itera hasta que est�n todos instalados |
... | ... | |
2210 | 2213 |
if ( dependency.getOptional() ) { |
2211 | 2214 |
this.logger.info("Plugin '" + pluginName + "', optional dependency '" + dependencyName + "' not found"); |
2212 | 2215 |
} else { |
2213 |
this.addError(Messages.getString("Launcher.Dependencia_no_resuelta_en_plugin") |
|
2214 |
+ " " |
|
2216 |
logger.warn("Dependencia no resuelta en plugin " |
|
2215 | 2217 |
+ pluginName |
2216 | 2218 |
+ ": " |
2217 | 2219 |
+ dependencies[j].getPluginName()); |
... | ... | |
2249 | 2251 |
loader, |
2250 | 2252 |
PluginsConfig.getAlternativeNames(config) |
2251 | 2253 |
); |
2254 |
logger.info("Plugin '"+pluginName+"' created"); |
|
2252 | 2255 |
pluginsServices.put(ps.getPluginName(), ps); |
2253 | 2256 |
installed.add(pluginName); |
2254 | 2257 |
pluginsOrdered.add(pluginName); |
... | ... | |
2281 | 2284 |
i = pluginsConfig.keySet().iterator(); |
2282 | 2285 |
} |
2283 | 2286 |
} |
2284 |
registerActions(); |
|
2285 | 2287 |
} |
2286 | 2288 |
|
2287 | 2289 |
private void dumpPluginsDependencyInformation() { |
... | ... | |
2344 | 2346 |
} |
2345 | 2347 |
|
2346 | 2348 |
|
2347 |
private void loadPlugins() {
|
|
2349 |
private PluginsConfig loadPluginConfigs() {
|
|
2348 | 2350 |
InstallerManager installerManager = InstallerLocator.getInstallerManager(); |
2349 | 2351 |
List<File> repositoriesFolders = installerManager.getLocalAddonRepositories("plugin"); |
2350 | 2352 |
for ( File repositoryFolder : repositoriesFolders ) { |
2351 |
logger.info("Loading plugins from repository folder " + repositoryFolder.getAbsolutePath() + "."); |
|
2353 |
logger.info("Loading plugins configuration from repository folder " + repositoryFolder.getAbsolutePath() + ".");
|
|
2352 | 2354 |
|
2353 | 2355 |
if ( !repositoryFolder.exists() ) { |
2354 | 2356 |
logger.warn("Plugins repository folder not found '" + repositoryFolder.getAbsolutePath() + "'."); |
... | ... | |
2357 | 2359 |
|
2358 | 2360 |
File[] pluginsFolders = repositoryFolder.listFiles(); |
2359 | 2361 |
if ( pluginsFolders.length == 0 ) { |
2360 |
logger.warn("Plugins repository folder is empty '" + repositoryFolder.getAbsolutePath() + "'.");
|
|
2362 |
logger.info("Plugins repository folder is empty '" + repositoryFolder.getAbsolutePath() + "'.");
|
|
2361 | 2363 |
continue; |
2362 | 2364 |
} |
2363 | 2365 |
|
... | ... | |
2399 | 2401 |
} |
2400 | 2402 |
} |
2401 | 2403 |
} |
2402 |
if ( pluginsConfig.isEmpty() ) { |
|
2403 |
logger.warn("No valid plugin was found."); |
|
2404 |
System.exit(-1); |
|
2405 |
} |
|
2404 |
return pluginsConfig; |
|
2406 | 2405 |
} |
2407 | 2406 |
|
2408 | 2407 |
private static Locale getLocale(String language, String country, |
... | ... | |
2998 | 2997 |
localeStr = andamiConfig.getLocaleLanguage(); |
2999 | 2998 |
} |
3000 | 2999 |
localeStr = normalizeLanguageCode(localeStr); |
3001 |
locale = getLocale(localeStr, andamiConfig.getLocaleCountry(), |
|
3002 |
andamiConfig.getLocaleVariant()); |
|
3000 |
locale = getLocale( |
|
3001 |
localeStr, |
|
3002 |
andamiConfig.getLocaleCountry(), |
|
3003 |
andamiConfig.getLocaleVariant() |
|
3004 |
); |
|
3003 | 3005 |
org.gvsig.i18n.Messages.setCurrentLocale(locale); |
3004 | 3006 |
JComponent.setDefaultLocale(locale); |
3005 | 3007 |
/* |
... | ... | |
3543 | 3545 |
myArgs[2] = "language=" + line.getOptionValue("language"); |
3544 | 3546 |
} else { |
3545 | 3547 |
// prevent null |
3546 |
myArgs[2] = "";
|
|
3548 |
myArgs[2] = Locale.getDefault().toString();
|
|
3547 | 3549 |
} |
3548 | 3550 |
|
3549 | 3551 |
if ( line.hasOption("installURL") ) { |
... | ... | |
3570 | 3572 |
return; |
3571 | 3573 |
} |
3572 | 3574 |
} catch (ParseException exp) { |
3573 |
System.out.println("Unexpected exception:" + exp.getMessage());
|
|
3575 |
System.err.println("Unexpected exception:" + exp.getMessage());
|
|
3574 | 3576 |
System.exit(-1); |
3575 | 3577 |
} |
3576 | 3578 |
|
3577 | 3579 |
initializeApp(myArgs, "installer"); |
3578 |
initializeLibraries(); |
|
3579 | 3580 |
|
3580 |
AndamiConfig config = getAndamiConfig(); |
|
3581 |
config.setLocaleLanguage(locale.getLanguage()); |
|
3582 |
config.setLocaleCountry(locale.getCountry()); |
|
3583 |
config.setLocaleVariant(locale.getVariant()); |
|
3584 |
|
|
3581 |
new DefaultLibrariesInitializer().fullInitialize(true); |
|
3582 |
|
|
3585 | 3583 |
initializeInstallerManager(); |
3586 | 3584 |
|
3587 | 3585 |
InstallerManager installerManager = InstallerLocator.getInstallerManager(); |
3588 | 3586 |
|
3587 |
try { |
|
3588 |
logger.info("Loading plugins configurations"); |
|
3589 |
this.loadPluginConfigs(); |
|
3590 |
} catch (Throwable ex) { |
|
3591 |
logger.warn("Can't load plugins configurations", ex); |
|
3592 |
} |
|
3593 |
|
|
3594 |
try { |
|
3595 |
logger.info("Loading plugins"); |
|
3596 |
this.loadPluginServices(); |
|
3597 |
} catch (Throwable ex) { |
|
3598 |
logger.warn("Can't load plugins", ex); |
|
3599 |
} |
|
3600 |
|
|
3601 |
AndamiConfig config = getAndamiConfig(); |
|
3602 |
|
|
3603 |
initializeIdentityManagement(new File(config.getPluginsDirectory()).getAbsoluteFile()); |
|
3604 |
|
|
3605 |
initializeLibraries(); |
|
3606 |
|
|
3607 |
// config.setLocaleLanguage(locale.getLanguage()); |
|
3608 |
// config.setLocaleCountry(locale.getCountry()); |
|
3609 |
// config.setLocaleVariant(locale.getVariant()); |
|
3610 |
|
|
3589 | 3611 |
packageInfo = getPackageInfo(myArgs[1]); |
3590 | 3612 |
|
3591 | 3613 |
// set the gvSIG version to the install manager, to compose the download URL |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.installer.app/org.gvsig.installer.app.mainplugin/pom.xml | ||
---|---|---|
3 | 3 |
<modelVersion>4.0.0</modelVersion> |
4 | 4 |
<artifactId>org.gvsig.installer.app.mainplugin</artifactId> |
5 | 5 |
<packaging>jar</packaging> |
6 |
<name>Add-ons manager</name>
|
|
6 |
<name>${project.artifactId}</name>
|
|
7 | 7 |
<parent> |
8 | 8 |
<groupId>org.gvsig</groupId> |
9 | 9 |
<artifactId>org.gvsig.installer.app</artifactId> |
... | ... | |
69 | 69 |
<properties> |
70 | 70 |
<gvsig.package.info.categories>Addon Management</gvsig.package.info.categories> |
71 | 71 |
<gvsig.package.info.codealias>org.gvsig.installer.app.extension</gvsig.package.info.codealias> |
72 |
<gvsig.package.info.official>true</gvsig.package.info.official> |
|
72 |
<gvsig.package.info.official>true</gvsig.package.info.official> |
|
73 |
<gvsig.package.info.name>Add-ons manager</gvsig.package.info.name> |
|
73 | 74 |
</properties> |
74 | 75 |
|
75 | 76 |
</project> |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.installer.app/org.gvsig.installer.app.mainplugin/src/main/java/org/gvsig/installer/app/extension/execution/InstallPackageExtension.java | ||
---|---|---|
3 | 3 |
* |
4 | 4 |
* Copyright (C) 2007-2013 gvSIG Association. |
5 | 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.
|
|
6 |
* This program is free software; you can redistribute it and/or modify it under
|
|
7 |
* the terms of the GNU General Public License as published by the Free Software
|
|
8 |
* Foundation; either version 3 of the License, or (at your option) any later
|
|
9 |
* version. |
|
10 | 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.
|
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
14 |
* details. |
|
15 | 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. |
|
16 |
* You should have received a copy of the GNU General Public License along with |
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51 |
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
20 | 19 |
* |
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
|
20 |
* For any additional information, do not hesitate to contact us at info AT
|
|
21 |
* gvsig.com, or visit our website www.gvsig.com. |
|
23 | 22 |
*/ |
24 | 23 |
/* |
25 | 24 |
* AUTHORS (In addition to CIT): |
... | ... | |
28 | 27 |
package org.gvsig.installer.app.extension.execution; |
29 | 28 |
|
30 | 29 |
import java.io.BufferedReader; |
30 |
import java.io.File; |
|
31 |
import java.io.IOException; |
|
31 | 32 |
import java.io.InputStream; |
32 | 33 |
import java.io.InputStreamReader; |
33 | 34 |
import java.net.MalformedURLException; |
35 |
import java.util.logging.Level; |
|
34 | 36 |
|
35 | 37 |
import org.gvsig.andami.IconThemeHelper; |
36 | 38 |
import org.gvsig.andami.Launcher; |
... | ... | |
52 | 54 |
*/ |
53 | 55 |
public class InstallPackageExtension extends Extension { |
54 | 56 |
|
55 |
private static final Logger LOG = LoggerFactory
|
|
57 |
private static final Logger logger = LoggerFactory
|
|
56 | 58 |
.getLogger(InstallPackageExtension.class); |
57 | 59 |
|
58 | 60 |
public void execute(String actionCommand) { |
59 | 61 |
this.execute(actionCommand, null); |
60 | 62 |
} |
61 |
|
|
63 |
|
|
62 | 64 |
public void execute(String actionCommand, Object[] args) { |
63 |
|
|
64 |
if ( "tools-addonsmanager".equalsIgnoreCase(actionCommand) ) { |
|
65 |
boolean skipBundleSelection = false; |
|
66 |
if( args!=null && args.length>0 ) { |
|
67 |
String subcmd = (String) args[0]; |
|
68 |
if( "skipBundleSelection".equalsIgnoreCase(subcmd) ) { |
|
69 |
skipBundleSelection=true; |
|
65 |
|
|
66 |
if ("tools-addonsmanager".equalsIgnoreCase(actionCommand)) { |
|
67 |
// InstallerManager installManager = InstallerLocator.getInstallerManager(); |
|
68 |
// if (installManager.needAdminRights()) { |
|
69 |
// showExternalAddonsManager(); |
|
70 |
// } else { |
|
71 |
showInternalAddonsManager(args); |
|
72 |
// } |
|
73 |
} |
|
74 |
} |
|
75 |
|
|
76 |
private void showExternalAddonsManager() { |
|
77 |
InstallerManager installManager = InstallerLocator.getInstallerManager(); |
|
78 |
|
|
79 |
PluginsManager pluginManager = PluginsLocator.getManager(); |
|
80 |
|
|
81 |
String cmd = null; |
|
82 |
boolean useInternalAddonsManager = false; |
|
83 |
|
|
84 |
if( InstallerManager.OS.WINDOWS.equalsIgnoreCase(installManager.getOperatingSystem()) ) { |
|
85 |
cmd = "runas /noprofile /user:Administrator " + pluginManager.getApplicationFolder() + File.separator + "gvsig-package-installer.exe --install"; |
|
86 |
try { |
|
87 |
Process p = Runtime.getRuntime().exec(cmd); |
|
88 |
if( p.exitValue() != 0 ) { |
|
89 |
useInternalAddonsManager = true; |
|
70 | 90 |
} |
91 |
} catch (IOException ex) { |
|
92 |
logger.warn("Can't execute command '"+cmd+"'.",ex); |
|
93 |
useInternalAddonsManager = true; |
|
71 | 94 |
} |
72 |
PluginsManager manager = PluginsLocator.getManager(); |
|
95 |
} else { |
|
96 |
cmd = "pkexec " + pluginManager.getApplicationFolder() + File.separator + "/gvSIG.sh --install"; |
|
73 | 97 |
try { |
74 |
PluginServices.getMDIManager().addCentredWindow( |
|
75 |
new InstallPackageWindow( |
|
76 |
manager.getApplicationFolder(), |
|
77 |
manager.getInstallFolder(), |
|
78 |
skipBundleSelection |
|
79 |
) |
|
80 |
); |
|
81 |
} catch (Error e) { |
|
82 |
LOG.error("Error creating the wizard to install a package ", e); |
|
83 |
} catch (Exception e) { |
|
84 |
LOG.error("Error creating the wizard to install a package ", e); |
|
98 |
Process p = Runtime.getRuntime().exec(cmd); |
|
99 |
if( p.exitValue() != 0 ) { |
|
100 |
useInternalAddonsManager = true; |
|
101 |
} |
|
102 |
} catch (IOException ex) { |
|
103 |
logger.warn("Can't execute command '"+cmd+"'.",ex); |
|
104 |
useInternalAddonsManager = true; |
|
85 | 105 |
} |
86 | 106 |
} |
107 |
if( useInternalAddonsManager ) { |
|
108 |
logger.warn("Use internal addons manager."); |
|
109 |
showInternalAddonsManager(null); |
|
110 |
} |
|
87 | 111 |
} |
112 |
|
|
113 |
|
|
114 |
private void showInternalAddonsManager(Object[] args) { |
|
115 |
boolean skipBundleSelection = false; |
|
116 |
if (args != null && args.length > 0) { |
|
117 |
String subcmd = (String) args[0]; |
|
118 |
if ("skipBundleSelection".equalsIgnoreCase(subcmd)) { |
|
119 |
skipBundleSelection = true; |
|
120 |
} |
|
121 |
} |
|
122 |
PluginsManager manager = PluginsLocator.getManager(); |
|
123 |
try { |
|
124 |
PluginServices.getMDIManager().addCentredWindow( |
|
125 |
new InstallPackageWindow( |
|
126 |
manager.getApplicationFolder(), |
|
127 |
manager.getInstallFolder(), |
|
128 |
skipBundleSelection |
|
129 |
) |
|
130 |
); |
|
131 |
} catch (Error e) { |
|
132 |
logger.error("Error creating the wizard to install a package ", e); |
|
133 |
} catch (Exception e) { |
|
134 |
logger.error("Error creating the wizard to install a package ", e); |
|
135 |
} |
|
88 | 136 |
|
137 |
} |
|
138 |
|
|
89 | 139 |
public void initialize() { |
90 | 140 |
PluginsManager pm = PluginsLocator.getManager(); |
91 | 141 |
PackageInfo packageInfo = pm.getPackageInfo(); |
... | ... | |
99 | 149 |
.getSwingInstallerManager(); |
100 | 150 |
|
101 | 151 |
try { |
102 |
if ( packageInfo != null && (packageInfo.getState().startsWith(InstallerManager.STATE.BETA)
|
|
152 |
if (packageInfo != null && (packageInfo.getState().startsWith(InstallerManager.STATE.BETA) |
|
103 | 153 |
|| packageInfo.getState().startsWith(InstallerManager.STATE.RC) |
104 |
|| packageInfo.getState().equalsIgnoreCase(InstallerManager.STATE.FINAL)) ) {
|
|
154 |
|| packageInfo.getState().equalsIgnoreCase(InstallerManager.STATE.FINAL))) { |
|
105 | 155 |
|
106 | 156 |
String installURL = manager.getInstallerManager().getDownloadBaseURL().toString() |
107 | 157 |
+ "dists/<%Version%>/builds/<%Build%>/packages.gvspki ## Official gvSIG repository (frozen in this version)"; |
108 | 158 |
manager.addDefaultDownloadURL(installURL); |
109 | 159 |
} |
110 | 160 |
} catch (Throwable th) { |
111 |
LOG.info("Error. Can't select default gvspki", th);
|
|
161 |
logger.info("Error. Can't select default gvspki", th);
|
|
112 | 162 |
} |
113 | 163 |
|
114 | 164 |
InputStream is = this.getClass().getResourceAsStream( |
115 | 165 |
"/defaultDownloadsURLs"); |
116 | 166 |
BufferedReader in = new BufferedReader(new InputStreamReader(is)); |
117 | 167 |
String line = null; |
118 |
for ( line = in.readLine(); line != null; line = in.readLine() ) {
|
|
168 |
for (line = in.readLine(); line != null; line = in.readLine()) {
|
|
119 | 169 |
try { |
120 | 170 |
manager.addDefaultDownloadURL(line); |
121 | 171 |
} catch (MalformedURLException e) { |
122 |
LOG.error(
|
|
172 |
logger.error(
|
|
123 | 173 |
"Error creating the default packages download URL pointing to " |
124 | 174 |
+ line, e); |
125 | 175 |
} |
126 | 176 |
} |
127 | 177 |
manager.getInstallerManager().setVersion(version); |
128 | 178 |
} catch (Throwable e) { |
129 |
LOG.error("Error reading the default packages download URL file "
|
|
179 |
logger.error("Error reading the default packages download URL file "
|
|
130 | 180 |
+ "/defaultDownloadsURLs", e); |
131 | 181 |
} |
132 | 182 |
} |
Also available in: Unified diff