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

History | View | Annotate | Download (6.12 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 directory like an zipped outputstream with a concrete name.
69
     * 
70
     * @param directory
71
     *            the directory to compress.
72
     * @param fileName
73
     *            name of the zip entry that has the output file.
74
     *            The name that have to have
75
     * @param os
76
     *            output stream to write the output.
77
     * @throws MakePluginPackageServiceException
78
     *             if there is any problem compressing.
79
     */
80
    public void compress(File directory, String fileName, OutputStream os)
81
        throws MakePluginPackageServiceException;
82

    
83
    /**
84
     * Reads the package.info file from a directory a fills the the properties
85
     * of the {@link PackageInfo} object.
86
     * 
87
     * @param directory
88
     *            the root directory that contains the installinfo file
89
     * @param installInfo
90
     *            the installinfo file that has to be filled.
91
     * @throws InstallerInfoFileException.
92
     *         if there is any problem reading the file
93
     */
94
    public void readPackageInfo(File directory, PackageInfo installerInfo)
95
        throws InstallerInfoFileException;
96

    
97
    /**
98
     * Reads the package.info file from a bundle fills the the properties
99
     * of the {@link PackageInfo} objects.
100
     * 
101
     * @param is
102
     *            the input stream of a bundle.
103
     * @param packageInfos
104
     *            a list of the information of the packages to install.
105
     * @param zipEntriesMap
106
     *            a map to retrieve the zipEntry for every package. This
107
     *            information is necessary to
108
     *            select the plugin to decompress.
109
     * @throws InstallPackageServiceException
110
     *             if there is a problem reading the bundle.
111
     */
112
    public void readPackageInfo(InputStream is, List<PackageInfo> packageInfos,
113
        Map<PackageInfo, String> zipEntriesMap)
114
        throws InstallPackageServiceException;
115

    
116
    /**
117
     * Writes the package.info file in a concrete directory.
118
     * 
119
     * @param directory
120
     *            the directory.
121
     * @param packageInfo
122
     *            the information to write.
123
     * @throws InstallerInfoFileException
124
     *             if there is any problem writing the package.info file.
125
     */
126
    public void writePackageInfo(File directory, PackageInfo packageInfo)
127
        throws InstallerInfoFileException;
128

    
129
    /**
130
     * It search a package inside an installer file by the zip name and returns
131
     * the stream in this position ready to decompres.
132
     * 
133
     * @param is
134
     *            the input stream of a bundle.
135
     * @param zipEntry
136
     *            the name of the zip entry.
137
     * @return
138
     *         the input stream ready to install.
139
     * @throws InstallPackageServiceException
140
     *             if there is a problem reading the stream
141
     */
142
    public InputStream searchPackage(InputStream is, String zipEntry)
143
        throws InstallPackageServiceException;
144

    
145
    /**
146
     * It reads a compressed file and retrieve the package information.
147
     * 
148
     * @param is
149
     *            the compressed file
150
     * @return
151
     *         the information of the package
152
     * @throws InstallPackageServiceException
153
     *             if there is a problem decompressing the file.
154
     */
155
    public PackageInfo readCompressedPackageInfo(InputStream is)
156
        throws InstallPackageServiceException;
157

    
158
    /**
159
     * Downloads a temporal file from the given {@link URL}.
160
     * 
161
     * @param fileURL
162
     *            to download the file from
163
     * @param defaultFileName
164
     *            default name for the file. If the URL ends with / the file
165
     *            name will be appended to the URL. If null it will be ignored
166
     * @return the temporal downloaded file
167
     * @throws IOException
168
     *             if there is an error downloading the file
169
     */
170
    public File downloadFile(URL fileURL, String defaultFileName)
171
        throws IOException;
172
}