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 @ 41691
History | View | Annotate | Download (15 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 |
/**
|
102 |
* Package state default values.
|
103 |
*/
|
104 |
public static interface STATE { |
105 |
|
106 |
static final String DEVEL = "devel"; |
107 |
static final String TESTING = "testing"; |
108 |
static final String PILOT = "pilot"; |
109 |
static final String PROTOTYPE = "prototype"; |
110 |
static final String ALPHA = "alpha"; |
111 |
static final String BETA = "beta"; |
112 |
static final String RC = "RC"; |
113 |
static final String FINAL = "final"; |
114 |
} |
115 |
|
116 |
/**
|
117 |
* Supported operating system default values.
|
118 |
*/
|
119 |
public static interface OS { |
120 |
|
121 |
static final String ALL = "all"; |
122 |
static final String LINUX = "lin"; |
123 |
static final String WINDOWS = "win"; |
124 |
static final String OSX_10_4 = "osx_10_4"; |
125 |
static final String OSX_10_5 = "osx_10_5"; |
126 |
static final String OSX_10_6 = "osx_10_6"; |
127 |
} |
128 |
|
129 |
/**
|
130 |
* Supported architecture default values.
|
131 |
*/
|
132 |
public static interface ARCH { |
133 |
|
134 |
static final String ALL = "all"; |
135 |
static final String X86 = "x86"; |
136 |
static final String X86_64 = "x86_64"; |
137 |
} |
138 |
|
139 |
/**
|
140 |
* Supported Java virtual machine version default values.
|
141 |
*/
|
142 |
public static interface JVM { |
143 |
|
144 |
static final String J1_5 = "j1_5"; |
145 |
static final String J1_6 = "j1_6"; |
146 |
} |
147 |
|
148 |
/**
|
149 |
* Fields into the bundle file name message format.
|
150 |
*
|
151 |
* @see InstallerManager#getPackageSetNameFormat()
|
152 |
* @see InstallerManager#setPackageSetNameFormat(String)
|
153 |
*/
|
154 |
public static interface PACKAGE_FILE_NAME_FIELDS { |
155 |
|
156 |
static final int GVSIG_VERSION = 0; |
157 |
static final int NAME = 1; |
158 |
static final int VERSION = 2; |
159 |
static final int BUILD = 3; |
160 |
static final int STATE = 4; |
161 |
static final int OS = 5; |
162 |
static final int ARCH = 6; |
163 |
static final int JVM = 7; |
164 |
} |
165 |
|
166 |
/**
|
167 |
* It registers a class that implements the service for the creation of
|
168 |
* bundle that contains inside a package of type plugin. The registered
|
169 |
* class have to implement the {@link MakePluginPackageService} interface.
|
170 |
*
|
171 |
* @param clazz
|
172 |
* class that implements the {@link MakePluginPackageService}
|
173 |
* interface.
|
174 |
*/
|
175 |
public void registerMakePluginPackageService( |
176 |
Class<? extends MakePluginPackageService> clazz); |
177 |
|
178 |
// /**
|
179 |
// * It creates and returns an object that is used to create a bundle that
|
180 |
// * contains inside a package of type plugin. All the parameters are set
|
181 |
// * using the {@link MakePluginPackageService} interface. *
|
182 |
// *
|
183 |
// * @return an object that is used to create a plugin installer
|
184 |
// * @throws MakePluginPackageServiceException
|
185 |
// * when there is a problem creating the service
|
186 |
// */
|
187 |
// public MakePluginPackageService getMakePluginPackageService(
|
188 |
// File pluginsDirectory) throws MakePluginPackageServiceException;
|
189 |
|
190 |
/**
|
191 |
* It creates and returns an object that is used to create a bundle that
|
192 |
* contains inside a package of type plugin. All the parameters are set
|
193 |
* using the {@link MakePluginPackageService} interface. *
|
194 |
*
|
195 |
* @return an object that is used to create a plugin installer
|
196 |
* @throws MakePluginPackageServiceException
|
197 |
* @throws MakePluginPackageServiceException
|
198 |
* when there is a problem creating the service
|
199 |
*/
|
200 |
public MakePluginPackageService getMakePluginPackageService()
|
201 |
throws MakePluginPackageServiceException;
|
202 |
|
203 |
/**
|
204 |
* Returns a list of package infos for the already installed plugins.
|
205 |
*
|
206 |
* @param pluginsDirectory
|
207 |
* where to look for the installed plugins
|
208 |
* @return the list of package infos for the already installed plugins
|
209 |
* @throws MakePluginPackageServiceException
|
210 |
* if there is an error loading the information of the installed
|
211 |
* plugins
|
212 |
*/
|
213 |
public PackageInfo[] getInstalledPackages(File pluginsDirectory) |
214 |
throws MakePluginPackageServiceException;
|
215 |
|
216 |
/**
|
217 |
* Returns a list of package infos for the already installed plugins.
|
218 |
*
|
219 |
* @return the list of package infos for the already installed plugins
|
220 |
* @throws MakePluginPackageServiceException
|
221 |
* if there is an error loading the information of the installed
|
222 |
* plugins
|
223 |
*/
|
224 |
public PackageInfo[] getInstalledPackages() |
225 |
throws MakePluginPackageServiceException;
|
226 |
|
227 |
/**
|
228 |
* Returns the package bundle file name format.
|
229 |
* <p>
|
230 |
* The string has to use a suitable {@link MessageFormat} format, and the
|
231 |
* available field numbers are the ones defined in the
|
232 |
* BUNDLE_FILE_NAME_FIELDS interface.
|
233 |
* </p>
|
234 |
*
|
235 |
* @return the package bundle file name format.
|
236 |
*/
|
237 |
public String getPackageSetNameFormat(); |
238 |
|
239 |
/**
|
240 |
* Sets the package bundle file name format.
|
241 |
*
|
242 |
* @see InstallerManager#getPackageSetNameFormat()
|
243 |
* @param packageBundleNameFormat
|
244 |
* the package bundle file name format.
|
245 |
*/
|
246 |
public void setPackageSetNameFormat(String packageBundleNameFormat); |
247 |
|
248 |
/**
|
249 |
* Returns the name of the package set file for a given package info.
|
250 |
*
|
251 |
* @param info
|
252 |
* of the plugin
|
253 |
* @return the name of the package set file
|
254 |
*/
|
255 |
public String getPackageSetFileName(PackageInfo info); |
256 |
|
257 |
/**
|
258 |
* Returns the name of the package file for a given package info.
|
259 |
*
|
260 |
* @param info
|
261 |
* of the plugin
|
262 |
* @return the name of the package file
|
263 |
*/
|
264 |
public String getPackageFileName(PackageInfo info); |
265 |
|
266 |
/**
|
267 |
* Returns the name of the package index file for a given package info.
|
268 |
*
|
269 |
* @param info
|
270 |
* of the plugin
|
271 |
* @return the name of the package index file
|
272 |
*/
|
273 |
public String getPackageIndexFileName(PackageInfo info); |
274 |
|
275 |
/**
|
276 |
* It registers a class that implements the service for the installation of
|
277 |
* a package that is inside a bundle. This class has to implement the
|
278 |
* {@link InstallPackageService} interface.
|
279 |
*
|
280 |
* @param clazz
|
281 |
* class that implements the {@link InstallPackageService}
|
282 |
* interface.
|
283 |
*/
|
284 |
public void registerInstallPackageService( |
285 |
Class<? extends InstallPackageService> clazz); |
286 |
|
287 |
/**
|
288 |
* It creates and returns an object that is used to install a package in
|
289 |
* gvSIG. All the parameters are set using the {@link InstallPackageService}
|
290 |
* interface.
|
291 |
*
|
292 |
* @return an object that is used to install the package.
|
293 |
* @throws InstallPackageServiceException
|
294 |
* when there is a problem creating the service.
|
295 |
*/
|
296 |
public InstallPackageService getInstallPackageService()
|
297 |
throws InstallPackageServiceException;
|
298 |
|
299 |
/**
|
300 |
* Returns the default extensions of the package files.
|
301 |
*
|
302 |
* @return the default extensions of the package files
|
303 |
*/
|
304 |
public String getDefaultPackageFileExtension(); |
305 |
|
306 |
/**
|
307 |
* Returns the default extensions of the package set files.
|
308 |
*
|
309 |
* @return the default extensions of the package set files
|
310 |
*/
|
311 |
public String getDefaultPackageSetFileExtension(); |
312 |
|
313 |
/**
|
314 |
* Returns the default extensions of the index set files.
|
315 |
*
|
316 |
* @return the default extensions of the index set files
|
317 |
*/
|
318 |
public String getDefaultIndexSetFileExtension(); |
319 |
|
320 |
/**
|
321 |
* Return the OS code of the system
|
322 |
*
|
323 |
* @return os code of the system
|
324 |
*/
|
325 |
public String getOperatingSystem(); |
326 |
|
327 |
/**
|
328 |
* Returns the Architecture code of the system
|
329 |
*
|
330 |
* @return architecture code of the system
|
331 |
*/
|
332 |
public String getArchitecture(); |
333 |
|
334 |
/**
|
335 |
* Create a empty dependency object.
|
336 |
*
|
337 |
* @return the dependency
|
338 |
*/
|
339 |
public Dependency createDependency();
|
340 |
|
341 |
/**
|
342 |
* Create a dependency instance with the data of the package.
|
343 |
*
|
344 |
* @param packageInfo
|
345 |
* @return a dependency of the package
|
346 |
*/
|
347 |
public Dependency createDependency(PackageInfo packageInfo);
|
348 |
|
349 |
/**
|
350 |
* Create a dependencies calculator.
|
351 |
*
|
352 |
* @return the dependencias calculator
|
353 |
*/
|
354 |
public DependenciesCalculator createDependenciesCalculator(
|
355 |
InstallPackageService installService); |
356 |
|
357 |
/**
|
358 |
* Create a version instance
|
359 |
*
|
360 |
* @return the version
|
361 |
*/
|
362 |
public Version createVersion();
|
363 |
|
364 |
public PackageInfo createPackageInfo();
|
365 |
|
366 |
/**
|
367 |
* Create a PackageInfo and load contents from the specified InputStream using the
|
368 |
* default reader.
|
369 |
*
|
370 |
* @param packegeinfo as URL
|
371 |
* @return the created packageInfo
|
372 |
* @throws IOException
|
373 |
* @throws BaseException
|
374 |
*/
|
375 |
public PackageInfo createPackageInfo(InputStream packegeinfo) throws BaseException; |
376 |
|
377 |
public PackageInfoWriter getDefaultPackageInfoWriter();
|
378 |
|
379 |
public PackageInfoReader getDefaultPackageInfoReader();
|
380 |
|
381 |
public MakePackageService createMakePackage(File packageFolder, |
382 |
PackageInfo packageInfo); |
383 |
|
384 |
public void setDownloadBaseURL(URL url); |
385 |
|
386 |
public URL getDownloadBaseURL(); |
387 |
|
388 |
public void setVersion(Version version); |
389 |
|
390 |
public Version getVersionEx();
|
391 |
|
392 |
|
393 |
/**
|
394 |
*
|
395 |
* @param version
|
396 |
* @deprecated Use {@link #setVersion(Version)}
|
397 |
*/
|
398 |
public void setVersion(String version); |
399 |
|
400 |
/**
|
401 |
*
|
402 |
* @return
|
403 |
* @deprecated Use {@link #getVersionEx()}
|
404 |
*/
|
405 |
public String getVersion(); |
406 |
|
407 |
/**
|
408 |
* Gets a List of all the folders where there might be addons folders
|
409 |
* (addons repositories).
|
410 |
*
|
411 |
* @return list of repositories paths
|
412 |
*/
|
413 |
public List<File> getLocalAddonRepositories(); |
414 |
|
415 |
/**
|
416 |
* Adds an addon local repository location to the manager list,
|
417 |
* and register the type of addons for this repository.
|
418 |
*
|
419 |
* @param path
|
420 |
* of the repository
|
421 |
* @param type
|
422 |
* of addons in this repository
|
423 |
*/
|
424 |
public void addLocalAddonRepository(File path, String type); |
425 |
|
426 |
/**
|
427 |
* @deprecated use addLocalAddonRepository(File path, String type)
|
428 |
*/
|
429 |
public void addLocalAddonRepository(File path); |
430 |
|
431 |
/**
|
432 |
* Retrieve the default type of addons for the file.
|
433 |
* Use the registry of local addon repositories to identify the
|
434 |
* type for this file.
|
435 |
*
|
436 |
* @param file
|
437 |
* @return
|
438 |
*/
|
439 |
public String getDefaultLocalRepositoryType(File file); |
440 |
|
441 |
/**
|
442 |
* Gets a List of all the addon folders. An addon folder is a folder inside
|
443 |
* any addon repository with a package.info file inside. (addons
|
444 |
* repositories).
|
445 |
*
|
446 |
* @return list of addon paths folders.
|
447 |
*/
|
448 |
public List<File> getAddonFolders(); |
449 |
|
450 |
/**
|
451 |
* Gets the folder of the addon with the code provided, or null if not
|
452 |
* found.
|
453 |
*
|
454 |
* @param code
|
455 |
* of the addon
|
456 |
*
|
457 |
* @return File of the folder of the addon.
|
458 |
*/
|
459 |
public File getAddonFolder(String code); |
460 |
|
461 |
/**
|
462 |
* The local addons folder where normally all addons are installed.
|
463 |
*
|
464 |
* @param defaultAddonsRepository
|
465 |
* @deprecated use {@link #setDefaultLocalAddonRepository(java.io.File, java.lang.String) }
|
466 |
*/
|
467 |
public void setDefaultLocalAddonRepository(File defaultAddonsRepository); |
468 |
|
469 |
/**
|
470 |
* The local addons folder where normally all addons are installed.
|
471 |
*
|
472 |
* @return default addons repository folder.
|
473 |
* @deprecated use {@link #getDefaultLocalAddonRepository(java.lang.String) }
|
474 |
*/
|
475 |
public File getDefaultLocalAddonRepository(); |
476 |
|
477 |
/**
|
478 |
* Get the path to the default local repository for a type of package
|
479 |
* @param packageType type of package for that ask the default path
|
480 |
* @return the path to the repository
|
481 |
*/
|
482 |
public File getDefaultLocalAddonRepository(String packageType); |
483 |
|
484 |
/**
|
485 |
* Set the path to the default local repository for a type of package
|
486 |
* @param defaultAddonsRepository path to the repository
|
487 |
* @param packageType type of package in this repository path
|
488 |
*/
|
489 |
public void setDefaultLocalAddonRepository(File defaultAddonsRepository, String packageType); |
490 |
|
491 |
|
492 |
public List<byte[]> getPublicKeys(); |
493 |
|
494 |
// public PackageInfoFiles getPackageInfoFiles(PackageInfo packageInfo);
|
495 |
|
496 |
public boolean hasProviderToThisPackage(PackageInfo packageInfo); |
497 |
} |