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 / creation / MakePluginPackageService.java @ 37822

History | View | Annotate | Download (8.86 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.creation;
29

    
30
import java.io.File;
31
import java.io.OutputStream;
32

    
33
import org.gvsig.installer.lib.api.InstallerManager;
34
import org.gvsig.installer.lib.api.PackageInfo;
35
import org.gvsig.tools.service.Service;
36

    
37
/**
38
 * <p>
39
 * This service is used to create a bundle that contains a package of plugin
40
 * type. It supports just one package for every installer. It contains a method
41
 * to set the plugin path and some methods to set the installer information.
42
 * </p>
43
 * <p>
44
 * It has also methods to load the installed plugins from a directory (if
45
 * exists) and methods to create the bundle file in an {@link OutputStream}.
46
 * </p>
47
 * <p>
48
 * A plugin package has the same structure of a standard package defined in
49
 * {@link InstallerManager} but it adds some new files. An example of the
50
 * structure of a bundle with a plugin package could be:
51
 * </p>
52
 * 
53
 * <pre>
54
 * - bundle (compressed file)
55
 *                 - org.gvsig.plugin1-1_0_0-23 (compressed file)
56
 *                         - org.gvsig.plugin1
57
 *                                   - package.info   
58
 *                          - install.xml
59
 *                          - files
60
 *                                  - gvSIG
61
 *                                          - extensiones
62
 *                                                  - org.gvsig.plugin2
63
 *                                                          - file1
64
 *                                                          - file2
65
 * </pre>
66
 * <p>
67
 * This structure has some extra files:
68
 * </p>
69
 * <lu> <li><b>install.xml</b>: ant file that is executed in the execution of
70
 * the installer to do some extra actions in the installation process. One of
71
 * these actions is copy all the files located in the files directory</li> <li>
72
 * <b>files directory</b>: it contains some files of other extensions that have
73
 * to be copied using the ant script.</li> </lu>
74
 * <p>
75
 * The usage of the ant script to copy files from other plugins is not
76
 * recommended because it is possible that different installers overrides the
77
 * same file. The suggestion it that one plugin has to have all the files that
78
 * it needs to work inside the plugin and it never has to override some external
79
 * files.
80
 * </p>
81
 * <p>
82
 * The implementations of this interface have to have a constructor with a File
83
 * parameter that is the directory when the plugins are located. If the
84
 * directory doens't exists the creation throws an exception.
85
 * </p>
86
 * 
87
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
88
 */
89
public interface MakePluginPackageService extends Service {
90

    
91
        /**
92
         * It creates a package set with a single plugin package inside.
93
         * 
94
         * @param packageInfo
95
         *            the information of the plugin that has to be included in the
96
         *            package set
97
         * @param packageStream
98
         *            the stream where the the package set will be created
99
         * @throws MakePluginPackageServiceException
100
         *             it is thrown when there is an exception creating the package
101
         *             set
102
         */
103
        public void createPackageSet(PackageInfo packageInfo,
104
                        OutputStream packageStream)
105
                        throws MakePluginPackageServiceException;
106

    
107
        /**
108
         * It creates a package of a plugin.
109
         * 
110
         * @param packageInfo
111
         *            the information of the plugin that has to be included in the
112
         *            package
113
         * @param packageStream
114
         *            the stream where the the package will be created
115
         * @throws MakePluginPackageServiceException
116
         *             it is thrown when there is an exception creating the package
117
         */
118
        public void createPackage(PackageInfo packageInfo,
119
                        OutputStream packageStream)
120
                        throws MakePluginPackageServiceException;
121

    
122
        /**
123
         * Prepares and copies the needed files for the package. It is used to copy
124
         * the ant build file and the additional external files to be included in
125
         * the package.
126
         * 
127
         * @param newPackageInfo
128
         *            the information of the new plugin.
129
         * @param originalPackageInfo
130
         *            the information of the original plugin.
131
         * @throws MakePluginPackageServiceException
132
         *             it is thrown when there is an exception preparing the package
133
         */
134
        public void preparePackage(PackageInfo packageInfo,
135
                        File originalPackageFolder)
136
                        throws MakePluginPackageServiceException;
137

    
138
        /**
139
         * It creates the index for a package of a plugin. This file may be used to
140
         * be included in the main gvSIG remote index, or downloaded as it is.
141
         * 
142
         * @param packageInfo
143
         *            the information of the plugin that has to be included in the
144
         *            package index
145
         * @param packageStream
146
         *            the stream where the the package index will be created
147
         * @throws MakePluginPackageServiceException
148
         *             it is thrown when there is an exception creating the package
149
         */
150
        public void createPackageIndex(PackageInfo packageInfo,
151
                        OutputStream packageStream)
152
                        throws MakePluginPackageServiceException;
153

    
154
        /**
155
         * Writes a package info file with the information provided.
156
         * 
157
         * @param packageInfo
158
         *            the package that has to be written into the file
159
         * @param folder
160
         *            the folder where the file is to be created
161
         * @throws MakePluginPackageServiceException
162
         *             it is thrown when there is an exception writing the file
163
         */
164
        public void writePackageInfo(PackageInfo packageInfo, File folder)
165
                        throws MakePluginPackageServiceException;
166

    
167
        /**
168
         * Writes a package info file with the information provided.
169
         * 
170
         * @param packageInfo
171
         *            the package that has to be written into the file
172
         * @param folder
173
         *            the folder where the file is to be created
174
         * @throws MakePluginPackageServiceException
175
         *             it is thrown when there is an exception writing the file
176
         */
177
        public void writePackageInfoForIndex(PackageInfo packageInfo, File folder)
178
                        throws MakePluginPackageServiceException;
179

    
180
        /**
181
         * It returns the number of plugin packages that are installed in the folder
182
         * that has been added using the constructor. It can be used in an iteration
183
         * process combined with the {@link #getPluginPackageInfo(int)} method to
184
         * know all the installed plugins.
185
         * 
186
         * @return the number of plugins installed in a directory.
187
         */
188
        public int getPluginPackageCount();
189

    
190
        /**
191
         * It returns an instance of an {@link PackageInfo} class, that is a class
192
         * that contains all the package information (name, version...).
193
         * 
194
         * @param index
195
         *            the position of the plugin that has to be retrieved.
196
         * @return the installer information of a plugin package. Returns
197
         *         <code>null</code> if the package doesn't exist.
198
         */
199
        public PackageInfo getPluginPackageInfo(int index);
200

    
201
        /**
202
         * It returns an instance of an {@link PackageInfo} class, that is a class
203
         * that contains all the package information (name, version...).
204
         * 
205
         * @param code
206
         *            code of the plugin, defined in the <b>package.info</b> file
207
         *            like a property.
208
         * @return the installer information of a plugin package. Returns
209
         *         <code>null</code> if the package doesn't exist.
210
         */
211
        public PackageInfo getPluginPackageInfo(String code);
212

    
213
        /**
214
         * This method returns the default ant script that will be used by some
215
         * plugins to copy some external files in the installation process.
216
         * 
217
         * @return a string that contains the standard ant script
218
         * @throws MakePluginPackageServiceException
219
         *             if there is a problem reading the file
220
         */
221
        public String getDefaultAntScript()
222
                        throws MakePluginPackageServiceException;
223

    
224
        /**
225
         * Returns the list of packages already installed in the application.
226
         * 
227
         * @return the list of packages already installed in the application
228
         * @throws MakePluginPackageServiceException
229
         *             if there is an error getting the installed packages
230
         */
231
        public PackageInfo[] getInstalledPackages()
232
                        throws MakePluginPackageServiceException;
233

    
234
        /**
235
         * Returns the folder where a plugin is located.
236
         * 
237
         * @param selectedPackageInfo
238
         *            the info of theplugin to look for
239
         * @return the plugin's folder
240
         * @throws MakePluginPackageServiceException
241
         *             if there is an error locating the folder
242
         */
243
        public File getPluginFolder(PackageInfo packageInfo)
244
                        throws MakePluginPackageServiceException;
245

    
246
        /**
247
         * @param folder
248
         * @return
249
         */
250
        public boolean deleteDir(File folder);
251

    
252
}