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