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 @ 44831
History | View | Annotate | Download (22.4 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* 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 |
*
|
11 |
* 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 |
*
|
16 |
* 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 |
*
|
20 |
* For any additional information, do not hesitate to contact us at info AT
|
21 |
* gvsig.com, or visit our website www.gvsig.com.
|
22 |
*/
|
23 |
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 |
import java.util.function.Predicate; |
32 |
import org.apache.commons.io.FilenameUtils; |
33 |
|
34 |
import org.gvsig.fmap.dal.DALFileLocator; |
35 |
import org.gvsig.fmap.dal.DALLocator; |
36 |
import org.gvsig.fmap.dal.DataManager; |
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.feature.NewFeatureStoreParameters; |
48 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemFileFilter; |
49 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorer; |
50 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemServerExplorerParameters; |
51 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
52 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProvider; |
53 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderFactory; |
54 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.spi.FilesystemServerExplorerProviderServices; |
55 |
import org.gvsig.fmap.dal.spi.AbstractDataServerExplorer; |
56 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
57 |
import org.gvsig.fmap.dal.spi.DataServerExplorerProviderServices; |
58 |
import org.gvsig.fmap.dal.spi.ZipResourcesStorage; |
59 |
import org.gvsig.tools.exception.BaseException; |
60 |
import org.gvsig.tools.extensionpoint.ExtensionPoint.Extension; |
61 |
import org.gvsig.tools.resourcesstorage.ResourcesStorage; |
62 |
import org.gvsig.tools.resourcesstorage.FilesResourcesStorage; |
63 |
import org.gvsig.tools.util.FilteredIterator; |
64 |
|
65 |
@SuppressWarnings("UseSpecificCatch") |
66 |
public class DefaultFilesystemServerExplorer extends AbstractDataServerExplorer |
67 |
implements FilesystemServerExplorerProviderServices,
|
68 |
FilesystemFileFilter { |
69 |
|
70 |
private File root; |
71 |
private File current; // Current path |
72 |
private List<FilesystemServerExplorerProvider> serverProviders; |
73 |
|
74 |
public DefaultFilesystemServerExplorer(
|
75 |
FilesystemServerExplorerParameters parameters, |
76 |
DataServerExplorerProviderServices services) |
77 |
throws InitializeException {
|
78 |
super(parameters, services);
|
79 |
if (this.getFSParameters().getRoot() != null) { |
80 |
this.root = new File(this.getFSParameters().getRoot()); |
81 |
} |
82 |
if (this.getFSParameters().getInitialpath() != null) { |
83 |
this.current = new File(this.getFSParameters().getInitialpath()); |
84 |
} |
85 |
if (this.root == null && this.current == null) { |
86 |
// throw new InitializeException(this.getName(),
|
87 |
// new IllegalArgumentException());
|
88 |
} else if (this.current == null) { |
89 |
this.current = new File(this.getFSParameters().getRoot()); |
90 |
} |
91 |
} |
92 |
|
93 |
private FilesystemServerExplorerParameters getFSParameters() {
|
94 |
return (FilesystemServerExplorerParameters) this.getParameters(); |
95 |
} |
96 |
|
97 |
@Override
|
98 |
protected void doDispose() throws BaseException { |
99 |
this.root = null; |
100 |
super.doDispose();
|
101 |
} |
102 |
|
103 |
@Override
|
104 |
public List list(int mode) throws DataException { |
105 |
if (this.current == null) { |
106 |
throw new IllegalStateException(); |
107 |
} |
108 |
if (!this.current.exists()) { |
109 |
throw new org.gvsig.fmap.dal.exception.FileNotFoundException(this.current); |
110 |
} |
111 |
|
112 |
if (!this.current.isDirectory()) { |
113 |
throw new IllegalArgumentException(this.getProviderName() |
114 |
+ ": Path not a directory '" + this.current + "'"); |
115 |
} |
116 |
|
117 |
List files = new ArrayList(); // return files |
118 |
List providers = this.getProviders(mode); |
119 |
String allfiles[] = this.current.list(); |
120 |
|
121 |
for (String f : allfiles) { |
122 |
File file = new File(this.root, f); |
123 |
Iterator providersit = providers.iterator();
|
124 |
while (providersit.hasNext()) {
|
125 |
FilesystemServerExplorerProvider provider = (FilesystemServerExplorerProvider) providersit |
126 |
.next(); |
127 |
if (provider.accept(file)) {
|
128 |
DataStoreParameters dsp = this.createStoreParameters(file);
|
129 |
if (dsp != null) { |
130 |
files.add(dsp); |
131 |
} |
132 |
break;
|
133 |
} |
134 |
} |
135 |
} |
136 |
return files;
|
137 |
} |
138 |
|
139 |
public List list() throws DataException { |
140 |
if (this.current == null) { |
141 |
throw new IllegalStateException(); // FIXME |
142 |
} |
143 |
if (!this.current.exists()) { |
144 |
throw new FileNotFoundException(this.current); |
145 |
} |
146 |
|
147 |
if (!this.current.isDirectory()) { |
148 |
throw new IllegalArgumentException(this.getProviderName() |
149 |
+ ": Path not a directory '" + this.current + "'"); |
150 |
} |
151 |
|
152 |
String files[] = this.current.list(); |
153 |
int i;
|
154 |
File theFile;
|
155 |
ArrayList list = new ArrayList(); |
156 |
DataStoreParameters dsp; |
157 |
|
158 |
for (i = 0; i < files.length; i++) { |
159 |
theFile = new File(this.root, files[i]); |
160 |
dsp = this.createStoreParameters(theFile);
|
161 |
if (dsp != null) { |
162 |
list.add(dsp); |
163 |
} |
164 |
} |
165 |
return list;
|
166 |
} |
167 |
|
168 |
public void setCurrentPath(File path) throws FileNotFoundException { |
169 |
// FIXME Comprobar si es un directorio existente
|
170 |
if (!path.exists()) {
|
171 |
throw new FileNotFoundException(path); |
172 |
} |
173 |
if (!path.isDirectory()) {
|
174 |
throw new IllegalArgumentException(path.getPath() |
175 |
+ " is not a directory");
|
176 |
} |
177 |
if (!isFromRoot(path)) {
|
178 |
throw new IllegalArgumentException(path.getPath() |
179 |
+ " is not from root");
|
180 |
|
181 |
} |
182 |
|
183 |
this.current = path;
|
184 |
} |
185 |
|
186 |
public File getCurrentPath() { |
187 |
return this.current; |
188 |
} |
189 |
|
190 |
public File getRoot() { |
191 |
return this.root; |
192 |
} |
193 |
|
194 |
public void remove(DataStoreParameters dsp) throws RemoveException { |
195 |
String providerName = dsp.getDataStoreName();
|
196 |
try {
|
197 |
this.checkIsMine(dsp);
|
198 |
FilesystemServerExplorerProvider provider = this
|
199 |
.getProvider(providerName); |
200 |
|
201 |
provider.remove(dsp); |
202 |
} catch (DataException e) {
|
203 |
throw new RemoveException(this.getProviderName(), e); |
204 |
} |
205 |
} |
206 |
|
207 |
public boolean add(String providerName, NewDataStoreParameters ndsp, |
208 |
boolean overwrite) throws DataException { |
209 |
|
210 |
try {
|
211 |
this.checkIsMine(ndsp);
|
212 |
FilesystemServerExplorerProvider provider = this
|
213 |
.getProvider(providerName); |
214 |
|
215 |
ndsp.validate(); |
216 |
provider.create(ndsp, overwrite); |
217 |
|
218 |
if( ndsp instanceof NewFeatureStoreParameters ) { |
219 |
DataManager dataManager = DALLocator.getDataManager(); |
220 |
ResourcesStorage resources = this.getResourcesStorage(ndsp);
|
221 |
dataManager.writeDALResource(resources, ((NewFeatureStoreParameters) ndsp).getDefaultFeatureType()); |
222 |
} |
223 |
return true; |
224 |
} catch (DataException | ValidateDataParametersException e) {
|
225 |
throw new ServerExplorerAddException(this.getProviderName(), e); |
226 |
} |
227 |
} |
228 |
|
229 |
public boolean canAdd() { |
230 |
return this.root.canWrite(); |
231 |
} |
232 |
|
233 |
public String getProviderName() { |
234 |
return FilesystemServerExplorer.NAME;
|
235 |
} |
236 |
|
237 |
public NewDataStoreParameters getAddParameters(String storeName) |
238 |
throws DataException {
|
239 |
FilesystemServerExplorerProvider provider = this.getProvider(storeName);
|
240 |
if (provider == null) { |
241 |
throw new IllegalArgumentException( |
242 |
"Not registered in this explorer"); // FIXME |
243 |
} |
244 |
|
245 |
NewDataStoreParameters nParams = provider.getCreateParameters(); |
246 |
// nParams.setAttribute("path", this.getCurrentPath().getPath());
|
247 |
return nParams;
|
248 |
} |
249 |
|
250 |
public boolean canAdd(String storeName) throws DataException { |
251 |
if (storeName == null) { |
252 |
return false;// CanAdd with genericFilter |
253 |
} |
254 |
FilesystemServerExplorerProvider provider = this.getProvider(storeName);
|
255 |
if (provider == null) { |
256 |
throw new IllegalArgumentException( |
257 |
"Not registered in this explorer"); // FIXME |
258 |
} |
259 |
|
260 |
return provider.canCreate();
|
261 |
|
262 |
} |
263 |
|
264 |
// ==========================================
|
265 |
private FilesystemServerExplorerProvider getProvider(String providerName) |
266 |
throws InitializeException, ProviderNotRegisteredException {
|
267 |
Iterator providers = getProviders(FilesystemServerExplorer.MODE_ALL).iterator();
|
268 |
FilesystemServerExplorerProvider provider; |
269 |
while (providers.hasNext()) {
|
270 |
provider = (FilesystemServerExplorerProvider) providers.next(); |
271 |
if (provider.getDataStoreProviderName().equals(providerName)) {
|
272 |
return provider;
|
273 |
} |
274 |
} |
275 |
return null; |
276 |
} |
277 |
|
278 |
private DataManagerProviderServices getManager() {
|
279 |
return (DataManagerProviderServices) DALLocator.getDataManager();
|
280 |
} |
281 |
|
282 |
public DataStoreParameters createStoreParameters(File file, String providerName) throws DataException { |
283 |
|
284 |
return this.getParametersFor(file, providerName, true); |
285 |
} |
286 |
|
287 |
public DataStoreParameters createStoreParameters(File file) throws DataException { |
288 |
|
289 |
return this.getParametersFor(file, null, true); |
290 |
} |
291 |
|
292 |
public DataStoreParameters getParametersFor(File file, String providerName, boolean checksExist) throws DataException { |
293 |
|
294 |
if (checksExist) {
|
295 |
if (!file.exists()) {
|
296 |
return null; |
297 |
} |
298 |
if (!file.isFile()) {
|
299 |
return null; |
300 |
} |
301 |
if (!file.canRead()) {
|
302 |
return null; |
303 |
} |
304 |
if (file.isHidden()) { // XXX ??? |
305 |
return null; |
306 |
} |
307 |
} |
308 |
if (providerName == null) { |
309 |
providerName = this.getProviderName(file);
|
310 |
} |
311 |
if (providerName != null) { |
312 |
DataStoreParameters params = this.getManager()
|
313 |
.createStoreParameters(providerName); |
314 |
((FilesystemStoreParameters) params).setFile(file); |
315 |
return params;
|
316 |
|
317 |
} |
318 |
return null; |
319 |
} |
320 |
|
321 |
public List<String> getProviderNameList(File file) { |
322 |
Iterator filters = getFilters();
|
323 |
List list = new ArrayList(); |
324 |
while (filters.hasNext()) {
|
325 |
FilesystemFileFilter filter = (FilesystemFileFilter) filters.next(); |
326 |
if (filter.accept(file)) {
|
327 |
list.add(filter.getDataStoreProviderName()); |
328 |
} |
329 |
} |
330 |
return list;
|
331 |
} |
332 |
|
333 |
@Override
|
334 |
public String getProviderName(File file) { |
335 |
Iterator filters = getFilters();
|
336 |
while (filters.hasNext()) {
|
337 |
FilesystemFileFilter filter = (FilesystemFileFilter) filters.next(); |
338 |
if (filter.accept(file)) {
|
339 |
return filter.getDataStoreProviderName();
|
340 |
} |
341 |
} |
342 |
return null; |
343 |
} |
344 |
|
345 |
public List getDataStoreProviderNames() { |
346 |
Set names = new HashSet(); |
347 |
|
348 |
Iterator filters = getFilters();
|
349 |
while (filters.hasNext()) {
|
350 |
FilesystemFileFilter filter = (FilesystemFileFilter) filters.next(); |
351 |
names.add(filter.getDataStoreProviderName()); |
352 |
} |
353 |
return new ArrayList(names); |
354 |
} |
355 |
|
356 |
private void checkIsMine(DataStoreParameters dsp) |
357 |
throws IllegalArgumentException, DataException { |
358 |
if (!(dsp instanceof FilesystemStoreParameters)) { |
359 |
throw new IllegalArgumentException("not instance of FilesystemStoreParameters"); |
360 |
} |
361 |
Iterator filters = getFilters();
|
362 |
File file = ((FilesystemStoreParameters) dsp).getFile();
|
363 |
if (!this.isFromRoot(file)) { |
364 |
throw new IllegalArgumentException("worng explorer"); |
365 |
} |
366 |
FilesystemFileFilter filter; |
367 |
while (filters.hasNext()) {
|
368 |
filter = (FilesystemFileFilter) filters.next(); |
369 |
if (dsp.getDataStoreName()
|
370 |
.equals(filter.getDataStoreProviderName())) { |
371 |
return;
|
372 |
} |
373 |
} |
374 |
throw new IllegalArgumentException("worng explorer"); |
375 |
} |
376 |
|
377 |
private boolean isFromRoot(File file) { |
378 |
if (this.root == null) { |
379 |
return true; |
380 |
} |
381 |
return file.getAbsolutePath().startsWith(this.root.getAbsolutePath()); |
382 |
} |
383 |
|
384 |
public List<FilesystemServerExplorerProvider> getProviders() { |
385 |
if (this.serverProviders == null) { |
386 |
Iterator iter = DALFileLocator.getFilesystemServerExplorerManager()
|
387 |
.getRegisteredProviders(); |
388 |
this.serverProviders = new ArrayList(); |
389 |
Extension ext; |
390 |
FilesystemServerExplorerProvider provider; |
391 |
FilesystemServerExplorerProviderFactory factory; |
392 |
while (iter.hasNext()) {
|
393 |
ext = (Extension) iter.next(); |
394 |
try {
|
395 |
factory = (FilesystemServerExplorerProviderFactory) ext.create(); |
396 |
} catch (Exception e) { |
397 |
throw new RuntimeException(e);// FIXME !!! |
398 |
} |
399 |
try {
|
400 |
provider=factory.createProvider(); |
401 |
} catch (InitializeException e) {
|
402 |
throw new RuntimeException(e);// FIXME !!! |
403 |
} |
404 |
provider.initialize(this);
|
405 |
this.serverProviders.add(provider);
|
406 |
} |
407 |
} |
408 |
return this.serverProviders; |
409 |
} |
410 |
|
411 |
public List getProviders(int mode) { |
412 |
List<FilesystemServerExplorerProvider> providers = new ArrayList(); |
413 |
List<FilesystemServerExplorerProvider> allProviders = getProviders();
|
414 |
for (FilesystemServerExplorerProvider provider:allProviders){
|
415 |
if (provider.isMode(mode)) {
|
416 |
provider.initialize(this);
|
417 |
providers.add(provider); |
418 |
} |
419 |
} |
420 |
return providers;
|
421 |
} |
422 |
|
423 |
@Override
|
424 |
public Iterator getFilters(int mode) { |
425 |
final Iterator<FilesystemServerExplorerProvider> it = this.getProviders(mode).iterator(); |
426 |
return new FilteredIterator(it, new Predicate<FilesystemServerExplorerProvider>() { |
427 |
@Override
|
428 |
public boolean test(FilesystemServerExplorerProvider p) { |
429 |
if( p instanceof AbstractFilesystemServerExplorerProvider ) { |
430 |
FilesystemServerExplorerProviderFactory factory = ((AbstractFilesystemServerExplorerProvider)p).getFactory(); |
431 |
if( factory!=null ) { |
432 |
return !factory.isHidden();
|
433 |
} |
434 |
} |
435 |
return true; |
436 |
} |
437 |
}); |
438 |
} |
439 |
|
440 |
@Override
|
441 |
public Iterator<FilesystemServerExplorerProvider> getFilters() { |
442 |
final Iterator<FilesystemServerExplorerProvider> it = this.getProviders().iterator(); |
443 |
return new FilteredIterator(it, new Predicate<FilesystemServerExplorerProvider>() { |
444 |
@Override
|
445 |
public boolean test(FilesystemServerExplorerProvider p) { |
446 |
if( p instanceof AbstractFilesystemServerExplorerProvider ) { |
447 |
FilesystemServerExplorerProviderFactory factory = ((AbstractFilesystemServerExplorerProvider)p).getFactory(); |
448 |
if( factory!=null ) { |
449 |
return !factory.isHidden();
|
450 |
} |
451 |
} |
452 |
return true; |
453 |
} |
454 |
}); |
455 |
} |
456 |
|
457 |
@Override
|
458 |
public FilesystemFileFilter getFilter(int mode, final String description) { |
459 |
|
460 |
final List filters = new ArrayList(); |
461 |
Iterator it = this.getFilters(mode); |
462 |
while (it.hasNext()) {
|
463 |
filters.add(it.next()); |
464 |
} |
465 |
FilesystemFileFilter filter = new FilesystemFileFilter() {
|
466 |
|
467 |
@Override
|
468 |
public boolean accept(File f) { |
469 |
if (f.isDirectory()) {
|
470 |
return true; |
471 |
} |
472 |
for (int i = 0; i < filters.size(); i++) { |
473 |
if (((FilesystemFileFilter) filters.get(i)).accept(f)) {
|
474 |
return true; |
475 |
} |
476 |
} |
477 |
return false; |
478 |
} |
479 |
|
480 |
@Override
|
481 |
public String getDescription() { |
482 |
return description;
|
483 |
} |
484 |
|
485 |
@Override
|
486 |
public String getDataStoreProviderName() { |
487 |
return null; |
488 |
} |
489 |
}; |
490 |
return filter;
|
491 |
} |
492 |
|
493 |
@Override
|
494 |
public FilesystemFileFilter getGenericFilter() {
|
495 |
// FIXME: Este metodo, getGenericFilter, no tengo claro que deba existir (jjdc)
|
496 |
return this; |
497 |
} |
498 |
|
499 |
@Override
|
500 |
public String getDataStoreProviderName() { |
501 |
return null; |
502 |
} |
503 |
|
504 |
public String getDescription() { |
505 |
return "All supporteds"; |
506 |
} |
507 |
|
508 |
public boolean accept(File pathname) { |
509 |
try {
|
510 |
return this.createStoreParameters(pathname) != null; |
511 |
} catch (DataException e) {
|
512 |
throw new RuntimeException(e); // FIXME excpetion?? |
513 |
} |
514 |
} |
515 |
|
516 |
public DataStore open(File file) throws DataException, |
517 |
ValidateDataParametersException { |
518 |
DataManager manager = DALLocator.getDataManager(); |
519 |
String providerName = this.getProviderName(file); |
520 |
|
521 |
DataStoreParameters params = this.getAddParameters(file);
|
522 |
return manager.openStore(providerName, params);
|
523 |
} |
524 |
|
525 |
public NewDataStoreParameters getAddParameters(File file) |
526 |
throws DataException {
|
527 |
DataStoreParameters params = this.getParametersFor(file, null, false); |
528 |
NewDataStoreParameters newParams = this.getAddParameters(params
|
529 |
.getDataStoreName()); |
530 |
((FilesystemStoreParameters) newParams) |
531 |
.setFile(((FilesystemStoreParameters) params).getFile()); |
532 |
return newParams;
|
533 |
} |
534 |
|
535 |
@Deprecated
|
536 |
@Override
|
537 |
public File getResourcePath(DataStore dataStore, String resourceName) throws DataException { |
538 |
try {
|
539 |
ResourcesStorage theResourceStorage = this.getResourcesStorage(dataStore);
|
540 |
if( theResourceStorage==null ) { |
541 |
return null; |
542 |
} |
543 |
FilesResourcesStorage.FileResource res = (FilesResourcesStorage.FileResource) theResourceStorage.getResource(resourceName); |
544 |
if( res==null ) { |
545 |
return null; |
546 |
} |
547 |
return res.getFile();
|
548 |
} catch(Exception ex) { |
549 |
return null; |
550 |
} |
551 |
} |
552 |
|
553 |
private String getResourcePathName(DataStoreParameters parameters) { |
554 |
FilesystemServerExplorerProvider provider; |
555 |
try {
|
556 |
provider = this.getProvider(parameters.getProviderName());
|
557 |
} catch (Exception ex) { |
558 |
return null; |
559 |
} |
560 |
if (provider == null) { |
561 |
return null; |
562 |
} |
563 |
String pathName = provider.getResourceRootPathName(parameters);
|
564 |
if (pathName == null) { |
565 |
return null; |
566 |
} |
567 |
pathName = FilenameUtils.removeExtension(pathName); |
568 |
return pathName;
|
569 |
} |
570 |
|
571 |
@Override
|
572 |
public ResourcesStorage getResourcesStorage(DataStoreParameters parameters) {
|
573 |
String pathName = this.getResourcePathName(parameters); |
574 |
ResourcesStorage theResourcesStorage; |
575 |
if( ZipResourcesStorage.existsStorage(pathName) ) {
|
576 |
String resourceName = FilenameUtils.getBaseName(pathName);
|
577 |
theResourcesStorage = new ZipResourcesStorage(
|
578 |
pathName, |
579 |
resourceName |
580 |
); |
581 |
} else {
|
582 |
theResourcesStorage = new FilesResourcesStorage(
|
583 |
pathName |
584 |
); |
585 |
} |
586 |
return theResourcesStorage;
|
587 |
} |
588 |
|
589 |
@Override
|
590 |
public ResourcesStorage getResourcesStorage(DataStore dataStore) {
|
591 |
ResourcesStorage theResourcesStorage; |
592 |
if( dataStore.getChildren().isEmpty() ) {
|
593 |
theResourcesStorage = this.getResourcesStorage(dataStore.getParameters());
|
594 |
} else {
|
595 |
String pathName = this.getResourcePathName(dataStore.getParameters()); |
596 |
theResourcesStorage = new ZipResourcesStorage(
|
597 |
pathName, |
598 |
dataStore.getName() |
599 |
); |
600 |
} |
601 |
return theResourcesStorage;
|
602 |
} |
603 |
|
604 |
@Override
|
605 |
public DataStoreParameters get(String name) throws DataException { |
606 |
File theFile = new File(this.current,name); |
607 |
DataStoreParameters dsp = this.createStoreParameters(theFile);
|
608 |
return dsp;
|
609 |
} |
610 |
|
611 |
@Override
|
612 |
public boolean exists(DataStoreParameters parameters) throws DataException { |
613 |
if( !(parameters instanceof FilesystemStoreParameters) ) { |
614 |
return false; |
615 |
} |
616 |
File f = ((FilesystemStoreParameters)parameters).getFile();
|
617 |
return f.exists();
|
618 |
} |
619 |
} |