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

History | View | Annotate | Download (6.58 KB)

1 32400 jpiera
/* gvSIG. Geographic Information System of the Valencian Government
2 33729 cordinyana
 *
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 32400 jpiera
23
/*
24 33729 cordinyana
 * AUTHORS (In addition to CIT):
25
 * 2010 {Prodevelop}   {Task}
26
 */
27
28 32400 jpiera
package org.gvsig.installer.lib.spi;
29
30
import java.io.File;
31 33982 cordinyana
import java.io.IOException;
32 32400 jpiera
import java.io.InputStream;
33 32498 jpiera
import java.io.OutputStream;
34 33982 cordinyana
import java.net.URL;
35 32500 jpiera
import java.util.List;
36
import java.util.Map;
37 32400 jpiera
38 32563 jpiera
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 32400 jpiera
import org.gvsig.tools.service.spi.ProviderServices;
42
43
/**
44 33729 cordinyana
 * 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 32598 jpiera
 * read an install a package file from a directory.
48 32498 jpiera
 *
49 32400 jpiera
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodr&aacute;</a>
50
 */
51 33729 cordinyana
public interface InstallPackageProviderServices extends ProviderServices {
52 32400 jpiera
53 33729 cordinyana
    /**
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 34005 cordinyana
     * Compress a folder as a zipped package set in the given outputstream with
69
     * a concrete name.
70 33729 cordinyana
     *
71 34005 cordinyana
     * @param folder
72
     *            the folder to compress.
73 33729 cordinyana
     * @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 34005 cordinyana
    public void compressPackageSet(File folder, String fileName, OutputStream os)
82 33729 cordinyana
        throws MakePluginPackageServiceException;
83
84
    /**
85 34005 cordinyana
     * 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 33729 cordinyana
     * Reads the package.info file from a directory a fills the the properties
99
     * of the {@link PackageInfo} object.
100
     *
101
     * @param directory
102
     *            the root directory that contains the installinfo file
103
     * @param installInfo
104
     *            the installinfo file that has to be filled.
105
     * @throws InstallerInfoFileException.
106
     *         if there is any problem reading the file
107
     */
108
    public void readPackageInfo(File directory, PackageInfo installerInfo)
109
        throws InstallerInfoFileException;
110
111
    /**
112
     * Reads the package.info file from a bundle fills the the properties
113
     * of the {@link PackageInfo} objects.
114
     *
115
     * @param is
116
     *            the input stream of a bundle.
117
     * @param packageInfos
118
     *            a list of the information of the packages to install.
119
     * @param zipEntriesMap
120
     *            a map to retrieve the zipEntry for every package. This
121
     *            information is necessary to
122
     *            select the plugin to decompress.
123
     * @throws InstallPackageServiceException
124
     *             if there is a problem reading the bundle.
125
     */
126
    public void readPackageInfo(InputStream is, List<PackageInfo> packageInfos,
127
        Map<PackageInfo, String> zipEntriesMap)
128
        throws InstallPackageServiceException;
129
130
    /**
131
     * Writes the package.info file in a concrete directory.
132
     *
133
     * @param directory
134
     *            the directory.
135
     * @param packageInfo
136
     *            the information to write.
137
     * @throws InstallerInfoFileException
138
     *             if there is any problem writing the package.info file.
139
     */
140
    public void writePackageInfo(File directory, PackageInfo packageInfo)
141
        throws InstallerInfoFileException;
142
143
    /**
144
     * It search a package inside an installer file by the zip name and returns
145
     * the stream in this position ready to decompres.
146
     *
147
     * @param is
148
     *            the input stream of a bundle.
149
     * @param zipEntry
150
     *            the name of the zip entry.
151
     * @return
152
     *         the input stream ready to install.
153
     * @throws InstallPackageServiceException
154
     *             if there is a problem reading the stream
155
     */
156
    public InputStream searchPackage(InputStream is, String zipEntry)
157
        throws InstallPackageServiceException;
158
159
    /**
160
     * It reads a compressed file and retrieve the package information.
161
     *
162
     * @param is
163
     *            the compressed file
164
     * @return
165
     *         the information of the package
166
     * @throws InstallPackageServiceException
167
     *             if there is a problem decompressing the file.
168
     */
169
    public PackageInfo readCompressedPackageInfo(InputStream is)
170
        throws InstallPackageServiceException;
171 33982 cordinyana
172
    /**
173
     * Downloads a temporal file from the given {@link URL}.
174
     *
175
     * @param fileURL
176
     *            to download the file from
177 34003 cordinyana
     * @param defaultFileName
178
     *            default name for the file. If the URL ends with / the file
179
     *            name will be appended to the URL. If null it will be ignored
180 33982 cordinyana
     * @return the temporal downloaded file
181
     * @throws IOException
182
     *             if there is an error downloading the file
183
     */
184 34003 cordinyana
    public File downloadFile(URL fileURL, String defaultFileName)
185
        throws IOException;
186 32400 jpiera
}