Revision 41706
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 | ||
---|---|---|
98 | 98 |
public static final String PACKAGE_SET_EXTENSION = ".gvspks"; |
99 | 99 |
public static final String PACKAGE_EXTENSION = ".gvspkg"; |
100 | 100 |
|
101 |
public static final String PACKAGE_INFO_FILE_NAME = "package.info"; |
|
101 | 102 |
/** |
102 | 103 |
* Package state default values. |
103 | 104 |
*/ |
... | ... | |
209 | 210 |
* @throws MakePluginPackageServiceException |
210 | 211 |
* if there is an error loading the information of the installed |
211 | 212 |
* plugins |
213 |
* @deprecated use getInstalledPackages() without parameters |
|
212 | 214 |
*/ |
213 | 215 |
public PackageInfo[] getInstalledPackages(File pluginsDirectory) |
214 | 216 |
throws MakePluginPackageServiceException; |
... | ... | |
492 | 494 |
* @deprecated use {@link #getDefaultLocalAddonRepository(java.lang.String) } |
493 | 495 |
*/ |
494 | 496 |
public File getDefaultLocalAddonRepository(); |
497 |
|
|
498 |
public static final int ACCESS_READ = 0; |
|
499 |
public static final int ACCESS_WRITE = 1; |
|
500 |
/** |
|
501 |
* Get the path to the default local repository for a type of package. |
|
502 |
* Grant that the path has the access required, can be: |
|
503 |
* |
|
504 |
* ACCESS_READ |
|
505 |
* ACCESS_WRITE |
|
506 |
* |
|
507 |
* If don't has a repository for this type of package or don't has the |
|
508 |
* requiered access mode return null. |
|
509 |
* |
|
510 |
* @param packageType type of package for that ask the default path |
|
511 |
* @param access type of access to the repository. |
|
512 |
* @return the path to the repository |
|
513 |
*/ |
|
514 |
public File getDefaultLocalAddonRepository(String packageType, int access); |
|
495 | 515 |
|
496 | 516 |
/** |
497 |
* Get the path to the default local repository for a type of package |
|
517 |
* Get the path to the default local repository for a type of package. |
|
518 |
* This is a utility method using by default ACCESS_READ to the reppository. |
|
519 |
* |
|
498 | 520 |
* @param packageType type of package for that ask the default path |
499 | 521 |
* @return the path to the repository |
500 | 522 |
*/ |
501 | 523 |
public File getDefaultLocalAddonRepository(String packageType); |
502 | 524 |
|
525 |
|
|
503 | 526 |
/** |
504 | 527 |
* Set the path to the default local repository for a type of package |
505 | 528 |
* @param defaultAddonsRepository path to the repository |
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 | ||
---|---|---|
128 | 128 |
return false; |
129 | 129 |
} |
130 | 130 |
|
131 |
public boolean contains(PackageInfo packageInfo) { |
|
132 |
if( !this.support(packageInfo.getType()) ) { |
|
133 |
return false; |
|
134 |
} |
|
135 |
String packageInfoName = packageInfo.getCode() + File.separator + PACKAGE_INFO_FILE_NAME; |
|
136 |
File packageInfoFile = new File(this.location,packageInfoName); |
|
137 |
return packageInfoFile.exists(); |
|
138 |
} |
|
139 |
|
|
131 | 140 |
public boolean support(String type) { |
132 | 141 |
for( String atype : this.types ) { |
133 | 142 |
if( atype != null ) { |
... | ... | |
470 | 479 |
} |
471 | 480 |
|
472 | 481 |
public File getDefaultLocalAddonRepository(String packageType) { |
482 |
return this.getDefaultLocalAddonRepository(packageType,ACCESS_READ); |
|
483 |
} |
|
484 |
|
|
485 |
public File getDefaultLocalAddonRepository(String packageType, int access) { |
|
473 | 486 |
File f = this.defaultRepositoryLocation.get(packageType); |
474 |
return f; |
|
487 |
switch(access) { |
|
488 |
case ACCESS_WRITE: |
|
489 |
if( f.canWrite() ) { |
|
490 |
return f; |
|
491 |
} |
|
492 |
break; |
|
493 |
case ACCESS_READ: |
|
494 |
default: |
|
495 |
if( f.canRead()) { |
|
496 |
return f; |
|
497 |
} |
|
498 |
break; |
|
499 |
} |
|
500 |
List<File> repositoriesLocaltions = this.getLocalAddonRepositories(packageType); |
|
501 |
for( File repositoryLocation : repositoriesLocaltions ) { |
|
502 |
switch(access) { |
|
503 |
case ACCESS_WRITE: |
|
504 |
if( repositoryLocation.canWrite() ) { |
|
505 |
return repositoryLocation; |
|
506 |
} |
|
507 |
break; |
|
508 |
case ACCESS_READ: |
|
509 |
default: |
|
510 |
if( repositoryLocation.canRead()) { |
|
511 |
return repositoryLocation; |
|
512 |
} |
|
513 |
break; |
|
514 |
} |
|
515 |
} |
|
516 |
return null; |
|
475 | 517 |
} |
476 | 518 |
|
477 | 519 |
public void setDefaultLocalAddonRepository(File defaultAddonsRepository, String packageType) { |
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/creation/DefaultMakePluginPackageService.java | ||
---|---|---|
358 | 358 |
} |
359 | 359 |
|
360 | 360 |
private File getAbsolutePluginPackageDirectory(PackageInfo packageInfo) |
361 |
throws MakePluginPackageServiceException { |
|
362 |
String destinationFilePath = manager.getDefaultLocalAddonRepository(packageInfo.getType()) |
|
363 |
.getAbsolutePath() |
|
364 |
+ File.separator + packageInfo.getCode(); |
|
365 |
return new File(destinationFilePath); |
|
361 |
throws MakePluginPackageServiceException { |
|
362 |
File folder = manager.getAddonFolder(packageInfo.getCode()); |
|
363 |
// Si existe un addon para ese packageinfo lo usamos, y si no |
|
364 |
// devolbemos la carpeta del addon en el repositorio local por defecto |
|
365 |
// para ese tipo de addon en el que se pueda escribir para que se |
|
366 |
// pueda crear alli el addon. |
|
367 |
if( folder == null ) { |
|
368 |
folder = manager.getDefaultLocalAddonRepository(packageInfo.getType(), InstallerManager.ACCESS_WRITE); |
|
369 |
folder = new File(folder, packageInfo.getCode()); |
|
370 |
} |
|
371 |
return folder.getAbsoluteFile(); |
|
366 | 372 |
} |
367 | 373 |
|
368 | 374 |
public Manager getManager() { |
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.installer/org.gvsig.installer.prov/org.gvsig.installer.prov.plugin/src/main/java/org/gvsig/installer/prov/plugin/execution/PluginInstallerExecutionProvider.java | ||
---|---|---|
10 | 10 |
* |
11 | 11 |
* This program is distributed in the hope that it will be useful, |
12 | 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 | 14 |
* GNU General Public License for more details. |
15 | 15 |
* |
16 | 16 |
* You should have received a copy of the GNU General Public License |
17 | 17 |
* along with this program; if not, write to the Free Software |
18 | 18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
19 |
* MA 02110-1301, USA.
|
|
19 |
* MA 02110-1301, USA. |
|
20 | 20 |
* |
21 | 21 |
* For any additional information, do not hesitate to contact us |
22 | 22 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
... | ... | |
25 | 25 |
* AUTHORS (In addition to CIT): |
26 | 26 |
* 2010 {Prodevelop} {Task} |
27 | 27 |
*/ |
28 |
|
|
29 | 28 |
package org.gvsig.installer.prov.plugin.execution; |
30 | 29 |
|
31 | 30 |
import java.io.BufferedWriter; |
... | ... | |
49 | 48 |
|
50 | 49 |
import com.sardak.antform.AntForm; |
51 | 50 |
import com.sardak.antform.AntMenu; |
51 |
import org.gvsig.installer.lib.api.InstallerLocator; |
|
52 |
import org.gvsig.installer.lib.api.InstallerManager; |
|
52 | 53 |
|
53 | 54 |
/** |
54 | 55 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a> |
55 | 56 |
*/ |
56 | 57 |
public class PluginInstallerExecutionProvider extends AbstractProvider |
57 |
implements InstallPackageProvider {
|
|
58 |
implements InstallPackageProvider {
|
|
58 | 59 |
|
59 |
private static Logger logger = LoggerFactory.getLogger(PluginInstallerExecutionProvider.class); |
|
60 |
private static final String ANT_FILE_NAME = "install.xml"; |
|
61 |
private File pluginsDirectory = null; |
|
62 |
private File applicationDirectory = null; |
|
63 |
private File decompressDir = null; |
|
64 |
private static final InstallerProviderManager installerProviderManager = InstallerProviderLocator |
|
65 |
.getProviderManager(); |
|
60 |
private static Logger logger = LoggerFactory.getLogger(PluginInstallerExecutionProvider.class); |
|
61 |
private static final String ANT_FILE_NAME = "install.xml"; |
|
66 | 62 |
|
67 |
public PluginInstallerExecutionProvider(ProviderServices providerServices) {
|
|
68 |
super(providerServices);
|
|
69 |
}
|
|
63 |
public PluginInstallerExecutionProvider(ProviderServices providerServices) {
|
|
64 |
super(providerServices);
|
|
65 |
}
|
|
70 | 66 |
|
71 |
public class InstallerPluginsDirectoryNotFoundException extends
|
|
72 |
InstallPackageServiceException {
|
|
67 |
public class InstallerPluginsDirectoryNotFoundException extends
|
|
68 |
InstallPackageServiceException {
|
|
73 | 69 |
|
74 |
private static final long serialVersionUID = 4416143986837955880L;
|
|
70 |
private static final long serialVersionUID = 4416143986837955880L;
|
|
75 | 71 |
|
76 |
private static final String message = "Plugins directory not found";
|
|
72 |
private static final String message = "Plugins directory not found";
|
|
77 | 73 |
|
78 |
private static final String KEY = "plugins_directory_not_found";
|
|
74 |
private static final String KEY = "plugins_directory_not_found";
|
|
79 | 75 |
|
80 |
public InstallerPluginsDirectoryNotFoundException() {
|
|
81 |
super(message, KEY, serialVersionUID);
|
|
82 |
}
|
|
76 |
public InstallerPluginsDirectoryNotFoundException() {
|
|
77 |
super(message, KEY, serialVersionUID);
|
|
78 |
}
|
|
83 | 79 |
|
84 |
}
|
|
80 |
}
|
|
85 | 81 |
|
86 |
public void install(File applicationDirectory, InputStream inputStream,
|
|
87 |
PackageInfo packageInfo) throws InstallPackageServiceException {
|
|
82 |
public void install(File applicationDirectory, InputStream inputStream,
|
|
83 |
PackageInfo packageInfo) throws InstallPackageServiceException {
|
|
88 | 84 |
|
89 |
this.applicationDirectory = applicationDirectory; |
|
90 |
pluginsDirectory = new File(applicationDirectory + File.separator |
|
91 |
+ "gvSIG" + File.separator + "extensiones"); |
|
92 |
logger.info("Installing package '"+packageInfo.getCode()+"' in '"+pluginsDirectory+"'."); |
|
93 |
try { |
|
94 |
if (!pluginsDirectory.exists()) { |
|
95 |
logger.warn("Can install package '"+packageInfo.getCode()+"', install folder '"+pluginsDirectory+"' does not exists"); |
|
96 |
throw new InstallerPluginsDirectoryNotFoundException(); |
|
97 |
} |
|
85 |
InstallerProviderManager installerProviderManager = InstallerProviderLocator.getProviderManager(); |
|
86 |
InstallerManager installerManager = InstallerLocator.getInstallerManager(); |
|
87 |
|
|
88 |
File pluginsDirectory = installerManager.getDefaultLocalAddonRepository( |
|
89 |
"plugin", |
|
90 |
InstallerManager.ACCESS_WRITE |
|
91 |
); |
|
98 | 92 |
|
99 |
InstallPackageProviderServices installerProviderServices = installerProviderManager |
|
100 |
.createInstallerProviderServices(); |
|
93 |
logger.info("Installing package '" + packageInfo.getCode() + "' in '" + pluginsDirectory + "'."); |
|
94 |
try { |
|
95 |
if ( !pluginsDirectory.exists() ) { |
|
96 |
logger.warn("Can install package '" + packageInfo.getCode() + "', install folder '" + pluginsDirectory + "' does not exists"); |
|
97 |
throw new InstallerPluginsDirectoryNotFoundException(); |
|
98 |
} |
|
101 | 99 |
|
102 |
installerProviderServices.decompress(inputStream, pluginsDirectory); |
|
103 |
File antFile = new File(pluginsDirectory + File.separator |
|
104 |
+ packageInfo.getCode() + File.separator + "install" |
|
105 |
+ File.separator + ANT_FILE_NAME); |
|
100 |
InstallPackageProviderServices installerProviderServices = installerProviderManager |
|
101 |
.createInstallerProviderServices(); |
|
106 | 102 |
|
107 |
if (antFile.exists()) { |
|
108 |
executeAntFile(antFile); |
|
109 |
} |
|
103 |
installerProviderServices.decompress(inputStream, pluginsDirectory); |
|
104 |
File antFile = new File(pluginsDirectory + File.separator |
|
105 |
+ packageInfo.getCode() + File.separator + "install" |
|
106 |
+ File.separator + ANT_FILE_NAME); |
|
110 | 107 |
|
111 |
} catch (Exception e) { |
|
112 |
try { |
|
113 |
logger.warn("Can install package '"+packageInfo.getCode()+"'.", e); |
|
114 |
// if there is an exception, installLater is called |
|
115 |
installLater(applicationDirectory, inputStream, packageInfo); |
|
116 |
} catch (IOException e1) { |
|
117 |
logger.warn("Can install package '"+packageInfo.getCode()+"'.", e1); |
|
118 |
throw new InstallPackageServiceException(e1); |
|
119 |
} |
|
120 |
} |
|
121 |
} |
|
108 |
if ( antFile.exists() ) { |
|
109 |
executeAntFile(applicationDirectory, pluginsDirectory, antFile); |
|
110 |
} |
|
122 | 111 |
|
123 |
/** |
|
124 |
* This function will is called when an exception is produced during the |
|
125 |
* installation of a plugin. It will prepare the package to be installed on |
|
126 |
* the next gvSIG restart. |
|
127 |
*/ |
|
128 |
public void installLater(File applicationDirectory, |
|
129 |
InputStream inputStream, PackageInfo packageInfo) |
|
130 |
throws InstallPackageServiceException, IOException { |
|
112 |
} catch (Exception e) { |
|
113 |
try { |
|
114 |
logger.warn("Can install package '" + packageInfo.getCode() + "'.", e); |
|
115 |
// if there is an exception, installLater is called |
|
116 |
installLater(applicationDirectory, inputStream, packageInfo); |
|
117 |
} catch (IOException e1) { |
|
118 |
logger.warn("Can install package '" + packageInfo.getCode() + "'.", e1); |
|
119 |
throw new InstallPackageServiceException(e1); |
|
120 |
} |
|
121 |
} |
|
122 |
} |
|
131 | 123 |
|
132 |
logger.info("Delayed the package installation ("+packageInfo.getCode()+")."); |
|
133 |
this.applicationDirectory = applicationDirectory; |
|
124 |
/** |
|
125 |
* This function will is called when an exception is produced during the |
|
126 |
* installation of a plugin. It will prepare the package to be installed on |
|
127 |
* the next gvSIG restart. |
|
128 |
*/ |
|
129 |
public void installLater(File applicationDirectory, |
|
130 |
InputStream inputStream, PackageInfo packageInfo) |
|
131 |
throws InstallPackageServiceException, IOException { |
|
134 | 132 |
|
135 |
File updateDirectory = new File(applicationDirectory + File.separator |
|
136 |
+ "update"); |
|
133 |
InstallerProviderManager installerProviderManager = InstallerProviderLocator.getProviderManager(); |
|
134 |
File decompressDir = null; |
|
135 |
|
|
136 |
logger.info("Delayed the package installation (" + packageInfo.getCode() + ")."); |
|
137 | 137 |
|
138 |
if (!updateDirectory.exists()) { |
|
139 |
forceMkdir(updateDirectory); |
|
140 |
} |
|
138 |
File updateDirectory = new File(applicationDirectory + File.separator |
|
139 |
+ "update"); |
|
141 | 140 |
|
142 |
File filesDirectory = new File(updateDirectory + File.separator |
|
143 |
+ "files"); |
|
144 |
if (!filesDirectory.exists()) { |
|
145 |
forceMkdir(filesDirectory); |
|
146 |
} |
|
141 |
if ( !updateDirectory.exists() ) { |
|
142 |
forceMkdir(updateDirectory); |
|
143 |
} |
|
147 | 144 |
|
148 |
File scriptsFile = new File(updateDirectory + File.separator |
|
149 |
+ "scripts.lst"); |
|
145 |
File filesDirectory = new File(updateDirectory + File.separator |
|
146 |
+ "files"); |
|
147 |
if ( !filesDirectory.exists() ) { |
|
148 |
forceMkdir(filesDirectory); |
|
149 |
} |
|
150 | 150 |
|
151 |
decompressDir = new File(filesDirectory.toString() + File.separator |
|
152 |
+ packageInfo.getCode()); |
|
153 |
if (decompressDir.exists()) { |
|
154 |
deleteDir(decompressDir); |
|
155 |
} |
|
151 |
File scriptsFile = new File(updateDirectory + File.separator |
|
152 |
+ "scripts.lst"); |
|
156 | 153 |
|
157 |
InstallPackageProviderServices installerProviderServices = installerProviderManager |
|
158 |
.createInstallerProviderServices(); |
|
159 |
installerProviderServices.decompress(inputStream, filesDirectory); |
|
154 |
decompressDir = new File(filesDirectory.toString() + File.separator |
|
155 |
+ packageInfo.getCode()); |
|
156 |
if ( decompressDir.exists() ) { |
|
157 |
deleteDir(decompressDir); |
|
158 |
} |
|
160 | 159 |
|
161 |
File antFile = new File(decompressDir + File.separator + "install" |
|
162 |
+ File.separator + ANT_FILE_NAME); |
|
160 |
InstallPackageProviderServices installerProviderServices = installerProviderManager |
|
161 |
.createInstallerProviderServices(); |
|
162 |
installerProviderServices.decompress(inputStream, filesDirectory); |
|
163 | 163 |
|
164 |
if (antFile.exists()) { |
|
165 |
if (!scriptsFile.exists()) { |
|
166 |
forceMkdir(scriptsFile); |
|
167 |
scriptsFile.createNewFile(); |
|
168 |
} |
|
169 |
FileWriter writer = new FileWriter(scriptsFile, true); |
|
170 |
BufferedWriter out = new BufferedWriter(writer); |
|
171 |
String str = antFile.toString(); |
|
172 |
out.append(str + "\n"); |
|
173 |
out.close(); |
|
174 |
} |
|
164 |
File antFile = new File(decompressDir + File.separator + "install" |
|
165 |
+ File.separator + ANT_FILE_NAME); |
|
175 | 166 |
|
176 |
} |
|
167 |
if ( antFile.exists() ) { |
|
168 |
if ( !scriptsFile.exists() ) { |
|
169 |
forceMkdir(scriptsFile); |
|
170 |
scriptsFile.createNewFile(); |
|
171 |
} |
|
172 |
FileWriter writer = new FileWriter(scriptsFile, true); |
|
173 |
BufferedWriter out = new BufferedWriter(writer); |
|
174 |
String str = antFile.toString(); |
|
175 |
out.append(str + "\n"); |
|
176 |
out.close(); |
|
177 |
} |
|
177 | 178 |
|
178 |
private void forceMkdir(File file) throws IOException { |
|
179 |
if( file.isDirectory() ) { |
|
180 |
org.apache.commons.io.FileUtils.forceMkdir(file); |
|
181 |
} else { |
|
182 |
org.apache.commons.io.FileUtils.forceMkdir(file.getParentFile()); |
|
183 |
} |
|
184 |
} |
|
185 |
|
|
186 |
private void executeAntFile(File file) { |
|
187 |
logger.info("Running install script '"+file.getAbsolutePath()+"'."); |
|
188 |
try { |
|
189 |
Project p = new Project(); |
|
190 |
p.setUserProperty("ant.file", file.getAbsolutePath()); |
|
191 |
p.setUserProperty("gvsig_dir", applicationDirectory.getAbsolutePath()); |
|
192 |
p.setUserProperty("extensions_dir", pluginsDirectory.getAbsolutePath()); |
|
193 |
p.setBaseDir(file.getParentFile()); |
|
194 |
p.addTaskDefinition("antform", AntForm.class); |
|
195 |
p.addTaskDefinition("antmenu", AntMenu.class); |
|
196 |
p.init(); |
|
197 |
ProjectHelper helper = ProjectHelper.getProjectHelper(); |
|
198 |
p.addReference("ant.projectHelper", helper); |
|
199 |
helper.parse(p, file); |
|
200 |
p.executeTarget(p.getDefaultTarget()); |
|
201 |
} catch(Exception ex) { |
|
202 |
logger.warn("Problems executing installation script.", ex); |
|
203 |
} |
|
204 |
} |
|
179 |
} |
|
205 | 180 |
|
206 |
private boolean deleteDir(File dir) { |
|
207 |
if (dir.isDirectory()) { |
|
208 |
String[] children = dir.list(); |
|
209 |
for (int i = 0; i < children.length; i++) { |
|
210 |
boolean success = deleteDir(new File(dir, children[i])); |
|
211 |
if (!success) { |
|
212 |
return false; |
|
213 |
} |
|
214 |
} |
|
215 |
} |
|
216 |
// The directory is now empty so delete it |
|
217 |
return dir.delete(); |
|
218 |
} |
|
181 |
private void forceMkdir(File file) throws IOException { |
|
182 |
if ( file.isDirectory() ) { |
|
183 |
org.apache.commons.io.FileUtils.forceMkdir(file); |
|
184 |
} else { |
|
185 |
org.apache.commons.io.FileUtils.forceMkdir(file.getParentFile()); |
|
186 |
} |
|
187 |
} |
|
219 | 188 |
|
189 |
private void executeAntFile(File applicationDirectory, File pluginsDirectory, File file) { |
|
190 |
logger.info("Running install script '" + file.getAbsolutePath() + "'."); |
|
191 |
try { |
|
192 |
Project p = new Project(); |
|
193 |
p.setUserProperty("ant.file", file.getAbsolutePath()); |
|
194 |
p.setUserProperty("gvsig_dir", applicationDirectory.getAbsolutePath()); |
|
195 |
p.setUserProperty("extensions_dir", pluginsDirectory.getAbsolutePath()); |
|
196 |
p.setBaseDir(file.getParentFile()); |
|
197 |
p.addTaskDefinition("antform", AntForm.class); |
|
198 |
p.addTaskDefinition("antmenu", AntMenu.class); |
|
199 |
p.init(); |
|
200 |
ProjectHelper helper = ProjectHelper.getProjectHelper(); |
|
201 |
p.addReference("ant.projectHelper", helper); |
|
202 |
helper.parse(p, file); |
|
203 |
p.executeTarget(p.getDefaultTarget()); |
|
204 |
} catch (Exception ex) { |
|
205 |
logger.warn("Problems executing installation script.", ex); |
|
206 |
} |
|
207 |
} |
|
208 |
|
|
209 |
private boolean deleteDir(File dir) { |
|
210 |
if ( dir.isDirectory() ) { |
|
211 |
String[] children = dir.list(); |
|
212 |
for ( int i = 0; i < children.length; i++ ) { |
|
213 |
boolean success = deleteDir(new File(dir, children[i])); |
|
214 |
if ( !success ) { |
|
215 |
return false; |
|
216 |
} |
|
217 |
} |
|
218 |
} |
|
219 |
// The directory is now empty so delete it |
|
220 |
return dir.delete(); |
|
221 |
} |
|
222 |
|
|
220 | 223 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/Launcher.java | ||
---|---|---|
98 | 98 |
import org.apache.commons.configuration.PropertiesConfiguration; |
99 | 99 |
import org.apache.commons.io.FileUtils; |
100 | 100 |
import org.apache.commons.lang3.JavaVersion; |
101 |
import org.apache.commons.lang3.StringUtils; |
|
101 | 102 |
import org.apache.commons.lang3.SystemUtils; |
102 | 103 |
import org.apache.log4j.AppenderSkeleton; |
103 | 104 |
import org.apache.log4j.PatternLayout; |
... | ... | |
330 | 331 |
protected static MultiSplashWindow splashWindow; |
331 | 332 |
protected static String appName; |
332 | 333 |
protected static Locale locale; |
333 |
protected static PluginsConfig pluginsConfig = new PluginsConfig(); |
|
334 |
protected static PluginsConfig pluginsConfig = new PluginsConfig();
|
|
334 | 335 |
protected static PluginsServices pluginsServices = new PluginsServices(); |
335 | 336 |
protected static MDIFrame frame; |
336 | 337 |
protected static HashMap<Class<? extends IExtension>, ExtensionDecorator> classesExtensions = new HashMap<Class<? extends IExtension>, ExtensionDecorator>(); |
... | ... | |
512 | 513 |
this.addError("Can't downloads plugins", ex); |
513 | 514 |
} |
514 | 515 |
|
515 |
// Initialize andami libraries |
|
516 | 516 |
splashWindow.process(translate("SplashWindow.initialize_install_manager")); |
517 |
PluginsManager pluginmgr = PluginsLocator.getManager(); |
|
518 |
File defaultAddonsRepository = pluginmgr.getPluginsFolder(); |
|
519 |
InstallerManager installerManager = InstallerLocator.getInstallerManager(); |
|
520 |
installerManager.setDefaultLocalAddonRepository(defaultAddonsRepository,"plugin"); |
|
517 |
initializeInstallerManager(); |
|
521 | 518 |
|
522 |
splashWindow.process(translate("SplashWindow.initialize_list_of_addons_installeds")); |
|
523 |
// --------------------------------------------- |
|
524 |
// Get the list of installed packages |
|
525 |
|
|
526 |
PackageInfo[] installedPackages = null; |
|
527 |
try { |
|
528 |
installedPackages = installerManager.getInstalledPackages( |
|
529 |
pluginmgr.getPluginsFolder() |
|
530 |
); |
|
531 |
} catch (MakePluginPackageServiceException e) { |
|
532 |
// Do nothing, ignore errors |
|
533 |
} |
|
519 |
|
|
520 |
InstallerManager installerManager = InstallerLocator.getInstallerManager(); |
|
521 |
PackageInfo[] installedPackages = null; |
|
522 |
try { |
|
523 |
installedPackages = installerManager.getInstalledPackages(); |
|
524 |
} catch (MakePluginPackageServiceException e) { |
|
525 |
// Do nothing, ignore errors |
|
526 |
} |
|
527 |
logger.info("Dump system information"); |
|
528 |
logger_info(getInformation(installedPackages)); |
|
529 |
saveEnvironInformation(installedPackages); |
|
534 | 530 |
|
535 |
splashWindow.process(translate("SplashWindow.Dump_system_information")); |
|
536 |
logger.info("Dump system information"); |
|
537 |
logger_info(getInformation(installedPackages)); |
|
538 |
saveEnvironInformation(installedPackages); |
|
539 |
|
|
540 |
// Se leen los config.xml de los plugins |
|
531 |
|
|
532 |
// Se leen los config.xml de los plugins |
|
541 | 533 |
splashWindow.process(translate("SplashWindow.load_plugins_configuration")); |
542 | 534 |
try { |
543 | 535 |
logger.info("Load plugins information"); |
544 |
this.loadPlugins(andamiConfig.getPluginsDirectory());
|
|
536 |
this.loadPlugins(); |
|
545 | 537 |
} catch (Throwable ex) { |
546 | 538 |
this.addError("Can't load plugins", ex); |
547 | 539 |
} |
... | ... | |
636 | 628 |
} |
637 | 629 |
}); |
638 | 630 |
|
639 |
/* |
|
640 |
* Initialize local repository folders of the installer |
|
641 |
*/ |
|
642 |
message(translate("SplashWindow.initializing_local_addon_repository_folders")); |
|
643 |
initializeLocalAddOnRepositoryFolders(); |
|
644 |
|
|
645 | 631 |
message(translate("SplashWindow.initializing_server_data_persistence")); |
646 | 632 |
ServerDataPersistence.registerPersistence(); |
647 | 633 |
|
... | ... | |
711 | 697 |
PluginsLocator.getManager().executeStartupTasks(); |
712 | 698 |
|
713 | 699 |
} |
714 |
|
|
700 |
|
|
701 |
private void initializeInstallerManager() { |
|
702 |
PluginsManager pluginmgr = PluginsLocator.getManager(); |
|
703 |
InstallerManager installerManager = InstallerLocator.getInstallerManager(); |
|
704 |
|
|
705 |
// |
|
706 |
// Configure repository of plugins |
|
707 |
// |
|
708 |
List<File> folders = pluginmgr.getPluginsFolders(); |
|
709 |
for ( File folder : folders ) { |
|
710 |
installerManager.addLocalAddonRepository(folder, "plugin"); |
|
711 |
} |
|
712 |
installerManager.setDefaultLocalAddonRepository(folders.get(0), "plugin"); |
|
713 |
|
|
714 |
// |
|
715 |
// Configure repository of iconsets |
|
716 |
// |
|
717 |
IconThemeManager iconManager = ToolsSwingLocator.getIconThemeManager(); |
|
718 |
FolderSet fset = iconManager.getRepository(); |
|
719 |
Iterator<FolderSet.FolderEntry> it = fset.iterator(); |
|
720 |
boolean first = true; |
|
721 |
while( it.hasNext() ) { |
|
722 |
FolderEntry entry = it.next(); |
|
723 |
installerManager.addLocalAddonRepository(entry.getFolder(),"iconset"); |
|
724 |
if( first ) { |
|
725 |
first = false; |
|
726 |
installerManager.setDefaultLocalAddonRepository(entry.getFolder(),"iconset"); |
|
727 |
} |
|
728 |
} |
|
729 |
|
|
730 |
} |
|
731 |
|
|
715 | 732 |
private void message(final String msg) { |
716 | 733 |
if (!SwingUtilities.isEventDispatchThread()) { |
717 | 734 |
try { |
... | ... | |
734 | 751 |
} |
735 | 752 |
} |
736 | 753 |
|
737 |
private void initializeLocalAddOnRepositoryFolders() { |
|
738 |
InstallerManager installerManager = InstallerLocator.getInstallerManager(); |
|
739 |
|
|
740 |
File defaultAddonsRepository = PluginsLocator.getManager().getPluginsFolder(); |
|
741 |
|
|
742 |
installerManager.addLocalAddonRepository(defaultAddonsRepository,"plugin"); |
|
743 |
installerManager.setDefaultLocalAddonRepository(defaultAddonsRepository); |
|
744 |
|
|
745 |
IconThemeManager iconManager = ToolsSwingLocator.getIconThemeManager(); |
|
746 |
FolderSet fset = iconManager.getRepository(); |
|
747 |
Iterator<FolderSet.FolderEntry> it = fset.iterator(); |
|
748 |
while( it.hasNext() ) { |
|
749 |
FolderEntry entry = it.next(); |
|
750 |
installerManager.addLocalAddonRepository(entry.getFolder(),"iconset"); |
|
751 |
} |
|
752 |
} |
|
753 |
|
|
754 |
|
|
755 |
|
|
756 |
/** |
|
757 |
* |
|
758 |
*/ |
|
759 | 754 |
private void initializeLibraries() { |
760 | 755 |
List<ClassLoader> classLoaders = new ArrayList<ClassLoader>( |
761 | 756 |
pluginsOrdered.size() + 1); |
... | ... | |
2132 | 2127 |
} |
2133 | 2128 |
} |
2134 | 2129 |
} |
2130 |
|
|
2131 |
private URL[] getPluginClasspathURLs(PluginConfig pluginConfig) { |
|
2132 |
URL[] urls = null; |
|
2135 | 2133 |
|
2136 |
private void pluginsClassLoaders() {
|
|
2137 |
Set<String> installed = new HashSet<String>();
|
|
2134 |
String libfolderPath = pluginConfig.getLibraries().getLibraryDir();
|
|
2135 |
File libFolderFile = new File(pluginConfig.getPluginFolder(), libfolderPath);
|
|
2138 | 2136 |
|
2139 |
// Se itera hasta que est�n todos instalados |
|
2140 |
while (installed.size() != pluginsConfig.size()) { |
|
2141 |
boolean circle = true; |
|
2137 |
File[] files = libFolderFile.listFiles(new FileFilter() { |
|
2142 | 2138 |
|
2143 |
// Hacemos una pasada por todos los plugins |
|
2144 |
Iterator<String> i = pluginsConfig.keySet().iterator(); |
|
2139 |
public boolean accept(File pathname) { |
|
2140 |
return (pathname.getName().toUpperCase().endsWith(".JAR") |
|
2141 |
|| pathname.getName().toUpperCase().endsWith(".ZIP")); |
|
2142 |
} |
|
2143 |
}); |
|
2144 |
if ( files == null ) { |
|
2145 |
urls = new URL[0]; |
|
2146 |
} else { |
|
2147 |
urls = new URL[files.length]; |
|
2148 |
for ( int j = 0; j < files.length; j++ ) { |
|
2149 |
try { |
|
2150 |
urls[j] = new URL("file:" + files[j]); |
|
2151 |
} catch (MalformedURLException e) { |
|
2152 |
logger.warn("Can't add file '" + files[j] + "' to the classpath of plugin '" + pluginConfig.getPluginName() + "'."); |
|
2153 |
} |
|
2154 |
} |
|
2155 |
} |
|
2156 |
return urls; |
|
2157 |
} |
|
2145 | 2158 |
|
2146 |
while (i.hasNext()) { |
|
2147 |
String pluginName = i.next(); |
|
2148 |
PluginConfig config = (PluginConfig) pluginsConfig |
|
2149 |
.get(pluginName); |
|
2159 |
private void pluginsClassLoaders() { |
|
2160 |
Set<String> installed = new HashSet<String>(); |
|
2150 | 2161 |
|
2151 |
if (installed.contains(pluginName)) {
|
|
2152 |
continue;
|
|
2153 |
}
|
|
2162 |
// Se itera hasta que est�n todos instalados
|
|
2163 |
while ( installed.size() != pluginsConfig.size() ) {
|
|
2164 |
boolean circle = true;
|
|
2154 | 2165 |
|
2155 |
// Se obtienen las dependencias y sus class loaders |
|
2156 |
boolean ready = true; |
|
2157 |
Depends[] dependencies = config.getDepends(); |
|
2158 |
List<PluginClassLoader> loaders = new ArrayList<PluginClassLoader>(); |
|
2166 |
// Hacemos una pasada por todos los plugins |
|
2167 |
Iterator<String> i = pluginsConfig.keySet().iterator(); |
|
2159 | 2168 |
|
2160 |
for (int j = 0; j < dependencies.length; j++) { |
|
2161 |
Depends dependency = dependencies[j]; |
|
2162 |
String dependencyName = dependency.getPluginName(); |
|
2163 |
PluginConfig dependencyPluginConfig = pluginsConfig.get(dependencyName); |
|
2164 |
PluginServices dependencyPluginService = pluginsServices.get(dependencyName); |
|
2165 |
|
|
2166 |
if( getDeprecatedPluginNames().contains(dependencyName) ) { |
|
2167 |
logger.warn("Plugin '"+pluginName+"' use a deprecated plugin name '"+dependencyName+"' as dependency. Must use '"+pluginsConfig.getMainKey(dependencyName)+"'."); |
|
2168 |
} |
|
2169 |
if ( dependencyPluginConfig == null) { |
|
2170 |
if( dependency.getOptional() ) { |
|
2171 |
this.logger.info("Plugin '"+pluginName+"', optional dependency '"+dependencyName+"' not found"); |
|
2172 |
} else { |
|
2173 |
this.addError(Messages.getString("Launcher.Dependencia_no_resuelta_en_plugin") |
|
2174 |
+ " " |
|
2175 |
+ pluginName |
|
2176 |
+ ": " |
|
2177 |
+ dependencies[j].getPluginName()); |
|
2178 |
} |
|
2179 |
} else { |
|
2180 |
if ( dependencyPluginService!=null && |
|
2181 |
installed.contains(dependencyPluginService.getPluginName())) { |
|
2182 |
loaders.add(dependencyPluginService.getClassLoader()); |
|
2183 |
} else { |
|
2184 |
// if( !dependency.getOptional() ) { |
|
2185 |
ready = false; |
|
2186 |
// } |
|
2187 |
} |
|
2188 |
} |
|
2189 |
} |
|
2169 |
while ( i.hasNext() ) { |
|
2170 |
String pluginName = i.next(); |
|
2171 |
PluginConfig config = (PluginConfig) pluginsConfig |
|
2172 |
.get(pluginName); |
|
2190 | 2173 |
|
2191 |
// Si no est�n sus dependencias satisfechas se aborta la |
|
2192 |
// instalaci�n |
|
2193 |
if (!ready) { |
|
2194 |
continue; |
|
2195 |
} |
|
2174 |
if ( installed.contains(pluginName) ) { |
|
2175 |
continue; |
|
2176 |
} |
|
2196 | 2177 |
|
2197 |
// Se genera el class loader |
|
2198 |
String jardir = config.getLibraries().getLibraryDir(); |
|
2199 |
File jarDir = new File(andamiConfig.getPluginsDirectory(), |
|
2200 |
pluginName + File.separator + jardir); |
|
2201 |
File[] jarFiles = jarDir.listFiles(new FileFilter() { |
|
2178 |
// Se obtienen las dependencias y sus class loaders |
|
2179 |
boolean ready = true; |
|
2180 |
Depends[] dependencies = config.getDepends(); |
|
2181 |
List<PluginClassLoader> loaders = new ArrayList<PluginClassLoader>(); |
|
2202 | 2182 |
|
2203 |
public boolean accept(File pathname) { |
|
2204 |
return (pathname.getName().toUpperCase() |
|
2205 |
.endsWith(".JAR")) |
|
2206 |
|| (pathname.getName().toUpperCase() |
|
2207 |
.endsWith(".ZIP")); |
|
2208 |
} |
|
2209 |
}); |
|
2210 |
URL[] urls = null; |
|
2211 |
if( jarFiles==null ) { |
|
2212 |
urls = new URL[0]; |
|
2213 |
} else { |
|
2214 |
urls = new URL[jarFiles.length]; |
|
2215 |
|
|
2216 |
for (int j = 0; j < jarFiles.length; j++) { |
|
2217 |
try { |
|
2218 |
urls[j] = new URL("file:" + jarFiles[j]); |
|
2219 |
} catch (MalformedURLException e) { |
|
2220 |
this.addError(Messages |
|
2221 |
.getString("Launcher.No_se_puede_acceder_a") |
|
2222 |
+ " " + jarFiles[j]); |
|
2223 |
} |
|
2224 |
} |
|
2225 |
} |
|
2226 |
|
|
2227 |
PluginClassLoader loader; |
|
2183 |
for ( int j = 0; j < dependencies.length; j++ ) { |
|
2184 |
Depends dependency = dependencies[j]; |
|
2185 |
String dependencyName = dependency.getPluginName(); |
|
2186 |
PluginConfig dependencyPluginConfig = pluginsConfig.get(dependencyName); |
|
2187 |
PluginServices dependencyPluginService = pluginsServices.get(dependencyName); |
|
2228 | 2188 |
|
2229 |
try { |
|
2230 |
loader = new PluginClassLoader(urls, andamiConfig |
|
2231 |
.getPluginsDirectory() |
|
2232 |
+ File.separator + pluginName, Launcher.class |
|
2233 |
.getClassLoader(), loaders); |
|
2189 |
if ( getDeprecatedPluginNames().contains(dependencyName) ) { |
|
2190 |
logger.warn("Plugin '" + pluginName + "' use a deprecated plugin name '" + dependencyName + "' as dependency. Must use '" + pluginsConfig.getMainKey(dependencyName) + "'."); |
|
2191 |
} |
|
2192 |
if ( dependencyPluginConfig == null ) { |
|
2193 |
if ( dependency.getOptional() ) { |
|
2194 |
this.logger.info("Plugin '" + pluginName + "', optional dependency '" + dependencyName + "' not found"); |
|
2195 |
} else { |
|
2196 |
this.addError(Messages.getString("Launcher.Dependencia_no_resuelta_en_plugin") |
|
2197 |
+ " " |
|
2198 |
+ pluginName |
|
2199 |
+ ": " |
|
2200 |
+ dependencies[j].getPluginName()); |
|
2201 |
} |
|
2202 |
} else { |
|
2203 |
if ( dependencyPluginService != null |
|
2204 |
&& installed.contains(dependencyPluginService.getPluginName()) ) { |
|
2205 |
loaders.add(dependencyPluginService.getClassLoader()); |
|
2206 |
} else { |
|
2207 |
// if( !dependency.getOptional() ) { |
|
2208 |
ready = false; |
|
2209 |
// } |
|
2210 |
} |
|
2211 |
} |
|
2212 |
} |
|
2234 | 2213 |
|
2235 |
PluginServices ps = new PluginServices(loader, PluginsConfig.getAlternativeNames(config)); |
|
2214 |
// Si no est�n sus dependencias satisfechas se aborta la |
|
2215 |
// instalaci�n |
|
2216 |
if ( !ready ) { |
|
2217 |
continue; |
|
2218 |
} |
|
2236 | 2219 |
|
2237 |
pluginsServices.put(ps.getPluginName(), ps); |
|
2220 |
// Se genera el class loader |
|
2221 |
URL[] urls = getPluginClasspathURLs(config); |
|
2222 |
PluginClassLoader loader; |
|
2238 | 2223 |
|
2239 |
installed.add(pluginName); |
|
2240 |
// FJP: Los metemos ordenados para luego no cargar uno que |
|
2241 |
// necesita de otro antes de tiempo. Esto lo usaremos al |
|
2242 |
// inicializar los plugins |
|
2243 |
pluginsOrdered.add(pluginName); |
|
2224 |
try { |
|
2225 |
loader = new PluginClassLoader( |
|
2226 |
urls, |
|
2227 |
config.getPluginFolder().getAbsolutePath(), |
|
2228 |
Launcher.class.getClassLoader(), |
|
2229 |
loaders |
|
2230 |
); |
|
2231 |
PluginServices ps = new PluginServices( |
|
2232 |
loader, |
|
2233 |
PluginsConfig.getAlternativeNames(config) |
|
2234 |
); |
|
2235 |
pluginsServices.put(ps.getPluginName(), ps); |
|
2236 |
installed.add(pluginName); |
|
2237 |
pluginsOrdered.add(pluginName); |
|
2244 | 2238 |
|
2245 |
circle = false; |
|
2246 |
} catch (IOException e) { |
|
2247 |
this |
|
2248 |
.addError( |
|
2249 |
Messages |
|
2250 |
.getString("Launcher.Error_con_las_librerias_del_plugin"), |
|
2251 |
e); |
|
2252 |
pluginsConfig.remove(pluginName); |
|
2253 |
i = pluginsConfig.keySet().iterator(); |
|
2254 |
} |
|
2255 |
} |
|
2239 |
circle = false; |
|
2240 |
} catch (IOException e) { |
|
2241 |
logger.warn("Can't create PluginServices for '"+config.getPluginName()+"'.",e); |
|
2242 |
pluginsConfig.remove(pluginName); |
|
2243 |
i = pluginsConfig.keySet().iterator(); |
|
2244 |
} |
|
2245 |
} |
|
2256 | 2246 |
|
2257 |
if (circle) {
|
|
2258 |
dumpPluginsDependencyInformation();
|
|
2259 |
this.addError("Has circular dependencies betewn plugins");
|
|
2260 |
break;
|
|
2261 |
}
|
|
2262 |
}
|
|
2247 |
if ( circle ) {
|
|
2248 |
dumpPluginsDependencyInformation();
|
|
2249 |
this.addError("Has circular dependencies betewn plugins");
|
|
2250 |
break;
|
|
2251 |
}
|
|
2252 |
}
|
|
2263 | 2253 |
|
2264 |
// Se eliminan los plugins que no fueron instalados
|
|
2265 |
Iterator<String> i = pluginsConfig.keySet().iterator();
|
|
2254 |
// Se eliminan los plugins que no fueron instalados
|
|
2255 |
Iterator<String> i = pluginsConfig.keySet().iterator();
|
|
2266 | 2256 |
|
2267 |
while (i.hasNext()) {
|
|
2268 |
String pluginName = i.next();
|
|
2269 |
PluginServices ps = (PluginServices) pluginsServices
|
|
2270 |
.get(pluginName);
|
|
2257 |
while ( i.hasNext() ) {
|
|
2258 |
String pluginName = i.next();
|
|
2259 |
PluginServices ps = (PluginServices) pluginsServices
|
|
2260 |
.get(pluginName);
|
|
2271 | 2261 |
|
2272 |
if (ps == null) {
|
|
2273 |
pluginsConfig.remove(pluginName);
|
|
2274 |
i = pluginsConfig.keySet().iterator();
|
|
2275 |
}
|
|
2276 |
}
|
|
2277 |
registerActions();
|
|
2278 |
}
|
|
2262 |
if ( ps == null ) {
|
|
2263 |
pluginsConfig.remove(pluginName);
|
|
2264 |
i = pluginsConfig.keySet().iterator();
|
|
2265 |
}
|
|
2266 |
}
|
|
2267 |
registerActions();
|
|
2268 |
}
|
|
2279 | 2269 |
|
2280 | 2270 |
private void dumpPluginsDependencyInformation() { |
2281 | 2271 |
logger.info("Plugin dependency information"); |
... | ... | |
2323 | 2313 |
static String getPluginsDir() { |
2324 | 2314 |
return andamiConfig.getPluginsDirectory(); |
2325 | 2315 |
} |
2316 |
|
|
2317 |
static File getPluginFolder(String pluginName) { |
|
2318 |
return pluginsConfig.get(pluginName).getPluginFolder(); |
|
2319 |
} |
|
2326 | 2320 |
|
2327 | 2321 |
static void setPluginsDir(String s) { |
2328 | 2322 |
andamiConfig.setPluginsDirectory(s); |
... | ... | |
2332 | 2326 |
return frame; |
2333 | 2327 |
} |
2334 | 2328 |
|
2335 |
private void loadPlugins(String pluginsDirectory) { |
|
2336 |
File pDir = new File(pluginsDirectory); |
|
2329 |
|
|
2330 |
private void loadPlugins() { |
|
2331 |
InstallerManager installerManager = InstallerLocator.getInstallerManager(); |
|
2332 |
List<File> repositoriesFolders = installerManager.getLocalAddonRepositories("plugin"); |
|
2333 |
for ( File repositoryFolder : repositoriesFolders ) { |
|
2334 |
logger.info("Loading plugins from repository folder " + repositoryFolder.getAbsolutePath() + "."); |
|
2337 | 2335 |
|
2338 |
if (!pDir.exists()) { |
|
2339 |
logger |
|
2340 |
.error("\n\tPlugins directory not found: " |
|
2341 |
+ pDir.getAbsolutePath() |
|
2342 |
+ "\n\tDid you specify the correct directory in the Launch Configuration parameters?\n\tExiting now..."); |
|
2343 |
System.exit(-1); |
|
2344 |
return; |
|
2345 |
} |
|
2336 |
if ( !repositoryFolder.exists() ) { |
|
2337 |
logger.warn("Plugins repository folder not found '" + repositoryFolder.getAbsolutePath() + "'."); |
|
2338 |
continue; |
|
2339 |
} |
|
2346 | 2340 |
|
2347 |
File[] pluginDirs = pDir.listFiles(); |
|
2348 |
if (pluginDirs.length == 0) { |
|
2349 |
logger |
|
2350 |
.error("\n\tPlugins directory is empty: " |
|
2351 |
+ pDir.getAbsolutePath() |
|
2352 |
+ "Did you specify the correct directory in the Launch Configuration parameters?\n\tExiting now..."); |
|
2353 |
System.exit(-1); |
|
2354 |
return; |
|
2355 |
} |
|
2341 |
File[] pluginsFolders = repositoryFolder.listFiles(); |
|
2342 |
if ( pluginsFolders.length == 0 ) { |
|
2343 |
logger.warn("Plugins repository folder is empty '" + repositoryFolder.getAbsolutePath() + "'."); |
|
2344 |
continue; |
|
2345 |
} |
|
2356 | 2346 |
|
2357 |
for (int i = 0; i < pluginDirs.length; i++) { |
|
2358 |
if (pluginDirs[i].isDirectory()) { |
|
2359 |
String pluginName = pluginDirs[i].getName(); |
|
2360 |
File configXml = new File(pluginDirs[i].getAbsolutePath(), |
|
2361 |
"config.xml"); |
|
2347 |
for ( int i = 0; i < pluginsFolders.length; i++ ) { |
|
2348 |
File pluginFolder = pluginsFolders[i]; |
|
2349 |
if ( !pluginFolder.isDirectory() ) { |
|
2350 |
continue; |
|
2351 |
} |
|
2352 |
String pluginName = pluginFolder.getName(); |
|
2353 |
File pluginConfigFile = new File(pluginFolder, "config.xml"); |
|
2354 |
if ( !pluginConfigFile.exists() ) { |
|
2355 |
logger.info("Plugin '" + pluginName + "' not has a config.xml file (" + pluginConfigFile.getAbsolutePath() + "."); |
|
2356 |
continue; |
|
2357 |
} |
|
2358 |
try { |
|
2359 |
FileInputStream is = new FileInputStream(pluginConfigFile); |
|
2360 |
Reader xml = org.gvsig.utils.xml.XMLEncodingUtils.getReader(is); |
|
2361 |
if ( xml == null ) { |
|
2362 |
// the encoding was not correctly detected, use system default |
|
2363 |
xml = new FileReader(pluginConfigFile); |
|
2364 |
} else { |
|
2365 |
// use a buffered reader to improve performance |
|
2366 |
xml = new BufferedReader(xml); |
|
2367 |
} |
|
2368 |
PluginConfig pluginConfig = (PluginConfig) PluginConfig.unmarshal(xml); |
|
2369 |
pluginConfig.setPluginName(pluginName); |
|
2370 |
pluginConfig.setPluginFolder(pluginFolder); |
|
2371 |
pluginsConfig.put(pluginName, pluginConfig); |
|
2362 | 2372 |
|
2363 |
try { |
|
2364 |
FileInputStream is = new FileInputStream(configXml); |
|
2365 |
Reader xml = org.gvsig.utils.xml.XMLEncodingUtils.getReader(is); |
|
2366 |
if (xml == null) { |
|
2367 |
// the encoding was not correctly detected, use system |
|
2368 |
// default |
|
2369 |
xml = new FileReader(configXml); |
|
2370 |
} else { |
|
2371 |
// use a buffered reader to improve performance |
|
2372 |
xml = new BufferedReader(xml); |
|
2373 |
} |
|
2374 |
PluginConfig pConfig = (PluginConfig) PluginConfig.unmarshal(xml); |
|
2375 |
pluginsConfig.put(pluginDirs[i].getName(), pConfig); |
|
2376 |
} catch (FileNotFoundException e) { |
|
2377 |
logger.info("Plugin '"+pluginName+"' without config.xml (" |
|
2378 |
+ pluginDirs[i].getAbsolutePath() + ")."); |
|
2379 |
} catch (MarshalException e) { |
|
2380 |
this.addError("Can't load plugin '"+pluginName+"', incorrect config.xml." + e.getMessage() +" (" |
|
2381 |
+ pluginDirs[i].getAbsolutePath() + ").", e); |
|
2382 |
} catch (ValidationException e) { |
|
2383 |
this.addError("Can't load plugin '"+pluginName+"', invalid config.xml." + e.getMessage() +" (" |
|
2384 |
+ pluginDirs[i].getAbsolutePath() + ").", e); |
|
2385 |
} |
|
2386 |
} |
|
2387 |
} |
|
2373 |
} catch (FileNotFoundException e) { |
|
2374 |
logger.info("Can't read plugin config file from plugin '" + pluginName + "' ('" + pluginConfigFile.getAbsolutePath() + ")."); |
|
2388 | 2375 |
|
2389 |
if (pluginsConfig.size() == 0) { |
|
2390 |
logger.error("No valid plugin was found. The plugins directory currently is: " |
|
2391 |
+ pDir.getAbsolutePath() |
|
2392 |
+ "\n\tDid you specify the correct directory in the Launch Configuration parameters?\n\tExiting now..."); |
|
2393 |
System.exit(-1); |
|
2394 |
return; |
|
2395 |
} |
|
2396 |
} |
|
2376 |
} catch (MarshalException e) { |
|
2377 |
logger.warn("Can't load plugin the config file from plugin '" + pluginName + "' is incorect. " + e.getMessage() + " ('" + pluginConfigFile.getAbsolutePath() + ").", e); |
|
2397 | 2378 |
|
2379 |
} catch (ValidationException e) { |
|
2380 |
logger.warn("Can't load plugin the config file from plugin '" + pluginName + "' is invalid. " + e.getMessage() + " ('" + pluginConfigFile.getAbsolutePath() + ").", e); |
|
2381 |
|
|
2382 |
} |
|
2383 |
} |
|
2384 |
} |
|
2385 |
if ( pluginsConfig.isEmpty() ) { |
|
2386 |
logger.warn("No valid plugin was found."); |
|
2387 |
System.exit(-1); |
|
2388 |
} |
|
2389 |
} |
|
2390 |
|
|
2398 | 2391 |
private static Locale getLocale(String language, String country, |
2399 | 2392 |
String variant) { |
2400 | 2393 |
if (variant != null) { |
... | ... | |
3646 | 3639 |
public static String getInformation() { |
3647 | 3640 |
return getInformation(null); |
3648 | 3641 |
} |
3649 |
|
|
3650 |
public static String getInformation(PackageInfo[] pkgs) { |
|
3651 |
PluginsManager pluginmgr = PluginsLocator.getManager(); |
|
3652 | 3642 |
|
3653 |
StringWriter writer = new StringWriter(); |
|
3643 |
private static final int INFO_OS_NAME = 0; |
|
3644 |
private static final int INFO_OS_ARCH = 1; |
|
3645 |
private static final int INFO_OS_VERSION = 2; |
|
3646 |
private static final int INFO_OS_ADITIONAL = 3; |
|
3647 |
private static final int INFO_JRE_VENDOR = 4; |
|
3648 |
private static final int INFO_JRE_VERSION = 5; |
|
3649 |
private static final int INFO_JRE_HOME = 6; |
|
3650 |
private static final int INFO_PROXY_HOST = 7; |
|
3651 |
private static final int INFO_PROXY_PORT = 8; |
|
3652 |
private static final int INFO_PROXY_USER = 9; |
|
3653 |
private static final int INFO_PROXY_PASSWORD = 10; |
|
3654 |
private static final int INFO_APP_LOCALE = 11; |
|
3655 |
private static final int INFO_APP_FOLDER = 12; |
|
3656 |
private static final int INFO_APP_HOME = 13; |
|
3657 |
private static final int INFO_APP_INSTALL_FOLDER = 14; |
|
3658 |
private static final int INFO_APP_PLUGINS_FOLDER = 15; |
|
3659 |
private static final int INFO_APP_THEME = 16; |
|
3660 |
private static final int INFO_APP_SKIN = 17; |
|
3661 |
private static final int INFO_PACKAGES = 18; |
|
3662 |
|
|
3663 |
|
|
3664 |
public static String getInformation(PackageInfo[] pkgs) { |
|
3665 |
|
|
3666 |
String template = "OS\n" |
|
3667 |
+" name : {"+INFO_OS_NAME+"}\n" |
|
3668 |
+" arch : {"+INFO_OS_ARCH+"}\n" |
|
3669 |
+" version : {"+INFO_OS_VERSION+"} \n" |
|
3670 |
+"{"+INFO_OS_ADITIONAL+"}" |
|
3671 |
+"JRE\n" |
|
3672 |
+" vendor : {"+INFO_JRE_VENDOR+"}\n" |
|
3673 |
+" version : {"+INFO_JRE_VERSION+"}\n" |
|
3674 |
+" home : {"+INFO_JRE_HOME+"}\n" |
|
3675 |
+"HTTP Proxy\n" |
|
3676 |
+" http.proxyHost : {"+INFO_PROXY_HOST+"}\n" |
|
3677 |
+" http.proxyPort : {"+INFO_PROXY_PORT+"}\n" |
|
3678 |
+" http.proxyUserName : {"+INFO_PROXY_USER+"}\n" |
|
3679 |
+" http.proxyPassword : {"+INFO_PROXY_PASSWORD+"}\n" |
|
3680 |
+"Application\n" |
|
3681 |
+" locale language : {"+INFO_APP_LOCALE+"}\n" |
|
3682 |
+" application forlder : {"+INFO_APP_FOLDER+"}\n" |
|
3683 |
+" application home forlder: {"+INFO_APP_HOME+"}\n" |
|
3684 |
+" install forlder : {"+INFO_APP_INSTALL_FOLDER+"}\n" |
|
3685 |
+" plugins forlder : {"+INFO_APP_PLUGINS_FOLDER+"}\n" |
|
3686 |
+" theme : {"+INFO_APP_THEME+"}\n" |
|
3687 |
+" Skin : {"+INFO_APP_SKIN+"}\n" |
|
3688 |
+"Installed packages\n" |
|
3689 |
+"{"+INFO_PACKAGES+"}"; |
|
3690 |
|
|
3654 | 3691 |
|
3655 |
Properties props = System.getProperties(); |
|
3692 |
String values[] = new String[INFO_PACKAGES+1]; |
|
3693 |
|
|
3694 |
PluginsManager pluginmgr = PluginsLocator.getManager(); |
|
3695 |
LocaleManager localemgr = PluginsLocator.getLocaleManager(); |
|
3696 |
|
|
3697 |
Properties props = System.getProperties(); |
|
3656 | 3698 |
|
3657 |
// OS information |
|
3658 |
String osName = props.getProperty("os.name"); |
|
3659 |
writer.write("OS\n"); |
|
3660 |
writer.write(" name : " + osName + "\n"); |
|
3661 |
writer.write(" arch : " + props.get("os.arch") + "\n"); |
|
3662 |
writer.write(" version: " + props.get("os.version") + "\n"); |
|
3663 |
if (osName.startsWith("Linux")) { |
|
3664 |
try { |
|
3665 |
String[] command = { "lsb_release", "-a" }; |
|
3666 |
Process p = Runtime.getRuntime().exec(command); |
|
3667 |
InputStream is = p.getInputStream(); |
|
3668 |
BufferedReader reader = new BufferedReader( |
|
3669 |
new InputStreamReader(is)); |
|
3670 |
String line; |
|
3671 |
while ((line = reader.readLine()) != null) { |
|
3672 |
writer.write(" " + line + "\n"); |
|
3673 |
} |
|
3674 |
} catch (Exception ex) { |
|
3675 |
writer |
|
3676 |
.write("Can't get detailled os information (lsb_release -a)."); |
|
3677 |
} |
|
3678 |
} |
|
3699 |
|
|
3700 |
// OS information |
|
3701 |
values[INFO_OS_NAME] = props.getProperty("os.name"); |
|
3702 |
values[INFO_OS_ARCH] = props.getProperty("os.arch"); |
|
3703 |
values[INFO_OS_VERSION] = props.getProperty("os.version"); |
|
3704 |
|
|
3705 |
if ( values[INFO_OS_NAME].startsWith("Linux") ) { |
|
3706 |
try { |
|
3707 |
StringWriter writer = new StringWriter(); |
|
3708 |
|
|
3709 |
String[] command = {"lsb_release", "-a"}; |
|
3710 |
Process p = Runtime.getRuntime().exec(command); |
|
3711 |
InputStream is = p.getInputStream(); |
|
3712 |
BufferedReader reader = new BufferedReader(new InputStreamReader(is)); |
|
3713 |
String line; |
|
3714 |
while ( (line = reader.readLine()) != null ) { |
|
3715 |
writer.write(" " + line + "\n"); |
|
3716 |
} |
|
3717 |
values[INFO_OS_ADITIONAL] = writer.toString(); |
|
3718 |
} catch (Exception ex) { |
|
3719 |
logger.warn("Can't get detailled os information (lsb_release -a).", ex); |
|
3720 |
} |
|
3721 |
} |
|
3679 | 3722 |
|
3680 |
// JRE information |
|
3681 |
writer.write("JRE\n"); |
|
3682 |
writer.write(" vendor : " + props.get("java.vendor") + "\n"); |
|
3683 |
writer.write(" version: " + props.get("java.version") + "\n"); |
|
3684 |
writer.write(" home : " + props.get("java.home") + "\n"); |
|
3723 |
values[INFO_JRE_VENDOR] = props.getProperty("java.vendor"); |
|
3724 |
values[INFO_JRE_VERSION] = props.getProperty("java.version"); |
|
3725 |
values[INFO_JRE_HOME] = props.getProperty("java.home"); |
|
3726 |
values[INFO_PROXY_HOST] = props.getProperty("http.proxyHost"); |
|
3727 |
values[INFO_PROXY_PORT] = props.getProperty("http.proxyPort"); |
|
3728 |
values[INFO_PROXY_USER] = props.getProperty("http.proxyUserName"); |
|
3685 | 3729 |
|
3686 |
writer.write("HTTP Proxy\n"); |
|
3687 |
writer.write(" http.proxyHost : " + props.get("http.proxyHost") |
|
3688 |
+ "\n"); |
|
3689 |
writer.write(" http.proxyPort : " + props.get("http.proxyPort") |
|
3690 |
+ "\n"); |
|
3691 |
writer.write(" http.proxyUserName : " |
|
3692 |
+ props.get("http.proxyUserName") + "\n"); |
|
3693 |
|
|
3694 |
String proxyPass = (String) props.get("http.proxyPassword"); |
|
3695 |
if( proxyPass!=null ) { |
|
3696 |
proxyPass = "**********"; |
|
3697 |
} |
|
3698 |
writer.write(" http.proxyPassword : " + proxyPass + "\n"); |
|
3730 |
if ( props.get("http.proxyPassword") == null ) { |
|
3731 |
values[INFO_PROXY_PASSWORD] = "(null)"; |
|
3732 |
} else { |
|
3733 |
values[INFO_PROXY_PASSWORD] = "***********"; |
|
3734 |
} |
|
3699 | 3735 |
|
3700 |
String skinName = "(unknow)"; |
|
3701 |
try { |
|
3702 |
skinName = MDIManagerFactory.getSkinExtension().getClassName(); |
|
3703 |
} catch (Throwable e) { |
|
3704 |
// Ignore |
|
3705 |
} |
|
3706 |
writer.write("Application\n"); |
|
3707 |
writer.write(" locale language : " |
|
3708 |
+ Launcher.getAndamiConfig().getLocaleLanguage() + "\n"); |
|
3709 |
writer.write(" application forlder : " |
|
3710 |
+ pluginmgr.getApplicationFolder() + "\n"); |
|
3711 |
writer.write(" application home forlder: " |
|
3712 |
+ pluginmgr.getApplicationHomeFolder() + "\n"); |
|
3713 |
writer.write(" install forlder : " |
|
3714 |
+ pluginmgr.getInstallFolder() + "\n"); |
|
3715 |
writer.write(" plugins forlder : " |
|
3716 |
+ pluginmgr.getPluginsFolder() + "\n"); |
|
3717 |
writer.write(" theme : " |
|
3718 |
+ Launcher.theme.getSource() + "\n"); |
|
3719 |
writer.write(" Skin : " + skinName + "\n"); |
|
3736 |
try { |
|
3737 |
values[INFO_APP_SKIN] = MDIManagerFactory.getSkinExtension().getClassName(); |
|
3738 |
} catch (Throwable e) { |
|
3739 |
values[INFO_APP_SKIN] = "(unknow)"; |
|
3740 |
} |
|
3741 |
values[INFO_APP_LOCALE] = localemgr.getCurrentLocale().toString(); |
|
3742 |
values[INFO_APP_FOLDER] = pluginmgr.getApplicationFolder().getAbsolutePath(); |
|
3743 |
values[INFO_APP_HOME] = pluginmgr.getApplicationHomeFolder().getAbsolutePath(); |
|
3744 |
values[INFO_APP_INSTALL_FOLDER] = pluginmgr.getInstallFolder().getAbsolutePath(); |
|
3745 |
values[INFO_APP_PLUGINS_FOLDER] = StringUtils.join(pluginmgr.getPluginsFolders()); |
|
3746 |
values[INFO_APP_THEME] = Launcher.theme.getSource().getAbsolutePath(); |
|
3720 | 3747 |
|
3721 |
try { |
|
3722 |
if( pkgs == null ) { |
|
3723 |
InstallerManager installmgr = InstallerLocator.getInstallerManager(); |
|
3724 |
pkgs = installmgr.getInstalledPackages(pluginmgr |
|
3725 |
.getPluginsFolder()); |
|
3726 |
} |
|
3727 |
writer.write("Installed packages\n"); |
|
3728 |
for (int i = 0; i < pkgs.length; i++) { |
|
3729 |
writer.write(" "); |
|
3730 |
writer.write(pkgs[i].toStringCompact()); |
|
3731 |
writer.write("\n"); |
|
3732 |
} |
|
3733 |
} catch (Throwable e) { |
|
3734 |
writer.write("Can't get installed package information."); |
|
3735 |
} |
|
3736 |
return writer.toString(); |
|
3737 |
} |
|
3748 |
try { |
|
3749 |
if ( pkgs == null ) { |
|
3750 |
InstallerManager installmgr = InstallerLocator.getInstallerManager(); |
|
3751 |
pkgs = installmgr.getInstalledPackages(); |
|
3752 |
} |
|
3753 |
StringWriter writer = new StringWriter(); |
|
3754 |
for ( int i = 0; i < pkgs.length; i++ ) { |
|
3755 |
writer.write(" "); |
|
3756 |
writer.write(pkgs[i].toStringCompact()); |
|
3757 |
writer.write("\n"); |
|
3758 |
} |
|
3759 |
values[INFO_PACKAGES] = writer.toString(); |
|
3760 |
|
|
3761 |
} catch (Throwable e) { |
|
3762 |
logger.warn("Can't get installed package information.",e); |
|
3763 |
} |
|
3764 |
|
|
3765 |
String s = MessageFormat.format(template, values); |
|
3766 |
return s; |
|
3767 |
} |
|
3738 | 3768 |
|
3739 | 3769 |
private void logger_info(String msg) { |
3740 | 3770 |
String info[] = msg.split("\n"); |
... | ... | |
3804 | 3834 |
} |
3805 | 3835 |
splashWindow.toBack(); |
3806 | 3836 |
DisablePluginsConflictingDialog dlg = new DisablePluginsConflictingDialog(packages, incompatiblePlugins); |
3807 |
// dlg.setAlwaysOnTop(true); |
|
3808 | 3837 |
dlg.setVisible(true); |
3809 | 3838 |
splashWindow.toFront(); |
3810 | 3839 |
switch(dlg.getAction()) { |
... | ... | |
3814 | 3843 |
case DisablePluginsConflictingDialog.CONTINUE: |
3815 | 3844 |
break; |
3816 | 3845 |
} |
3817 |
List<String> pluginsToDesable = dlg.getPluginNamesToDisable();
|
|
3818 |
if( pluginsToDesable == null ) {
|
|
3846 |
List<String> pluginsToDissable = dlg.getPluginNamesToDisable();
|
|
3847 |
if( pluginsToDissable == null ) {
|
|
3819 | 3848 |
return; |
3820 | 3849 |
} |
3821 |
PluginConfig x = pluginsConfig.get("org.gvsig.projection.app.mainplugin"); |
|
3822 | 3850 |
|
3823 |
Iterator<String> it2 = pluginsToDesable.iterator();
|
|
3851 |
Iterator<String> it2 = pluginsToDissable.iterator();
|
|
3824 | 3852 |
while( it2.hasNext() ) { |
3825 | 3853 |
String pluginName = it2.next(); |
3826 |
logger.info("Disabling plugin '"+pluginName+"' by user action."); |
|
3854 |
logger.info("Dissabling plugin '"+pluginName+"' by user action.");
|
|
3827 | 3855 |
pluginsConfig.remove(pluginName); |
3828 |
} |
|
3829 |
PluginConfig y = pluginsConfig.get("org.gvsig.projection.app.mainplugin"); |
|
3830 |
|
|
3856 |
} |
|
3831 | 3857 |
} |
3832 | 3858 |
|
3833 | 3859 |
private class DisablePluginsConflictingDialog extends JDialog { |
trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/plugins/config/generate/PluginConfig.java | ||
---|---|---|
34 | 34 |
//- Imported classes and packages -/ |
35 | 35 |
//---------------------------------/ |
36 | 36 |
|
37 |
import java.io.IOException; |
|
38 |
import java.io.Reader; |
|
39 |
import java.io.Serializable; |
|
40 |
import java.io.Writer; |
|
41 |
import java.util.Enumeration; |
|
37 |
import java.io.File; |
|
42 | 38 |
import java.util.Vector; |
43 | 39 |
|
44 |
import org.exolab.castor.xml.MarshalException; |
|
45 | 40 |
import org.exolab.castor.xml.Marshaller; |
46 | 41 |
import org.exolab.castor.xml.Unmarshaller; |
47 |
import org.exolab.castor.xml.ValidationException; |
|
48 | 42 |
import org.slf4j.Logger; |
49 | 43 |
import org.slf4j.LoggerFactory; |
50 |
import org.xml.sax.ContentHandler; |
|
51 | 44 |
|
52 | 45 |
/** |
53 | 46 |
* Class PluginConfig. |
... | ... | |
665 | 658 |
validator.validate(this); |
666 | 659 |
} //-- void validate() |
667 | 660 |
|
661 |
|
|
662 |
private String pluginName = null; |
|
663 |
private File pluginFolder = null; |
|
664 |
|
|
665 |
public String getPluginName() { |
|
666 |
return this.pluginName; |
|
667 |
} |
|
668 |
|
|
669 |
public void setPluginName(String name) { |
|
670 |
this.pluginName = name; |
|
671 |
} |
|
672 |
|
|
673 |
public File getPluginFolder() { |
|
674 |
return this.pluginFolder; |
|
675 |
} |
|
676 |
|
|
677 |
public void setPluginFolder(File folder) { |
|
678 |
this.pluginFolder = folder; |
|
679 |
} |
|
668 | 680 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/PluginServices.java | ||
---|---|---|
388 | 388 |
* @return A File pointing to the plugin's root directory. |
389 | 389 |
*/ |
390 | 390 |
public File getPluginDirectory() { |
391 |
return new File(Launcher.getPluginsDir() + File.separator |
|
392 |
+ getPluginName()); |
|
391 |
return Launcher.getPluginFolder(this.getPluginName()); |
|
393 | 392 |
} |
394 | 393 |
|
395 | 394 |
/** |
... | ... | |
731 | 730 |
DynStruct dynStruct = manager.getDynObjectDefinition(getPluginName()); |
732 | 731 |
if ( dynStruct == null) { |
733 | 732 |
File persistenceDefinitionFile = |
734 |
new File(getManager().getPluginsDirectory().getAbsolutePath() |
|
735 |
+ File.separator + this.getPluginName() |
|
736 |
+ File.separator + "plugin-persistence.def"); |
|
733 |
new File(this.getPluginDirectory(), "plugin-persistence.def"); |
|
737 | 734 |
String[] names = getAllPluginNames(); |
738 | 735 |
for( int i=0; i<names.length ; i++ ) { |
739 | 736 |
try { |
trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/impl/DefaultPluginsManager.java | ||
---|---|---|
24 | 24 |
package org.gvsig.andami.impl; |
25 | 25 |
|
26 | 26 |
import java.io.File; |
27 |
import java.io.IOException; |
|
27 | 28 |
import java.lang.reflect.InvocationTargetException; |
28 | 29 |
import java.util.ArrayList; |
29 | 30 |
import java.util.Collections; |
... | ... | |
31 | 32 |
import java.util.Iterator; |
32 | 33 |
import java.util.List; |
33 | 34 |
import java.util.Locale; |
35 |
import java.util.logging.Level; |
|
34 | 36 |
import javax.swing.JComponent; |
35 | 37 |
|
36 | 38 |
import javax.swing.SwingUtilities; |
39 |
import org.apache.commons.io.FileUtils; |
|
37 | 40 |
|
38 | 41 |
import org.gvsig.andami.Launcher; |
39 | 42 |
import org.gvsig.andami.PluginServices; |
... | ... | |
246 | 249 |
if ( this.pluginsFolders != null ) { |
247 | 250 |
return this.pluginsFolders; |
248 | 251 |
} |
249 |
String folder = "gvSIG/extensiones"; |
|
252 |
File folder; |
|
253 |
String folderPath = "gvSIG/extensiones"; |
|
250 | 254 |
if ( !(Launcher.getAndamiConfig() == null || Launcher.getAndamiConfig().getPluginsDirectory() == null) ) { |
251 |
folder = Launcher.getAndamiConfig().getPluginsDirectory(); |
|
255 |
folderPath = Launcher.getAndamiConfig().getPluginsDirectory();
|
|
252 | 256 |
} |
257 |
|
|
253 | 258 |
this.pluginsFolders = new ArrayList<File>(); |
254 |
this.pluginsFolders.add(new File(getApplicationFolder(), folder)); |
|
259 |
|
|
260 |
folder = new File(this.getApplicationFolder(), folderPath); |
|
261 |
if( !folder.exists() ) { |
|
262 |
try { |
|
263 |
FileUtils.forceMkdir(folder); |
|
264 |
} catch (IOException ex) { |
|
265 |
logger.warn("The plugins folder '"+folder.getAbsolutePath()+"' don't exist and can't create.",ex); |
|
266 |
} |
|
267 |
} |
|
268 |
this.pluginsFolders.add(folder); |
|
269 |
|
|
270 |
folder = new File(this.getApplicationHomeFolder(), "installation"); |
|
271 |
folder = new File(folder, folderPath); |
|
272 |
if( !folder.exists() ) { |
|
273 |
try { |
|
274 |
FileUtils.forceMkdir(folder); |
|
275 |
} catch (IOException ex) { |
|
276 |
logger.warn("The plugins folder '"+folder.getAbsolutePath()+"' don't exist and can't create.",ex); |
|
277 |
} |
|
278 |
} |
|
279 |
this.pluginsFolders.add(folder); |
|
280 |
|
|
255 | 281 |
return this.pluginsFolders; |
256 | 282 |
} |
257 | 283 |
|
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/InitializeApplicationExtension.java | ||
---|---|---|
29 | 29 |
import java.util.Properties; |
30 | 30 |
import javax.swing.JOptionPane; |
31 | 31 |
import org.apache.commons.lang3.BooleanUtils; |
32 |
import org.apache.commons.lang3.StringUtils; |
|
32 | 33 |
|
33 | 34 |
import org.gvsig.andami.IconThemeHelper; |
34 | 35 |
import org.gvsig.andami.PluginServices; |
... | ... | |
209 | 210 |
writer.write(" application forlder : " + pluginmgr.getApplicationFolder() + "\n"); |
210 | 211 |
writer.write(" install forlder : " + pluginmgr.getInstallFolder() + "\n"); |
211 | 212 |
writer.write(" application home forlder: " + pluginmgr.getApplicationHomeFolder() + "\n"); |
212 |
writer.write(" plugins forlder : " + pluginmgr.getPluginsFolder() + "\n");
|
|
213 |
writer.write(" plugins forlder : " + StringUtils.join(pluginmgr.getPluginsFolders()) + "\n");
|
|
213 | 214 |
|
214 | 215 |
try { |
215 |
PackageInfo[] pkgs = installmgr.getInstalledPackages(pluginmgr.getPluginsFolder());
|
|
216 |
PackageInfo[] pkgs = installmgr.getInstalledPackages(); |
|
216 | 217 |
writer.write("Installed packages\n"); |
217 | 218 |
for (int i = 0; i < pkgs.length; i++) { |
218 | 219 |
writer.write(" "); |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/CheckSOAndArquitectureExtension.java | ||
---|---|---|
88 | 88 |
|
89 | 89 |
Set<PackageInfo> mismatchs = new HashSet<PackageInfo>(); |
90 | 90 |
try { |
91 |
PackageInfo[] pkgs = installmgr |
|
92 |
.getInstalledPackages(pluginmgr.getPluginsFolder()); |
|
91 |
PackageInfo[] pkgs = installmgr.getInstalledPackages(); |
|
93 | 92 |
for (int i = 0; i < pkgs.length; i++) { |
94 | 93 |
PackageInfo pkg = pkgs[i]; |
95 | 94 |
if ( !InstallerManager.ARCH.ALL.equalsIgnoreCase(pkg.getArchitecture()) && !installmgr.getArchitecture().equalsIgnoreCase( |
Also available in: Unified diff