svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.file / org.gvsig.fmap.dal.file.lib / src / main / java / org / gvsig / fmap / dal / serverexplorer / filesystem / impl / DefaultFilesystemServerExplorer.java @ 42775
History | View | Annotate | Download (18.2 KB)
1 | 40559 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | *
|
||
4 | * Copyright (C) 2007-2013 gvSIG Association.
|
||
5 | *
|
||
6 | 42775 | jjdelcerro | * This program is free software; you can redistribute it and/or modify it under
|
7 | * the terms of the GNU General Public License as published by the Free Software
|
||
8 | * Foundation; either version 3 of the License, or (at your option) any later
|
||
9 | * version.
|
||
10 | 40559 | jjdelcerro | *
|
11 | 42775 | jjdelcerro | * This program is distributed in the hope that it will be useful, but WITHOUT
|
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||
14 | * details.
|
||
15 | 40559 | jjdelcerro | *
|
16 | 42775 | jjdelcerro | * You should have received a copy of the GNU General Public License along with
|
17 | * this program; if not, write to the Free Software Foundation, Inc., 51
|
||
18 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
19 | 40559 | jjdelcerro | *
|
20 | 42775 | jjdelcerro | * For any additional information, do not hesitate to contact us at info AT
|
21 | * gvsig.com, or visit our website www.gvsig.com.
|
||
22 | 40559 | jjdelcerro | */
|
23 | 40435 | jjdelcerro | package org.gvsig.fmap.dal.serverexplorer.filesystem.impl; |
24 | |||
25 | import java.io.File; |
||
26 | import java.util.ArrayList; |
||
27 | import java.util.HashSet; |
||
28 | import java.util.Iterator; |
||
29 | import java.util.List; |
||
30 | import java.util.Set; |
||
31 | |||
32 | import org.gvsig.fmap.dal.DALFileLocator; |
||
33 | import org.gvsig.fmap.dal.DALLocator; |
||
34 | import org.gvsig.fmap.dal.DataManager; |
||
35 | import org.gvsig.fmap.dal.DataServerExplorerParameters; |
||
36 | import org.gvsig.fmap.dal.DataStore; |
||
37 | import org.gvsig.fmap.dal.DataStoreParameters; |
||
38 | import org.gvsig.fmap.dal.NewDataStoreParameters; |
||
39 | import org.gvsig.fmap.dal.exception.DataException; |
||
40 | import org.gvsig.fmap.dal.exception.FileNotFoundException; |
||
41 | import org.gvsig.fmap.dal.exception.InitializeException; |
||
42 | import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
||
43 | import org.gvsig.fmap.dal.exception.RemoveException; |
||
44 | import org.gvsig.fmap.dal.exception.ServerExplorerAddException; |
||
45 | import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
||
46 | import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemFileFilter; |
||
47 | import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer; |
||
48 | import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters; |
||
49 | import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
||
50 | import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider; |
||
51 | import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderServices; |
||
52 | 42775 | jjdelcerro | import org.gvsig.fmap.dal.spi.AbstractDataServerExplorer; |
53 | 40435 | jjdelcerro | import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
54 | import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices; |
||
55 | import org.gvsig.tools.exception.BaseException; |
||
56 | import org.gvsig.tools.extensionpoint.ExtensionPoint.Extension; |
||
57 | |||
58 | 42775 | jjdelcerro | public class DefaultFilesystemServerExplorer extends AbstractDataServerExplorer |
59 | implements FilesystemServerExplorerProviderServices,
|
||
60 | FilesystemFileFilter { |
||
61 | 40435 | jjdelcerro | |
62 | 42775 | jjdelcerro | private File root; |
63 | private File current; // Current path |
||
64 | private List serverProviders; |
||
65 | 40435 | jjdelcerro | |
66 | 42775 | jjdelcerro | public DefaultFilesystemServerExplorer(
|
67 | FilesystemServerExplorerParameters parameters, |
||
68 | DataServerExplorerProviderServices services) |
||
69 | throws InitializeException {
|
||
70 | super(parameters, services);
|
||
71 | if (this.getFSParameters().getRoot() != null) { |
||
72 | this.root = new File(this.getFSParameters().getRoot()); |
||
73 | } |
||
74 | if (this.getFSParameters().getInitialpath() != null) { |
||
75 | this.current = new File(this.getFSParameters().getInitialpath()); |
||
76 | } |
||
77 | if (this.root == null && this.current == null) { |
||
78 | // throw new InitializeException(this.getName(),
|
||
79 | // new IllegalArgumentException());
|
||
80 | } else if (this.current == null) { |
||
81 | this.current = new File(this.getFSParameters().getRoot()); |
||
82 | } |
||
83 | } |
||
84 | 40435 | jjdelcerro | |
85 | 42775 | jjdelcerro | private FilesystemServerExplorerParameters getFSParameters() {
|
86 | return (FilesystemServerExplorerParameters) this.getParameters(); |
||
87 | } |
||
88 | 40435 | jjdelcerro | |
89 | 42775 | jjdelcerro | @Override
|
90 | protected void doDispose() throws BaseException { |
||
91 | this.root = null; |
||
92 | super.doDispose();
|
||
93 | } |
||
94 | 40435 | jjdelcerro | |
95 | 42775 | jjdelcerro | @Override
|
96 | public List list(int mode) throws DataException { |
||
97 | if (this.current == null) { |
||
98 | throw new IllegalStateException(); |
||
99 | } |
||
100 | if (!this.current.exists()) { |
||
101 | throw new org.gvsig.fmap.dal.exception.FileNotFoundException(this.current); |
||
102 | } |
||
103 | 40435 | jjdelcerro | |
104 | 42775 | jjdelcerro | if (!this.current.isDirectory()) { |
105 | throw new IllegalArgumentException(this.getProviderName() |
||
106 | + ": Path not a directory '" + this.current + "'"); |
||
107 | } |
||
108 | 40435 | jjdelcerro | |
109 | 42775 | jjdelcerro | List files = new ArrayList(); // return files |
110 | List providers = this.getProviders(mode); |
||
111 | String allfiles[] = this.current.list(); |
||
112 | 40435 | jjdelcerro | |
113 | 42775 | jjdelcerro | for (int i = 0; i < allfiles.length; i++) { |
114 | File file = new File(this.root, allfiles[i]); |
||
115 | Iterator providersit = providers.iterator();
|
||
116 | while (providersit.hasNext()) {
|
||
117 | FilesystemServerExplorerProvider provider = (FilesystemServerExplorerProvider) providersit |
||
118 | .next(); |
||
119 | if (provider.accept(file)) {
|
||
120 | DataStoreParameters dsp = this.createStoreParameters(file);
|
||
121 | if (dsp != null) { |
||
122 | files.add(dsp); |
||
123 | } |
||
124 | break;
|
||
125 | } |
||
126 | } |
||
127 | } |
||
128 | return files;
|
||
129 | } |
||
130 | 40435 | jjdelcerro | |
131 | 42775 | jjdelcerro | public List list() throws DataException { |
132 | if (this.current == null) { |
||
133 | throw new IllegalStateException(); // FIXME |
||
134 | } |
||
135 | if (!this.current.exists()) { |
||
136 | // TODO crear excepcion de Data??
|
||
137 | new org.gvsig.fmap.dal.exception.FileNotFoundException(this.current); |
||
138 | } |
||
139 | 40435 | jjdelcerro | |
140 | 42775 | jjdelcerro | if (!this.current.isDirectory()) { |
141 | new IllegalArgumentException(this.getProviderName() |
||
142 | + ": Path not a directory '" + this.current + "'"); |
||
143 | } |
||
144 | 40435 | jjdelcerro | |
145 | 42775 | jjdelcerro | String files[] = this.current.list(); |
146 | int i;
|
||
147 | File theFile;
|
||
148 | ArrayList list = new ArrayList(); |
||
149 | DataStoreParameters dsp = null;
|
||
150 | 40435 | jjdelcerro | |
151 | 42775 | jjdelcerro | for (i = 0; i < files.length; i++) { |
152 | theFile = new File(this.root, files[i]); |
||
153 | dsp = this.createStoreParameters(theFile);
|
||
154 | if (dsp != null) { |
||
155 | list.add(dsp); |
||
156 | } |
||
157 | } |
||
158 | return list;
|
||
159 | } |
||
160 | 40435 | jjdelcerro | |
161 | 42775 | jjdelcerro | public void setCurrentPath(File path) throws FileNotFoundException { |
162 | // FIXME Comprobar si es un directorio existente
|
||
163 | if (!path.exists()) {
|
||
164 | throw new FileNotFoundException(path); |
||
165 | } |
||
166 | if (!path.isDirectory()) {
|
||
167 | throw new IllegalArgumentException(path.getPath() |
||
168 | + " is not a directory");
|
||
169 | } |
||
170 | if (!isFromRoot(path)) {
|
||
171 | throw new IllegalArgumentException(path.getPath() |
||
172 | + " is not from root");
|
||
173 | 40435 | jjdelcerro | |
174 | 42775 | jjdelcerro | } |
175 | 40435 | jjdelcerro | |
176 | 42775 | jjdelcerro | this.current = path;
|
177 | } |
||
178 | 40435 | jjdelcerro | |
179 | 42775 | jjdelcerro | public File getCurrentPath() { |
180 | return this.current; |
||
181 | } |
||
182 | 40435 | jjdelcerro | |
183 | 42775 | jjdelcerro | public File getRoot() { |
184 | return this.root; |
||
185 | } |
||
186 | 40435 | jjdelcerro | |
187 | 42775 | jjdelcerro | public void remove(DataStoreParameters dsp) throws RemoveException { |
188 | String providerName = dsp.getDataStoreName();
|
||
189 | try {
|
||
190 | this.checkIsMine(dsp);
|
||
191 | FilesystemServerExplorerProvider provider = this
|
||
192 | .getProvider(providerName); |
||
193 | 40435 | jjdelcerro | |
194 | 42775 | jjdelcerro | provider.remove(dsp); |
195 | } catch (DataException e) {
|
||
196 | throw new RemoveException(this.getProviderName(), e); |
||
197 | } |
||
198 | } |
||
199 | 40435 | jjdelcerro | |
200 | 42775 | jjdelcerro | public boolean add(String providerName, NewDataStoreParameters ndsp, |
201 | boolean overwrite) throws DataException { |
||
202 | 40435 | jjdelcerro | |
203 | 42775 | jjdelcerro | try {
|
204 | this.checkIsMine(ndsp);
|
||
205 | FilesystemServerExplorerProvider provider = this
|
||
206 | .getProvider(providerName); |
||
207 | 40435 | jjdelcerro | |
208 | 42775 | jjdelcerro | ndsp.validate(); |
209 | provider.create(ndsp, overwrite); |
||
210 | return true; |
||
211 | } catch (DataException e) {
|
||
212 | throw new ServerExplorerAddException(this.getProviderName(), e); |
||
213 | } catch (ValidateDataParametersException e) {
|
||
214 | throw new ServerExplorerAddException(this.getProviderName(), e); |
||
215 | } |
||
216 | } |
||
217 | 40435 | jjdelcerro | |
218 | 42775 | jjdelcerro | public boolean canAdd() { |
219 | return this.root.canWrite(); |
||
220 | } |
||
221 | 40435 | jjdelcerro | |
222 | 42775 | jjdelcerro | public String getProviderName() { |
223 | return FilesystemServerExplorer.NAME;
|
||
224 | } |
||
225 | 40435 | jjdelcerro | |
226 | 42775 | jjdelcerro | public NewDataStoreParameters getAddParameters(String storeName) |
227 | throws DataException {
|
||
228 | FilesystemServerExplorerProvider provider = this.getProvider(storeName);
|
||
229 | if (provider == null) { |
||
230 | throw new IllegalArgumentException( |
||
231 | "Not registered in this explorer"); // FIXME |
||
232 | } |
||
233 | 40435 | jjdelcerro | |
234 | 42775 | jjdelcerro | NewDataStoreParameters nParams = provider.getCreateParameters(); |
235 | // nParams.setAttribute("path", this.getCurrentPath().getPath());
|
||
236 | return nParams;
|
||
237 | } |
||
238 | 40435 | jjdelcerro | |
239 | 42775 | jjdelcerro | public boolean canAdd(String storeName) throws DataException { |
240 | if (storeName == null) { |
||
241 | return false;// CanAdd with genericFilter |
||
242 | } |
||
243 | FilesystemServerExplorerProvider provider = this.getProvider(storeName);
|
||
244 | if (provider == null) { |
||
245 | throw new IllegalArgumentException( |
||
246 | "Not registered in this explorer"); // FIXME |
||
247 | } |
||
248 | 40435 | jjdelcerro | |
249 | 42775 | jjdelcerro | return provider.canCreate();
|
250 | 40435 | jjdelcerro | |
251 | 42775 | jjdelcerro | } |
252 | 40435 | jjdelcerro | |
253 | 42775 | jjdelcerro | // ==========================================
|
254 | private FilesystemServerExplorerProvider getProvider(String storeName) |
||
255 | throws InitializeException, ProviderNotRegisteredException {
|
||
256 | Iterator providers = getProviders(FilesystemServerExplorer.MODE_ALL).iterator();
|
||
257 | FilesystemServerExplorerProvider provider; |
||
258 | while (providers.hasNext()) {
|
||
259 | provider = (FilesystemServerExplorerProvider) providers.next(); |
||
260 | if (provider.getDataStoreProviderName().equals(storeName)) {
|
||
261 | return provider;
|
||
262 | } |
||
263 | } |
||
264 | return null; |
||
265 | } |
||
266 | 40435 | jjdelcerro | |
267 | 42775 | jjdelcerro | private DataManagerProviderServices getManager() {
|
268 | return (DataManagerProviderServices) DALLocator.getDataManager();
|
||
269 | } |
||
270 | 40435 | jjdelcerro | |
271 | 42775 | jjdelcerro | public DataStoreParameters createStoreParameters(File file, String providerName) throws DataException { |
272 | 40435 | jjdelcerro | |
273 | 42775 | jjdelcerro | return this.getParametersFor(file, providerName, true); |
274 | } |
||
275 | 40435 | jjdelcerro | |
276 | 42775 | jjdelcerro | public DataStoreParameters createStoreParameters(File file) throws DataException { |
277 | 40435 | jjdelcerro | |
278 | 42775 | jjdelcerro | return this.getParametersFor(file, null, true); |
279 | } |
||
280 | 40435 | jjdelcerro | |
281 | 42775 | jjdelcerro | public DataStoreParameters getParametersFor(File file, String providerName, boolean checksExist) throws DataException { |
282 | 40435 | jjdelcerro | |
283 | 42775 | jjdelcerro | if (checksExist) {
|
284 | if (!file.exists()) {
|
||
285 | return null; |
||
286 | } |
||
287 | if (!file.isFile()) {
|
||
288 | return null; |
||
289 | } |
||
290 | if (!file.canRead()) {
|
||
291 | return null; |
||
292 | } |
||
293 | if (file.isHidden()) { // XXX ??? |
||
294 | return null; |
||
295 | } |
||
296 | } |
||
297 | if (providerName == null) { |
||
298 | providerName = this.getProviderName(file);
|
||
299 | } |
||
300 | if (providerName != null) { |
||
301 | DataStoreParameters params = this.getManager()
|
||
302 | .createStoreParameters(providerName); |
||
303 | ((FilesystemStoreParameters) params).setFile(file); |
||
304 | return params;
|
||
305 | 40435 | jjdelcerro | |
306 | 42775 | jjdelcerro | } |
307 | return null; |
||
308 | } |
||
309 | 40435 | jjdelcerro | |
310 | 42775 | jjdelcerro | public List getProviderNameList(File file) { |
311 | Iterator filters = getFilters();
|
||
312 | List list = new ArrayList(); |
||
313 | while (filters.hasNext()) {
|
||
314 | FilesystemFileFilter filter = (FilesystemFileFilter) filters.next(); |
||
315 | if (filter.accept(file)) {
|
||
316 | list.add(filter.getDataStoreProviderName()); |
||
317 | } |
||
318 | } |
||
319 | return list;
|
||
320 | } |
||
321 | 40435 | jjdelcerro | |
322 | 42775 | jjdelcerro | public String getProviderName(File file) { |
323 | Iterator filters = getFilters();
|
||
324 | while (filters.hasNext()) {
|
||
325 | FilesystemFileFilter filter = (FilesystemFileFilter) filters.next(); |
||
326 | if (filter.accept(file)) {
|
||
327 | return filter.getDataStoreProviderName();
|
||
328 | } |
||
329 | } |
||
330 | return null; |
||
331 | } |
||
332 | 40435 | jjdelcerro | |
333 | 42775 | jjdelcerro | public List getDataStoreProviderNames() { |
334 | Set names = new HashSet(); |
||
335 | 40435 | jjdelcerro | |
336 | 42775 | jjdelcerro | Iterator filters = getFilters();
|
337 | while (filters.hasNext()) {
|
||
338 | FilesystemFileFilter filter = (FilesystemFileFilter) filters.next(); |
||
339 | names.add(filter.getDataStoreProviderName()); |
||
340 | } |
||
341 | return new ArrayList(names); |
||
342 | } |
||
343 | 40435 | jjdelcerro | |
344 | 42775 | jjdelcerro | private void checkIsMine(DataStoreParameters dsp) |
345 | throws IllegalArgumentException, DataException { |
||
346 | // FIXME Exception ???
|
||
347 | if (!(dsp instanceof FilesystemStoreParameters)) { |
||
348 | new IllegalArgumentException( |
||
349 | "not instance of FilesystemStoreParameters");
|
||
350 | } |
||
351 | Iterator filters = getFilters();
|
||
352 | File file = ((FilesystemStoreParameters) dsp).getFile();
|
||
353 | if (!this.isFromRoot(file)) { |
||
354 | throw new IllegalArgumentException("worng explorer"); |
||
355 | } |
||
356 | FilesystemFileFilter filter; |
||
357 | while (filters.hasNext()) {
|
||
358 | filter = (FilesystemFileFilter) filters.next(); |
||
359 | if (dsp.getDataStoreName()
|
||
360 | .equals(filter.getDataStoreProviderName())) { |
||
361 | return;
|
||
362 | } |
||
363 | } |
||
364 | throw new IllegalArgumentException("worng explorer"); |
||
365 | } |
||
366 | 40435 | jjdelcerro | |
367 | 42775 | jjdelcerro | private boolean isFromRoot(File file) { |
368 | if (this.root == null) { |
||
369 | return true; |
||
370 | } |
||
371 | return file.getAbsolutePath().startsWith(this.root.getAbsolutePath()); |
||
372 | } |
||
373 | 40435 | jjdelcerro | |
374 | 42775 | jjdelcerro | public List getProviders() { |
375 | if (this.serverProviders == null) { |
||
376 | Iterator iter = DALFileLocator.getFilesystemServerExplorerManager()
|
||
377 | .getRegisteredProviders(); |
||
378 | this.serverProviders = new ArrayList(); |
||
379 | Extension ext; |
||
380 | FilesystemServerExplorerProvider provider; |
||
381 | while (iter.hasNext()) {
|
||
382 | ext = (Extension) iter.next(); |
||
383 | try {
|
||
384 | provider = (FilesystemServerExplorerProvider) ext.create(); |
||
385 | } catch (Exception e) { |
||
386 | throw new RuntimeException(e);// FIXME !!! |
||
387 | } |
||
388 | provider.initialize(this);
|
||
389 | this.serverProviders.add(provider);
|
||
390 | } |
||
391 | } |
||
392 | return this.serverProviders; |
||
393 | } |
||
394 | 40435 | jjdelcerro | |
395 | 42775 | jjdelcerro | public List getProviders(int mode) { |
396 | Iterator iter = DALFileLocator.getFilesystemServerExplorerManager()
|
||
397 | .getRegisteredProviders(); |
||
398 | List providers = new ArrayList(); |
||
399 | Extension ext; |
||
400 | FilesystemServerExplorerProvider provider; |
||
401 | while (iter.hasNext()) {
|
||
402 | ext = (Extension) iter.next(); |
||
403 | try {
|
||
404 | provider = (FilesystemServerExplorerProvider) ext.create(); |
||
405 | } catch (Exception e) { |
||
406 | throw new RuntimeException(e);// FIXME !!! |
||
407 | } |
||
408 | if (provider.isMode(mode)) {
|
||
409 | provider.initialize(this);
|
||
410 | providers.add(provider); |
||
411 | } |
||
412 | } |
||
413 | return providers;
|
||
414 | } |
||
415 | 40435 | jjdelcerro | |
416 | 42775 | jjdelcerro | public Iterator getFilters(int mode) { |
417 | return this.getProviders(mode).iterator(); |
||
418 | } |
||
419 | 40435 | jjdelcerro | |
420 | 42775 | jjdelcerro | public Iterator getFilters() { |
421 | return this.getProviders().iterator(); |
||
422 | } |
||
423 | 40435 | jjdelcerro | |
424 | 42775 | jjdelcerro | public FilesystemFileFilter getFilter(int mode, final String description) { |
425 | 40435 | jjdelcerro | |
426 | 42775 | jjdelcerro | final List filters = new ArrayList(); |
427 | Iterator it = this.getFilters(mode); |
||
428 | while (it.hasNext()) {
|
||
429 | filters.add(it.next()); |
||
430 | } |
||
431 | FilesystemFileFilter filter = new FilesystemFileFilter() {
|
||
432 | 40435 | jjdelcerro | |
433 | 42775 | jjdelcerro | public boolean accept(File f) { |
434 | if (f.isDirectory()) {
|
||
435 | return true; |
||
436 | } |
||
437 | for (int i = 0; i < filters.size(); i++) { |
||
438 | if (((FilesystemFileFilter) filters.get(i)).accept(f)) {
|
||
439 | return true; |
||
440 | } |
||
441 | } |
||
442 | return false; |
||
443 | } |
||
444 | 40435 | jjdelcerro | |
445 | 42775 | jjdelcerro | public String getDescription() { |
446 | return description;
|
||
447 | } |
||
448 | 40435 | jjdelcerro | |
449 | 42775 | jjdelcerro | public String getDataStoreProviderName() { |
450 | return null; |
||
451 | } |
||
452 | }; |
||
453 | return filter;
|
||
454 | } |
||
455 | 40435 | jjdelcerro | |
456 | 42775 | jjdelcerro | public FilesystemFileFilter getGenericFilter() {
|
457 | // FIXME: Este metodo, getGenericFilter, no tengo claro que deba existir (jjdc)
|
||
458 | return this; |
||
459 | } |
||
460 | |||
461 | public String getDataStoreProviderName() { |
||
462 | return null; |
||
463 | } |
||
464 | |||
465 | public String getDescription() { |
||
466 | return "All supporteds"; |
||
467 | } |
||
468 | |||
469 | public boolean accept(File pathname) { |
||
470 | try {
|
||
471 | return this.createStoreParameters(pathname) != null; |
||
472 | } catch (DataException e) {
|
||
473 | throw new RuntimeException(e); // FIXME excpetion?? |
||
474 | } |
||
475 | } |
||
476 | |||
477 | public DataStore open(File file) throws DataException, |
||
478 | ValidateDataParametersException { |
||
479 | DataManager manager = DALLocator.getDataManager(); |
||
480 | String providerName = this.getProviderName(file); |
||
481 | |||
482 | 40435 | jjdelcerro | DataStoreParameters params = this.getAddParameters(file);
|
483 | 42775 | jjdelcerro | return manager.openStore(providerName, params);
|
484 | } |
||
485 | 40435 | jjdelcerro | |
486 | 42775 | jjdelcerro | public NewDataStoreParameters getAddParameters(File file) |
487 | throws DataException {
|
||
488 | DataStoreParameters params = this.getParametersFor(file, null, false); |
||
489 | NewDataStoreParameters newParams = this.getAddParameters(params
|
||
490 | .getDataStoreName()); |
||
491 | ((FilesystemStoreParameters) newParams) |
||
492 | .setFile(((FilesystemStoreParameters) params).getFile()); |
||
493 | return newParams;
|
||
494 | } |
||
495 | 40435 | jjdelcerro | |
496 | 42775 | jjdelcerro | public File getResourcePath(DataStore dataStore, String resourceName) throws DataException { |
497 | FilesystemServerExplorerProvider provider |
||
498 | = this.getProvider(dataStore.getProviderName());
|
||
499 | if (provider == null) { |
||
500 | return null; |
||
501 | } |
||
502 | String rootPath = provider.getResourceRootPathName(dataStore);
|
||
503 | if (rootPath == null) { |
||
504 | return null; |
||
505 | } |
||
506 | return new File(rootPath + "." + resourceName); |
||
507 | } |
||
508 | |||
509 | @Override
|
||
510 | public DataStoreParameters get(String name) throws DataException { |
||
511 | File theFile = new File(this.current,name); |
||
512 | DataStoreParameters dsp = this.createStoreParameters(theFile);
|
||
513 | return dsp;
|
||
514 | } |
||
515 | 40435 | jjdelcerro | } |