Statistics
| Revision:

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 40556 jjdelcerro
/**
2
 * gvSIG. Desktop Geographic Information System.
3 40435 jjdelcerro
 *
4 40556 jjdelcerro
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6 40435 jjdelcerro
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8 40556 jjdelcerro
 * as published by the Free Software Foundation; either version 3
9 40435 jjdelcerro
 * of the License, or (at your option) any later version.
10 40556 jjdelcerro
 *
11 40435 jjdelcerro
 * 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 40556 jjdelcerro
 *
16 40435 jjdelcerro
 * 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 40556 jjdelcerro
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 40435 jjdelcerro
 * MA  02110-1301, USA.
20 40556 jjdelcerro
 *
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 40435 jjdelcerro
 */
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 43126 jjdelcerro
    private final File symbolsFolder;
42 40435 jjdelcerro
43 43126 jjdelcerro
    public SymbolInstallerExecutionProvider(ProviderServices providerServices, File symbolsFolder) {
44 40435 jjdelcerro
        super(providerServices);
45 43126 jjdelcerro
        this.symbolsFolder = symbolsFolder;
46 40435 jjdelcerro
    }
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 43126 jjdelcerro
    @Override
61 40435 jjdelcerro
    public void install(File applicationDirectory, InputStream inputStream,
62
        PackageInfo packageInfo) throws InstallPackageServiceException {
63
64
        try {
65 43126 jjdelcerro
            if (!symbolsFolder.exists()) {
66 40435 jjdelcerro
                throw new InstallerSymbolsDirectoryNotFoundException();
67
            }
68
            InstallerProviderManager installerProviderManager =
69
                InstallerProviderLocator.getProviderManager();
70
            InstallPackageProviderServices installerProviderServices =
71
                installerProviderManager.createInstallerProviderServices();
72
73 43126 jjdelcerro
            installerProviderServices.decompress(inputStream, symbolsFolder);
74 40435 jjdelcerro
75
        } catch (Exception e) {
76
            throw new InstallPackageServiceException(e);
77
        }
78
    }
79
80 43126 jjdelcerro
    @Override
81 40435 jjdelcerro
    public void installLater(File applicationDirectory,
82
        InputStream inputStream, PackageInfo packageInfo)
83
        throws InstallPackageServiceException, IOException {
84
        // TODO Auto-generated method stub
85
86
    }
87
}