svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.installer / org.gvsig.installer.lib / org.gvsig.installer.lib.api / src / main / java / org / gvsig / installer / lib / api / creation / MakePluginPackageService.java @ 40560
History | View | Annotate | Download (8.91 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
/*
|
25 |
* AUTHORS (In addition to CIT):
|
26 |
* 2010 {Prodevelop} {Task}
|
27 |
*/
|
28 |
|
29 |
package org.gvsig.installer.lib.api.creation; |
30 |
|
31 |
import java.io.File; |
32 |
import java.io.OutputStream; |
33 |
|
34 |
import org.gvsig.installer.lib.api.InstallerManager; |
35 |
import org.gvsig.installer.lib.api.PackageInfo; |
36 |
import org.gvsig.tools.service.Service; |
37 |
|
38 |
/**
|
39 |
* <p>
|
40 |
* This service is used to create a bundle that contains a package of plugin
|
41 |
* type. It supports just one package for every installer. It contains a method
|
42 |
* to set the plugin path and some methods to set the installer information.
|
43 |
* </p>
|
44 |
* <p>
|
45 |
* It has also methods to load the installed plugins from a directory (if
|
46 |
* exists) and methods to create the bundle file in an {@link OutputStream}.
|
47 |
* </p>
|
48 |
* <p>
|
49 |
* A plugin package has the same structure of a standard package defined in
|
50 |
* {@link InstallerManager} but it adds some new files. An example of the
|
51 |
* structure of a bundle with a plugin package could be:
|
52 |
* </p>
|
53 |
*
|
54 |
* <pre>
|
55 |
* - bundle (compressed file)
|
56 |
* - org.gvsig.plugin1-1_0_0-23 (compressed file)
|
57 |
* - org.gvsig.plugin1
|
58 |
* - package.info
|
59 |
* - install.xml
|
60 |
* - files
|
61 |
* - gvSIG
|
62 |
* - extensiones
|
63 |
* - org.gvsig.plugin2
|
64 |
* - file1
|
65 |
* - file2
|
66 |
* </pre>
|
67 |
* <p>
|
68 |
* This structure has some extra files:
|
69 |
* </p>
|
70 |
* <lu> <li><b>install.xml</b>: ant file that is executed in the execution of
|
71 |
* the installer to do some extra actions in the installation process. One of
|
72 |
* these actions is copy all the files located in the files directory</li> <li>
|
73 |
* <b>files directory</b>: it contains some files of other extensions that have
|
74 |
* to be copied using the ant script.</li> </lu>
|
75 |
* <p>
|
76 |
* The usage of the ant script to copy files from other plugins is not
|
77 |
* recommended because it is possible that different installers overrides the
|
78 |
* same file. The suggestion it that one plugin has to have all the files that
|
79 |
* it needs to work inside the plugin and it never has to override some external
|
80 |
* files.
|
81 |
* </p>
|
82 |
* <p>
|
83 |
* The implementations of this interface have to have a constructor with a File
|
84 |
* parameter that is the directory when the plugins are located. If the
|
85 |
* directory doens't exists the creation throws an exception.
|
86 |
* </p>
|
87 |
*
|
88 |
* @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a>
|
89 |
*/
|
90 |
public interface MakePluginPackageService extends Service { |
91 |
|
92 |
/**
|
93 |
* It creates a package set with a single plugin package inside.
|
94 |
*
|
95 |
* @param packageInfo
|
96 |
* the information of the plugin that has to be included in the
|
97 |
* package set
|
98 |
* @param packageStream
|
99 |
* the stream where the the package set will be created
|
100 |
* @throws MakePluginPackageServiceException
|
101 |
* it is thrown when there is an exception creating the package
|
102 |
* set
|
103 |
*/
|
104 |
public void createPackageSet(PackageInfo packageInfo, |
105 |
OutputStream packageStream)
|
106 |
throws MakePluginPackageServiceException;
|
107 |
|
108 |
/**
|
109 |
* It creates a package of a plugin.
|
110 |
*
|
111 |
* @param packageInfo
|
112 |
* the information of the plugin that has to be included in the
|
113 |
* package
|
114 |
* @param packageStream
|
115 |
* the stream where the the package will be created
|
116 |
* @throws MakePluginPackageServiceException
|
117 |
* it is thrown when there is an exception creating the package
|
118 |
*/
|
119 |
public void createPackage(PackageInfo packageInfo, |
120 |
OutputStream packageStream)
|
121 |
throws MakePluginPackageServiceException;
|
122 |
|
123 |
/**
|
124 |
* Prepares and copies the needed files for the package. It is used to copy
|
125 |
* the ant build file and the additional external files to be included in
|
126 |
* the package.
|
127 |
*
|
128 |
* @param newPackageInfo
|
129 |
* the information of the new plugin.
|
130 |
* @param originalPackageInfo
|
131 |
* the information of the original plugin.
|
132 |
* @throws MakePluginPackageServiceException
|
133 |
* it is thrown when there is an exception preparing the package
|
134 |
*/
|
135 |
public void preparePackage(PackageInfo packageInfo, |
136 |
File originalPackageFolder)
|
137 |
throws MakePluginPackageServiceException;
|
138 |
|
139 |
/**
|
140 |
* It creates the index for a package of a plugin. This file may be used to
|
141 |
* be included in the main gvSIG remote index, or downloaded as it is.
|
142 |
*
|
143 |
* @param packageInfo
|
144 |
* the information of the plugin that has to be included in the
|
145 |
* package index
|
146 |
* @param packageStream
|
147 |
* the stream where the the package index will be created
|
148 |
* @throws MakePluginPackageServiceException
|
149 |
* it is thrown when there is an exception creating the package
|
150 |
*/
|
151 |
public void createPackageIndex(PackageInfo packageInfo, |
152 |
OutputStream packageStream)
|
153 |
throws MakePluginPackageServiceException;
|
154 |
|
155 |
/**
|
156 |
* Writes a package info file with the information provided.
|
157 |
*
|
158 |
* @param packageInfo
|
159 |
* the package that has to be written into the file
|
160 |
* @param folder
|
161 |
* the folder where the file is to be created
|
162 |
* @throws MakePluginPackageServiceException
|
163 |
* it is thrown when there is an exception writing the file
|
164 |
*/
|
165 |
public void writePackageInfo(PackageInfo packageInfo, File folder) |
166 |
throws MakePluginPackageServiceException;
|
167 |
|
168 |
/**
|
169 |
* Writes a package info file with the information provided.
|
170 |
*
|
171 |
* @param packageInfo
|
172 |
* the package that has to be written into the file
|
173 |
* @param folder
|
174 |
* the folder where the file is to be created
|
175 |
* @throws MakePluginPackageServiceException
|
176 |
* it is thrown when there is an exception writing the file
|
177 |
*/
|
178 |
public void writePackageInfoForIndex(PackageInfo packageInfo, File folder) |
179 |
throws MakePluginPackageServiceException;
|
180 |
|
181 |
/**
|
182 |
* It returns the number of plugin packages that are installed in the folder
|
183 |
* that has been added using the constructor. It can be used in an iteration
|
184 |
* process combined with the {@link #getPluginPackageInfo(int)} method to
|
185 |
* know all the installed plugins.
|
186 |
*
|
187 |
* @return the number of plugins installed in a directory.
|
188 |
*/
|
189 |
public int getPluginPackageCount(); |
190 |
|
191 |
/**
|
192 |
* It returns an instance of an {@link PackageInfo} class, that is a class
|
193 |
* that contains all the package information (name, version...).
|
194 |
*
|
195 |
* @param index
|
196 |
* the position of the plugin that has to be retrieved.
|
197 |
* @return the installer information of a plugin package. Returns
|
198 |
* <code>null</code> if the package doesn't exist.
|
199 |
*/
|
200 |
public PackageInfo getPluginPackageInfo(int index); |
201 |
|
202 |
/**
|
203 |
* It returns an instance of an {@link PackageInfo} class, that is a class
|
204 |
* that contains all the package information (name, version...).
|
205 |
*
|
206 |
* @param code
|
207 |
* code of the plugin, defined in the <b>package.info</b> file
|
208 |
* like a property.
|
209 |
* @return the installer information of a plugin package. Returns
|
210 |
* <code>null</code> if the package doesn't exist.
|
211 |
*/
|
212 |
public PackageInfo getPluginPackageInfo(String code); |
213 |
|
214 |
/**
|
215 |
* This method returns the default ant script that will be used by some
|
216 |
* plugins to copy some external files in the installation process.
|
217 |
*
|
218 |
* @return a string that contains the standard ant script
|
219 |
* @throws MakePluginPackageServiceException
|
220 |
* if there is a problem reading the file
|
221 |
*/
|
222 |
public String getDefaultAntScript() |
223 |
throws MakePluginPackageServiceException;
|
224 |
|
225 |
/**
|
226 |
* Returns the list of packages already installed in the application.
|
227 |
*
|
228 |
* @return the list of packages already installed in the application
|
229 |
* @throws MakePluginPackageServiceException
|
230 |
* if there is an error getting the installed packages
|
231 |
*/
|
232 |
public PackageInfo[] getInstalledPackages() |
233 |
throws MakePluginPackageServiceException;
|
234 |
|
235 |
/**
|
236 |
* Returns the folder where a plugin is located.
|
237 |
*
|
238 |
* @param selectedPackageInfo
|
239 |
* the info of theplugin to look for
|
240 |
* @return the plugin's folder
|
241 |
* @throws MakePluginPackageServiceException
|
242 |
* if there is an error locating the folder
|
243 |
*/
|
244 |
public File getPluginFolder(PackageInfo packageInfo) |
245 |
throws MakePluginPackageServiceException;
|
246 |
|
247 |
/**
|
248 |
* @param folder
|
249 |
* @return
|
250 |
*/
|
251 |
public boolean deleteDir(File folder); |
252 |
|
253 |
} |