root / branches / v2_0_0_prep / extensions / org.gvsig.installer / org.gvsig.installer.lib / org.gvsig.installer.lib.impl / src / main / java / org / gvsig / installer / lib / impl / DefaultInstallerProviderServices.java @ 32516
History | View | Annotate | Download (4.08 KB)
1 | 32400 | jpiera | /* 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.impl; |
||
29 | |||
30 | import java.io.File; |
||
31 | import java.io.InputStream; |
||
32 | 32498 | jpiera | import java.io.OutputStream; |
33 | 32500 | jpiera | import java.util.List; |
34 | import java.util.Map; |
||
35 | 32400 | jpiera | |
36 | import org.gvsig.installer.lib.api.InstallerInfo; |
||
37 | 32498 | jpiera | import org.gvsig.installer.lib.api.creation.InstallerCreationServiceException; |
38 | 32400 | jpiera | import org.gvsig.installer.lib.api.execution.InstallerExecutionServiceException; |
39 | 32498 | jpiera | import org.gvsig.installer.lib.impl.info.InstallerInfoFileReader; |
40 | import org.gvsig.installer.lib.impl.info.InstallerInfoFileWriter; |
||
41 | 32500 | jpiera | import org.gvsig.installer.lib.impl.utils.Compress; |
42 | import org.gvsig.installer.lib.impl.utils.Decompress; |
||
43 | 32498 | jpiera | import org.gvsig.installer.lib.spi.InstallerInfoFileException; |
44 | 32400 | jpiera | import org.gvsig.installer.lib.spi.InstallerProviderServices; |
45 | import org.gvsig.tools.service.spi.AbstractProviderServices; |
||
46 | |||
47 | /**
|
||
48 | * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera Llodrá</a>
|
||
49 | */
|
||
50 | public class DefaultInstallerProviderServices extends AbstractProviderServices implements InstallerProviderServices{ |
||
51 | 32498 | jpiera | private static final String INSTALL_INFO_FILE = "install.info"; |
52 | |||
53 | 32400 | jpiera | public void decompress(InputStream is, File outputDirectory) throws InstallerExecutionServiceException { |
54 | Decompress decompress = new Decompress();
|
||
55 | decompress.decompressPlugin(is, outputDirectory); |
||
56 | } |
||
57 | |||
58 | public InstallerInfo readCompressedInstallInfo(InputStream is) throws InstallerExecutionServiceException { |
||
59 | Decompress decompress = new Decompress();
|
||
60 | try {
|
||
61 | return decompress.readInstallerInfo(is);
|
||
62 | } catch (InstallerInfoFileException e) {
|
||
63 | throw new InstallerExecutionServiceException("Exception reading a compressed file", e); |
||
64 | } |
||
65 | } |
||
66 | |||
67 | 32498 | jpiera | public void compress(File directory, String fileName, OutputStream os) |
68 | throws InstallerCreationServiceException {
|
||
69 | Compress compress = new Compress();
|
||
70 | compress.compressPlugin(directory, fileName, os); |
||
71 | |||
72 | } |
||
73 | |||
74 | public void readInstallInfo(File directory, InstallerInfo installerInfo) throws InstallerInfoFileException { |
||
75 | File installInfoFile = new File (directory + File.separator + INSTALL_INFO_FILE); |
||
76 | if (installInfoFile.exists()){
|
||
77 | InstallerInfoFileReader reader = new InstallerInfoFileReader();
|
||
78 | reader.read(installerInfo, installInfoFile.getAbsolutePath()); |
||
79 | }else{
|
||
80 | installerInfo.setCode(directory.getName()); |
||
81 | installerInfo.setName(directory.getName()); |
||
82 | } |
||
83 | } |
||
84 | |||
85 | public void writeInstallInfo(File directory, InstallerInfo installerInfo) throws InstallerInfoFileException { |
||
86 | if (!directory.exists()){
|
||
87 | throw new InstallerInfoFileException("The directory doesn't exist"); |
||
88 | } |
||
89 | InstallerInfoFileWriter installerInfoFileWriter = new InstallerInfoFileWriter();
|
||
90 | 32516 | jpiera | installerInfoFileWriter.write(installerInfo, directory + File.separator + INSTALL_INFO_FILE);
|
91 | 32498 | jpiera | } |
92 | |||
93 | public InputStream searchPlugin(InputStream is, String zipEntry) throws InstallerExecutionServiceException { |
||
94 | Decompress decompress = new Decompress();
|
||
95 | return decompress.searchPlugin(is, zipEntry);
|
||
96 | } |
||
97 | |||
98 | 32500 | jpiera | public void readInstallInfo(InputStream is, |
99 | List<InstallerInfo> installerInfos,
|
||
100 | Map<InstallerInfo, String> zipEntriesMap) |
||
101 | throws InstallerExecutionServiceException {
|
||
102 | Decompress decompress = new Decompress();
|
||
103 | decompress.readInstallInfo(is, installerInfos, zipEntriesMap); |
||
104 | } |
||
105 | |||
106 | 32400 | jpiera | } |