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