Revision 24893
branches/v2_0_0_prep/libraries/libFMap_dalfile/src-test/org/gvsig/fmap/dal/explorer/filesystem/FileSystemExplorerTest.java | ||
---|---|---|
44 | 44 |
import org.gvsig.fmap.dal.exception.DataException; |
45 | 45 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
46 | 46 |
import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
47 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemExplorer; |
|
48 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemExplorerParameters; |
|
47 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer;
|
|
48 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters;
|
|
49 | 49 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
50 | 50 |
import org.gvsig.fmap.dal.store.dbf.DBFLibrary; |
51 | 51 |
import org.gvsig.fmap.dal.store.dbf.DBFStoreParameters; |
... | ... | |
83 | 83 |
|
84 | 84 |
public void testList() { |
85 | 85 |
try { |
86 |
FilesystemExplorerParameters exParam = (FilesystemExplorerParameters) dataManager
|
|
87 |
.createServerExplorerParameters(FilesystemExplorer.NAME); |
|
86 |
FilesystemServerExplorerParameters exParam = (FilesystemServerExplorerParameters) dataManager
|
|
87 |
.createServerExplorerParameters(FilesystemServerExplorer.NAME);
|
|
88 | 88 |
|
89 | 89 |
exParam.setRoot(dbf_data.getPath()); |
90 | 90 |
|
... | ... | |
150 | 150 |
|
151 | 151 |
tmpDir.mkdir(); |
152 | 152 |
|
153 |
FilesystemExplorerParameters exParam = (FilesystemExplorerParameters) dataManager
|
|
154 |
.createServerExplorerParameters(FilesystemExplorer.NAME); |
|
153 |
FilesystemServerExplorerParameters exParam = (FilesystemServerExplorerParameters) dataManager
|
|
154 |
.createServerExplorerParameters(FilesystemServerExplorer.NAME);
|
|
155 | 155 |
|
156 | 156 |
exParam.setRoot(tmpDir.getAbsolutePath()); |
157 | 157 |
|
branches/v2_0_0_prep/libraries/libFMap_dalfile/src/org/gvsig/fmap/dal/store/shp/SHPLibrary.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
package org.gvsig.fmap.dal.store.shp; |
29 | 29 |
|
30 |
import org.gvsig.fmap.dal.DALFileLocator; |
|
30 | 31 |
import org.gvsig.fmap.dal.DALLocator; |
31 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemExplorer; |
|
32 | 32 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
33 | 33 |
import org.gvsig.fmap.dal.store.dbf.DBFLibrary; |
34 | 34 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
... | ... | |
46 | 46 |
SHPStoreProvider.class, SHPStoreParameters.class); |
47 | 47 |
} |
48 | 48 |
|
49 |
FilesystemExplorer.registerFilter(new SHPFileFilter()); |
|
49 |
DALFileLocator.getFilesystemServerExplorerManager().registerFilter( |
|
50 |
new SHPFileFilter()); |
|
50 | 51 |
} |
51 | 52 |
|
52 | 53 |
} |
branches/v2_0_0_prep/libraries/libFMap_dalfile/src/org/gvsig/fmap/dal/store/dbf/DBFLibrary.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
package org.gvsig.fmap.dal.store.dbf; |
29 | 29 |
|
30 |
import org.gvsig.fmap.dal.DALFileLocator; |
|
30 | 31 |
import org.gvsig.fmap.dal.DALLocator; |
31 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemExplorer; |
|
32 | 32 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
33 | 33 |
import org.gvsig.tools.locator.BaseLibrary; |
34 | 34 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
... | ... | |
46 | 46 |
DBFStoreProvider.class, DBFStoreParameters.class); |
47 | 47 |
} |
48 | 48 |
|
49 |
FilesystemExplorer.registerFilter(new DBFFileFilter()); |
|
49 |
DALFileLocator.getFilesystemServerExplorerManager().registerFilter( |
|
50 |
new DBFFileFilter()); |
|
50 | 51 |
} |
51 | 52 |
|
52 | 53 |
} |
branches/v2_0_0_prep/libraries/libFMap_dalfile/src/org/gvsig/fmap/dal/store/dbf/DBFStoreProvider.java | ||
---|---|---|
48 | 48 |
import org.gvsig.fmap.dal.resource.file.FileResource; |
49 | 49 |
import org.gvsig.fmap.dal.resource.spi.ResourceConsumer; |
50 | 50 |
import org.gvsig.fmap.dal.resource.spi.ResourceProvider; |
51 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemExplorer; |
|
52 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemExplorerParameters; |
|
51 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer;
|
|
52 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters;
|
|
53 | 53 |
import org.gvsig.fmap.dal.store.dbf.utils.DbaseFile; |
54 | 54 |
import org.gvsig.metadata.Metadata; |
55 | 55 |
import org.gvsig.tools.exception.NotYetImplemented; |
... | ... | |
113 | 113 |
|
114 | 114 |
public DataServerExplorer getExplorer() throws ReadException { |
115 | 115 |
DataManager manager = DALLocator.getDataManager(); |
116 |
FilesystemExplorerParameters params; |
|
116 |
FilesystemServerExplorerParameters params;
|
|
117 | 117 |
try { |
118 |
params = (FilesystemExplorerParameters) manager |
|
119 |
.createServerExplorerParameters(FilesystemExplorer.NAME); |
|
118 |
params = (FilesystemServerExplorerParameters) manager
|
|
119 |
.createServerExplorerParameters(FilesystemServerExplorer.NAME);
|
|
120 | 120 |
params.setRoot(this.getDBFParameters().getDBFFile().getParent()); |
121 | 121 |
return manager.createServerExplorer(params); |
122 | 122 |
} catch (DataException e) { |
branches/v2_0_0_prep/libraries/libFMap_dalfile/src/org/gvsig/fmap/dal/store/dxf/DXFLibrary.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
package org.gvsig.fmap.dal.store.dxf; |
29 | 29 |
|
30 |
import org.gvsig.fmap.dal.DALFileLocator; |
|
30 | 31 |
import org.gvsig.fmap.dal.DALLocator; |
31 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemExplorer; |
|
32 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer;
|
|
32 | 33 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
33 | 34 |
import org.gvsig.tools.locator.BaseLibrary; |
34 | 35 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
... | ... | |
45 | 46 |
DXFStoreProvider.class, DXFStoreParameters.class); |
46 | 47 |
} |
47 | 48 |
|
48 |
FilesystemExplorer.registerFilter(new DXFFileFilter()); |
|
49 |
DALFileLocator.getFilesystemServerExplorerManager().registerFilter( |
|
50 |
new DXFFileFilter()); |
|
49 | 51 |
} |
50 | 52 |
} |
branches/v2_0_0_prep/libraries/libFMap_dalfile/src/org/gvsig/fmap/dal/store/dxf/DXFStoreProvider.java | ||
---|---|---|
53 | 53 |
import org.gvsig.fmap.dal.resource.file.FileResource; |
54 | 54 |
import org.gvsig.fmap.dal.resource.spi.ResourceConsumer; |
55 | 55 |
import org.gvsig.fmap.dal.resource.spi.ResourceProvider; |
56 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemExplorer; |
|
57 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemExplorerParameters; |
|
56 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer;
|
|
57 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters;
|
|
58 | 58 |
import org.gvsig.fmap.geom.Geometry; |
59 | 59 |
import org.gvsig.fmap.geom.GeometryFactory; |
60 | 60 |
import org.gvsig.fmap.geom.GeometryManager; |
... | ... | |
205 | 205 |
|
206 | 206 |
public DataServerExplorer getExplorer() throws ReadException { |
207 | 207 |
DataManager manager = DALLocator.getDataManager(); |
208 |
FilesystemExplorerParameters params; |
|
208 |
FilesystemServerExplorerParameters params;
|
|
209 | 209 |
try { |
210 |
params = (FilesystemExplorerParameters) manager |
|
211 |
.createServerExplorerParameters(FilesystemExplorer.NAME); |
|
210 |
params = (FilesystemServerExplorerParameters) manager
|
|
211 |
.createServerExplorerParameters(FilesystemServerExplorer.NAME);
|
|
212 | 212 |
params.setRoot(this.getParameters().getFile().getParent()); |
213 | 213 |
return manager.createServerExplorer(params); |
214 | 214 |
} catch (DataException e) { |
branches/v2_0_0_prep/libraries/libFMap_dalfile/src/org/gvsig/fmap/dal/DALFileLocator.java | ||
---|---|---|
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 |
* 2008 IVER T.I. S.A. {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.fmap.dal; |
|
29 |
|
|
30 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.impl.FilesystemServerExplorerManager; |
|
31 |
import org.gvsig.tools.locator.AbstractLocator; |
|
32 |
import org.gvsig.tools.locator.LocatorException; |
|
33 |
|
|
34 |
public class DALFileLocator extends AbstractLocator { |
|
35 |
|
|
36 |
|
|
37 |
private static final String LOCATOR_NAME = "DALFileLocator"; |
|
38 |
|
|
39 |
/** |
|
40 |
* DataManager name used by the locator to access the instance |
|
41 |
*/ |
|
42 |
public static final String FILESYSTEMSERVEREXPLORERE_MANAGER_NAME = "FilesystemServerExplorereManager"; |
|
43 |
|
|
44 |
private static final String FILESYSTEMSERVEREXPLORERE_MANAGER_DESCRIPTION = "FilesystemServerExplorereManager of gvSIG Data Access Library"; |
|
45 |
|
|
46 |
/** |
|
47 |
* Unique instance. |
|
48 |
*/ |
|
49 |
private static final DALFileLocator instance = new DALFileLocator(); |
|
50 |
|
|
51 |
/** |
|
52 |
* Return the singleton instance. |
|
53 |
* |
|
54 |
* @return the singleton instance |
|
55 |
*/ |
|
56 |
public static DALFileLocator getInstance() { |
|
57 |
return instance; |
|
58 |
} |
|
59 |
|
|
60 |
public String getLocatorName() { |
|
61 |
return this.LOCATOR_NAME; |
|
62 |
} |
|
63 |
|
|
64 |
/** |
|
65 |
* Return a reference to FilesystemServerExplorerManager. |
|
66 |
* |
|
67 |
* @return a reference to FilesystemServerExplorerManager |
|
68 |
* @throws LocatorException |
|
69 |
* if there is no access to the class or the class cannot be |
|
70 |
* instantiated |
|
71 |
* @see Locator#get(String) |
|
72 |
*/ |
|
73 |
public static FilesystemServerExplorerManager getFilesystemServerExplorerManager() |
|
74 |
throws LocatorException { |
|
75 |
return (FilesystemServerExplorerManager) getInstance().get( |
|
76 |
FILESYSTEMSERVEREXPLORERE_MANAGER_NAME); |
|
77 |
} |
|
78 |
|
|
79 |
/** |
|
80 |
* Registers the Class implementing the DataManager interface. |
|
81 |
* |
|
82 |
* @param clazz |
|
83 |
* implementing the DataManager interface |
|
84 |
*/ |
|
85 |
public static void registerDataManager(Class clazz) { |
|
86 |
getInstance().register(FILESYSTEMSERVEREXPLORERE_MANAGER_NAME, |
|
87 |
FILESYSTEMSERVEREXPLORERE_MANAGER_DESCRIPTION, |
|
88 |
clazz); |
|
89 |
} |
|
90 |
|
|
91 |
} |
|
0 | 92 |
branches/v2_0_0_prep/libraries/libFMap_dalfile/src/org/gvsig/fmap/dal/DALFileLibrary.java | ||
---|---|---|
28 | 28 |
|
29 | 29 |
package org.gvsig.fmap.dal; |
30 | 30 |
|
31 |
import org.gvsig.fmap.dal.DALLibrary; |
|
32 |
import org.gvsig.fmap.dal.DALLocator; |
|
33 | 31 |
import org.gvsig.fmap.dal.resource.file.FileResource; |
34 | 32 |
import org.gvsig.fmap.dal.resource.file.FileResourceParameters; |
35 | 33 |
import org.gvsig.fmap.dal.resource.spi.ResourceManagerProviderServices; |
36 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemExplorer; |
|
37 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemExplorerParameters; |
|
34 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer; |
|
35 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters; |
|
36 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.impl.FilesystemServerExplorerManager; |
|
38 | 37 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
39 | 38 |
import org.gvsig.tools.locator.BaseLibrary; |
40 | 39 |
import org.gvsig.tools.locator.ReferenceNotRegisteredException; |
... | ... | |
59 | 58 |
FileResource.class, FileResourceParameters.class); |
60 | 59 |
} |
61 | 60 |
|
62 |
if (!dataman.getExplorerProviders().contains(FilesystemExplorer.NAME)) { |
|
63 |
dataman.registerExplorerProvider(FilesystemExplorer.NAME, FilesystemExplorer.class, FilesystemExplorerParameters.class); |
|
61 |
if (!dataman.getExplorerProviders().contains(FilesystemServerExplorer.NAME)) { |
|
62 |
dataman.registerExplorerProvider(FilesystemServerExplorer.NAME, FilesystemServerExplorer.class, FilesystemServerExplorerParameters.class); |
|
63 |
DALFileLocator |
|
64 |
.registerDataManager(FilesystemServerExplorerManager.class); |
|
64 | 65 |
} |
65 | 66 |
|
66 | 67 |
} |
branches/v2_0_0_prep/libraries/libFMap_dalfile/src/org/gvsig/fmap/dal/serverexplorer/filesystem/FilesystemExplorer.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.serverexplorer.filesystem; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.io.FileFilter; |
|
5 |
import java.util.ArrayList; |
|
6 |
import java.util.Iterator; |
|
7 |
import java.util.List; |
|
8 |
import java.util.Map; |
|
9 |
|
|
10 |
import org.gvsig.fmap.dal.DALLocator; |
|
11 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
12 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
13 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
|
14 |
import org.gvsig.fmap.dal.exception.DataException; |
|
15 |
import org.gvsig.fmap.dal.exception.FileNotFoundException; |
|
16 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
17 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
18 |
import org.gvsig.fmap.dal.exception.RemoveException; |
|
19 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
|
20 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProvider; |
|
21 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices; |
|
22 |
import org.gvsig.fmap.dal.spi.DataStoreProvider; |
|
23 |
import org.gvsig.tools.ToolsLocator; |
|
24 |
import org.gvsig.tools.extensionpoint.ExtensionBuilder; |
|
25 |
import org.gvsig.tools.extensionpoint.ExtensionPoint.Extension; |
|
26 |
|
|
27 |
|
|
28 |
public class FilesystemExplorer implements DataServerExplorerProvider { |
|
29 |
// FIXME: , IPersistence{ |
|
30 |
|
|
31 |
public static final String NAME = "FilesystemExplorer"; |
|
32 |
|
|
33 |
final private static String FILE_FILTER_EPSNAME = "FilesystemExplorerFilters"; |
|
34 |
final private static String FILE_FILTER_EPSDESCRIPTION = "Registro de filtros asociados al explorador del sistema de ficheros."; |
|
35 |
|
|
36 |
FilesystemExplorerParameters parameters; |
|
37 |
private File root; |
|
38 |
|
|
39 |
private File current; |
|
40 |
|
|
41 |
private DataServerExplorerProviderServices providerServices; |
|
42 |
|
|
43 |
|
|
44 |
public static class FilterWraper implements ExtensionBuilder { |
|
45 |
|
|
46 |
private FileFilter filter; |
|
47 |
|
|
48 |
public FilterWraper(FileFilter filter) { |
|
49 |
this.filter = filter; |
|
50 |
} |
|
51 |
|
|
52 |
public Object create() { |
|
53 |
return filter; |
|
54 |
} |
|
55 |
|
|
56 |
public Object create(Object[] args) { |
|
57 |
return filter; |
|
58 |
} |
|
59 |
|
|
60 |
public Object create(Map args) { |
|
61 |
return filter; |
|
62 |
} |
|
63 |
|
|
64 |
} |
|
65 |
|
|
66 |
public static class FilterWraperIterator implements Iterator { |
|
67 |
private Iterator it; |
|
68 |
|
|
69 |
public FilterWraperIterator(Iterator it) { |
|
70 |
this.it = it; |
|
71 |
} |
|
72 |
|
|
73 |
public boolean hasNext() { |
|
74 |
return this.it.hasNext(); |
|
75 |
} |
|
76 |
|
|
77 |
public Object next() { |
|
78 |
return ((Extension) this.it.next()).getBuilder().create(); |
|
79 |
} |
|
80 |
|
|
81 |
public void remove() { |
|
82 |
throw new UnsupportedOperationException(); |
|
83 |
} |
|
84 |
|
|
85 |
} |
|
86 |
|
|
87 |
public static void registerFilter(FilesystemFileFilter filter) { |
|
88 |
FilterWraper filterWraper = new FilterWraper(filter); |
|
89 |
|
|
90 |
ToolsLocator.getExtensionPointManager().add(FILE_FILTER_EPSNAME, |
|
91 |
FILE_FILTER_EPSDESCRIPTION).append( |
|
92 |
filter.getDataStoreProviderName(), filter.getDescription(), |
|
93 |
filterWraper); |
|
94 |
} |
|
95 |
|
|
96 |
public static Iterator getFilters() { |
|
97 |
Iterator it = new FilterWraperIterator(ToolsLocator |
|
98 |
.getExtensionPointManager().get(FILE_FILTER_EPSNAME).iterator()); |
|
99 |
return it; |
|
100 |
} |
|
101 |
|
|
102 |
public FilesystemExplorer(FilesystemExplorerParameters parameters) |
|
103 |
throws InitializeException { |
|
104 |
this.parameters = parameters; |
|
105 |
this.root = new File(this.parameters.getRoot()); |
|
106 |
if (this.parameters.getInitialpath() == null) { |
|
107 |
this.current = new File(this.parameters.getRoot()); |
|
108 |
}else{ |
|
109 |
this.current = new File(this.parameters.getInitialpath()); |
|
110 |
} |
|
111 |
} |
|
112 |
|
|
113 |
public String getType() { |
|
114 |
return NAME; |
|
115 |
} |
|
116 |
|
|
117 |
public DataServerExplorerParameters getParameters() { |
|
118 |
return parameters; |
|
119 |
} |
|
120 |
|
|
121 |
public void dispose() throws DataException { |
|
122 |
this.parameters = null; |
|
123 |
this.root = null; |
|
124 |
} |
|
125 |
|
|
126 |
public List list() throws DataException { |
|
127 |
if (!this.current.exists()) { |
|
128 |
//TODO crear excepcion de Data?? |
|
129 |
new org.gvsig.fmap.dal.exception.FileNotFoundException(this.current); |
|
130 |
} |
|
131 |
|
|
132 |
if (!this.current.isDirectory()) { |
|
133 |
new IllegalArgumentException(this.getName() |
|
134 |
+ ": Path not a directory '" |
|
135 |
+ this.current + "'"); |
|
136 |
} |
|
137 |
// DataManager dsm=DataManager.getManager(); |
|
138 |
|
|
139 |
String files[] = this.current.list(); |
|
140 |
int i; |
|
141 |
File theFile; |
|
142 |
ArrayList list = new ArrayList(); |
|
143 |
DataStoreParameters dsp = null; |
|
144 |
|
|
145 |
for (i = 0; i < files.length; i++) { |
|
146 |
theFile = new File(this.root, files[i]); |
|
147 |
dsp = this.getParametersFor(theFile); |
|
148 |
if (dsp != null) { |
|
149 |
list.add(dsp); |
|
150 |
} |
|
151 |
} |
|
152 |
return list; |
|
153 |
} |
|
154 |
|
|
155 |
public void setCurrentPath(File path) throws FileNotFoundException { |
|
156 |
// FIXME Comprobar si es un directorio existente |
|
157 |
if (!path.exists()) { |
|
158 |
throw new FileNotFoundException(path); |
|
159 |
} |
|
160 |
if (!path.isDirectory()) { |
|
161 |
throw new IllegalArgumentException(path.getPath() |
|
162 |
+ " is not a directory"); |
|
163 |
} |
|
164 |
if (!isFromRoot(path)) { |
|
165 |
throw new IllegalArgumentException(path.getPath() |
|
166 |
+ " is not from root"); |
|
167 |
|
|
168 |
} |
|
169 |
|
|
170 |
this.current = path; |
|
171 |
} |
|
172 |
|
|
173 |
public File getCurrentPath() { |
|
174 |
return this.current; |
|
175 |
} |
|
176 |
|
|
177 |
public File getRoot() { |
|
178 |
return this.root; |
|
179 |
} |
|
180 |
|
|
181 |
public void remove(DataStoreParameters dsp) throws RemoveException { |
|
182 |
String providerName = dsp.getDataStoreName(); |
|
183 |
try { |
|
184 |
this.checkIsMine(dsp); |
|
185 |
DataStoreProvider provider = this.getManager().createStoreProvider( |
|
186 |
providerName); |
|
187 |
|
|
188 |
provider.remove(dsp); |
|
189 |
} catch (DataException e) { |
|
190 |
throw new RemoveException(this.getName(), e); |
|
191 |
} |
|
192 |
} |
|
193 |
|
|
194 |
public boolean add(NewDataStoreParameters ndsp, boolean overwrite) |
|
195 |
throws DataException { |
|
196 |
String providerName = ndsp.getDataStoreName(); |
|
197 |
this.checkIsMine(ndsp); |
|
198 |
try { |
|
199 |
DataStoreProvider provider = this.getManager().createStoreProvider( |
|
200 |
providerName); |
|
201 |
|
|
202 |
provider.create(ndsp, overwrite); |
|
203 |
return true; // TODO deber?a devolver un booleano el provider o esto ser un void |
|
204 |
} catch (DataException e) { |
|
205 |
throw new RemoveException(this.getName(), e); |
|
206 |
} |
|
207 |
} |
|
208 |
|
|
209 |
public boolean canAdd() { |
|
210 |
return this.root.canWrite(); |
|
211 |
} |
|
212 |
|
|
213 |
public String getName() { |
|
214 |
return this.FILE_FILTER_EPSNAME; |
|
215 |
} |
|
216 |
|
|
217 |
public NewDataStoreParameters getAddParameters(String storeName) |
|
218 |
throws DataException { |
|
219 |
DataStoreProvider provider = this.getProvider(storeName); |
|
220 |
if (provider == null) { |
|
221 |
throw new IllegalArgumentException( |
|
222 |
"Not registered in this explorer"); // FIXME |
|
223 |
} |
|
224 |
|
|
225 |
NewDataStoreParameters nParams = provider.getCreateParameters(); |
|
226 |
// nParams.setAttribute("path", this.getCurrentPath().getPath()); |
|
227 |
return nParams; |
|
228 |
} |
|
229 |
|
|
230 |
public boolean canAdd(String storeName) |
|
231 |
throws DataException { |
|
232 |
DataStoreProvider provider = this.getProvider(storeName); |
|
233 |
if (provider == null) { |
|
234 |
throw new IllegalArgumentException( |
|
235 |
"Not registered in this explorer"); // FIXME |
|
236 |
} |
|
237 |
|
|
238 |
return provider.canCreate(); |
|
239 |
|
|
240 |
} |
|
241 |
|
|
242 |
// ========================================== |
|
243 |
|
|
244 |
private DataStoreProvider getProvider(String storeName) |
|
245 |
throws InitializeException, ProviderNotRegisteredException { |
|
246 |
Iterator filters = getFilters(); |
|
247 |
while (filters.hasNext()) { |
|
248 |
FilesystemFileFilter filter = (FilesystemFileFilter) filters.next(); |
|
249 |
if (filter.getDataStoreProviderName().equals(storeName)) { |
|
250 |
return this.getManager().createStoreProvider(storeName); |
|
251 |
} |
|
252 |
} |
|
253 |
return null; |
|
254 |
} |
|
255 |
|
|
256 |
private DataManagerProviderServices getManager() { |
|
257 |
return (DataManagerProviderServices) DALLocator.getDataManager(); |
|
258 |
} |
|
259 |
|
|
260 |
public DataStoreParameters getParametersFor(File file) |
|
261 |
throws DataException { |
|
262 |
if (!file.exists()) { |
|
263 |
return null; |
|
264 |
} |
|
265 |
if (!file.isFile()) { |
|
266 |
return null; |
|
267 |
} |
|
268 |
if (!file.canRead()) { |
|
269 |
return null; |
|
270 |
} |
|
271 |
if (file.isHidden()) { // XXX ??? |
|
272 |
return null; |
|
273 |
} |
|
274 |
Iterator filters = getFilters(); |
|
275 |
while (filters.hasNext()) { |
|
276 |
FilesystemFileFilter filter = (FilesystemFileFilter) filters.next(); |
|
277 |
if (filter.accept(file)) { |
|
278 |
DataStoreParameters params = this.getManager() |
|
279 |
.createStoreParameters( |
|
280 |
filter.getDataStoreProviderName()); |
|
281 |
((FilesystemStoreParameters) params).setFile(file); |
|
282 |
return params; |
|
283 |
} |
|
284 |
} |
|
285 |
return null; |
|
286 |
} |
|
287 |
|
|
288 |
private void checkIsMine(DataStoreParameters dsp) |
|
289 |
throws IllegalArgumentException, DataException { |
|
290 |
if (!(dsp instanceof FilesystemExplorer)) { |
|
291 |
new IllegalArgumentException("not instance of FilesystemExplorer"); |
|
292 |
} |
|
293 |
Iterator filters = getFilters(); |
|
294 |
File file = ((FilesystemStoreParameters) dsp).getFile(); |
|
295 |
if (!this.isFromRoot(file)) { |
|
296 |
throw new IllegalArgumentException("worng explorer"); |
|
297 |
} |
|
298 |
FilesystemFileFilter filter; |
|
299 |
while (filters.hasNext()) { |
|
300 |
filter = (FilesystemFileFilter) filters.next(); |
|
301 |
if (dsp.getDataStoreName().equals(filter.getDataStoreProviderName())) { |
|
302 |
return; |
|
303 |
} |
|
304 |
} |
|
305 |
throw new IllegalArgumentException("worng explorer"); |
|
306 |
} |
|
307 |
|
|
308 |
private boolean isFromRoot(File file) { |
|
309 |
return file.getAbsolutePath().startsWith(this.root.getAbsolutePath()); |
|
310 |
} |
|
311 |
|
|
312 |
public void initialize( |
|
313 |
DataServerExplorerProviderServices dataServerExplorerProviderServices) { |
|
314 |
this.providerServices = dataServerExplorerProviderServices; |
|
315 |
|
|
316 |
} |
|
317 |
|
|
318 |
|
|
319 |
} |
branches/v2_0_0_prep/libraries/libFMap_dalfile/src/org/gvsig/fmap/dal/serverexplorer/filesystem/FilesystemExplorerParameters.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.serverexplorer.filesystem; |
|
2 |
|
|
3 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
4 |
import org.gvsig.fmap.dal.DataTypes; |
|
5 |
import org.gvsig.fmap.dal.spi.AbstractDataParameters; |
|
6 |
|
|
7 |
public class FilesystemExplorerParameters extends AbstractDataParameters |
|
8 |
implements DataServerExplorerParameters { |
|
9 |
|
|
10 |
public FilesystemExplorerParameters() { |
|
11 |
this.addParameter("root", DataTypes.STRING, "Ruta base a usar", null); |
|
12 |
this |
|
13 |
.addParameter("initialpath", DataTypes.STRING, "Ruta inicial", |
|
14 |
null); |
|
15 |
} |
|
16 |
|
|
17 |
public void setRoot(String path) { |
|
18 |
this.setAttribute("root", path); |
|
19 |
} |
|
20 |
|
|
21 |
public String getRoot() { |
|
22 |
return (String) this.getAttribute("root"); |
|
23 |
} |
|
24 |
|
|
25 |
public void setInitialpath(String path) { |
|
26 |
this.setAttribute("initialpath", path); |
|
27 |
} |
|
28 |
|
|
29 |
public String getInitialpath() { |
|
30 |
return (String) this.getAttribute("initialpath"); |
|
31 |
} |
|
32 |
|
|
33 |
public String getExplorerName() { |
|
34 |
return FilesystemExplorer.NAME; |
|
35 |
} |
|
36 |
|
|
37 |
} |
branches/v2_0_0_prep/libraries/libFMap_dalfile/src/org/gvsig/fmap/dal/serverexplorer/filesystem/FilesystemServerExplorerParameters.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.serverexplorer.filesystem; |
|
2 |
|
|
3 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
4 |
import org.gvsig.fmap.dal.DataTypes; |
|
5 |
import org.gvsig.fmap.dal.spi.AbstractDataParameters; |
|
6 |
|
|
7 |
public class FilesystemServerExplorerParameters extends AbstractDataParameters |
|
8 |
implements DataServerExplorerParameters { |
|
9 |
|
|
10 |
public FilesystemServerExplorerParameters() { |
|
11 |
this.addParameter("root", DataTypes.STRING, "Ruta base a usar", null); |
|
12 |
this |
|
13 |
.addParameter("initialpath", DataTypes.STRING, "Ruta inicial", |
|
14 |
null); |
|
15 |
} |
|
16 |
|
|
17 |
public void setRoot(String path) { |
|
18 |
this.setAttribute("root", path); |
|
19 |
} |
|
20 |
|
|
21 |
public String getRoot() { |
|
22 |
return (String) this.getAttribute("root"); |
|
23 |
} |
|
24 |
|
|
25 |
public void setInitialpath(String path) { |
|
26 |
this.setAttribute("initialpath", path); |
|
27 |
} |
|
28 |
|
|
29 |
public String getInitialpath() { |
|
30 |
return (String) this.getAttribute("initialpath"); |
|
31 |
} |
|
32 |
|
|
33 |
public String getExplorerName() { |
|
34 |
return FilesystemServerExplorer.NAME; |
|
35 |
} |
|
36 |
|
|
37 |
} |
|
0 | 38 |
branches/v2_0_0_prep/libraries/libFMap_dalfile/src/org/gvsig/fmap/dal/serverexplorer/filesystem/impl/FilesystemExplorer.java | ||
---|---|---|
1 |
package org.gvsig.fmap.dal.serverexplorer.filesystem.impl; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.Iterator; |
|
6 |
import java.util.List; |
|
7 |
|
|
8 |
import org.gvsig.fmap.dal.DALFileLocator; |
|
9 |
import org.gvsig.fmap.dal.DALLocator; |
|
10 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
11 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
12 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
|
13 |
import org.gvsig.fmap.dal.exception.DataException; |
|
14 |
import org.gvsig.fmap.dal.exception.FileNotFoundException; |
|
15 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
16 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
17 |
import org.gvsig.fmap.dal.exception.RemoveException; |
|
18 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemFileFilter; |
|
19 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer; |
|
20 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters; |
|
21 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
|
22 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
|
23 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProvider; |
|
24 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices; |
|
25 |
import org.gvsig.fmap.dal.spi.DataStoreProvider; |
|
26 |
|
|
27 |
|
|
28 |
public class FilesystemExplorer implements DataServerExplorerProvider, |
|
29 |
FilesystemServerExplorer, FilesystemFileFilter { |
|
30 |
// FIXME: , IPersistence{ |
|
31 |
|
|
32 |
|
|
33 |
FilesystemServerExplorerParameters parameters; |
|
34 |
private File root; |
|
35 |
|
|
36 |
private File current; |
|
37 |
|
|
38 |
private DataServerExplorerProviderServices providerServices; |
|
39 |
|
|
40 |
|
|
41 |
public FilesystemExplorer(FilesystemServerExplorerParameters parameters) |
|
42 |
throws InitializeException { |
|
43 |
this.parameters = parameters; |
|
44 |
this.root = new File(this.parameters.getRoot()); |
|
45 |
if (this.parameters.getInitialpath() == null) { |
|
46 |
this.current = new File(this.parameters.getRoot()); |
|
47 |
}else{ |
|
48 |
this.current = new File(this.parameters.getInitialpath()); |
|
49 |
} |
|
50 |
} |
|
51 |
|
|
52 |
/* (non-Javadoc) |
|
53 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer#getType() |
|
54 |
*/ |
|
55 |
public String getType() { |
|
56 |
return NAME; |
|
57 |
} |
|
58 |
|
|
59 |
/* (non-Javadoc) |
|
60 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer#getParameters() |
|
61 |
*/ |
|
62 |
public DataServerExplorerParameters getParameters() { |
|
63 |
return parameters; |
|
64 |
} |
|
65 |
|
|
66 |
/* (non-Javadoc) |
|
67 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer#dispose() |
|
68 |
*/ |
|
69 |
public void dispose() throws DataException { |
|
70 |
this.parameters = null; |
|
71 |
this.root = null; |
|
72 |
} |
|
73 |
|
|
74 |
/* (non-Javadoc) |
|
75 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer#list() |
|
76 |
*/ |
|
77 |
public List list() throws DataException { |
|
78 |
if (!this.current.exists()) { |
|
79 |
//TODO crear excepcion de Data?? |
|
80 |
new org.gvsig.fmap.dal.exception.FileNotFoundException(this.current); |
|
81 |
} |
|
82 |
|
|
83 |
if (!this.current.isDirectory()) { |
|
84 |
new IllegalArgumentException(this.getName() |
|
85 |
+ ": Path not a directory '" |
|
86 |
+ this.current + "'"); |
|
87 |
} |
|
88 |
// DataManager dsm=DataManager.getManager(); |
|
89 |
|
|
90 |
String files[] = this.current.list(); |
|
91 |
int i; |
|
92 |
File theFile; |
|
93 |
ArrayList list = new ArrayList(); |
|
94 |
DataStoreParameters dsp = null; |
|
95 |
|
|
96 |
for (i = 0; i < files.length; i++) { |
|
97 |
theFile = new File(this.root, files[i]); |
|
98 |
dsp = this.getParametersFor(theFile); |
|
99 |
if (dsp != null) { |
|
100 |
list.add(dsp); |
|
101 |
} |
|
102 |
} |
|
103 |
return list; |
|
104 |
} |
|
105 |
|
|
106 |
/* (non-Javadoc) |
|
107 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer#setCurrentPath(java.io.File) |
|
108 |
*/ |
|
109 |
public void setCurrentPath(File path) throws FileNotFoundException { |
|
110 |
// FIXME Comprobar si es un directorio existente |
|
111 |
if (!path.exists()) { |
|
112 |
throw new FileNotFoundException(path); |
|
113 |
} |
|
114 |
if (!path.isDirectory()) { |
|
115 |
throw new IllegalArgumentException(path.getPath() |
|
116 |
+ " is not a directory"); |
|
117 |
} |
|
118 |
if (!isFromRoot(path)) { |
|
119 |
throw new IllegalArgumentException(path.getPath() |
|
120 |
+ " is not from root"); |
|
121 |
|
|
122 |
} |
|
123 |
|
|
124 |
this.current = path; |
|
125 |
} |
|
126 |
|
|
127 |
/* (non-Javadoc) |
|
128 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer#getCurrentPath() |
|
129 |
*/ |
|
130 |
public File getCurrentPath() { |
|
131 |
return this.current; |
|
132 |
} |
|
133 |
|
|
134 |
/* (non-Javadoc) |
|
135 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer#getRoot() |
|
136 |
*/ |
|
137 |
public File getRoot() { |
|
138 |
return this.root; |
|
139 |
} |
|
140 |
|
|
141 |
/* (non-Javadoc) |
|
142 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer#remove(org.gvsig.fmap.dal.DataStoreParameters) |
|
143 |
*/ |
|
144 |
public void remove(DataStoreParameters dsp) throws RemoveException { |
|
145 |
String providerName = dsp.getDataStoreName(); |
|
146 |
try { |
|
147 |
this.checkIsMine(dsp); |
|
148 |
DataStoreProvider provider = this.getManager().createStoreProvider( |
|
149 |
providerName); |
|
150 |
|
|
151 |
provider.remove(dsp); |
|
152 |
} catch (DataException e) { |
|
153 |
throw new RemoveException(this.getName(), e); |
|
154 |
} |
|
155 |
} |
|
156 |
|
|
157 |
/* (non-Javadoc) |
|
158 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer#add(org.gvsig.fmap.dal.NewDataStoreParameters, boolean) |
|
159 |
*/ |
|
160 |
public boolean add(NewDataStoreParameters ndsp, boolean overwrite) |
|
161 |
throws DataException { |
|
162 |
String providerName = ndsp.getDataStoreName(); |
|
163 |
this.checkIsMine(ndsp); |
|
164 |
try { |
|
165 |
DataStoreProvider provider = this.getManager().createStoreProvider( |
|
166 |
providerName); |
|
167 |
|
|
168 |
provider.create(ndsp, overwrite); |
|
169 |
return true; // TODO deber?a devolver un booleano el provider o esto ser un void |
|
170 |
} catch (DataException e) { |
|
171 |
throw new RemoveException(this.getName(), e); |
|
172 |
} |
|
173 |
} |
|
174 |
|
|
175 |
/* (non-Javadoc) |
|
176 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer#canAdd() |
|
177 |
*/ |
|
178 |
public boolean canAdd() { |
|
179 |
return this.root.canWrite(); |
|
180 |
} |
|
181 |
|
|
182 |
/* (non-Javadoc) |
|
183 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer#getName() |
|
184 |
*/ |
|
185 |
public String getName() { |
|
186 |
return FilesystemServerExplorerManager.FILE_FILTER_EPSNAME; |
|
187 |
} |
|
188 |
|
|
189 |
/* (non-Javadoc) |
|
190 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer#getAddParameters(java.lang.String) |
|
191 |
*/ |
|
192 |
public NewDataStoreParameters getAddParameters(String storeName) |
|
193 |
throws DataException { |
|
194 |
DataStoreProvider provider = this.getProvider(storeName); |
|
195 |
if (provider == null) { |
|
196 |
throw new IllegalArgumentException( |
|
197 |
"Not registered in this explorer"); // FIXME |
|
198 |
} |
|
199 |
|
|
200 |
NewDataStoreParameters nParams = provider.getCreateParameters(); |
|
201 |
// nParams.setAttribute("path", this.getCurrentPath().getPath()); |
|
202 |
return nParams; |
|
203 |
} |
|
204 |
|
|
205 |
/* (non-Javadoc) |
|
206 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer#canAdd(java.lang.String) |
|
207 |
*/ |
|
208 |
public boolean canAdd(String storeName) |
|
209 |
throws DataException { |
|
210 |
DataStoreProvider provider = this.getProvider(storeName); |
|
211 |
if (provider == null) { |
|
212 |
throw new IllegalArgumentException( |
|
213 |
"Not registered in this explorer"); // FIXME |
|
214 |
} |
|
215 |
|
|
216 |
return provider.canCreate(); |
|
217 |
|
|
218 |
} |
|
219 |
|
|
220 |
// ========================================== |
|
221 |
|
|
222 |
private DataStoreProvider getProvider(String storeName) |
|
223 |
throws InitializeException, ProviderNotRegisteredException { |
|
224 |
Iterator filters = getFilters(); |
|
225 |
while (filters.hasNext()) { |
|
226 |
FilesystemFileFilter filter = (FilesystemFileFilter) filters.next(); |
|
227 |
if (filter.getDataStoreProviderName().equals(storeName)) { |
|
228 |
return this.getManager().createStoreProvider(storeName); |
|
229 |
} |
|
230 |
} |
|
231 |
return null; |
|
232 |
} |
|
233 |
|
|
234 |
private DataManagerProviderServices getManager() { |
|
235 |
return (DataManagerProviderServices) DALLocator.getDataManager(); |
|
236 |
} |
|
237 |
|
|
238 |
/* (non-Javadoc) |
|
239 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer#getParametersFor(java.io.File) |
|
240 |
*/ |
|
241 |
public DataStoreParameters getParametersFor(File file) |
|
242 |
throws DataException { |
|
243 |
if (!file.exists()) { |
|
244 |
return null; |
|
245 |
} |
|
246 |
if (!file.isFile()) { |
|
247 |
return null; |
|
248 |
} |
|
249 |
if (!file.canRead()) { |
|
250 |
return null; |
|
251 |
} |
|
252 |
if (file.isHidden()) { // XXX ??? |
|
253 |
return null; |
|
254 |
} |
|
255 |
Iterator filters = getFilters(); |
|
256 |
while (filters.hasNext()) { |
|
257 |
FilesystemFileFilter filter = (FilesystemFileFilter) filters.next(); |
|
258 |
if (filter.accept(file)) { |
|
259 |
DataStoreParameters params = this.getManager() |
|
260 |
.createStoreParameters( |
|
261 |
filter.getDataStoreProviderName()); |
|
262 |
((FilesystemStoreParameters) params).setFile(file); |
|
263 |
return params; |
|
264 |
} |
|
265 |
} |
|
266 |
return null; |
|
267 |
} |
|
268 |
|
|
269 |
private void checkIsMine(DataStoreParameters dsp) |
|
270 |
throws IllegalArgumentException, DataException { |
|
271 |
if (!(dsp instanceof FilesystemExplorer)) { |
|
272 |
new IllegalArgumentException("not instance of FilesystemExplorer"); |
|
273 |
} |
|
274 |
Iterator filters = getFilters(); |
|
275 |
File file = ((FilesystemStoreParameters) dsp).getFile(); |
|
276 |
if (!this.isFromRoot(file)) { |
|
277 |
throw new IllegalArgumentException("worng explorer"); |
|
278 |
} |
|
279 |
FilesystemFileFilter filter; |
|
280 |
while (filters.hasNext()) { |
|
281 |
filter = (FilesystemFileFilter) filters.next(); |
|
282 |
if (dsp.getDataStoreName().equals(filter.getDataStoreProviderName())) { |
|
283 |
return; |
|
284 |
} |
|
285 |
} |
|
286 |
throw new IllegalArgumentException("worng explorer"); |
|
287 |
} |
|
288 |
|
|
289 |
private boolean isFromRoot(File file) { |
|
290 |
return file.getAbsolutePath().startsWith(this.root.getAbsolutePath()); |
|
291 |
} |
|
292 |
|
|
293 |
/* (non-Javadoc) |
|
294 |
* @see org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer#initialize(org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices) |
|
295 |
*/ |
|
296 |
public void initialize( |
|
297 |
DataServerExplorerProviderServices dataServerExplorerProviderServices) { |
|
298 |
this.providerServices = dataServerExplorerProviderServices; |
|
299 |
|
|
300 |
} |
|
301 |
|
|
302 |
public Iterator getFilters() { |
|
303 |
return DALFileLocator.getFilesystemServerExplorerManager().getFilters(); |
|
304 |
} |
|
305 |
|
|
306 |
public FilesystemFileFilter getGenericFilter() { |
|
307 |
return this; |
|
308 |
} |
|
309 |
|
|
310 |
public String getDataStoreProviderName() { |
|
311 |
return null; |
|
312 |
} |
|
313 |
|
|
314 |
public String getDescription() { |
|
315 |
return "All supporteds"; |
|
316 |
} |
|
317 |
|
|
318 |
public boolean accept(File pathname) { |
|
319 |
try { |
|
320 |
return this.getParametersFor(pathname) != null; |
|
321 |
} catch (DataException e) { |
|
322 |
throw new RuntimeException(e); // FIXME excpetion?? |
|
323 |
} |
|
324 |
} |
|
325 |
|
|
326 |
|
|
327 |
} |
|
0 | 328 |
branches/v2_0_0_prep/libraries/libFMap_dalfile/src/org/gvsig/fmap/dal/serverexplorer/filesystem/impl/FilesystemServerExplorerManager.java | ||
---|---|---|
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 |
* 2008 IVER T.I. S.A. {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.fmap.dal.serverexplorer.filesystem.impl; |
|
29 |
|
|
30 |
import java.util.Iterator; |
|
31 |
import java.util.Map; |
|
32 |
|
|
33 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemFileFilter; |
|
34 |
import org.gvsig.tools.ToolsLocator; |
|
35 |
import org.gvsig.tools.extensionpoint.ExtensionBuilder; |
|
36 |
import org.gvsig.tools.extensionpoint.ExtensionPoint.Extension; |
|
37 |
|
|
38 |
public class FilesystemServerExplorerManager { |
|
39 |
final protected static String FILE_FILTER_EPSNAME = "FilesystemExplorerFilters"; |
|
40 |
final protected String FILE_FILTER_EPSDESCRIPTION = "Registro de filtros asociados al explorador del sistema de ficheros."; |
|
41 |
|
|
42 |
public class FilterWraper implements ExtensionBuilder { |
|
43 |
|
|
44 |
private FilesystemFileFilter filter; |
|
45 |
|
|
46 |
public FilterWraper(FilesystemFileFilter filter) { |
|
47 |
this.filter = filter; |
|
48 |
} |
|
49 |
|
|
50 |
public Object create() { |
|
51 |
return filter; |
|
52 |
} |
|
53 |
|
|
54 |
public Object create(Object[] args) { |
|
55 |
return filter; |
|
56 |
} |
|
57 |
|
|
58 |
public Object create(Map args) { |
|
59 |
return filter; |
|
60 |
} |
|
61 |
|
|
62 |
} |
|
63 |
|
|
64 |
public class FilterWraperIterator implements Iterator { |
|
65 |
private Iterator it; |
|
66 |
|
|
67 |
public FilterWraperIterator(Iterator it) { |
|
68 |
this.it = it; |
|
69 |
} |
|
70 |
|
|
71 |
public boolean hasNext() { |
|
72 |
return this.it.hasNext(); |
|
73 |
} |
|
74 |
|
|
75 |
public Object next() { |
|
76 |
return ((Extension) this.it.next()).getBuilder().create(); |
|
77 |
} |
|
78 |
|
|
79 |
public void remove() { |
|
80 |
throw new UnsupportedOperationException(); |
|
81 |
} |
|
82 |
|
|
83 |
} |
|
84 |
|
|
85 |
public void registerFilter(FilesystemFileFilter filter) { |
|
86 |
FilterWraper filterWraper = new FilterWraper(filter); |
|
87 |
|
|
88 |
ToolsLocator.getExtensionPointManager().add(FILE_FILTER_EPSNAME, |
|
89 |
FILE_FILTER_EPSDESCRIPTION).append( |
|
90 |
filter.getDataStoreProviderName(), filter.getDescription(), |
|
91 |
filterWraper); |
|
92 |
} |
|
93 |
|
|
94 |
public Iterator getFilters() { |
|
95 |
Iterator it = new FilterWraperIterator(ToolsLocator |
|
96 |
.getExtensionPointManager().get(FILE_FILTER_EPSNAME).iterator()); |
|
97 |
return it; |
|
98 |
} |
|
99 |
|
|
100 |
} |
|
0 | 101 |
branches/v2_0_0_prep/libraries/libFMap_dalfile/src/org/gvsig/fmap/dal/serverexplorer/filesystem/FilesystemServerExplorer.java | ||
---|---|---|
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 |
* 2008 IVER T.I. S.A. {{Task}} |
|
26 |
*/ |
|
27 |
|
|
28 |
package org.gvsig.fmap.dal.serverexplorer.filesystem; |
|
29 |
|
|
30 |
import java.io.File; |
|
31 |
import java.util.Iterator; |
|
32 |
import java.util.List; |
|
33 |
|
|
34 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
35 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
36 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
37 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
|
38 |
import org.gvsig.fmap.dal.exception.DataException; |
|
39 |
import org.gvsig.fmap.dal.exception.FileNotFoundException; |
|
40 |
import org.gvsig.fmap.dal.exception.RemoveException; |
|
41 |
|
|
42 |
public interface FilesystemServerExplorer extends DataServerExplorer { |
|
43 |
|
|
44 |
public static final String NAME = "FilesystemExplorer"; |
|
45 |
|
|
46 |
public abstract DataServerExplorerParameters getParameters(); |
|
47 |
|
|
48 |
public abstract void dispose() throws DataException; |
|
49 |
|
|
50 |
public abstract List list() throws DataException; |
|
51 |
|
|
52 |
public abstract void setCurrentPath(File path) throws FileNotFoundException; |
|
53 |
|
|
54 |
public abstract File getCurrentPath(); |
|
55 |
|
|
56 |
public abstract File getRoot(); |
|
57 |
|
|
58 |
public abstract void remove(DataStoreParameters dsp) throws RemoveException; |
|
59 |
|
|
60 |
public abstract boolean add(NewDataStoreParameters ndsp, boolean overwrite) |
|
61 |
throws DataException; |
|
62 |
|
|
63 |
public abstract boolean canAdd(); |
|
64 |
|
|
65 |
public abstract String getName(); |
|
66 |
|
|
67 |
public abstract NewDataStoreParameters getAddParameters(String storeName) |
|
68 |
throws DataException; |
|
69 |
|
|
70 |
public abstract boolean canAdd(String storeName) throws DataException; |
|
71 |
|
|
72 |
public abstract DataStoreParameters getParametersFor(File file) |
|
73 |
throws DataException; |
|
74 |
|
|
75 |
public abstract Iterator getFilters(); |
|
76 |
|
|
77 |
public abstract FilesystemFileFilter getGenericFilter(); |
|
78 |
} |
|
0 | 79 |
Also available in: Unified diff