Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.installer / org.gvsig.installer.lib / org.gvsig.installer.lib.spi / src / main / java / org / gvsig / installer / lib / spi / InstallPackageProviderServices.java @ 34444

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

    
30
import java.io.File;
31
import java.io.IOException;
32
import java.io.InputStream;
33
import java.io.OutputStream;
34
import java.net.URL;
35
import java.util.List;
36
import java.util.Map;
37

    
38
import org.gvsig.installer.lib.api.PackageInfo;
39
import org.gvsig.installer.lib.api.creation.MakePluginPackageServiceException;
40
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException;
41
import org.gvsig.tools.service.spi.ProviderServices;
42

    
43
/**
44
 * Services that can be used by the providers to create or exceute the bundle.
45
 * It
46
 * contains methods to compress and to decompress files and methods to
47
 * read an install a package file from a directory.
48
 * 
49
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
50
 */
51
public interface InstallPackageProviderServices extends ProviderServices {
52

    
53
    /**
54
     * It decompress an input stream and write it on a directory.
55
     * 
56
     * @param is
57
     *            The input stream to decompress
58
     * @param outputDirectory
59
     *            .
60
     *            The output directory.
61
     * @throws InstallPackageServiceException
62
     *             If there is a problem decompressing the stream.
63
     */
64
    public void decompress(InputStream is, File outputDirectory)
65
        throws InstallPackageServiceException;
66

    
67
    /**
68
     * Compress a folder as a zipped package set in the given outputstream with
69
     * a concrete name.
70
     * 
71
     * @param folder
72
     *            the folder to compress.
73
     * @param fileName
74
     *            name of the zip entry that has the output file.
75
     *            The name that have to have
76
     * @param os
77
     *            output stream to write the output.
78
     * @throws MakePluginPackageServiceException
79
     *             if there is any problem compressing.
80
     */
81
    public void compressPackageSet(File folder, String fileName, OutputStream os)
82
        throws MakePluginPackageServiceException;
83

    
84
    /**
85
     * Compress a plugin folder using the plugin's name as a package.
86
     * 
87
     * @param folder
88
     *            the directory to compress.
89
     * @param os
90
     *            output stream to write the output.
91
     * @throws MakePluginPackageServiceException
92
     *             if there is any problem compressing.
93
     */
94
    public void compressPackage(File folder, OutputStream os)
95
        throws MakePluginPackageServiceException;
96

    
97
    /**
98
     * Compress a plugin folder using the plugin's name as a package, only
99
     * with the files needed by the package index.
100
     * 
101
     * @param folder
102
     *            the directory to compress.
103
     * @param os
104
     *            output stream to write the output.
105
     * @throws MakePluginPackageServiceException
106
     *             if there is any problem compressing.
107
     */
108
    public void compressPackageIndex(File folder, OutputStream os)
109
        throws MakePluginPackageServiceException;
110

    
111
    /**
112
     * Reads the package.info file from a directory a fills the the properties
113
     * of the {@link PackageInfo} object.
114
     * 
115
     * @param directory
116
     *            the root directory that contains the installinfo file
117
     * @param installInfo
118
     *            the installinfo file that has to be filled.
119
     * @throws InstallerInfoFileException.
120
     *         if there is any problem reading the file
121
     */
122
    public void readPackageInfo(File directory, PackageInfo installerInfo)
123
        throws InstallerInfoFileException;
124

    
125
    /**
126
     * Reads the package.info file from a package set and fills the the
127
     * properties of the {@link PackageInfo} objects.
128
     * 
129
     * @param is
130
     *            the input stream of a bundle.
131
     * @param packageInfos
132
     *            a list of the information of the packages to install.
133
     * @param zipEntriesMap
134
     *            a map to retrieve the zipEntry for every package. This
135
     *            information is necessary to
136
     *            select the plugin to decompress.
137
     * @throws InstallPackageServiceException
138
     *             if there is a problem reading the bundle.
139
     */
140
    public void readPackageSetInfo(InputStream is,
141
        List<PackageInfo> packageInfos, Map<PackageInfo, String> zipEntriesMap)
142
        throws InstallPackageServiceException;
143

    
144
    /**
145
     * Reads the package.info file from a bundle fills the the properties
146
     * of the {@link PackageInfo} objects.
147
     * 
148
     * @param is
149
     *            the input stream of a bundle.
150
     * @param packageInfos
151
     *            a list of the information of the packages to install.
152
     * @param zipEntriesMap
153
     *            a map to retrieve the zipEntry for every package. This
154
     *            information is necessary to
155
     *            select the plugin to decompress.
156
     * @throws InstallPackageServiceException
157
     *             if there is a problem reading the bundle.
158
     */
159
    public void readPackageInfo(InputStream is, List<PackageInfo> packageInfos,
160
        Map<PackageInfo, String> zipEntriesMap, String name)
161
        throws InstallPackageServiceException;
162

    
163
    /**
164
     * Writes the package.info file in a concrete directory.
165
     * 
166
     * @param directory
167
     *            the directory.
168
     * @param packageInfo
169
     *            the information to write.
170
     * @throws InstallerInfoFileException
171
     *             if there is any problem writing the package.info file.
172
     */
173
    public void writePackageInfo(File directory, PackageInfo packageInfo)
174
        throws InstallerInfoFileException;
175

    
176
    /**
177
     * Writes the package.info file in a concrete directory to be used in
178
     * a package index.
179
     * 
180
     * @param directory
181
     *            the directory.
182
     * @param packageInfo
183
     *            the information to write.
184
     * @throws InstallerInfoFileException
185
     *             if there is any problem writing the package.info file.
186
     */
187
    public void writePackageInfoForIndex(File directory, PackageInfo packageInfo)
188
        throws InstallerInfoFileException;
189

    
190
    /**
191
     * It search a package inside an installer file by the zip name and returns
192
     * the stream in this position ready to decompres.
193
     * 
194
     * @param is
195
     *            the input stream of a bundle.
196
     * @param zipEntry
197
     *            the name of the zip entry.
198
     * @return
199
     *         the input stream ready to install.
200
     * @throws InstallPackageServiceException
201
     *             if there is a problem reading the stream
202
     */
203
    public InputStream searchPackage(InputStream is, String zipEntry)
204
        throws InstallPackageServiceException;
205

    
206
    /**
207
     * It reads a compressed file and retrieve the package information.
208
     * 
209
     * @param is
210
     *            the compressed file
211
     * @return
212
     *         the information of the package
213
     * @throws InstallPackageServiceException
214
     *             if there is a problem decompressing the file.
215
     */
216
    public PackageInfo readCompressedPackageInfo(InputStream is)
217
        throws InstallPackageServiceException;
218

    
219
    /**
220
     * Downloads a temporal file from the given {@link URL}.
221
     * 
222
     * @param fileURL
223
     *            to download the file from
224
     * @param defaultFileName
225
     *            default name for the file. If the URL ends with / the file
226
     *            name will be appended to the URL. If null it will be ignored
227
     * @return the temporal downloaded file
228
     * @throws IOException
229
     *             if there is an error downloading the file
230
     */
231
    public File downloadFile(URL fileURL, String defaultFileName)
232
        throws IOException;
233
}