Statistics
| Revision:

svn-gvsig-desktop / 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 @ 39599

History | View | Annotate | Download (13.4 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_SET_EXTENSION = ".gvspks";
98
        public static final String PACKAGE_EXTENSION = ".gvspkg";
99
        
100
        /**
101
         * Package state default values.
102
         */
103
        public static interface STATE {
104

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
376
        public PackageInfoWriter getDefaultPackageInfoWriter();
377

    
378
        public PackageInfoReader getDefaultPackageInfoReader();
379

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

    
383
        public void setDownloadBaseURL(URL url);
384

    
385
        public URL getDownloadBaseURL();
386

    
387
        public void setVersion(Version version);
388

    
389
        public Version getVersionEx();
390

    
391

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

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

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

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

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

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

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

    
458
        public PackageInfoFiles getPackageInfoFiles(PackageInfo packageInfo);
459

    
460
}