svn-gvsig-desktop / 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 @ 41706
History | View | Annotate | Download (16.5 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 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 |
/*
|
25 |
* AUTHORS (In addition to CIT):
|
26 |
* 2010 {Prodevelop} {Task}
|
27 |
*/
|
28 |
|
29 |
package org.gvsig.installer.lib.api; |
30 |
|
31 |
import java.io.File; |
32 |
import java.io.IOException; |
33 |
import java.io.InputStream; |
34 |
import java.net.URL; |
35 |
import java.text.MessageFormat; |
36 |
import java.util.List; |
37 |
|
38 |
import org.gvsig.installer.lib.api.creation.MakePackageService; |
39 |
import org.gvsig.installer.lib.api.creation.MakePluginPackageService; |
40 |
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException; |
41 |
import org.gvsig.installer.lib.api.execution.InstallPackageService; |
42 |
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException; |
43 |
import org.gvsig.tools.exception.BaseException; |
44 |
import org.gvsig.tools.service.Manager; |
45 |
|
46 |
/**
|
47 |
* <p>
|
48 |
* This manager is used to register and create the services that are used to
|
49 |
* manage the creation and the execution of installers. An installer is a file
|
50 |
* called <b>bundle</b> that is composed of a set <b>packages</b>.
|
51 |
* </p>
|
52 |
* <p>
|
53 |
* A package has some information that is defined by the {@link PackageInfo}
|
54 |
* class and is composed of a set of attributes. One of these attributes, the
|
55 |
* type, denotes if the package is a plugin, theme, translation, etc.
|
56 |
* </p>
|
57 |
* <p>
|
58 |
* In practice a bundle is just a compressed zip file that has a compressed zip
|
59 |
* file for every package to install. The structure of a bundle file with two
|
60 |
* packages of type plugin could be:
|
61 |
* </p>
|
62 |
*
|
63 |
* <pre>
|
64 |
* - bundle (compressed file)
|
65 |
* - org.gvsig.plugin1-1_0_0-23 (compressed file)
|
66 |
* - org.gvsig.plugin1
|
67 |
* - package.info
|
68 |
* - org.gvsig.plugin2-2_0_1-35 (compressed file)
|
69 |
* - org.gvsig.plugin1
|
70 |
* - package.info
|
71 |
* </pre>
|
72 |
* <p>
|
73 |
* <b>bundle</b> is the compressed file that contains a zip entry for every
|
74 |
* package to install. The name of the zip entry follows next pattern:
|
75 |
* </p>
|
76 |
*
|
77 |
* <pre>
|
78 |
* [package code]-[version]-[build]
|
79 |
* </pre>
|
80 |
* <p>
|
81 |
* Every zip entry contains a main folder inside that contains all the package
|
82 |
* files that are used in the installation process. Depending of the type of
|
83 |
* packages, the information inside this folder can be different, but all the
|
84 |
* types of packages have to have the <b>package.info</b>file that has all the
|
85 |
* package information. To see the <b>package.info</b> description see
|
86 |
* {@link PackageInfo}.
|
87 |
* <p>
|
88 |
* </p>
|
89 |
* The services that offers this managers are basically two: the creation of
|
90 |
* bundles for just one package of plugin type and a service for the
|
91 |
* installation of packages from a bundle. </p>
|
92 |
*
|
93 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a>
|
94 |
*/
|
95 |
public interface InstallerManager extends Manager { |
96 |
|
97 |
public static final String PACKAGE_INDEX_EXTENSION = ".gvspki"; |
98 |
public static final String PACKAGE_SET_EXTENSION = ".gvspks"; |
99 |
public static final String PACKAGE_EXTENSION = ".gvspkg"; |
100 |
|
101 |
public static final String PACKAGE_INFO_FILE_NAME = "package.info"; |
102 |
/**
|
103 |
* Package state default values.
|
104 |
*/
|
105 |
public static interface STATE { |
106 |
|
107 |
static final String DEVEL = "devel"; |
108 |
static final String TESTING = "testing"; |
109 |
static final String PILOT = "pilot"; |
110 |
static final String PROTOTYPE = "prototype"; |
111 |
static final String ALPHA = "alpha"; |
112 |
static final String BETA = "beta"; |
113 |
static final String RC = "RC"; |
114 |
static final String FINAL = "final"; |
115 |
} |
116 |
|
117 |
/**
|
118 |
* Supported operating system default values.
|
119 |
*/
|
120 |
public static interface OS { |
121 |
|
122 |
static final String ALL = "all"; |
123 |
static final String LINUX = "lin"; |
124 |
static final String WINDOWS = "win"; |
125 |
static final String OSX_10_4 = "osx_10_4"; |
126 |
static final String OSX_10_5 = "osx_10_5"; |
127 |
static final String OSX_10_6 = "osx_10_6"; |
128 |
} |
129 |
|
130 |
/**
|
131 |
* Supported architecture default values.
|
132 |
*/
|
133 |
public static interface ARCH { |
134 |
|
135 |
static final String ALL = "all"; |
136 |
static final String X86 = "x86"; |
137 |
static final String X86_64 = "x86_64"; |
138 |
} |
139 |
|
140 |
/**
|
141 |
* Supported Java virtual machine version default values.
|
142 |
*/
|
143 |
public static interface JVM { |
144 |
|
145 |
static final String J1_5 = "j1_5"; |
146 |
static final String J1_6 = "j1_6"; |
147 |
} |
148 |
|
149 |
/**
|
150 |
* Fields into the bundle file name message format.
|
151 |
*
|
152 |
* @see InstallerManager#getPackageSetNameFormat()
|
153 |
* @see InstallerManager#setPackageSetNameFormat(String)
|
154 |
*/
|
155 |
public static interface PACKAGE_FILE_NAME_FIELDS { |
156 |
|
157 |
static final int GVSIG_VERSION = 0; |
158 |
static final int NAME = 1; |
159 |
static final int VERSION = 2; |
160 |
static final int BUILD = 3; |
161 |
static final int STATE = 4; |
162 |
static final int OS = 5; |
163 |
static final int ARCH = 6; |
164 |
static final int JVM = 7; |
165 |
} |
166 |
|
167 |
/**
|
168 |
* It registers a class that implements the service for the creation of
|
169 |
* bundle that contains inside a package of type plugin. The registered
|
170 |
* class have to implement the {@link MakePluginPackageService} interface.
|
171 |
*
|
172 |
* @param clazz
|
173 |
* class that implements the {@link MakePluginPackageService}
|
174 |
* interface.
|
175 |
*/
|
176 |
public void registerMakePluginPackageService( |
177 |
Class<? extends MakePluginPackageService> clazz); |
178 |
|
179 |
// /**
|
180 |
// * It creates and returns an object that is used to create a bundle that
|
181 |
// * contains inside a package of type plugin. All the parameters are set
|
182 |
// * using the {@link MakePluginPackageService} interface. *
|
183 |
// *
|
184 |
// * @return an object that is used to create a plugin installer
|
185 |
// * @throws MakePluginPackageServiceException
|
186 |
// * when there is a problem creating the service
|
187 |
// */
|
188 |
// public MakePluginPackageService getMakePluginPackageService(
|
189 |
// File pluginsDirectory) throws MakePluginPackageServiceException;
|
190 |
|
191 |
/**
|
192 |
* It creates and returns an object that is used to create a bundle that
|
193 |
* contains inside a package of type plugin. All the parameters are set
|
194 |
* using the {@link MakePluginPackageService} interface. *
|
195 |
*
|
196 |
* @return an object that is used to create a plugin installer
|
197 |
* @throws MakePluginPackageServiceException
|
198 |
* @throws MakePluginPackageServiceException
|
199 |
* when there is a problem creating the service
|
200 |
*/
|
201 |
public MakePluginPackageService getMakePluginPackageService()
|
202 |
throws MakePluginPackageServiceException;
|
203 |
|
204 |
/**
|
205 |
* Returns a list of package infos for the already installed plugins.
|
206 |
*
|
207 |
* @param pluginsDirectory
|
208 |
* where to look for the installed plugins
|
209 |
* @return the list of package infos for the already installed plugins
|
210 |
* @throws MakePluginPackageServiceException
|
211 |
* if there is an error loading the information of the installed
|
212 |
* plugins
|
213 |
* @deprecated use getInstalledPackages() without parameters
|
214 |
*/
|
215 |
public PackageInfo[] getInstalledPackages(File pluginsDirectory) |
216 |
throws MakePluginPackageServiceException;
|
217 |
|
218 |
/**
|
219 |
* Returns a list of package infos for the already installed plugins.
|
220 |
*
|
221 |
* @return the list of package infos for the already installed plugins
|
222 |
* @throws MakePluginPackageServiceException
|
223 |
* if there is an error loading the information of the installed
|
224 |
* plugins
|
225 |
*/
|
226 |
public PackageInfo[] getInstalledPackages() |
227 |
throws MakePluginPackageServiceException;
|
228 |
|
229 |
/**
|
230 |
* Returns the package bundle file name format.
|
231 |
* <p>
|
232 |
* The string has to use a suitable {@link MessageFormat} format, and the
|
233 |
* available field numbers are the ones defined in the
|
234 |
* BUNDLE_FILE_NAME_FIELDS interface.
|
235 |
* </p>
|
236 |
*
|
237 |
* @return the package bundle file name format.
|
238 |
*/
|
239 |
public String getPackageSetNameFormat(); |
240 |
|
241 |
/**
|
242 |
* Sets the package bundle file name format.
|
243 |
*
|
244 |
* @see InstallerManager#getPackageSetNameFormat()
|
245 |
* @param packageBundleNameFormat
|
246 |
* the package bundle file name format.
|
247 |
*/
|
248 |
public void setPackageSetNameFormat(String packageBundleNameFormat); |
249 |
|
250 |
/**
|
251 |
* Returns the name of the package set file for a given package info.
|
252 |
*
|
253 |
* @param info
|
254 |
* of the plugin
|
255 |
* @return the name of the package set file
|
256 |
*/
|
257 |
public String getPackageSetFileName(PackageInfo info); |
258 |
|
259 |
/**
|
260 |
* Returns the name of the package file for a given package info.
|
261 |
*
|
262 |
* @param info
|
263 |
* of the plugin
|
264 |
* @return the name of the package file
|
265 |
*/
|
266 |
public String getPackageFileName(PackageInfo info); |
267 |
|
268 |
/**
|
269 |
* Returns the name of the package index file for a given package info.
|
270 |
*
|
271 |
* @param info
|
272 |
* of the plugin
|
273 |
* @return the name of the package index file
|
274 |
*/
|
275 |
public String getPackageIndexFileName(PackageInfo info); |
276 |
|
277 |
/**
|
278 |
* It registers a class that implements the service for the installation of
|
279 |
* a package that is inside a bundle. This class has to implement the
|
280 |
* {@link InstallPackageService} interface.
|
281 |
*
|
282 |
* @param clazz
|
283 |
* class that implements the {@link InstallPackageService}
|
284 |
* interface.
|
285 |
*/
|
286 |
public void registerInstallPackageService( |
287 |
Class<? extends InstallPackageService> clazz); |
288 |
|
289 |
/**
|
290 |
* It creates and returns an object that is used to install a package in
|
291 |
* gvSIG. All the parameters are set using the {@link InstallPackageService}
|
292 |
* interface.
|
293 |
*
|
294 |
* @return an object that is used to install the package.
|
295 |
* @throws InstallPackageServiceException
|
296 |
* when there is a problem creating the service.
|
297 |
*/
|
298 |
public InstallPackageService getInstallPackageService()
|
299 |
throws InstallPackageServiceException;
|
300 |
|
301 |
/**
|
302 |
* Returns the default extensions of the package files.
|
303 |
*
|
304 |
* @return the default extensions of the package files
|
305 |
*/
|
306 |
public String getDefaultPackageFileExtension(); |
307 |
|
308 |
/**
|
309 |
* Returns the default extensions of the package set files.
|
310 |
*
|
311 |
* @return the default extensions of the package set files
|
312 |
*/
|
313 |
public String getDefaultPackageSetFileExtension(); |
314 |
|
315 |
/**
|
316 |
* Returns the default extensions of the index set files.
|
317 |
*
|
318 |
* @return the default extensions of the index set files
|
319 |
*/
|
320 |
public String getDefaultIndexSetFileExtension(); |
321 |
|
322 |
/**
|
323 |
* Return the OS code of the system
|
324 |
*
|
325 |
* @return os code of the system
|
326 |
*/
|
327 |
public String getOperatingSystem(); |
328 |
|
329 |
/**
|
330 |
* Returns the Architecture code of the system
|
331 |
*
|
332 |
* @return architecture code of the system
|
333 |
*/
|
334 |
public String getArchitecture(); |
335 |
|
336 |
/**
|
337 |
* Create a empty dependency object.
|
338 |
*
|
339 |
* @return the dependency
|
340 |
*/
|
341 |
public Dependency createDependency();
|
342 |
|
343 |
/**
|
344 |
* Create a dependency instance with the data of the package.
|
345 |
*
|
346 |
* @param packageInfo
|
347 |
* @return a dependency of the package
|
348 |
*/
|
349 |
public Dependency createDependency(PackageInfo packageInfo);
|
350 |
|
351 |
/**
|
352 |
* Create a dependencies calculator.
|
353 |
*
|
354 |
* @return the dependencias calculator
|
355 |
*/
|
356 |
public DependenciesCalculator createDependenciesCalculator(
|
357 |
InstallPackageService installService); |
358 |
|
359 |
/**
|
360 |
* Create a version instance
|
361 |
*
|
362 |
* @return the version
|
363 |
*/
|
364 |
public Version createVersion();
|
365 |
|
366 |
public PackageInfo createPackageInfo();
|
367 |
|
368 |
/**
|
369 |
* Create a PackageInfo and load contents from the specified InputStream using the
|
370 |
* default reader.
|
371 |
*
|
372 |
* @param packegeinfo as URL
|
373 |
* @return the created packageInfo
|
374 |
* @throws IOException
|
375 |
* @throws BaseException
|
376 |
*/
|
377 |
public PackageInfo createPackageInfo(InputStream packegeinfo) throws BaseException; |
378 |
|
379 |
public PackageInfoWriter getDefaultPackageInfoWriter();
|
380 |
|
381 |
public PackageInfoReader getDefaultPackageInfoReader();
|
382 |
|
383 |
public MakePackageService createMakePackage(File packageFolder, |
384 |
PackageInfo packageInfo); |
385 |
|
386 |
public void setDownloadBaseURL(URL url); |
387 |
|
388 |
public URL getDownloadBaseURL(); |
389 |
|
390 |
public void setVersion(Version version); |
391 |
|
392 |
public Version getVersionEx();
|
393 |
|
394 |
|
395 |
/**
|
396 |
*
|
397 |
* @param version
|
398 |
* @deprecated Use {@link #setVersion(Version)}
|
399 |
*/
|
400 |
public void setVersion(String version); |
401 |
|
402 |
/**
|
403 |
*
|
404 |
* @return
|
405 |
* @deprecated Use {@link #getVersionEx()}
|
406 |
*/
|
407 |
public String getVersion(); |
408 |
|
409 |
/**
|
410 |
* Gets a List of all the folders where there might be addons folders
|
411 |
* (addons repositories).
|
412 |
*
|
413 |
* @return list of repositories paths
|
414 |
*/
|
415 |
public List<File> getLocalAddonRepositories(); |
416 |
|
417 |
/**
|
418 |
* Gets a List of all the folders where there might be addons folders
|
419 |
* for the specified type of packages
|
420 |
* (addons repositories).
|
421 |
*
|
422 |
* @return list of repositories paths
|
423 |
*/
|
424 |
public List<File> getLocalAddonRepositories(String type); |
425 |
|
426 |
/**
|
427 |
* Adds an addon local repository location to the manager list,
|
428 |
* and register the type of addons for this repository.
|
429 |
*
|
430 |
* @param path
|
431 |
* of the repository
|
432 |
* @param type
|
433 |
* of addons in this repository
|
434 |
*/
|
435 |
public void addLocalAddonRepository(File path, String type); |
436 |
|
437 |
/**
|
438 |
* @deprecated use addLocalAddonRepository(File path, String type)
|
439 |
*/
|
440 |
public void addLocalAddonRepository(File path); |
441 |
|
442 |
/**
|
443 |
* Retrieve the default type of addons for the file.
|
444 |
* Use the registry of local addon repositories to identify the
|
445 |
* type for this file.
|
446 |
*
|
447 |
* @param file
|
448 |
* @return
|
449 |
*/
|
450 |
public String getDefaultLocalRepositoryType(File file); |
451 |
|
452 |
/**
|
453 |
* Gets a List of all the addon folders. An addon folder is a folder inside
|
454 |
* any addon repository with a package.info file inside. (addons
|
455 |
* repositories).
|
456 |
*
|
457 |
* @return list of addon paths folders.
|
458 |
*/
|
459 |
public List<File> getAddonFolders(); |
460 |
|
461 |
/**
|
462 |
* Gets a List of all the addon folders of a type of package.
|
463 |
* An addon folder is a folder inside
|
464 |
* any addon repository with a package.info file inside. (addons
|
465 |
* repositories).
|
466 |
*
|
467 |
* @return list of addon paths folders.
|
468 |
*/
|
469 |
public List<File> getAddonFolders(String type); |
470 |
|
471 |
/**
|
472 |
* Gets the folder of the addon with the code provided, or null if not
|
473 |
* found.
|
474 |
*
|
475 |
* @param code
|
476 |
* of the addon
|
477 |
*
|
478 |
* @return File of the folder of the addon.
|
479 |
*/
|
480 |
public File getAddonFolder(String code); |
481 |
|
482 |
/**
|
483 |
* The local addons folder where normally all addons are installed.
|
484 |
*
|
485 |
* @param defaultAddonsRepository
|
486 |
* @deprecated use {@link #setDefaultLocalAddonRepository(java.io.File, java.lang.String) }
|
487 |
*/
|
488 |
public void setDefaultLocalAddonRepository(File defaultAddonsRepository); |
489 |
|
490 |
/**
|
491 |
* The local addons folder where normally all addons are installed.
|
492 |
*
|
493 |
* @return default addons repository folder.
|
494 |
* @deprecated use {@link #getDefaultLocalAddonRepository(java.lang.String) }
|
495 |
*/
|
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); |
515 |
|
516 |
/**
|
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 |
*
|
520 |
* @param packageType type of package for that ask the default path
|
521 |
* @return the path to the repository
|
522 |
*/
|
523 |
public File getDefaultLocalAddonRepository(String packageType); |
524 |
|
525 |
|
526 |
/**
|
527 |
* Set the path to the default local repository for a type of package
|
528 |
* @param defaultAddonsRepository path to the repository
|
529 |
* @param packageType type of package in this repository path
|
530 |
*/
|
531 |
public void setDefaultLocalAddonRepository(File defaultAddonsRepository, String packageType); |
532 |
|
533 |
|
534 |
public List<byte[]> getPublicKeys(); |
535 |
|
536 |
// public PackageInfoFiles getPackageInfoFiles(PackageInfo packageInfo);
|
537 |
|
538 |
public boolean hasProviderToThisPackage(PackageInfo packageInfo); |
539 |
} |