svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.symbology.app / org.gvsig.symbology.app.symbolinstaller / src / main / java / org / gvsig / symbology / app / symbolinstaller / execution / SymbolInstallerExecutionProvider.java @ 43126
History | View | Annotate | Download (3.33 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.symbology.app.symbolinstaller.execution; |
25 |
|
26 |
import java.io.File; |
27 |
import java.io.IOException; |
28 |
import java.io.InputStream; |
29 |
|
30 |
import org.gvsig.installer.lib.api.PackageInfo; |
31 |
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException; |
32 |
import org.gvsig.installer.lib.spi.InstallPackageProviderServices; |
33 |
import org.gvsig.installer.lib.spi.InstallerProviderLocator; |
34 |
import org.gvsig.installer.lib.spi.InstallerProviderManager; |
35 |
import org.gvsig.installer.lib.spi.execution.InstallPackageProvider; |
36 |
import org.gvsig.tools.service.spi.AbstractProvider; |
37 |
import org.gvsig.tools.service.spi.ProviderServices; |
38 |
|
39 |
public class SymbolInstallerExecutionProvider extends AbstractProvider |
40 |
implements InstallPackageProvider {
|
41 |
private final File symbolsFolder; |
42 |
|
43 |
public SymbolInstallerExecutionProvider(ProviderServices providerServices, File symbolsFolder) { |
44 |
super(providerServices);
|
45 |
this.symbolsFolder = symbolsFolder;
|
46 |
} |
47 |
|
48 |
public class InstallerSymbolsDirectoryNotFoundException extends |
49 |
InstallPackageServiceException { |
50 |
|
51 |
private static final long serialVersionUID = 4416143986837955880L; |
52 |
private static final String message = "Symbols directory not found"; |
53 |
private static final String KEY = "symbols_directory_not_found"; |
54 |
|
55 |
public InstallerSymbolsDirectoryNotFoundException() {
|
56 |
super(message, KEY, serialVersionUID);
|
57 |
} |
58 |
} |
59 |
|
60 |
@Override
|
61 |
public void install(File applicationDirectory, InputStream inputStream, |
62 |
PackageInfo packageInfo) throws InstallPackageServiceException {
|
63 |
|
64 |
try {
|
65 |
if (!symbolsFolder.exists()) {
|
66 |
throw new InstallerSymbolsDirectoryNotFoundException(); |
67 |
} |
68 |
InstallerProviderManager installerProviderManager = |
69 |
InstallerProviderLocator.getProviderManager(); |
70 |
InstallPackageProviderServices installerProviderServices = |
71 |
installerProviderManager.createInstallerProviderServices(); |
72 |
|
73 |
installerProviderServices.decompress(inputStream, symbolsFolder); |
74 |
|
75 |
} catch (Exception e) { |
76 |
throw new InstallPackageServiceException(e); |
77 |
} |
78 |
} |
79 |
|
80 |
@Override
|
81 |
public void installLater(File applicationDirectory, |
82 |
InputStream inputStream, PackageInfo packageInfo)
|
83 |
throws InstallPackageServiceException, IOException { |
84 |
// TODO Auto-generated method stub
|
85 |
|
86 |
} |
87 |
} |