Statistics
| Revision:

gvsig-3d / 2.0 / trunk / org.gvsig.gvsig3d.osg / org.gvsig.gvsig3d.osg.io / src / main / java / org / gvsig / gvsig3d / osg / io / OSGFilesystemServerProvider.java @ 304

History | View | Annotate | Download (3.65 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
* 2009 IVER T.I   {{Task}}
26
*/
27

    
28
package org.gvsig.gvsig3d.osg.io;
29

    
30
import java.io.File;
31
import java.io.FileNotFoundException;
32

    
33
import org.gvsig.fmap.dal.DataServerExplorer;
34
import org.gvsig.fmap.dal.DataStoreParameters;
35
import org.gvsig.fmap.dal.NewDataStoreParameters;
36
import org.gvsig.fmap.dal.exception.CreateException;
37
import org.gvsig.fmap.dal.exception.DataException;
38
import org.gvsig.fmap.dal.exception.RemoveException;
39
import org.gvsig.fmap.dal.resource.spi.ResourceConsumer;
40
import org.gvsig.fmap.dal.resource.spi.ResourceProvider;
41
import org.gvsig.fmap.dal.serverexplorer.filesystem.impl.AbstractFilesystemServerExplorerProvider;
42
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider;
43
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderServices;
44

    
45
public class OSGFilesystemServerProvider extends AbstractFilesystemServerExplorerProvider 
46
implements FilesystemServerExplorerProvider, ResourceConsumer {
47
        public static final String NAME       = OSGStoreProvider.NAME;
48

    
49
        public boolean canCreate() {
50
                // TODO Auto-generated method stub
51
                return false;
52
        }
53

    
54
        public boolean canCreate(NewDataStoreParameters parameters) {
55
                // not yet, studying load osg files first
56
                return false;
57
        }
58

    
59
        public void create(NewDataStoreParameters parameters, boolean overwrite)
60
                        throws CreateException {
61
                // not yet, studying load osg files first
62
                
63
        }
64

    
65
        public NewDataStoreParameters getCreateParameters() throws DataException {
66
                // not yet, studying load osg files first
67
                return null;
68
        }
69

    
70
        public void initialize(
71
                        FilesystemServerExplorerProviderServices serverExplorer) {
72
                
73
                
74
        }
75

    
76
        public void remove(DataStoreParameters parameters) throws RemoveException {
77
                // mmh I really want to do that?
78
                File file = new File(((OSGStoreParameters) parameters).getFileName());
79
                if (!file.exists()) {
80
                        throw new RemoveException(this.getDataStoreProviderName(),
81
                                        new FileNotFoundException(file.getPath()));
82
                }
83
                if (!file.delete()) {
84
                        // FIXME throws ???
85
                }
86
        }
87

    
88
        public String getDataStoreProviderName() {
89
                // TODO Auto-generated method stub
90
                return OSGStoreProvider.NAME;
91
        }
92

    
93
        public String getDescription() {
94
                // TODO Auto-generated method stub
95
                return OSGStoreProvider.DESCRIPTION;
96
        }
97

    
98
        public boolean accept(File fname) {
99
                String icfname = fname.getName().toLowerCase();
100
                return (icfname.endsWith(".osg")  ||
101
                                icfname.endsWith(".osgt") ||
102
                                icfname.endsWith(".osgb") ||
103
                                icfname.endsWith(".osgx") ||
104
                                icfname.endsWith(".ive")  ||
105
                                icfname.endsWith(".ptree"));
106
        }
107

    
108
        public boolean closeResourceRequested(ResourceProvider arg0) {
109
                return false;
110
        }
111

    
112
        public void resourceChanged(ResourceProvider arg0) {
113
                
114
        }
115
        
116
        public int getMode() {
117
                return DataServerExplorer.MODE_FEATURE | DataServerExplorer.MODE_GEOMETRY;
118
        }
119

    
120

    
121
}