svn-gvsig-desktop / tags / v2_0_0_Build_2021 / extensions / org.gvsig.installer / org.gvsig.installer.lib / org.gvsig.installer.lib.spi / src / main / java / org / gvsig / installer / lib / spi / InstallPackageProviderServices.java @ 34107
History | View | Annotate | Download (7.37 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á</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 | 34020 | cordinyana | * Reads the package.info file from a package set and fills the the
|
113 | * properties 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 readPackageSetInfo(InputStream is, |
||
127 | List<PackageInfo> packageInfos, Map<PackageInfo, String> zipEntriesMap) |
||
128 | throws InstallPackageServiceException;
|
||
129 | |||
130 | /**
|
||
131 | 33729 | cordinyana | * Reads the package.info file from a bundle fills the the properties
|
132 | * of the {@link PackageInfo} objects.
|
||
133 | *
|
||
134 | * @param is
|
||
135 | * the input stream of a bundle.
|
||
136 | * @param packageInfos
|
||
137 | * a list of the information of the packages to install.
|
||
138 | * @param zipEntriesMap
|
||
139 | * a map to retrieve the zipEntry for every package. This
|
||
140 | * information is necessary to
|
||
141 | * select the plugin to decompress.
|
||
142 | * @throws InstallPackageServiceException
|
||
143 | * if there is a problem reading the bundle.
|
||
144 | */
|
||
145 | public void readPackageInfo(InputStream is, List<PackageInfo> packageInfos, |
||
146 | 34027 | cordinyana | Map<PackageInfo, String> zipEntriesMap, String name) |
147 | 33729 | cordinyana | throws InstallPackageServiceException;
|
148 | |||
149 | /**
|
||
150 | * Writes the package.info file in a concrete directory.
|
||
151 | *
|
||
152 | * @param directory
|
||
153 | * the directory.
|
||
154 | * @param packageInfo
|
||
155 | * the information to write.
|
||
156 | * @throws InstallerInfoFileException
|
||
157 | * if there is any problem writing the package.info file.
|
||
158 | */
|
||
159 | public void writePackageInfo(File directory, PackageInfo packageInfo) |
||
160 | throws InstallerInfoFileException;
|
||
161 | |||
162 | /**
|
||
163 | * It search a package inside an installer file by the zip name and returns
|
||
164 | * the stream in this position ready to decompres.
|
||
165 | *
|
||
166 | * @param is
|
||
167 | * the input stream of a bundle.
|
||
168 | * @param zipEntry
|
||
169 | * the name of the zip entry.
|
||
170 | * @return
|
||
171 | * the input stream ready to install.
|
||
172 | * @throws InstallPackageServiceException
|
||
173 | * if there is a problem reading the stream
|
||
174 | */
|
||
175 | public InputStream searchPackage(InputStream is, String zipEntry) |
||
176 | throws InstallPackageServiceException;
|
||
177 | |||
178 | /**
|
||
179 | * It reads a compressed file and retrieve the package information.
|
||
180 | *
|
||
181 | * @param is
|
||
182 | * the compressed file
|
||
183 | * @return
|
||
184 | * the information of the package
|
||
185 | * @throws InstallPackageServiceException
|
||
186 | * if there is a problem decompressing the file.
|
||
187 | */
|
||
188 | public PackageInfo readCompressedPackageInfo(InputStream is) |
||
189 | throws InstallPackageServiceException;
|
||
190 | 33982 | cordinyana | |
191 | /**
|
||
192 | * Downloads a temporal file from the given {@link URL}.
|
||
193 | *
|
||
194 | * @param fileURL
|
||
195 | * to download the file from
|
||
196 | 34003 | cordinyana | * @param defaultFileName
|
197 | * default name for the file. If the URL ends with / the file
|
||
198 | * name will be appended to the URL. If null it will be ignored
|
||
199 | 33982 | cordinyana | * @return the temporal downloaded file
|
200 | * @throws IOException
|
||
201 | * if there is an error downloading the file
|
||
202 | */
|
||
203 | 34003 | cordinyana | public File downloadFile(URL fileURL, String defaultFileName) |
204 | throws IOException; |
||
205 | 32400 | jpiera | } |