Statistics
| Revision:

svn-gvsig-desktop / tags / v2_0_0_Build_2052 / extensions / org.gvsig.installer / org.gvsig.installer.lib / org.gvsig.installer.lib.api / src / main / java / org / gvsig / installer / lib / api / InstallerManager.java @ 38854

History | View | Annotate | Download (13.3 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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 2
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
 */
22

    
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27

    
28
package org.gvsig.installer.lib.api;
29

    
30
import java.io.File;
31
import java.io.IOException;
32
import java.io.InputStream;
33
import java.net.URL;
34
import java.text.MessageFormat;
35
import java.util.List;
36

    
37
import org.gvsig.installer.lib.api.creation.MakePackageService;
38
import org.gvsig.installer.lib.api.creation.MakePluginPackageService;
39
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException;
40
import org.gvsig.installer.lib.api.execution.InstallPackageService;
41
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException;
42
import org.gvsig.tools.exception.BaseException;
43
import org.gvsig.tools.service.Manager;
44

    
45
/**
46
 * <p>
47
 * This manager is used to register and create the services that are used to
48
 * manage the creation and the execution of installers. An installer is a file
49
 * called <b>bundle</b> that is composed of a set <b>packages</b>.
50
 * </p>
51
 * <p>
52
 * A package has some information that is defined by the {@link PackageInfo}
53
 * class and is composed of a set of attributes. One of these attributes, the
54
 * type, denotes if the package is a plugin, theme, translation, etc.
55
 * </p>
56
 * <p>
57
 * In practice a bundle is just a compressed zip file that has a compressed zip
58
 * file for every package to install. The structure of a bundle file with two
59
 * packages of type plugin could be:
60
 * </p>
61
 * 
62
 * <pre>
63
 * - bundle (compressed file)
64
 *                 - org.gvsig.plugin1-1_0_0-23 (compressed file)
65
 *                         - org.gvsig.plugin1
66
 *                                   - package.info                           
67
 *          - org.gvsig.plugin2-2_0_1-35 (compressed file)
68
 *                  - org.gvsig.plugin1
69
 *                          - package.info
70
 * </pre>
71
 * <p>
72
 * <b>bundle</b> is the compressed file that contains a zip entry for every
73
 * package to install. The name of the zip entry follows next pattern:
74
 * </p>
75
 * 
76
 * <pre>
77
 *                 [package code]-[version]-[build]
78
 * </pre>
79
 * <p>
80
 * Every zip entry contains a main folder inside that contains all the package
81
 * files that are used in the installation process. Depending of the type of
82
 * packages, the information inside this folder can be different, but all the
83
 * types of packages have to have the <b>package.info</b>file that has all the
84
 * package information. To see the <b>package.info</b> description see
85
 * {@link PackageInfo}.
86
 * <p>
87
 * </p>
88
 * The services that offers this managers are basically two: the creation of
89
 * bundles for just one package of plugin type and a service for the
90
 * installation of packages from a bundle. </p>
91
 * 
92
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
93
 */
94
public interface InstallerManager extends Manager {
95

    
96
        public static final String PACKAGE_INDEX_EXTENSION = ".gvspki";
97
        public static final String PACKAGE_EXTENSION = ".gvspkg";
98
        
99
        /**
100
         * Package state default values.
101
         */
102
        public static interface STATE {
103

    
104
                static final String DEVEL = "devel";
105
                static final String TESTING = "testing";
106
                static final String PILOT = "pilot";
107
                static final String PROTOTYPE = "prototype";
108
                static final String ALPHA = "alpha";
109
                static final String BETA = "beta";
110
                static final String RC = "RC";
111
                static final String FINAL = "final";
112
        }
113

    
114
        /**
115
         * Supported operating system default values.
116
         */
117
        public static interface OS {
118

    
119
                static final String ALL = "all";
120
                static final String LINUX = "lin";
121
                static final String WINDOWS = "win";
122
                static final String OSX_10_4 = "osx_10_4";
123
                static final String OSX_10_5 = "osx_10_5";
124
                static final String OSX_10_6 = "osx_10_6";
125
        }
126

    
127
        /**
128
         * Supported architecture default values.
129
         */
130
        public static interface ARCH {
131

    
132
                static final String ALL = "all";
133
                static final String X86 = "x86";
134
                static final String X86_64 = "x86_64";
135
        }
136

    
137
        /**
138
         * Supported Java virtual machine version default values.
139
         */
140
        public static interface JVM {
141

    
142
                static final String J1_5 = "j1_5";
143
                static final String J1_6 = "j1_6";
144
        }
145

    
146
        /**
147
         * Fields into the bundle file name message format.
148
         * 
149
         * @see InstallerManager#getPackageSetNameFormat()
150
         * @see InstallerManager#setPackageSetNameFormat(String)
151
         */
152
        public static interface PACKAGE_FILE_NAME_FIELDS {
153

    
154
                static final int GVSIG_VERSION = 0;
155
                static final int NAME = 1;
156
                static final int VERSION = 2;
157
                static final int BUILD = 3;
158
                static final int STATE = 4;
159
                static final int OS = 5;
160
                static final int ARCH = 6;
161
                static final int JVM = 7;
162
        }
163

    
164
        /**
165
         * It registers a class that implements the service for the creation of
166
         * bundle that contains inside a package of type plugin. The registered
167
         * class have to implement the {@link MakePluginPackageService} interface.
168
         * 
169
         * @param clazz
170
         *            class that implements the {@link MakePluginPackageService}
171
         *            interface.
172
         */
173
        public void registerMakePluginPackageService(
174
                        Class<? extends MakePluginPackageService> clazz);
175

    
176
        // /**
177
        // * It creates and returns an object that is used to create a bundle that
178
        // * contains inside a package of type plugin. All the parameters are set
179
        // * using the {@link MakePluginPackageService} interface. *
180
        // *
181
        // * @return an object that is used to create a plugin installer
182
        // * @throws MakePluginPackageServiceException
183
        // * when there is a problem creating the service
184
        // */
185
        // public MakePluginPackageService getMakePluginPackageService(
186
        // File pluginsDirectory) throws MakePluginPackageServiceException;
187

    
188
        /**
189
         * It creates and returns an object that is used to create a bundle that
190
         * contains inside a package of type plugin. All the parameters are set
191
         * using the {@link MakePluginPackageService} interface. *
192
         * 
193
         * @return an object that is used to create a plugin installer
194
         * @throws MakePluginPackageServiceException
195
         * @throws MakePluginPackageServiceException
196
         *             when there is a problem creating the service
197
         */
198
        public MakePluginPackageService getMakePluginPackageService()
199
                        throws MakePluginPackageServiceException;
200

    
201
        /**
202
         * Returns a list of package infos for the already installed plugins.
203
         * 
204
         * @param pluginsDirectory
205
         *            where to look for the installed plugins
206
         * @return the list of package infos for the already installed plugins
207
         * @throws MakePluginPackageServiceException
208
         *             if there is an error loading the information of the installed
209
         *             plugins
210
         */
211
        public PackageInfo[] getInstalledPackages(File pluginsDirectory)
212
                        throws MakePluginPackageServiceException;
213

    
214
        /**
215
         * Returns a list of package infos for the already installed plugins.
216
         * 
217
         * @return the list of package infos for the already installed plugins
218
         * @throws MakePluginPackageServiceException
219
         *             if there is an error loading the information of the installed
220
         *             plugins
221
         */
222
        public PackageInfo[] getInstalledPackages()
223
                        throws MakePluginPackageServiceException;
224

    
225
        /**
226
         * Returns the package bundle file name format.
227
         * <p>
228
         * The string has to use a suitable {@link MessageFormat} format, and the
229
         * available field numbers are the ones defined in the
230
         * BUNDLE_FILE_NAME_FIELDS interface.
231
         * </p>
232
         * 
233
         * @return the package bundle file name format.
234
         */
235
        public String getPackageSetNameFormat();
236

    
237
        /**
238
         * Sets the package bundle file name format.
239
         * 
240
         * @see InstallerManager#getPackageSetNameFormat()
241
         * @param packageBundleNameFormat
242
         *            the package bundle file name format.
243
         */
244
        public void setPackageSetNameFormat(String packageBundleNameFormat);
245

    
246
        /**
247
         * Returns the name of the package set file for a given package info.
248
         * 
249
         * @param info
250
         *            of the plugin
251
         * @return the name of the package set file
252
         */
253
        public String getPackageSetFileName(PackageInfo info);
254

    
255
        /**
256
         * Returns the name of the package file for a given package info.
257
         * 
258
         * @param info
259
         *            of the plugin
260
         * @return the name of the package file
261
         */
262
        public String getPackageFileName(PackageInfo info);
263

    
264
        /**
265
         * Returns the name of the package index file for a given package info.
266
         * 
267
         * @param info
268
         *            of the plugin
269
         * @return the name of the package index file
270
         */
271
        public String getPackageIndexFileName(PackageInfo info);
272

    
273
        /**
274
         * It registers a class that implements the service for the installation of
275
         * a package that is inside a bundle. This class has to implement the
276
         * {@link InstallPackageService} interface.
277
         * 
278
         * @param clazz
279
         *            class that implements the {@link InstallPackageService}
280
         *            interface.
281
         */
282
        public void registerInstallPackageService(
283
                        Class<? extends InstallPackageService> clazz);
284

    
285
        /**
286
         * It creates and returns an object that is used to install a package in
287
         * gvSIG. All the parameters are set using the {@link InstallPackageService}
288
         * interface.
289
         * 
290
         * @return an object that is used to install the package.
291
         * @throws InstallPackageServiceException
292
         *             when there is a problem creating the service.
293
         */
294
        public InstallPackageService getInstallPackageService()
295
                        throws InstallPackageServiceException;
296

    
297
        /**
298
         * Returns the default extensions of the package files.
299
         * 
300
         * @return the default extensions of the package files
301
         */
302
        public String getDefaultPackageFileExtension();
303

    
304
        /**
305
         * Returns the default extensions of the package set files.
306
         * 
307
         * @return the default extensions of the package set files
308
         */
309
        public String getDefaultPackageSetFileExtension();
310

    
311
        /**
312
         * Returns the default extensions of the index set files.
313
         * 
314
         * @return the default extensions of the index set files
315
         */
316
        public String getDefaultIndexSetFileExtension();
317

    
318
        /**
319
         * Return the OS code of the system
320
         * 
321
         * @return os code of the system
322
         */
323
        public String getOperatingSystem();
324

    
325
        /**
326
         * Returns the Architecture code of the system
327
         * 
328
         * @return architecture code of the system
329
         */
330
        public String getArchitecture();
331

    
332
        /**
333
         * Create a empty dependency object.
334
         * 
335
         * @return the dependency
336
         */
337
        public Dependency createDependency();
338

    
339
        /**
340
         * Create a dependency instance with the data of the package.
341
         * 
342
         * @param packageInfo
343
         * @return a dependency of the package
344
         */
345
        public Dependency createDependency(PackageInfo packageInfo);
346

    
347
        /**
348
         * Create a dependencies calculator.
349
         * 
350
         * @return the dependencias calculator
351
         */
352
        public DependenciesCalculator createDependenciesCalculator(
353
                        InstallPackageService installService);
354

    
355
        /**
356
         * Create a version instance
357
         * 
358
         * @return the version
359
         */
360
        public Version createVersion();
361

    
362
        public PackageInfo createPackageInfo();
363
        
364
        /**
365
         * Create a PackageInfo and load contents from the specified InputStream using the
366
         * default reader.
367
         * 
368
         * @param packegeinfo as URL
369
         * @return the created packageInfo
370
         * @throws IOException 
371
         * @throws BaseException 
372
         */
373
        public PackageInfo createPackageInfo(InputStream packegeinfo) throws BaseException;
374

    
375
        public PackageInfoWriter getDefaultPackageInfoWriter();
376

    
377
        public PackageInfoReader getDefaultPackageInfoReader();
378

    
379
        public MakePackageService createMakePackage(File packageFolder,
380
                        PackageInfo packageInfo);
381

    
382
        public void setDownloadBaseURL(URL url);
383

    
384
        public URL getDownloadBaseURL();
385

    
386
        public void setVersion(Version version);
387

    
388
        public Version getVersionEx();
389

    
390

    
391
        /**
392
         * 
393
         * @param version
394
         * @deprecated Use {@link #setVersion(Version)}
395
         */
396
    public void setVersion(String version);
397

    
398
    /**
399
     * 
400
     * @return
401
     * @deprecated Use {@link #getVersionEx()}
402
     */
403
    public String getVersion();
404

    
405
        /**
406
         * Gets a List of all the folders where there might be addons folders
407
         * (addons repositories).
408
         * 
409
         * @return list of repositories paths
410
         */
411
        public List<File> getLocalAddonRepositories();
412

    
413
        /**
414
         * Adds an addon repository path to the manager list.
415
         * 
416
         * @param path
417
         *            of the repository
418
         */
419
        public void addLocalAddonRepository(File path);
420

    
421
        /**
422
         * Gets a List of all the addon folders. An addon folder is a folder inside
423
         * any addon repository with a package.info file inside. (addons
424
         * repositories).
425
         * 
426
         * @return list of addon paths folders.
427
         */
428
        public List<File> getAddonFolders();
429

    
430
        /**
431
         * Gets the folder of the addon with the code provided, or null if not
432
         * found.
433
         * 
434
         * @param code
435
         *            of the addon
436
         * 
437
         * @return File of the folder of the addon.
438
         */
439
        public File getAddonFolder(String code);
440

    
441
        /**
442
         * The local addons folder where normally all addons are installed.
443
         * 
444
         * @param defaultAddonsRepository
445
         */
446
        public void setDefaultLocalAddonRepository(File defaultAddonsRepository);
447
        
448
        /**
449
         * The local addons folder where normally all addons are installed.
450
         * 
451
         * @return default addons repository folder.
452
         */
453
        public File getDefaultLocalAddonRepository();
454
        
455
        public List<byte[]> getPublicKeys();
456

    
457

    
458
}