svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.impl / src / main / java / org / gvsig / fmap / dal / impl / DefaultDataManager.java @ 44328
History | View | Annotate | Download (41.7 KB)
1 |
package org.gvsig.fmap.dal.impl; |
---|---|
2 |
|
3 |
import java.io.ByteArrayInputStream; |
4 |
import java.io.File; |
5 |
import java.io.InputStream; |
6 |
import java.net.URL; |
7 |
import java.net.URLClassLoader; |
8 |
import java.util.ArrayList; |
9 |
import java.util.Collections; |
10 |
import java.util.HashMap; |
11 |
import java.util.List; |
12 |
import java.util.Map; |
13 |
import org.apache.commons.io.IOUtils; |
14 |
import org.apache.commons.lang3.StringUtils; |
15 |
import org.gvsig.expressionevaluator.Expression; |
16 |
import org.gvsig.expressionevaluator.ExpressionBuilder; |
17 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorLocator; |
18 |
import org.gvsig.fmap.dal.BaseStoresRepository; |
19 |
|
20 |
import org.gvsig.fmap.dal.DataFactory; |
21 |
import org.gvsig.fmap.dal.DataManager; |
22 |
import org.gvsig.fmap.dal.DataServerExplorer; |
23 |
import org.gvsig.fmap.dal.DataServerExplorerFactory; |
24 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
25 |
import org.gvsig.fmap.dal.DataServerExplorerPool; |
26 |
import org.gvsig.fmap.dal.DataStore; |
27 |
import org.gvsig.fmap.dal.DataStoreFactory_v2_4; |
28 |
import org.gvsig.fmap.dal.DataStoreParameters; |
29 |
import org.gvsig.fmap.dal.DataStoreProviderFactory; |
30 |
import org.gvsig.fmap.dal.DataTypes; |
31 |
import org.gvsig.fmap.dal.DatabaseWorkspaceManager; |
32 |
|
33 |
import org.gvsig.fmap.dal.NewDataStoreParameters; |
34 |
import org.gvsig.fmap.dal.OpenErrorHandler; |
35 |
import org.gvsig.fmap.dal.Register; |
36 |
import org.gvsig.fmap.dal.StoresRepository; |
37 |
import org.gvsig.fmap.dal.exception.DataException; |
38 |
import org.gvsig.fmap.dal.exception.InitializeException; |
39 |
import org.gvsig.fmap.dal.exception.OpenException; |
40 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
41 |
import org.gvsig.fmap.dal.exception.CreateFileStoreException; |
42 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
43 |
import org.gvsig.fmap.dal.expressionevaluator.FeatureAttributeEmulatorExpression; |
44 |
import org.gvsig.fmap.dal.expressionevaluator.FeatureSymbolTable; |
45 |
import org.gvsig.fmap.dal.feature.DataProfile; |
46 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
47 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
48 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
49 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
50 |
import org.gvsig.fmap.dal.feature.FeatureType; |
51 |
import org.gvsig.fmap.dal.feature.impl.DALFile; |
52 |
import org.gvsig.fmap.dal.feature.impl.DefaultEditableFeatureType; |
53 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureIndex; |
54 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStore; |
55 |
import org.gvsig.fmap.dal.feature.impl.FeatureStoreFactory; |
56 |
import org.gvsig.fmap.dal.feature.paging.FeaturePagingHelper; |
57 |
import org.gvsig.fmap.dal.feature.paging.impl.FeaturePagingHelperImpl; |
58 |
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProvider; |
59 |
import org.gvsig.fmap.dal.feature.spi.FeatureStoreProviderServices; |
60 |
import org.gvsig.fmap.dal.feature.spi.cache.FeatureCacheProvider; |
61 |
import org.gvsig.fmap.dal.feature.spi.cache.FeatureCacheProviderFactory; |
62 |
import org.gvsig.fmap.dal.feature.spi.index.FeatureIndexProvider; |
63 |
import org.gvsig.fmap.dal.feature.spi.index.FeatureIndexProviderServices; |
64 |
import org.gvsig.fmap.dal.impl.expressionevaluator.DefaultExpressionEvaluator; |
65 |
import org.gvsig.fmap.dal.impl.expressionevaluator.DefaultFeatureAttributeEmulatorExpression; |
66 |
import org.gvsig.fmap.dal.impl.expressionevaluator.DefaultFeatureSymbolTable; |
67 |
import org.gvsig.fmap.dal.raster.impl.RasterStoreFactory; |
68 |
import org.gvsig.fmap.dal.raster.impl.RasterStoreOldFactory; |
69 |
import org.gvsig.fmap.dal.raster.spi.CoverageStoreProvider; |
70 |
import org.gvsig.fmap.dal.spi.DALSPILocator; |
71 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
72 |
import org.gvsig.fmap.dal.spi.DataStoreProvider; |
73 |
import org.gvsig.fmap.dal.spi.DataStoreProviderServices; |
74 |
import org.gvsig.fmap.dal.store.memory.MemoryStoreParameters; |
75 |
import org.gvsig.fmap.dal.store.memory.MemoryStoreProvider; |
76 |
import org.gvsig.tools.ToolsLocator; |
77 |
import org.gvsig.tools.dataTypes.DataType; |
78 |
import org.gvsig.tools.dataTypes.DataTypesManager; |
79 |
import org.gvsig.tools.dynobject.DynObject; |
80 |
import org.gvsig.tools.dynobject.DynStruct; |
81 |
import org.gvsig.tools.dynobject.DynStruct_v2; |
82 |
import org.gvsig.tools.dynobject.Tags; |
83 |
import org.gvsig.tools.evaluator.Evaluator; |
84 |
import org.gvsig.tools.exception.BaseException; |
85 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
86 |
import org.gvsig.tools.folders.FoldersManager; |
87 |
import org.gvsig.tools.identitymanagement.SimpleIdentityManager; |
88 |
import org.gvsig.tools.identitymanagement.UnauthorizedException; |
89 |
import org.gvsig.tools.persistence.PersistenceManager; |
90 |
import org.gvsig.tools.resourcesstorage.ResourcesStorage; |
91 |
import org.gvsig.tools.service.spi.Services; |
92 |
import org.slf4j.Logger; |
93 |
import org.slf4j.LoggerFactory; |
94 |
|
95 |
@SuppressWarnings("UseSpecificCatch") |
96 |
public class DefaultDataManager |
97 |
implements DataManager, DataManagerProviderServices, Services {
|
98 |
|
99 |
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultDataManager.class); |
100 |
|
101 |
final static private String DATA_MANAGER_CACHE = "Data.manager.caches"; |
102 |
final static private String DATA_MANAGER_CACHE_DESCRIPTION = |
103 |
"DAL cache providers";
|
104 |
|
105 |
public static final String FILESYSTEM_EXPLORER_NAME = "FilesystemExplorer"; |
106 |
|
107 |
|
108 |
private class Registers { |
109 |
|
110 |
private final Register store; |
111 |
private final Register storeProvider; |
112 |
private final Register serverExplorer; |
113 |
private final Register featureIndexProvider; |
114 |
|
115 |
public Registers() {
|
116 |
this.store = new RegisterImpl( |
117 |
"Data.manager.stores.factory",
|
118 |
"DAL store factories"
|
119 |
); |
120 |
this.storeProvider = new RegisterImpl( |
121 |
"Data.manager.providers.factory",
|
122 |
"DAL store provider factories"
|
123 |
); |
124 |
this.serverExplorer = new RegisterImpl( |
125 |
"Data.manager.servereexplorer.factory",
|
126 |
"DAL server explorer factories"
|
127 |
); |
128 |
this.featureIndexProvider = new RegisterImpl( |
129 |
"Data.manager.feature.index.factory",
|
130 |
"DAL feature index factories"
|
131 |
); |
132 |
|
133 |
this.store.register(new FeatureStoreFactory()); |
134 |
} |
135 |
} |
136 |
private static final String TAG_DAL_OPENSTORE = "dal.openstore."; |
137 |
|
138 |
private final Registers registers; |
139 |
|
140 |
private final Map<Integer, String> defaultDataIndexProviders; |
141 |
|
142 |
private OpenErrorHandler openErrorHandler = null; |
143 |
|
144 |
private DataServerExplorerPool dataServerExplorerPool = null; |
145 |
|
146 |
private List<DataType> dataTypes = null; |
147 |
|
148 |
private ClassLoader resourcesLoader = null; |
149 |
|
150 |
private List<DataProfile> dataProfiles; |
151 |
|
152 |
public DefaultDataManager() {
|
153 |
this.registers = new Registers(); |
154 |
this.defaultDataIndexProviders = new HashMap<>(); |
155 |
} |
156 |
|
157 |
@Override
|
158 |
public Register getStoreRegister() {
|
159 |
return this.registers.store; |
160 |
} |
161 |
|
162 |
@Override
|
163 |
public Register getStoreProviderRegister() {
|
164 |
return this.registers.storeProvider; |
165 |
} |
166 |
|
167 |
@Override
|
168 |
public Register getServerExplorerRegister() {
|
169 |
return this.registers.serverExplorer; |
170 |
} |
171 |
|
172 |
@Override
|
173 |
public Register getFeatureIndexRegister() {
|
174 |
return this.registers.featureIndexProvider; |
175 |
} |
176 |
|
177 |
private String getStoreName(DataStoreParameters parameters) { |
178 |
for (DataFactory factory : this.getStoreRegister()) { |
179 |
DataStoreFactory_v2_4 storeFactory = (DataStoreFactory_v2_4) factory; |
180 |
if (storeFactory.canUse(parameters)) {
|
181 |
return storeFactory.getName();
|
182 |
} |
183 |
} |
184 |
return null; |
185 |
} |
186 |
|
187 |
/**
|
188 |
* @deprecated
|
189 |
*/
|
190 |
@Override
|
191 |
public void registerDefaultRasterStore(Class rasterStoreClass) { |
192 |
// Metodo usado por el raster nuevo para regstrar su factoria de store
|
193 |
this.getStoreRegister().register(new RasterStoreFactory(rasterStoreClass)); |
194 |
} |
195 |
|
196 |
/**
|
197 |
* @deprecated
|
198 |
*/
|
199 |
@Override
|
200 |
public void registerStoreFactory(String name, Class storeFactoryClass) { |
201 |
// Metodo usado por el raster viejo para registrar las factorias de sus stores
|
202 |
this.getStoreRegister().register(new RasterStoreOldFactory(name, storeFactoryClass)); |
203 |
} |
204 |
|
205 |
/**
|
206 |
* @param name
|
207 |
* @param storeProviderClass
|
208 |
* @param parametersClass
|
209 |
* @deprecated use registerStoreProviderFactory
|
210 |
*/
|
211 |
@Override
|
212 |
public void registerStoreProvider(String name, Class storeProviderClass, |
213 |
Class parametersClass) {
|
214 |
if (name == null || storeProviderClass == null || parametersClass == null) { |
215 |
throw new IllegalArgumentException("Any parameters can be null"); |
216 |
} |
217 |
|
218 |
if (!DataStoreParameters.class.isAssignableFrom(parametersClass)) {
|
219 |
throw new IllegalArgumentException(parametersClass.getName() |
220 |
+ " must implement org.gvsig.fmap.dal.DataStoreParameters");
|
221 |
} |
222 |
|
223 |
if (CoverageStoreProvider.class.isAssignableFrom(storeProviderClass)) {
|
224 |
// Envuelve al proveedor en una factoria por defecto.
|
225 |
this.registerStoreProviderFactory(new DataStoreProviderToCoverageProviderFactoryWrapper( |
226 |
name, "", storeProviderClass, parametersClass));
|
227 |
return;
|
228 |
} |
229 |
|
230 |
if (FeatureStoreProvider.class.isAssignableFrom(storeProviderClass)) {
|
231 |
// Envuelve al proveedor en una factoria por defecto.
|
232 |
this.registerStoreProviderFactory(new DataStoreProviderToFeatureStoreProviderFactoryWrapper( |
233 |
name, "", storeProviderClass, parametersClass));
|
234 |
return;
|
235 |
} |
236 |
|
237 |
throw new IllegalArgumentException("Not supported implemtation: name=" |
238 |
+ name + " provider class=" + storeProviderClass.getName());
|
239 |
|
240 |
} |
241 |
|
242 |
@Override
|
243 |
public void registerExplorerProvider(String name, Class explorerClass, Class parametersClass) { |
244 |
if (name == null || explorerClass == null || parametersClass == null) { |
245 |
// FIXME Exception
|
246 |
throw new IllegalArgumentException("Any parameters can be null"); |
247 |
} |
248 |
|
249 |
if (!DataServerExplorerParameters.class
|
250 |
.isAssignableFrom(parametersClass)) { |
251 |
// FIXME Exception
|
252 |
throw new IllegalArgumentException( |
253 |
parametersClass.getName() |
254 |
+ " must implement org.gvsig.fmap.dal.DataServerExplorerParameters");
|
255 |
} |
256 |
|
257 |
if (!DataServerExplorer.class.isAssignableFrom(explorerClass)) {
|
258 |
// FIXME Exception
|
259 |
throw new IllegalArgumentException(explorerClass.getName() |
260 |
+ " must implement org.gvsig.fmap.dal.DataServerExplorer");
|
261 |
} |
262 |
|
263 |
// Envuelve al proveedor en una factoria por defecto.
|
264 |
this.registerServerExplorerFactory(
|
265 |
new DataServerExplorerToDataExplorerFactoryWrapper(
|
266 |
name, "", explorerClass, parametersClass
|
267 |
) |
268 |
); |
269 |
|
270 |
} |
271 |
|
272 |
@Override
|
273 |
public void registerStoreFactory(DataStoreFactory_v2_4 factory) { |
274 |
this.getStoreRegister().register(factory);
|
275 |
} |
276 |
|
277 |
@Override
|
278 |
public void registerStoreProviderFactory(DataStoreProviderFactory factory) { |
279 |
this.getStoreProviderRegister().register(factory);
|
280 |
} |
281 |
|
282 |
@Override
|
283 |
public void registerServerExplorerFactory(DataServerExplorerFactory factory) { |
284 |
this.getServerExplorerRegister().register(factory);
|
285 |
} |
286 |
|
287 |
@Override
|
288 |
public DataStoreParameters createStoreParameters(byte[] data) { |
289 |
try {
|
290 |
PersistenceManager persistenceManager = ToolsLocator.getPersistenceManager(); |
291 |
ByteArrayInputStream stream = new ByteArrayInputStream(data); |
292 |
DataStoreParameters parameters = (DataStoreParameters) persistenceManager.getObject(stream); |
293 |
return parameters;
|
294 |
} catch (Exception ex) { |
295 |
LOGGER.warn("Can't get parameters from byte[].",ex);
|
296 |
return null; |
297 |
} |
298 |
} |
299 |
|
300 |
@Override
|
301 |
public DataStoreParameters createStoreParameters(String providerName) throws InitializeException, ProviderNotRegisteredException { |
302 |
if( providerName == null ) { |
303 |
String msg = "Provider name can't be null."; |
304 |
LOGGER.warn(msg); |
305 |
throw new IllegalArgumentException(msg); |
306 |
} |
307 |
DataFactory providerFactory = this.getStoreProviderRegister().getFactory(providerName);
|
308 |
if( providerFactory == null ) { |
309 |
String msg = "Can't locate provider factory for '"+providerName+"'."; |
310 |
LOGGER.warn(msg); |
311 |
throw new IllegalArgumentException(msg); |
312 |
} |
313 |
return (DataStoreParameters) providerFactory.createParameters();
|
314 |
} |
315 |
|
316 |
@Override
|
317 |
public NewDataStoreParameters createNewStoreParameters(String explorerName, String providerName) throws InitializeException, ProviderNotRegisteredException { |
318 |
try {
|
319 |
DataServerExplorer explorer = this.openServerExplorer(explorerName, (DataServerExplorerParameters)null); |
320 |
return explorer.getAddParameters(providerName);
|
321 |
} catch (Exception ex) { |
322 |
throw new InitializeException(ex); |
323 |
} |
324 |
} |
325 |
|
326 |
@Override
|
327 |
public DataServerExplorerParameters createServerExplorerParameters(String explorerName) throws InitializeException, ProviderNotRegisteredException { |
328 |
if( explorerName == null ) { |
329 |
String msg = "Explorer name can't be null."; |
330 |
LOGGER.warn(msg); |
331 |
throw new IllegalArgumentException(msg); |
332 |
} |
333 |
DataFactory explorerFactory = this.getServerExplorerRegister().getFactory(explorerName);
|
334 |
if( explorerFactory == null ) { |
335 |
String msg = "Can't locate server explorer factory for '"+explorerName+"'."; |
336 |
LOGGER.warn(msg); |
337 |
throw new IllegalArgumentException(msg); |
338 |
} |
339 |
DataServerExplorerParameters params = (DataServerExplorerParameters) explorerFactory.createParameters(); |
340 |
return params;
|
341 |
} |
342 |
|
343 |
@Override
|
344 |
public DataStoreParameters createMemoryStoreParameters(String autoOrderAttributeName) throws InitializeException { |
345 |
try {
|
346 |
DataStoreParameters parameters = createStoreParameters(MemoryStoreProvider.NAME); |
347 |
if (autoOrderAttributeName != null) { |
348 |
parameters.setDynValue( |
349 |
MemoryStoreParameters.ORDER_PARAMETER_NAME, |
350 |
autoOrderAttributeName); |
351 |
} |
352 |
return parameters;
|
353 |
} catch (Exception ex) { |
354 |
throw new InitializeException(ex); |
355 |
} |
356 |
} |
357 |
|
358 |
@Override
|
359 |
public DataServerExplorer openServerExplorer(String explorerName, DataServerExplorerParameters parameters) throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException { |
360 |
if( explorerName == null ) { |
361 |
String msg = "Explorer name can't be null."; |
362 |
LOGGER.warn(msg); |
363 |
throw new IllegalArgumentException(msg); |
364 |
} |
365 |
DataFactory explorerFactory = this.getServerExplorerRegister().getFactory(explorerName);
|
366 |
if( explorerFactory == null ) { |
367 |
String msg = "Can't locate server explorer factory for '"+explorerName+"'."; |
368 |
LOGGER.warn(msg); |
369 |
throw new IllegalArgumentException(msg); |
370 |
} |
371 |
if (parameters == null) { |
372 |
parameters = (DataServerExplorerParameters) explorerFactory.createParameters(); |
373 |
} |
374 |
DataServerExplorer explorer = (DataServerExplorer) explorerFactory.create( |
375 |
parameters, |
376 |
new DefaultDataServerExplorerProviderServices()
|
377 |
); |
378 |
return explorer;
|
379 |
} |
380 |
|
381 |
@Override
|
382 |
public DataServerExplorer openServerExplorer(String explorerName, Object... arguments) throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException { |
383 |
if( arguments.length==1 && arguments[0] instanceof DataServerExplorerParameters ) { |
384 |
// Esto hace falta ya que desde scripting si se invoca a openServerExplorercon solo
|
385 |
// un parametro de tipo DataServerExplorerParameters llama ha este metodo en lugar de
|
386 |
// llamar al que toca.
|
387 |
return openServerExplorer(explorerName, (DataServerExplorerParameters)(arguments[0])); |
388 |
} |
389 |
if( explorerName == null ) { |
390 |
String msg = "Explorer name can't be null."; |
391 |
LOGGER.warn(msg); |
392 |
throw new IllegalArgumentException(msg); |
393 |
} |
394 |
if( (arguments.length % 2)!= 0 ) { |
395 |
throw new ValidateDataParametersException(); |
396 |
} |
397 |
DataFactory explorerFactory = this.getServerExplorerRegister().getFactory(explorerName);
|
398 |
DataServerExplorerParameters parameters = (DataServerExplorerParameters) explorerFactory.createParameters(); |
399 |
for( int i=0; i<arguments.length; i+=2 ) { |
400 |
String name = (String) arguments[i]; |
401 |
Object value = arguments[i+1]; |
402 |
parameters.setDynValue(name, value); |
403 |
} |
404 |
return this.openServerExplorer(explorerName, parameters); |
405 |
|
406 |
} |
407 |
|
408 |
/**
|
409 |
* @param parameters
|
410 |
* @return
|
411 |
* @throws org.gvsig.fmap.dal.exception.InitializeException
|
412 |
* @throws org.gvsig.fmap.dal.exception.ProviderNotRegisteredException
|
413 |
* @throws org.gvsig.fmap.dal.exception.ValidateDataParametersException
|
414 |
* @deprecated see openServerExplorer
|
415 |
*/
|
416 |
@Override
|
417 |
public DataServerExplorer createServerExplorer(
|
418 |
DataServerExplorerParameters parameters) throws InitializeException,
|
419 |
ProviderNotRegisteredException, ValidateDataParametersException { |
420 |
return openServerExplorer(parameters.getExplorerName(), parameters);
|
421 |
} |
422 |
|
423 |
/**
|
424 |
* @deprecated use openStore
|
425 |
* @param parameters
|
426 |
* @return
|
427 |
* @throws InitializeException
|
428 |
* @throws ProviderNotRegisteredException
|
429 |
* @throws ValidateDataParametersException
|
430 |
*/
|
431 |
@Override
|
432 |
public DataStore createStore(DataStoreParameters parameters)
|
433 |
throws InitializeException, ProviderNotRegisteredException,
|
434 |
ValidateDataParametersException { |
435 |
return openStore(parameters.getDataStoreName(), parameters);
|
436 |
} |
437 |
|
438 |
@Override
|
439 |
public DataStore openStore(String providerName, DataStoreParameters parameters) throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException { |
440 |
if( providerName == null ) { |
441 |
String msg = "Provider name can't be null."; |
442 |
LOGGER.warn(msg); |
443 |
throw new IllegalArgumentException(msg); |
444 |
} |
445 |
SimpleIdentityManager identityManager = ToolsLocator.getIdentityManager(); |
446 |
if (!identityManager.getCurrentIdentity().isAuthorized(READ_STORE_AUTHORIZATION, parameters, providerName)) {
|
447 |
throw new UnauthorizedException(READ_STORE_AUTHORIZATION, parameters, providerName); |
448 |
} |
449 |
|
450 |
parameters.validate(); |
451 |
|
452 |
String storeName = this.getStoreName(parameters); |
453 |
if( StringUtils.isEmpty(storeName) ) {
|
454 |
String msg = "Can't locate the store name from the parameters. parameters=" + parameters.toString(); |
455 |
LOGGER.warn(msg); |
456 |
throw new IllegalArgumentException(msg); |
457 |
} |
458 |
|
459 |
DataStoreFactory_v2_4 storeFactory = (DataStoreFactory_v2_4) this.getStoreRegister().getFactory(storeName);
|
460 |
if( storeFactory == null ) { |
461 |
String msg = "Can't locate store factory for '"+storeName+"'."; |
462 |
LOGGER.warn(msg); |
463 |
throw new IllegalArgumentException(msg); |
464 |
} |
465 |
DataFactory providerFactory = this.getStoreProviderRegister().getFactory(providerName);
|
466 |
if( providerFactory == null ) { |
467 |
String msg = "Can't locate provider factory for '"+providerName+"'."; |
468 |
LOGGER.warn(msg); |
469 |
throw new IllegalArgumentException(msg); |
470 |
} |
471 |
|
472 |
DataStore store = (DataStore) storeFactory.create(parameters, this);
|
473 |
DataStoreProvider provider = (DataStoreProvider) providerFactory.create(parameters, store); |
474 |
|
475 |
storeFactory.setProvider(store, provider); |
476 |
return store;
|
477 |
} |
478 |
|
479 |
public DataStore openStore(DataStoreParameters parameters, DataStoreProvider provider) {
|
480 |
String storeName = this.getStoreName(parameters); |
481 |
if( StringUtils.isEmpty(storeName) ) {
|
482 |
String msg = "Can't locate the store name from the parameters. parameters=" + parameters.toString(); |
483 |
LOGGER.warn(msg); |
484 |
throw new IllegalArgumentException(msg); |
485 |
} |
486 |
|
487 |
DataStoreFactory_v2_4 storeFactory = (DataStoreFactory_v2_4) this.getStoreRegister().getFactory(storeName);
|
488 |
if( storeFactory == null ) { |
489 |
String msg = "Can't locate store factory for '"+storeName+"'."; |
490 |
LOGGER.warn(msg); |
491 |
throw new IllegalArgumentException(msg); |
492 |
} |
493 |
DataStore store = (DataStore) storeFactory.create(parameters, this);
|
494 |
storeFactory.setProvider(store, provider); |
495 |
return store;
|
496 |
} |
497 |
|
498 |
@Override
|
499 |
public DataStore openStore(String provider, DynObject parameters) throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException { |
500 |
DataStoreParameters params = toDataStoreParameters(provider, parameters); |
501 |
DataStore store = openStore(params.getDataStoreName(), params); |
502 |
return store;
|
503 |
} |
504 |
|
505 |
@Override
|
506 |
public DataStore openStore(String providerName, Object... arguments) throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException { |
507 |
if( arguments.length == 1 ) { |
508 |
// Desde jython entra por este metodo en lugar de los especificos
|
509 |
// de DataStoreParameters o DynObject
|
510 |
if( arguments[0] instanceof DataStoreParameters ) { |
511 |
return this.openStore(providerName, (DataStoreParameters)(arguments[0])); |
512 |
} else if( arguments[0] instanceof DynObject ) { |
513 |
return this.openStore(providerName, (DynObject)(arguments[0])); |
514 |
} |
515 |
} |
516 |
if( (arguments.length % 2)!= 0 ) { |
517 |
throw new ValidateDataParametersException(); |
518 |
} |
519 |
if( providerName == null ) { |
520 |
String msg = "Provider name can't be null."; |
521 |
LOGGER.warn(msg); |
522 |
throw new IllegalArgumentException(msg); |
523 |
} |
524 |
DataFactory providerFactory = this.getStoreProviderRegister().getFactory(providerName);
|
525 |
DataStoreParameters parameters = (DataStoreParameters) providerFactory.createParameters(); |
526 |
for( int i=0; i<arguments.length; i+=2 ) { |
527 |
String name = (String) arguments[i]; |
528 |
Object value = arguments[i+1]; |
529 |
parameters.setDynValue(name, value); |
530 |
} |
531 |
return this.openStore(providerName, parameters); |
532 |
} |
533 |
|
534 |
@Override
|
535 |
public FeatureStore createMemoryStore(String autoOrderAttributeName) throws InitializeException { |
536 |
try {
|
537 |
DataStoreParameters parameters = createMemoryStoreParameters(autoOrderAttributeName); |
538 |
DataStore store = openStore(MemoryStoreProvider.NAME, parameters); |
539 |
return (FeatureStore) store;
|
540 |
} catch (Exception ex) { |
541 |
throw new InitializeException(ex); |
542 |
} |
543 |
} |
544 |
|
545 |
@Override
|
546 |
public DataStoreProviderFactory getStoreProviderFactory(String providerName) { |
547 |
if( providerName == null ) { |
548 |
String msg = "Provider name can't be null."; |
549 |
LOGGER.warn(msg); |
550 |
throw new IllegalArgumentException(msg); |
551 |
} |
552 |
DataFactory providerFactory = this.getStoreProviderRegister().getFactory(providerName);
|
553 |
return (DataStoreProviderFactory) providerFactory;
|
554 |
} |
555 |
|
556 |
@Override
|
557 |
public List<String> getStoreProviders() { |
558 |
return this.getStoreProviderRegister().getFactoryNames(); |
559 |
} |
560 |
|
561 |
@Override
|
562 |
public List<String> getStoreProviders(String explorerName) { |
563 |
if( explorerName == null ) { |
564 |
String msg = "Explorer name can't be null."; |
565 |
LOGGER.warn(msg); |
566 |
throw new IllegalArgumentException(msg); |
567 |
} |
568 |
try {
|
569 |
DataServerExplorer explorer = openServerExplorer(explorerName, (DataServerExplorerParameters)null);
|
570 |
List names = explorer.getDataStoreProviderNames();
|
571 |
return names;
|
572 |
} catch (Exception ex) { |
573 |
throw new RuntimeException("Can't get stores availables for explorer '" + explorerName + "'.", ex); |
574 |
} |
575 |
} |
576 |
|
577 |
@Override
|
578 |
public List<String> getExplorerProviders() { |
579 |
List<String> names = this.getServerExplorerRegister().getFactoryNames(); |
580 |
return names;
|
581 |
} |
582 |
|
583 |
@Override
|
584 |
public DataStoreProvider createProvider(DataStoreProviderServices providerServices, DataStoreParameters parameters) throws InitializeException, ProviderNotRegisteredException { |
585 |
|
586 |
String providerName = parameters.getDataStoreName();
|
587 |
DataFactory providerFactory = this.getStoreProviderRegister().getFactory(providerName);
|
588 |
if (providerFactory == null) { |
589 |
throw new ProviderNotRegisteredException(providerName); |
590 |
} |
591 |
while (true) { |
592 |
try {
|
593 |
DataStoreProvider provider = (DataStoreProvider) providerFactory.create( |
594 |
parameters, providerServices |
595 |
); |
596 |
return provider;
|
597 |
} catch (Exception e) { |
598 |
if (openErrorHandler == null) { |
599 |
throw new InitializeException(providerName, e); |
600 |
} |
601 |
boolean retry = openErrorHandler.canRetryOpen(e, parameters);
|
602 |
if (!retry) {
|
603 |
throw new InitializeException(providerName, e); |
604 |
} |
605 |
} |
606 |
} |
607 |
} |
608 |
|
609 |
@Override
|
610 |
public List<String> getFeatureIndexProviders() { |
611 |
List<String> names = this.getFeatureIndexRegister().getFactoryNames(); |
612 |
return names;
|
613 |
} |
614 |
|
615 |
@Override
|
616 |
public void setDefaultFeatureIndexProviderName(int dataType, String name) { |
617 |
this.defaultDataIndexProviders.put(dataType, name);
|
618 |
} |
619 |
|
620 |
@Override
|
621 |
public String getDefaultFeatureIndexProviderName(int dataType) { |
622 |
return this.defaultDataIndexProviders.get(dataType); |
623 |
} |
624 |
|
625 |
@Override
|
626 |
public FeatureIndexProviderServices createFeatureIndexProvider(
|
627 |
String name,
|
628 |
FeatureStore store, |
629 |
FeatureType type, |
630 |
String indexName,
|
631 |
FeatureAttributeDescriptor attr |
632 |
) throws InitializeException, ProviderNotRegisteredException {
|
633 |
|
634 |
if (name == null) { |
635 |
name = getDefaultFeatureIndexProviderName(attr.getType()); |
636 |
} |
637 |
|
638 |
if (name == null) { |
639 |
throw new InitializeException( |
640 |
"There not any index provider registered.", null); |
641 |
} |
642 |
DataFactory indexfactory = this.getFeatureIndexRegister().getFactory(name);
|
643 |
if (indexfactory == null) { |
644 |
throw new InitializeException( |
645 |
"There not any index provider registered with name '" + name + "'.", null); |
646 |
|
647 |
} |
648 |
FeatureIndexProvider provider = (FeatureIndexProvider) indexfactory.create(null, null); |
649 |
|
650 |
FeatureIndexProviderServices services = new DefaultFeatureIndex(
|
651 |
(FeatureStoreProviderServices) store, |
652 |
type, |
653 |
provider, |
654 |
attr.getName(), |
655 |
indexName |
656 |
); |
657 |
services.initialize(); |
658 |
return services;
|
659 |
|
660 |
} |
661 |
|
662 |
@Override
|
663 |
public String getTemporaryDirectory() { |
664 |
FoldersManager manager = ToolsLocator.getFoldersManager(); |
665 |
File folder = manager.getUniqueTemporaryFile("_daltmp_"); |
666 |
return folder.getAbsolutePath();
|
667 |
} |
668 |
|
669 |
@Override
|
670 |
public DataStoreParameters createStoreParameters(DynStruct struct) throws InitializeException, ProviderNotRegisteredException { |
671 |
if (!(struct instanceof DynStruct_v2)) { |
672 |
throw new IllegalArgumentException("A DynStruct_v2 is required."); |
673 |
} |
674 |
Tags tags = ((DynStruct_v2) struct).getTags(); |
675 |
return this.createStoreParameters(tags); |
676 |
} |
677 |
|
678 |
@Override
|
679 |
public DataStoreParameters createStoreParameters(Tags tags) throws InitializeException, ProviderNotRegisteredException { |
680 |
String providerName = (String) tags.get(TAG_DAL_OPENSTORE + "provider"); |
681 |
if (providerName == null) { |
682 |
throw new IllegalArgumentException("Tag DAL.OpenStore.provider is missing in struct."); |
683 |
} |
684 |
int prefixlen = TAG_DAL_OPENSTORE.length();
|
685 |
DataStoreParameters parameters = this.createStoreParameters(providerName);
|
686 |
for (String key : tags) { |
687 |
if (key.startsWith(TAG_DAL_OPENSTORE)) {
|
688 |
parameters.setDynValue(key.substring(prefixlen), tags.get(key)); |
689 |
} |
690 |
} |
691 |
return parameters;
|
692 |
} |
693 |
|
694 |
@Override
|
695 |
public DataStore openStore(DynStruct struct) throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException { |
696 |
DataStoreParameters paramters = this.createStoreParameters(struct);
|
697 |
DataStore store = this.openStore(paramters.getDataStoreName(), paramters);
|
698 |
return store;
|
699 |
} |
700 |
|
701 |
@Override
|
702 |
public void newStore(String explorerName, String providerName, NewDataStoreParameters parameters, boolean overwrite) throws InitializeException, ProviderNotRegisteredException, ValidateDataParametersException { |
703 |
if( explorerName == null ) { |
704 |
String msg = "Explorer name can't be null."; |
705 |
LOGGER.warn(msg); |
706 |
throw new IllegalArgumentException(msg); |
707 |
} |
708 |
if( providerName == null ) { |
709 |
String msg = "Provider name can't be null."; |
710 |
LOGGER.warn(msg); |
711 |
throw new IllegalArgumentException(msg); |
712 |
} |
713 |
|
714 |
SimpleIdentityManager identityManager = ToolsLocator.getIdentityManager(); |
715 |
if (!identityManager.getCurrentIdentity().isAuthorized(CREATE_STORE_AUTHORIZATION, parameters, providerName)) {
|
716 |
throw new UnauthorizedException(CREATE_STORE_AUTHORIZATION, parameters, providerName); |
717 |
} |
718 |
parameters.validate(); |
719 |
try {
|
720 |
DataServerExplorerParameters explorerParameters = this.createServerExplorerParameters(explorerName);
|
721 |
DataServerExplorer server = this.openServerExplorer(explorerName, explorerParameters);
|
722 |
server.add(providerName, parameters, overwrite); |
723 |
} catch (Exception e) { |
724 |
throw new InitializeException(e); |
725 |
} |
726 |
} |
727 |
|
728 |
@Override
|
729 |
@Deprecated
|
730 |
public Evaluator createExpresion(String expression) throws InitializeException { |
731 |
Expression exp = ExpressionEvaluatorLocator.getManager().createExpression();
|
732 |
exp.setPhrase(expression); |
733 |
return this.createExpresion(exp); |
734 |
} |
735 |
|
736 |
@Override
|
737 |
@Deprecated
|
738 |
public Evaluator createExpresion(Expression expression) throws InitializeException { |
739 |
DefaultExpressionEvaluator exp = new DefaultExpressionEvaluator(expression);
|
740 |
return exp;
|
741 |
} |
742 |
|
743 |
|
744 |
@Override
|
745 |
public Evaluator createFilter(String expression) throws InitializeException { |
746 |
Expression exp = ExpressionEvaluatorLocator.getManager().createExpression();
|
747 |
exp.setPhrase(expression); |
748 |
return this.createFilter(exp); |
749 |
} |
750 |
|
751 |
@Override
|
752 |
public Evaluator createFilter(Expression expression) throws InitializeException { |
753 |
DefaultExpressionEvaluator exp = new DefaultExpressionEvaluator(expression);
|
754 |
return exp;
|
755 |
} |
756 |
|
757 |
@Override
|
758 |
public FeaturePagingHelper createFeaturePagingHelper(
|
759 |
FeatureStore featureStore, int pageSize) throws BaseException { |
760 |
return new FeaturePagingHelperImpl(featureStore, pageSize); |
761 |
} |
762 |
|
763 |
@Override
|
764 |
public FeaturePagingHelper createFeaturePagingHelper(
|
765 |
FeatureStore featureStore, FeatureQuery featureQuery, int pageSize)
|
766 |
throws BaseException {
|
767 |
return new FeaturePagingHelperImpl(featureStore, featureQuery, pageSize); |
768 |
} |
769 |
|
770 |
@Override
|
771 |
public void setOpenErrorHandler(OpenErrorHandler handler) { |
772 |
openErrorHandler = handler; |
773 |
} |
774 |
|
775 |
@Override
|
776 |
public OpenErrorHandler getOpenErrorHandler() {
|
777 |
return this.openErrorHandler; |
778 |
} |
779 |
|
780 |
@Override
|
781 |
public EditableFeatureType createFeatureType() {
|
782 |
return new DefaultEditableFeatureType(null); |
783 |
} |
784 |
|
785 |
@Override
|
786 |
public DataServerExplorerPool getDataServerExplorerPool() {
|
787 |
if (this.dataServerExplorerPool == null) { |
788 |
this.dataServerExplorerPool = new DefaultDataServerExplorerPool(); |
789 |
} |
790 |
return this.dataServerExplorerPool; |
791 |
} |
792 |
|
793 |
@Override
|
794 |
public void setDataServerExplorerPool(DataServerExplorerPool pool) { |
795 |
this.dataServerExplorerPool = pool;
|
796 |
} |
797 |
|
798 |
public DataStoreParameters toDataStoreParameters(String provider, DynObject params) throws InitializeException, ProviderNotRegisteredException { |
799 |
if (params instanceof DataStoreParameters) { |
800 |
return (DataStoreParameters) params;
|
801 |
} |
802 |
String providerName;
|
803 |
try {
|
804 |
providerName = (String) params.getDynValue(DataStoreProviderServices.PROVIDER_PARAMTER_NAME);
|
805 |
} catch (Exception ex) { |
806 |
providerName = provider; |
807 |
} |
808 |
DataStoreParameters parameters = this.createStoreParameters(providerName);
|
809 |
ToolsLocator.getDynObjectManager().copy(params, parameters); |
810 |
return parameters;
|
811 |
} |
812 |
|
813 |
@Override
|
814 |
public List<DataType> getDataTypes() { |
815 |
if (dataTypes == null) { |
816 |
DataTypesManager manager = ToolsLocator.getDataTypesManager(); |
817 |
dataTypes = new ArrayList<>(); |
818 |
dataTypes.add(manager.get(DataTypes.STRING)); |
819 |
dataTypes.add(manager.get(DataTypes.BOOLEAN)); |
820 |
dataTypes.add(manager.get(DataTypes.INT)); |
821 |
dataTypes.add(manager.get(DataTypes.DOUBLE)); |
822 |
dataTypes.add(manager.get(DataTypes.DATE)); |
823 |
dataTypes.add(manager.get(DataTypes.GEOMETRY)); |
824 |
} |
825 |
return dataTypes;
|
826 |
} |
827 |
|
828 |
@Override
|
829 |
public void setResourcesLoader(ClassLoader loader) { |
830 |
this.resourcesLoader = loader;
|
831 |
} |
832 |
|
833 |
@Override
|
834 |
public void setResourcesLoader(File folder) { |
835 |
if (folder == null) { |
836 |
this.resourcesLoader = null; |
837 |
return;
|
838 |
} |
839 |
try {
|
840 |
URL[] urls = new URL[]{folder.toURI().toURL()}; |
841 |
this.resourcesLoader = new URLClassLoader(urls); |
842 |
} catch (Exception ex) { |
843 |
throw new IllegalArgumentException("Can't create a ClassLoader from '" + folder.toString() + "'.", ex); |
844 |
} |
845 |
} |
846 |
|
847 |
@Override
|
848 |
public URL getResource(Object reourceLoader, String name) { |
849 |
URL x;
|
850 |
if (this.resourcesLoader != null) { |
851 |
x = this.resourcesLoader.getResource(name);
|
852 |
if (x != null) { |
853 |
return x;
|
854 |
} |
855 |
} |
856 |
x = reourceLoader.getClass().getResource(name); |
857 |
return x;
|
858 |
} |
859 |
|
860 |
@Override
|
861 |
public InputStream getResourceAsStream(Object reourceLoader, String name) { |
862 |
InputStream x;
|
863 |
if (this.resourcesLoader != null) { |
864 |
x = this.resourcesLoader.getResourceAsStream(name);
|
865 |
if (x != null) { |
866 |
return x;
|
867 |
} |
868 |
} |
869 |
x = reourceLoader.getClass().getResourceAsStream(name); |
870 |
return x;
|
871 |
} |
872 |
|
873 |
@Override
|
874 |
public ExpressionBuilder createExpressionBuilder() {
|
875 |
return ExpressionEvaluatorLocator.getManager().createExpressionBuilder();
|
876 |
} |
877 |
|
878 |
public void registerFeatureCacheProvider( |
879 |
FeatureCacheProviderFactory providerFactory) { |
880 |
ToolsLocator.getExtensionPointManager() |
881 |
.add(DATA_MANAGER_CACHE, DATA_MANAGER_CACHE_DESCRIPTION) |
882 |
.append(providerFactory.getName(), "", providerFactory);
|
883 |
} |
884 |
|
885 |
public FeatureCacheProvider createFeatureCacheProvider(String name, |
886 |
DynObject parameters) throws DataException {
|
887 |
if (name == null) { |
888 |
throw new InitializeException( |
889 |
"It is necessary to provide a cache name", null); |
890 |
} |
891 |
if (parameters == null) { |
892 |
throw new InitializeException( |
893 |
"It is necessary to provide parameters to create the explorer",
|
894 |
null);
|
895 |
} |
896 |
FeatureCacheProviderFactory featureCacheProviderFactory; |
897 |
try {
|
898 |
featureCacheProviderFactory = |
899 |
(FeatureCacheProviderFactory) ToolsLocator |
900 |
.getExtensionPointManager().get(DATA_MANAGER_CACHE) |
901 |
.create(name); |
902 |
if (featureCacheProviderFactory == null) { |
903 |
throw new ProviderNotRegisteredException(name); |
904 |
} |
905 |
return featureCacheProviderFactory.createCacheProvider(parameters);
|
906 |
} catch (InstantiationException e) { |
907 |
throw new InitializeException(e); |
908 |
} catch (IllegalAccessException e) { |
909 |
throw new InitializeException(e); |
910 |
} |
911 |
} |
912 |
|
913 |
@Override
|
914 |
public List getFeatureCacheProviders() { |
915 |
ExtensionPoint extensionPoint = |
916 |
ToolsLocator.getExtensionPointManager().get(DATA_MANAGER_CACHE); |
917 |
if (extensionPoint != null) { |
918 |
return ToolsLocator.getExtensionPointManager()
|
919 |
.get(DATA_MANAGER_CACHE).getNames(); |
920 |
} else {
|
921 |
return new ArrayList(); |
922 |
} |
923 |
} |
924 |
|
925 |
@Override
|
926 |
public DynObject createCacheParameters(String name) |
927 |
throws InitializeException, ProviderNotRegisteredException {
|
928 |
if (name == null) { |
929 |
throw new InitializeException( |
930 |
"It is necessary to provide a cache name", null); |
931 |
} |
932 |
FeatureCacheProviderFactory featureCacheProviderFactory; |
933 |
try {
|
934 |
featureCacheProviderFactory = |
935 |
(FeatureCacheProviderFactory) ToolsLocator |
936 |
.getExtensionPointManager().get(DATA_MANAGER_CACHE) |
937 |
.create(name); |
938 |
if (featureCacheProviderFactory == null) { |
939 |
throw new ProviderNotRegisteredException(name); |
940 |
} |
941 |
return featureCacheProviderFactory.createParameters();
|
942 |
} catch (InstantiationException e) { |
943 |
throw new InitializeException(e); |
944 |
} catch (IllegalAccessException e) { |
945 |
throw new InitializeException(e); |
946 |
} |
947 |
} |
948 |
|
949 |
@Override
|
950 |
public void createFileStore(String providerName, NewDataStoreParameters params, boolean overwrite) throws DataException { |
951 |
DataManagerProviderServices dataManager = DALSPILocator.getDataManagerProviderServices(); |
952 |
DataServerExplorerParameters eparams = null;
|
953 |
DataServerExplorer serverExplorer; |
954 |
try {
|
955 |
serverExplorer = dataManager.openServerExplorer(FILESYSTEM_EXPLORER_NAME, eparams); |
956 |
} catch (ValidateDataParametersException | InitializeException | ProviderNotRegisteredException e) {
|
957 |
throw new OpenException(FILESYSTEM_EXPLORER_NAME, e); |
958 |
} |
959 |
|
960 |
try {
|
961 |
serverExplorer.add(providerName, params, overwrite); |
962 |
} catch (DataException e) {
|
963 |
throw new CreateFileStoreException(e, providerName); |
964 |
} |
965 |
} |
966 |
|
967 |
@Override
|
968 |
public FeatureSymbolTable createFeatureSymbolTable() {
|
969 |
FeatureSymbolTable symbolTable = new DefaultFeatureSymbolTable();
|
970 |
return symbolTable;
|
971 |
} |
972 |
|
973 |
@Override
|
974 |
public FeatureAttributeEmulatorExpression createFeatureAttributeEmulatorExpression(FeatureType type, Expression expression) { |
975 |
FeatureAttributeEmulatorExpression emulator = new DefaultFeatureAttributeEmulatorExpression(type, expression);
|
976 |
return emulator;
|
977 |
} |
978 |
|
979 |
@Override
|
980 |
public void registerDataProfile(DataProfile profile) { |
981 |
if( profile==null ) { |
982 |
return;
|
983 |
} |
984 |
if( this.dataProfiles==null ) { |
985 |
this.dataProfiles = new ArrayList<>(); |
986 |
this.dataProfiles.add(profile);
|
987 |
return;
|
988 |
} |
989 |
for (DataProfile theProfile : this.dataProfiles) { |
990 |
if( theProfile.getID().equalsIgnoreCase(profile.getID()) ) {
|
991 |
return;
|
992 |
} |
993 |
} |
994 |
this.dataProfiles.add(profile);
|
995 |
} |
996 |
|
997 |
@Override
|
998 |
public List<DataProfile> getDataProfiles() { |
999 |
if( this.dataProfiles==null ) { |
1000 |
return null; |
1001 |
} |
1002 |
return Collections.unmodifiableList(this.dataProfiles); |
1003 |
} |
1004 |
|
1005 |
@Override
|
1006 |
public DataProfile getDataProfile(String name) { |
1007 |
if( StringUtils.isBlank(name) ) {
|
1008 |
return null; |
1009 |
} |
1010 |
for (DataProfile theProfile : this.dataProfiles) { |
1011 |
if( name.equalsIgnoreCase(theProfile.getName()) ) {
|
1012 |
return theProfile;
|
1013 |
} |
1014 |
} |
1015 |
return null; |
1016 |
} |
1017 |
|
1018 |
private StoresRepository storesRepository;
|
1019 |
|
1020 |
@Override
|
1021 |
public StoresRepository getStoresRepository() {
|
1022 |
if( this.storesRepository==null ) { |
1023 |
this.storesRepository = new BaseStoresRepository("DAL"); |
1024 |
} |
1025 |
return this.storesRepository; |
1026 |
} |
1027 |
|
1028 |
@Override
|
1029 |
public DatabaseWorkspaceManager createDatabaseWorkspaceManager(DataServerExplorerParameters connection) {
|
1030 |
DatabaseWorkspaceManager workspace = new DefaultDatabaseWorkspaceManager(connection);
|
1031 |
return workspace;
|
1032 |
} |
1033 |
|
1034 |
@Override
|
1035 |
public void writeDALResource(ResourcesStorage resources, DataStore store) { |
1036 |
ResourcesStorage.Resource resource = null;
|
1037 |
try {
|
1038 |
if( resources == null || resources.isReadOnly() ) { |
1039 |
return;
|
1040 |
} |
1041 |
resource = resources.getResource("dal");
|
1042 |
if( resource == null || resource.isReadOnly() ) { |
1043 |
return;
|
1044 |
} |
1045 |
DALFile dalFile = DALFile.getDALFile(); |
1046 |
dalFile.setStore((DefaultFeatureStore) store); |
1047 |
if( !dalFile.isEmpty() ) {
|
1048 |
dalFile.write(resource); |
1049 |
} |
1050 |
} catch (Throwable ex) { |
1051 |
LOGGER.warn("Can't save DAL resource", ex);
|
1052 |
} finally {
|
1053 |
IOUtils.closeQuietly(resource); |
1054 |
} |
1055 |
|
1056 |
|
1057 |
} |
1058 |
|
1059 |
@Override
|
1060 |
public void writeDALResource(ResourcesStorage resources, FeatureType featureType) { |
1061 |
ResourcesStorage.Resource resource = null;
|
1062 |
try {
|
1063 |
if( resources == null || resources.isReadOnly() ) { |
1064 |
return;
|
1065 |
} |
1066 |
resource = resources.getResource("dal");
|
1067 |
if( resource == null || resource.isReadOnly() ) { |
1068 |
return;
|
1069 |
} |
1070 |
DALFile dalFile = DALFile.getDALFile(); |
1071 |
dalFile.setFeatureType(featureType); |
1072 |
if( !dalFile.isEmpty() ) {
|
1073 |
dalFile.write(resource); |
1074 |
} |
1075 |
} catch (Throwable ex) { |
1076 |
LOGGER.warn("Can't save DAL resource", ex);
|
1077 |
} finally {
|
1078 |
IOUtils.closeQuietly(resource); |
1079 |
} |
1080 |
} |
1081 |
} |