gvsig-educa / org.gvsig.educa.portableview / trunk / org.gvsig.educa.portableview / org.gvsig.educa.portableview.lib / org.gvsig.educa.portableview.lib.prov.installer / src / main / java / org / gvsig / educa / portableview / lib / prov / installer / execution / PortableViewInstallerExecutionProvider.java @ 256
History | View | Annotate | Download (3.41 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.educa.portableview.lib.prov.installer.execution; |
29 |
|
30 |
import java.io.File; |
31 |
import java.io.IOException; |
32 |
import java.io.InputStream; |
33 |
|
34 |
import org.gvsig.educa.portableview.PortableViewLocator; |
35 |
import org.gvsig.educa.portableview.PortableViewManager; |
36 |
import org.gvsig.installer.lib.api.PackageInfo; |
37 |
import org.gvsig.installer.lib.api.execution.InstallPackageServiceException; |
38 |
import org.gvsig.installer.lib.spi.InstallPackageProviderServices; |
39 |
import org.gvsig.installer.lib.spi.InstallerProviderLocator; |
40 |
import org.gvsig.installer.lib.spi.InstallerProviderManager; |
41 |
import org.gvsig.installer.lib.spi.execution.InstallPackageProvider; |
42 |
import org.gvsig.tools.service.spi.AbstractProvider; |
43 |
import org.gvsig.tools.service.spi.ProviderServices; |
44 |
|
45 |
public class PortableViewInstallerExecutionProvider extends AbstractProvider |
46 |
implements InstallPackageProvider {
|
47 |
|
48 |
private static final InstallerProviderManager installerProviderManager = |
49 |
InstallerProviderLocator.getProviderManager(); |
50 |
private final PortableViewManager tmManager; |
51 |
|
52 |
public PortableViewInstallerExecutionProvider(
|
53 |
ProviderServices providerServices) { |
54 |
super(providerServices);
|
55 |
tmManager = PortableViewLocator.getManager(); |
56 |
} |
57 |
|
58 |
public void install(File applicationDirectory, InputStream inputStream, |
59 |
PackageInfo packageInfo) throws InstallPackageServiceException {
|
60 |
|
61 |
try {
|
62 |
File installationFolder =
|
63 |
new File(tmManager.getInstallationMapFolder()); |
64 |
|
65 |
InstallPackageProviderServices installerProviderServices = |
66 |
installerProviderManager.createInstallerProviderServices(); |
67 |
|
68 |
installerProviderServices.decompress(inputStream, |
69 |
installationFolder); |
70 |
|
71 |
} catch (Exception e) { |
72 |
try {
|
73 |
// if there is an exception, installLater is called
|
74 |
installLater(applicationDirectory, inputStream, packageInfo); |
75 |
} catch (IOException e1) { |
76 |
e1.printStackTrace(); |
77 |
throw new InstallPackageServiceException(e1); |
78 |
} |
79 |
} |
80 |
} |
81 |
|
82 |
/**
|
83 |
* This function will is called when an exception is produced during the
|
84 |
* installation of a plugin. It will prepare the package to be installed on
|
85 |
* the next gvSIG restart.
|
86 |
*/
|
87 |
public void installLater(File applicationDirectory, |
88 |
InputStream inputStream, PackageInfo packageInfo)
|
89 |
throws InstallPackageServiceException, IOException { |
90 |
|
91 |
} |
92 |
|
93 |
} |