Statistics
| Revision:

gvsig-raster / org.gvsig.raster / branches / org.gvsig.raster.2.4 / org.gvsig.wcs / org.gvsig.wcs.provider / src / main / java / org / gvsig / wcs / provider / WCSRasterLibrary.java @ 8786

History | View | Annotate | Download (3.68 KB)

1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2016 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.wcs.provider;
24

    
25

    
26
import java.util.ArrayList;
27
import java.util.List;
28

    
29
import org.gvsig.fmap.dal.DALLibrary;
30
import org.gvsig.fmap.dal.FileHelper;
31
import org.gvsig.fmap.dal.spi.DALSPILocator;
32
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
33
import org.gvsig.fmap.mapcontext.MapContextLibrary;
34
import org.gvsig.metadata.exceptions.MetadataException;
35
import org.gvsig.tools.library.AbstractLibrary;
36
import org.gvsig.tools.library.LibraryException;
37

    
38

    
39
/**
40
 * @author fdiaz
41
 *
42
 */
43
public class WCSRasterLibrary extends AbstractLibrary{
44

    
45
    @Override
46
    public void doRegistration() {
47
        registerAsServiceOf(DALLibrary.class);
48
        require(MapContextLibrary.class);
49
    }
50

    
51
    @Override
52
    protected void doInitialize() throws LibraryException {
53
        // TODO Auto-generated method stub
54

    
55
    }
56

    
57
    @Override
58
    protected void doPostInitialize() throws LibraryException {
59
        List<Throwable> exs = new ArrayList<Throwable>();
60

    
61
        try {
62
            FileHelper.registerParametersDefinition(WCSRasterProviderParameters.PARAMETERS_DEFINITION_NAME,
63
                WCSRasterProviderParameters.class, "WCSRasterParameters.xml");
64
        } catch (RuntimeException e) {
65
            exs.add(e);
66
        }
67

    
68
        try {
69
            FileHelper.registerMetadataDefinition(WCSRasterProvider.METADATA_DEFINITION_NAME, WCSRasterProvider.class,
70
                "WCSRasterMetadata.xml");
71

    
72
        } catch (MetadataException e) {
73
            exs.add(e);
74
        }
75

    
76
        try {
77
            FileHelper.registerParametersDefinition(WCSRasterServerExplorerParameters.PARAMETERS_DEFINITION_NAME,
78
                WCSRasterServerExplorerParameters.class, "WCSRasterParameters.xml");
79

    
80
        } catch (RuntimeException e) {
81
            exs.add(e);
82
        }
83

    
84
        DataManagerProviderServices dataman = DALSPILocator.getDataManagerProviderServices();
85

    
86

    
87
        try {
88
            if (!dataman.getStoreProviders()
89
                .contains(WCSRasterProvider.NAME)) {
90
                dataman.registerStoreProviderFactory(
91
                    new WCSRasterProviderFactory(
92
                        WCSRasterProvider.NAME,
93
                        WCSRasterProvider.DESCRIPTION));
94
            }
95
        } catch (RuntimeException e) {
96
            exs.add(e);
97
        }
98

    
99
        try {
100
            if (!dataman.getExplorerProviders().contains(WCSRasterServerExplorer.NAME)) {
101
                WCSRasterServerExplorerFactory factory = new WCSRasterServerExplorerFactory(WCSRasterServerExplorer.NAME, DefaultWCSRasterServerExplorer.DESCRIPTION);
102
                dataman.registerServerExplorerFactory(factory);
103

    
104
            }
105
        } catch (RuntimeException e) {
106
            exs.add(e);
107
        }
108

    
109

    
110
        if (exs.size() > 0) {
111
            throw new LibraryException(this.getClass(), exs);
112
        }
113
    }
114

    
115
}