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 @ 37599

History | View | Annotate | Download (8.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.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
         * @return the directory when the gvSIG plugins are located.
93
         */
94
        public File getPluginsDirectory();
95

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

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

    
127
        /**
128
         * Prepares and copies the needed files for the package. It is used to copy
129
         * the ant build file and the additional external files to be included in
130
         * the package.
131
         * 
132
         * @param packageInfo
133
         *            the information of the plugin that has to be included in the
134
         *            package
135
         * @throws MakePluginPackageServiceException
136
         *             it is thrown when there is an exception preparing the package
137
         */
138
        public void preparePackage(PackageInfo packageInfo)
139
                        throws MakePluginPackageServiceException;
140

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

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

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

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

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

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

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

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

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

    
249
        /**
250
         * @param folder
251
         * @return
252
         */
253
        public boolean deleteDir(File folder);
254

    
255
}