Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / org.gvsig.installer / org.gvsig.installer.lib / org.gvsig.installer.lib.api / src / main / java / org / gvsig / installer / lib / api / InstallerManager.java @ 38578

History | View | Annotate | Download (12.9 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
        /**
97
         * Package state default values.
98
         */
99
        public static interface STATE {
100

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

    
111
        /**
112
         * Supported operating system default values.
113
         */
114
        public static interface OS {
115

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

    
124
        /**
125
         * Supported architecture default values.
126
         */
127
        public static interface ARCH {
128

    
129
                static final String ALL = "all";
130
                static final String X86 = "x86";
131
                static final String X86_64 = "x86_64";
132
        }
133

    
134
        /**
135
         * Supported Java virtual machine version default values.
136
         */
137
        public static interface JVM {
138

    
139
                static final String J1_5 = "j1_5";
140
                static final String J1_6 = "j1_6";
141
        }
142

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
294
        /**
295
         * Returns the default extensions of the package files.
296
         * 
297
         * @return the default extensions of the package files
298
         */
299
        public String getDefaultPackageFileExtension();
300

    
301
        /**
302
         * Returns the default extensions of the package set files.
303
         * 
304
         * @return the default extensions of the package set files
305
         */
306
        public String getDefaultPackageSetFileExtension();
307

    
308
        /**
309
         * Returns the default extensions of the index set files.
310
         * 
311
         * @return the default extensions of the index set files
312
         */
313
        public String getDefaultIndexSetFileExtension();
314

    
315
        /**
316
         * Return the OS code of the system
317
         * 
318
         * @return os code of the system
319
         */
320
        public String getOperatingSystem();
321

    
322
        /**
323
         * Returns the Architecture code of the system
324
         * 
325
         * @return architecture code of the system
326
         */
327
        public String getArchitecture();
328

    
329
        /**
330
         * Create a empty dependency object.
331
         * 
332
         * @return the dependency
333
         */
334
        public Dependency createDependency();
335

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

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

    
352
        /**
353
         * Create a version instance
354
         * 
355
         * @return the version
356
         */
357
        public Version createVersion();
358

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

    
372
        public PackageInfoWriter getDefaultPackageInfoWriter();
373

    
374
        public PackageInfoReader getDefaultPackageInfoReader();
375

    
376
        public MakePackageService createMakePackage(File packageFolder,
377
                        PackageInfo packageInfo);
378

    
379
        public void setDownloadBaseURL(URL url);
380

    
381
        public URL getDownloadBaseURL();
382

    
383
        public void setVersion(String version);
384

    
385
        public String getVersion();
386

    
387
        /**
388
         * Gets a List of all the folders where there might be addons folders
389
         * (addons repositories).
390
         * 
391
         * @return list of repositories paths
392
         */
393
        public List<File> getLocalAddonRepositories();
394

    
395
        /**
396
         * Adds an addon repository path to the manager list.
397
         * 
398
         * @param path
399
         *            of the repository
400
         */
401
        public void addLocalAddonRepository(File path);
402

    
403
        /**
404
         * Gets a List of all the addon folders. An addon folder is a folder inside
405
         * any addon repository with a package.info file inside. (addons
406
         * repositories).
407
         * 
408
         * @return list of addon paths folders.
409
         */
410
        public List<File> getAddonFolders();
411

    
412
        /**
413
         * Gets the folder of the addon with the code provided, or null if not
414
         * found.
415
         * 
416
         * @param code
417
         *            of the addon
418
         * 
419
         * @return File of the folder of the addon.
420
         */
421
        public File getAddonFolder(String code);
422

    
423
        /**
424
         * The local addons folder where normally all addons are installed.
425
         * 
426
         * @param defaultAddonsRepository
427
         */
428
        public void setDefaultLocalAddonRepository(File defaultAddonsRepository);
429
        
430
        /**
431
         * The local addons folder where normally all addons are installed.
432
         * 
433
         * @return default addons repository folder.
434
         */
435
        public File getDefaultLocalAddonRepository();
436
        
437
        public List<byte[]> getPublicKeys();
438

    
439

    
440
}