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 / DefaultDatabaseWorkspaceManager.java @ 44390
History | View | Annotate | Download (17.5 KB)
1 | 44304 | jjdelcerro | package org.gvsig.fmap.dal.impl; |
---|---|---|---|
2 | 44297 | jjdelcerro | |
3 | 44346 | jjdelcerro | import java.io.File; |
4 | 44304 | jjdelcerro | import org.gvsig.fmap.dal.DatabaseWorkspaceManager; |
5 | 44297 | jjdelcerro | import org.apache.commons.lang3.StringUtils; |
6 | 44346 | jjdelcerro | import org.apache.commons.lang3.mutable.Mutable; |
7 | import org.apache.commons.lang3.mutable.MutableObject; |
||
8 | 44304 | jjdelcerro | import org.gvsig.expressionevaluator.ExpressionBuilder; |
9 | import org.gvsig.expressionevaluator.ExpressionUtils; |
||
10 | 44297 | jjdelcerro | import org.gvsig.fmap.dal.DALLocator; |
11 | import org.gvsig.fmap.dal.DataManager; |
||
12 | 44304 | jjdelcerro | import org.gvsig.fmap.dal.DataServerExplorer; |
13 | import org.gvsig.fmap.dal.DataServerExplorerParameters; |
||
14 | 44297 | jjdelcerro | import org.gvsig.fmap.dal.DataStoreParameters; |
15 | import org.gvsig.fmap.dal.DataTypes; |
||
16 | 44346 | jjdelcerro | import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.CONFIG_NAME_STORESREPOSITORYID; |
17 | import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.CONFIG_NAME_STORESREPOSITORYLABEL; |
||
18 | import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.FIELD_CONFIGURATION_NAME; |
||
19 | import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.FIELD_CONFIGURATION_VALUE; |
||
20 | 44297 | jjdelcerro | import org.gvsig.fmap.dal.StoresRepository; |
21 | 44304 | jjdelcerro | import org.gvsig.fmap.dal.feature.EditableFeature; |
22 | 44297 | jjdelcerro | import org.gvsig.fmap.dal.feature.EditableFeatureType; |
23 | 44304 | jjdelcerro | import org.gvsig.fmap.dal.feature.Feature; |
24 | 44297 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureStore; |
25 | 44304 | jjdelcerro | import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.FIELD_REPOSITORY_NAME; |
26 | 44346 | jjdelcerro | import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.FIELD_REPOSITORY_PARAMETERS; |
27 | import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.FIELD_RESOURCES_NAME; |
||
28 | import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.FIELD_RESOURCES_RESOURCE; |
||
29 | import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.TABLE_CONFIGURATION; |
||
30 | import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.TABLE_CONFIGURATION_NAME; |
||
31 | import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.TABLE_REPOSITORY; |
||
32 | import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.TABLE_REPOSITORY_NAME; |
||
33 | import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.TABLE_RESOURCES; |
||
34 | import static org.gvsig.fmap.dal.DatabaseWorkspaceManager.TABLE_RESOURCES_NAME; |
||
35 | 44304 | jjdelcerro | import org.gvsig.fmap.dal.feature.NewFeatureStoreParameters; |
36 | 44346 | jjdelcerro | import org.gvsig.tools.resourcesstorage.FilesResourcesStorage; |
37 | import org.gvsig.tools.resourcesstorage.ResourcesStorage; |
||
38 | 44297 | jjdelcerro | import org.slf4j.Logger; |
39 | import org.slf4j.LoggerFactory; |
||
40 | |||
41 | /**
|
||
42 | *
|
||
43 | * @author jjdelcerro
|
||
44 | */
|
||
45 | @SuppressWarnings("UseSpecificCatch") |
||
46 | 44346 | jjdelcerro | public class DefaultDatabaseWorkspaceManager |
47 | implements DatabaseWorkspaceManager
|
||
48 | { |
||
49 | 44297 | jjdelcerro | |
50 | 44304 | jjdelcerro | private static final Logger LOGGER = LoggerFactory.getLogger(DefaultDatabaseWorkspaceManager.class); |
51 | 44346 | jjdelcerro | |
52 | private final DataServerExplorerParameters serverParameters; |
||
53 | 44304 | jjdelcerro | private Boolean existsConfiguration = null; |
54 | private StoresRepository storesRepository;
|
||
55 | 44380 | jjdelcerro | private Mutable<File> alternativeResourcesFolder = null; |
56 | 44297 | jjdelcerro | |
57 | 44346 | jjdelcerro | |
58 | public DefaultDatabaseWorkspaceManager(DataServerExplorerParameters serverParameters) {
|
||
59 | this.serverParameters = serverParameters;
|
||
60 | 44297 | jjdelcerro | } |
61 | 44390 | jjdelcerro | |
62 | @Override
|
||
63 | public String toString() { |
||
64 | return this.getLabel(); |
||
65 | } |
||
66 | 44297 | jjdelcerro | |
67 | @Override
|
||
68 | 44346 | jjdelcerro | public String getId() { |
69 | String id = this.get(CONFIG_NAME_STORESREPOSITORYID); |
||
70 | return id;
|
||
71 | } |
||
72 | |||
73 | @Override
|
||
74 | public String getLabel() { |
||
75 | String label = this.get(CONFIG_NAME_STORESREPOSITORYLABEL); |
||
76 | return label;
|
||
77 | } |
||
78 | 44390 | jjdelcerro | |
79 | @Override
|
||
80 | public DatabaseWorkspaceManager getValue() {
|
||
81 | return this; |
||
82 | } |
||
83 | 44346 | jjdelcerro | |
84 | @Override
|
||
85 | 44304 | jjdelcerro | public boolean existsTable(int tableid) { |
86 | switch(tableid) {
|
||
87 | case TABLE_RESOURCES:
|
||
88 | return this.existsTable(TABLE_RESOURCES_NAME); |
||
89 | case TABLE_REPOSITORY:
|
||
90 | return this.existsTable(TABLE_REPOSITORY_NAME); |
||
91 | case TABLE_CONFIGURATION:
|
||
92 | return this.existsTable(TABLE_CONFIGURATION_NAME); |
||
93 | default:
|
||
94 | throw new IllegalArgumentException("Invalid table identitier "+tableid); |
||
95 | } |
||
96 | 44297 | jjdelcerro | } |
97 | 44304 | jjdelcerro | |
98 | @Override
|
||
99 | public void createTable(int tableid) { |
||
100 | switch(tableid) {
|
||
101 | case TABLE_RESOURCES:
|
||
102 | createTableResources(); |
||
103 | break;
|
||
104 | case TABLE_REPOSITORY:
|
||
105 | createTableRepository(); |
||
106 | break;
|
||
107 | case TABLE_CONFIGURATION:
|
||
108 | createTableConfiguration(); |
||
109 | break;
|
||
110 | default:
|
||
111 | throw new IllegalArgumentException("Invalid table identitier "+tableid); |
||
112 | } |
||
113 | } |
||
114 | |||
115 | @Override
|
||
116 | public void dropTable(int tableid) { |
||
117 | switch(tableid) {
|
||
118 | case TABLE_RESOURCES:
|
||
119 | this.dropTable(TABLE_RESOURCES_NAME);
|
||
120 | break;
|
||
121 | case TABLE_REPOSITORY:
|
||
122 | this.dropTable(TABLE_REPOSITORY_NAME);
|
||
123 | break;
|
||
124 | case TABLE_CONFIGURATION:
|
||
125 | this.dropTable(TABLE_CONFIGURATION_NAME);
|
||
126 | break;
|
||
127 | default:
|
||
128 | throw new IllegalArgumentException("Invalid table identitier "+tableid); |
||
129 | } |
||
130 | } |
||
131 | |||
132 | @Override
|
||
133 | public FeatureStore getTable(int tableid) { |
||
134 | switch(tableid) {
|
||
135 | case TABLE_RESOURCES:
|
||
136 | return this.getTable(TABLE_RESOURCES_NAME); |
||
137 | case TABLE_REPOSITORY:
|
||
138 | return this.getTable(TABLE_REPOSITORY_NAME); |
||
139 | case TABLE_CONFIGURATION:
|
||
140 | return this.getTable(TABLE_CONFIGURATION_NAME); |
||
141 | default:
|
||
142 | throw new IllegalArgumentException("Invalid table identitier "+tableid); |
||
143 | } |
||
144 | } |
||
145 | |||
146 | 44297 | jjdelcerro | private boolean existsTable(String tableName) { |
147 | try {
|
||
148 | DataManager dataManager = DALLocator.getDataManager(); |
||
149 | 44304 | jjdelcerro | DataServerExplorer server = dataManager.openServerExplorer( |
150 | 44346 | jjdelcerro | this.serverParameters.getProviderName(),
|
151 | this.serverParameters
|
||
152 | 44297 | jjdelcerro | ); |
153 | for (DataStoreParameters params : server.list()) {
|
||
154 | 44304 | jjdelcerro | String theTableName = (String) params.getDynValue("Table"); |
155 | 44297 | jjdelcerro | if( StringUtils.equals(theTableName, tableName) ) {
|
156 | return true; |
||
157 | } |
||
158 | } |
||
159 | } catch (Exception ex) { |
||
160 | LOGGER.warn("Can't check if the table '"+tableName+"' exists.",ex); |
||
161 | } |
||
162 | return false; |
||
163 | } |
||
164 | |||
165 | private FeatureStore getTable(String tableName) { |
||
166 | try {
|
||
167 | DataManager dataManager = DALLocator.getDataManager(); |
||
168 | 44304 | jjdelcerro | DataServerExplorer server = dataManager.openServerExplorer( |
169 | 44346 | jjdelcerro | this.serverParameters.getProviderName(),
|
170 | this.serverParameters
|
||
171 | 44297 | jjdelcerro | ); |
172 | DataStoreParameters params = server.get(tableName); |
||
173 | if( params!=null ) { |
||
174 | FeatureStore store = (FeatureStore) dataManager.openStore( |
||
175 | 44326 | jjdelcerro | params.getProviderName(), |
176 | 44297 | jjdelcerro | params |
177 | ); |
||
178 | return store;
|
||
179 | } |
||
180 | } catch (Exception ex) { |
||
181 | LOGGER.warn("Can't open table '"+tableName+"'.",ex); |
||
182 | } |
||
183 | return null; |
||
184 | } |
||
185 | |||
186 | private void dropTable(String tableName) { |
||
187 | try {
|
||
188 | DataManager dataManager = DALLocator.getDataManager(); |
||
189 | 44304 | jjdelcerro | DataServerExplorer server = dataManager.openServerExplorer( |
190 | 44346 | jjdelcerro | this.serverParameters.getProviderName(),
|
191 | this.serverParameters
|
||
192 | 44297 | jjdelcerro | ); |
193 | DataStoreParameters params = server.get(tableName); |
||
194 | if( params!=null ) { |
||
195 | server.remove(params); |
||
196 | } |
||
197 | } catch (Exception ex) { |
||
198 | LOGGER.warn("Can't drop table '"+tableName+"'.",ex); |
||
199 | } |
||
200 | } |
||
201 | |||
202 | 44304 | jjdelcerro | private void createTableResources() { |
203 | String tableName = TABLE_RESOURCES_NAME;
|
||
204 | 44297 | jjdelcerro | try {
|
205 | DataManager dataManager = DALLocator.getDataManager(); |
||
206 | 44304 | jjdelcerro | DataServerExplorer server = dataManager.openServerExplorer( |
207 | 44346 | jjdelcerro | this.serverParameters.getProviderName(),
|
208 | this.serverParameters
|
||
209 | 44297 | jjdelcerro | ); |
210 | 44304 | jjdelcerro | NewFeatureStoreParameters params = (NewFeatureStoreParameters) server.getAddParameters(tableName); |
211 | 44297 | jjdelcerro | EditableFeatureType ft = params.getDefaultFeatureType(); |
212 | 44304 | jjdelcerro | ft.add(FIELD_RESOURCES_NAME, DataTypes.STRING, 150)
|
213 | 44297 | jjdelcerro | .setAllowNull(false)
|
214 | .setIsPrimaryKey(true);
|
||
215 | 44304 | jjdelcerro | ft.add(FIELD_RESOURCES_RESOURCE, DataTypes.BYTEARRAY) |
216 | 44297 | jjdelcerro | .setAllowNull(true);
|
217 | server.add(tableName, params, false);
|
||
218 | } catch (Exception ex) { |
||
219 | LOGGER.warn("Can't create table '"+tableName+"'.",ex); |
||
220 | } |
||
221 | } |
||
222 | |||
223 | 44304 | jjdelcerro | private void createTableRepository() { |
224 | String tableName = TABLE_REPOSITORY_NAME;
|
||
225 | try {
|
||
226 | DataManager dataManager = DALLocator.getDataManager(); |
||
227 | DataServerExplorer server = dataManager.openServerExplorer( |
||
228 | 44346 | jjdelcerro | this.serverParameters.getProviderName(),
|
229 | this.serverParameters
|
||
230 | 44304 | jjdelcerro | ); |
231 | NewFeatureStoreParameters params = (NewFeatureStoreParameters) server.getAddParameters(tableName); |
||
232 | EditableFeatureType ft = params.getDefaultFeatureType(); |
||
233 | ft.add(FIELD_REPOSITORY_NAME, DataTypes.STRING, 150)
|
||
234 | .setAllowNull(false)
|
||
235 | .setIsPrimaryKey(true);
|
||
236 | ft.add(FIELD_REPOSITORY_PARAMETERS, DataTypes.BYTEARRAY) |
||
237 | .setAllowNull(true);
|
||
238 | server.add(tableName, params, false);
|
||
239 | } catch (Exception ex) { |
||
240 | LOGGER.warn("Can't create table '"+tableName+"'.",ex); |
||
241 | } |
||
242 | 44297 | jjdelcerro | } |
243 | |||
244 | 44304 | jjdelcerro | private void createTableConfiguration() { |
245 | String tableName = TABLE_CONFIGURATION_NAME;
|
||
246 | try {
|
||
247 | DataManager dataManager = DALLocator.getDataManager(); |
||
248 | DataServerExplorer server = dataManager.openServerExplorer( |
||
249 | 44346 | jjdelcerro | this.serverParameters.getProviderName(),
|
250 | this.serverParameters
|
||
251 | 44304 | jjdelcerro | ); |
252 | NewFeatureStoreParameters params = (NewFeatureStoreParameters) server.getAddParameters(tableName); |
||
253 | EditableFeatureType ft = params.getDefaultFeatureType(); |
||
254 | ft.add(FIELD_CONFIGURATION_NAME, DataTypes.STRING, 200)
|
||
255 | .setAllowNull(false)
|
||
256 | .setIsPrimaryKey(true);
|
||
257 | ft.add(FIELD_CONFIGURATION_VALUE, DataTypes.STRING, 200)
|
||
258 | .setAllowNull(true);
|
||
259 | server.add(tableName, params, false);
|
||
260 | } catch (Exception ex) { |
||
261 | LOGGER.warn("Can't create table '"+tableName+"'.",ex); |
||
262 | } |
||
263 | 44297 | jjdelcerro | } |
264 | 44304 | jjdelcerro | |
265 | private boolean existsConfiguration() { |
||
266 | if( this.existsConfiguration==null ) { |
||
267 | this.existsConfiguration = this.existsTable(TABLE_CONFIGURATION_NAME); |
||
268 | } |
||
269 | return this.existsConfiguration; |
||
270 | } |
||
271 | 44297 | jjdelcerro | |
272 | @Override
|
||
273 | public String get(String name) { |
||
274 | 44304 | jjdelcerro | try {
|
275 | if( !this.existsConfiguration() ) { |
||
276 | return null; |
||
277 | } |
||
278 | FeatureStore store = this.getTable(TABLE_CONFIGURATION);
|
||
279 | if( store == null ) { |
||
280 | return null; |
||
281 | } |
||
282 | ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder(); |
||
283 | String filter = builder.eq(
|
||
284 | builder.column(FIELD_CONFIGURATION_NAME), |
||
285 | builder.constant(name) |
||
286 | ).toString(); |
||
287 | Feature feature = store.findFirst(filter); |
||
288 | if( feature == null ) { |
||
289 | return null; |
||
290 | } |
||
291 | String value = feature.getString(FIELD_CONFIGURATION_VALUE);
|
||
292 | return value;
|
||
293 | |||
294 | } catch (Exception ex) { |
||
295 | LOGGER.warn("Can't read configuration value '"+name+"'", ex); |
||
296 | return null; |
||
297 | } |
||
298 | 44297 | jjdelcerro | } |
299 | |||
300 | @Override
|
||
301 | 44326 | jjdelcerro | public boolean set(String name, String value) { |
302 | try {
|
||
303 | if( !this.existsConfiguration() ) { |
||
304 | return false; |
||
305 | } |
||
306 | FeatureStore store = this.getTable(TABLE_CONFIGURATION);
|
||
307 | if( store == null ) { |
||
308 | return false; |
||
309 | } |
||
310 | store.edit(); |
||
311 | ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder(); |
||
312 | String filter = builder.eq(
|
||
313 | builder.column(FIELD_CONFIGURATION_NAME), |
||
314 | builder.constant(name) |
||
315 | ).toString(); |
||
316 | Feature feature = store.findFirst(filter); |
||
317 | EditableFeature efeature; |
||
318 | if (feature == null) { |
||
319 | efeature = store.createNewFeature(); |
||
320 | efeature.set(FIELD_CONFIGURATION_NAME, name); |
||
321 | efeature.set(FIELD_CONFIGURATION_VALUE, value); |
||
322 | store.insert(efeature); |
||
323 | } else {
|
||
324 | efeature = feature.getEditable(); |
||
325 | efeature.set(FIELD_CONFIGURATION_VALUE, value); |
||
326 | store.update(efeature); |
||
327 | } |
||
328 | store.finishEditing(); |
||
329 | return true; |
||
330 | } catch (Exception ex) { |
||
331 | LOGGER.warn("Can't write configuration value '"+name+"'", ex); |
||
332 | return false; |
||
333 | } |
||
334 | 44297 | jjdelcerro | } |
335 | |||
336 | @Override
|
||
337 | public StoresRepository getStoresRepository() {
|
||
338 | 44304 | jjdelcerro | if( this.storesRepository==null ) { |
339 | String id = this.get(CONFIG_NAME_STORESREPOSITORYID); |
||
340 | String label = this.get(CONFIG_NAME_STORESREPOSITORYLABEL); |
||
341 | this.storesRepository = new DatabaseWorkspaceStoresRepository( |
||
342 | id, |
||
343 | label, |
||
344 | 44346 | jjdelcerro | this.serverParameters
|
345 | 44304 | jjdelcerro | ); |
346 | } |
||
347 | return this.storesRepository; |
||
348 | 44297 | jjdelcerro | } |
349 | 44346 | jjdelcerro | |
350 | public boolean contains(DataStoreParameters parameters) { |
||
351 | boolean c = this.getStoresRepository().contains(parameters); |
||
352 | return c;
|
||
353 | } |
||
354 | 44297 | jjdelcerro | |
355 | @Override
|
||
356 | public boolean canAnonymousUserWriteInTheTables() { |
||
357 | throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. |
||
358 | } |
||
359 | |||
360 | @Override
|
||
361 | 44346 | jjdelcerro | public boolean writeStoresRepositoryEntry(String name, DataStoreParameters parameters) { |
362 | 44304 | jjdelcerro | try {
|
363 | byte[] data = parameters.toByteArray(); |
||
364 | if( data == null ) { |
||
365 | throw new RuntimeException("Can't convert parameters to byte array."); |
||
366 | } |
||
367 | FeatureStore store = this.getTable(TABLE_REPOSITORY);
|
||
368 | store.edit(); |
||
369 | ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder(); |
||
370 | String filter = builder.eq(
|
||
371 | builder.column(FIELD_REPOSITORY_NAME), |
||
372 | builder.constant(name) |
||
373 | ).toString(); |
||
374 | Feature feature = store.findFirst(filter); |
||
375 | EditableFeature efeature; |
||
376 | if (feature == null) { |
||
377 | efeature = store.createNewFeature(); |
||
378 | efeature.set(FIELD_REPOSITORY_NAME, name); |
||
379 | efeature.set(FIELD_REPOSITORY_PARAMETERS, data); |
||
380 | store.insert(efeature); |
||
381 | } else {
|
||
382 | efeature = feature.getEditable(); |
||
383 | efeature.set(FIELD_REPOSITORY_PARAMETERS, data); |
||
384 | store.update(efeature); |
||
385 | } |
||
386 | store.finishEditing(); |
||
387 | return true; |
||
388 | |||
389 | } catch (Exception ex) { |
||
390 | LOGGER.warn("Can't save entry '"+name+"' in repository information", ex); |
||
391 | return false; |
||
392 | } |
||
393 | 44297 | jjdelcerro | } |
394 | |||
395 | @Override
|
||
396 | 44380 | jjdelcerro | public boolean isValid() { |
397 | 44304 | jjdelcerro | String id = this.get(CONFIG_NAME_STORESREPOSITORYID); |
398 | if( StringUtils.isBlank(id) ) {
|
||
399 | return false; |
||
400 | } |
||
401 | 44380 | jjdelcerro | return true; |
402 | } |
||
403 | |||
404 | @Override
|
||
405 | public boolean isValidStoresRepository() { |
||
406 | if( !this.isValid() ) { |
||
407 | return false; |
||
408 | } |
||
409 | 44304 | jjdelcerro | if( !this.existsTable(TABLE_REPOSITORY_NAME) ) { |
410 | return false; |
||
411 | } |
||
412 | return true; |
||
413 | |||
414 | 44297 | jjdelcerro | } |
415 | 44346 | jjdelcerro | |
416 | @Override
|
||
417 | 44380 | jjdelcerro | public ResourcesStorage getAlternativeResourcesStorage(String tableName) { |
418 | if( this.alternativeResourcesFolder==null ) { |
||
419 | this.alternativeResourcesFolder = new MutableObject<>(null); |
||
420 | 44346 | jjdelcerro | String resourcesPath = this.get("ALTERNATIVE_RESOURCES_PATH"); |
421 | if( !StringUtils.isBlank(resourcesPath) ) {
|
||
422 | try {
|
||
423 | resourcesPath = (String) ExpressionUtils.evaluate(resourcesPath);
|
||
424 | } catch(Throwable th) { |
||
425 | // Do nothing
|
||
426 | } |
||
427 | File f = new File(resourcesPath); |
||
428 | if( f.exists() ) {
|
||
429 | 44380 | jjdelcerro | this.alternativeResourcesFolder.setValue(f);
|
430 | 44346 | jjdelcerro | } |
431 | } |
||
432 | } |
||
433 | 44380 | jjdelcerro | File folder = this.alternativeResourcesFolder.getValue(); |
434 | if( folder==null ) { |
||
435 | return null; |
||
436 | } |
||
437 | String resourcesRoot = folder.getAbsolutePath().replace("\\","/") + "/" + tableName; |
||
438 | ResourcesStorage resources = new FilesResourcesStorage(resourcesRoot);
|
||
439 | return resources;
|
||
440 | 44346 | jjdelcerro | } |
441 | 44362 | jjdelcerro | |
442 | @Override
|
||
443 | public void drop() { |
||
444 | if( !this.existsTable(TABLE_RESOURCES) ) { |
||
445 | this.dropTable(TABLE_RESOURCES);
|
||
446 | } |
||
447 | if( !this.existsTable(TABLE_CONFIGURATION) ) { |
||
448 | this.dropTable(TABLE_CONFIGURATION);
|
||
449 | } |
||
450 | if( !this.existsTable(TABLE_REPOSITORY) ) { |
||
451 | this.dropTable(TABLE_REPOSITORY);
|
||
452 | } |
||
453 | } |
||
454 | 44346 | jjdelcerro | |
455 | 44362 | jjdelcerro | |
456 | @Override
|
||
457 | 44346 | jjdelcerro | public void create(String id, String description) { |
458 | if( !this.existsTable(TABLE_RESOURCES) ) { |
||
459 | this.createTable(TABLE_RESOURCES);
|
||
460 | } |
||
461 | if( !this.existsTable(TABLE_CONFIGURATION) ) { |
||
462 | this.createTable(TABLE_CONFIGURATION);
|
||
463 | } |
||
464 | if( !this.existsTable(TABLE_REPOSITORY) ) { |
||
465 | this.createTable(TABLE_REPOSITORY);
|
||
466 | } |
||
467 | this.set(CONFIG_NAME_STORESREPOSITORYID,id);
|
||
468 | this.set(CONFIG_NAME_STORESREPOSITORYLABEL,description);
|
||
469 | this.set(CONFIG_CAN_ANONYMOUS_USER_WRITE_IN_THE_TABLES,"true"); |
||
470 | this.set("ALTERNATIVE_RESOURCES_PATH",""); |
||
471 | } |
||
472 | 44297 | jjdelcerro | } |