1
|
|
2
|
// $Id$
|
3
|
/**
|
4
|
* Copyright (C) 2007 EDIT
|
5
|
* European Distributed Institute of Taxonomy
|
6
|
* http://www.e-taxonomy.eu
|
7
|
*
|
8
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
9
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
10
|
*/
|
11
|
|
12
|
package eu.etaxonomy.cdm.api.application;
|
13
|
|
14
|
import java.util.EnumSet;
|
15
|
import java.util.List;
|
16
|
import java.util.UUID;
|
17
|
|
18
|
import org.apache.log4j.Logger;
|
19
|
import org.hibernate.SessionFactory;
|
20
|
import org.springframework.beans.MutablePropertyValues;
|
21
|
import org.springframework.beans.factory.config.BeanDefinition;
|
22
|
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
|
23
|
import org.springframework.context.ApplicationListener;
|
24
|
import org.springframework.context.support.AbstractApplicationContext;
|
25
|
import org.springframework.core.io.ClassPathResource;
|
26
|
import org.springframework.core.io.Resource;
|
27
|
import org.springframework.security.authentication.ProviderManager;
|
28
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
29
|
import org.springframework.security.core.Authentication;
|
30
|
import org.springframework.security.core.context.SecurityContext;
|
31
|
import org.springframework.security.core.context.SecurityContextHolder;
|
32
|
import org.springframework.transaction.PlatformTransactionManager;
|
33
|
import org.springframework.transaction.TransactionStatus;
|
34
|
|
35
|
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
36
|
import eu.etaxonomy.cdm.api.service.IAgentService;
|
37
|
import eu.etaxonomy.cdm.api.service.IAnnotationService;
|
38
|
import eu.etaxonomy.cdm.api.service.IClassificationService;
|
39
|
import eu.etaxonomy.cdm.api.service.ICollectionService;
|
40
|
import eu.etaxonomy.cdm.api.service.ICommonService;
|
41
|
import eu.etaxonomy.cdm.api.service.IDatabaseService;
|
42
|
import eu.etaxonomy.cdm.api.service.IDescriptionService;
|
43
|
import eu.etaxonomy.cdm.api.service.IEntityConstraintViolationService;
|
44
|
import eu.etaxonomy.cdm.api.service.IEntityValidationService;
|
45
|
import eu.etaxonomy.cdm.api.service.IFeatureNodeService;
|
46
|
import eu.etaxonomy.cdm.api.service.IFeatureTreeService;
|
47
|
import eu.etaxonomy.cdm.api.service.IGrantedAuthorityService;
|
48
|
import eu.etaxonomy.cdm.api.service.IGroupService;
|
49
|
import eu.etaxonomy.cdm.api.service.IIdentificationKeyService;
|
50
|
import eu.etaxonomy.cdm.api.service.ILocationService;
|
51
|
import eu.etaxonomy.cdm.api.service.IMediaService;
|
52
|
import eu.etaxonomy.cdm.api.service.INameService;
|
53
|
import eu.etaxonomy.cdm.api.service.IOccurrenceService;
|
54
|
import eu.etaxonomy.cdm.api.service.IPolytomousKeyNodeService;
|
55
|
import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
|
56
|
import eu.etaxonomy.cdm.api.service.IProgressMonitorService;
|
57
|
import eu.etaxonomy.cdm.api.service.IReferenceService;
|
58
|
import eu.etaxonomy.cdm.api.service.IService;
|
59
|
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
|
60
|
import eu.etaxonomy.cdm.api.service.ITaxonService;
|
61
|
import eu.etaxonomy.cdm.api.service.ITermService;
|
62
|
import eu.etaxonomy.cdm.api.service.IUserService;
|
63
|
import eu.etaxonomy.cdm.api.service.IVocabularyService;
|
64
|
import eu.etaxonomy.cdm.api.service.IWorkingSetService;
|
65
|
import eu.etaxonomy.cdm.api.service.molecular.IAmplificationService;
|
66
|
import eu.etaxonomy.cdm.api.service.molecular.IPrimerService;
|
67
|
import eu.etaxonomy.cdm.api.service.molecular.ISequenceService;
|
68
|
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor;
|
69
|
import eu.etaxonomy.cdm.common.monitor.NullProgressMonitor;
|
70
|
import eu.etaxonomy.cdm.common.monitor.SubProgressMonitor;
|
71
|
import eu.etaxonomy.cdm.database.CdmPersistentDataSource;
|
72
|
import eu.etaxonomy.cdm.database.DataSourceNotFoundException;
|
73
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
74
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
75
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
76
|
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
|
77
|
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
|
78
|
import eu.etaxonomy.cdm.persistence.hibernate.permission.ICdmPermissionEvaluator;
|
79
|
|
80
|
/**
|
81
|
* @author a.mueller
|
82
|
*/
|
83
|
public class CdmApplicationController implements ICdmApplicationConfiguration {
|
84
|
private static final Logger logger = Logger.getLogger(CdmApplicationController.class);
|
85
|
|
86
|
public static final String DEFAULT_APPLICATION_CONTEXT_RESOURCE = "/eu/etaxonomy/cdm/defaultApplicationContext.xml";
|
87
|
|
88
|
public AbstractApplicationContext applicationContext;
|
89
|
protected ICdmApplicationConfiguration configuration;
|
90
|
private final Resource applicationContextResource;
|
91
|
|
92
|
private final IProgressMonitor progressMonitor;
|
93
|
|
94
|
final protected static DbSchemaValidation defaultDbSchemaValidation = DbSchemaValidation.VALIDATE;
|
95
|
|
96
|
|
97
|
/**
|
98
|
* Constructor, opens a spring ApplicationContext by using the default data source
|
99
|
*
|
100
|
* @throws DataSourceNotFoundException
|
101
|
*/
|
102
|
public static CdmApplicationController NewInstance() throws DataSourceNotFoundException{
|
103
|
logger.info("Start CdmApplicationController with default data source");
|
104
|
CdmPersistentDataSource dataSource = getDefaultDatasource();
|
105
|
DbSchemaValidation dbSchemaValidation = defaultDbSchemaValidation;
|
106
|
return CdmApplicationController.NewInstance(null, dataSource, dbSchemaValidation, false);
|
107
|
}
|
108
|
|
109
|
|
110
|
/**
|
111
|
* Constructor, opens a spring ApplicationContext by using the default data source
|
112
|
*
|
113
|
* @param dbSchemaValidation
|
114
|
* validation type for database schema
|
115
|
* @throws DataSourceNotFoundException
|
116
|
*/
|
117
|
public static CdmApplicationController NewInstance(DbSchemaValidation dbSchemaValidation) throws DataSourceNotFoundException{
|
118
|
logger.info("Start CdmApplicationController with default data source");
|
119
|
CdmPersistentDataSource dataSource = getDefaultDatasource();
|
120
|
return CdmApplicationController.NewInstance(null, dataSource, dbSchemaValidation, false);
|
121
|
}
|
122
|
|
123
|
|
124
|
/**
|
125
|
* Constructor, opens an spring ApplicationContext by using the according data source
|
126
|
* and the default database schema validation type
|
127
|
*
|
128
|
* @param dataSource
|
129
|
*/
|
130
|
public static CdmApplicationController NewInstance(ICdmDataSource dataSource){
|
131
|
return CdmApplicationController.NewInstance(null, dataSource, defaultDbSchemaValidation, false);
|
132
|
}
|
133
|
|
134
|
|
135
|
public static CdmApplicationController NewInstance(ICdmDataSource dataSource, DbSchemaValidation dbSchemaValidation){
|
136
|
return CdmApplicationController.NewInstance(null, dataSource, dbSchemaValidation, false);
|
137
|
}
|
138
|
|
139
|
|
140
|
public static CdmApplicationController NewInstance(ICdmDataSource dataSource, DbSchemaValidation dbSchemaValidation, boolean omitTermLoading){
|
141
|
return CdmApplicationController.NewInstance(null, dataSource, dbSchemaValidation, omitTermLoading);
|
142
|
}
|
143
|
|
144
|
public static CdmApplicationController NewInstance(Resource applicationContextResource, ICdmDataSource dataSource,
|
145
|
DbSchemaValidation dbSchemaValidation, boolean omitTermLoading){
|
146
|
return CdmApplicationController.NewInstance(applicationContextResource, dataSource, dbSchemaValidation, omitTermLoading, null);
|
147
|
}
|
148
|
|
149
|
public static CdmApplicationController NewInstance(Resource applicationContextResource, ICdmDataSource dataSource,
|
150
|
DbSchemaValidation dbSchemaValidation, boolean omitTermLoading, IProgressMonitor progressMonitor){
|
151
|
return new CdmApplicationController(applicationContextResource, dataSource, dbSchemaValidation, omitTermLoading, progressMonitor, null);
|
152
|
}
|
153
|
|
154
|
|
155
|
//TODO discuss need for listeners before commit to trunk
|
156
|
// public static CdmApplicationController NewInstance(Resource applicationContextResource, ICdmDataSource dataSource, DbSchemaValidation dbSchemaValidation, boolean omitTermLoading, IProgressMonitor progressMonitor, List<ApplicationListener> listeners) {
|
157
|
// return new CdmApplicationController(applicationContextResource, dataSource, dbSchemaValidation, omitTermLoading, progressMonitor,listeners);
|
158
|
// }
|
159
|
|
160
|
/**
|
161
|
* @return
|
162
|
*/
|
163
|
protected static ClassPathResource getClasspathResource(){
|
164
|
return new ClassPathResource(DEFAULT_APPLICATION_CONTEXT_RESOURCE);
|
165
|
}
|
166
|
|
167
|
|
168
|
/**
|
169
|
* @return
|
170
|
* @throws DataSourceNotFoundException
|
171
|
*/
|
172
|
protected static CdmPersistentDataSource getDefaultDatasource() throws DataSourceNotFoundException{
|
173
|
CdmPersistentDataSource dataSource = CdmPersistentDataSource.NewDefaultInstance();
|
174
|
return dataSource;
|
175
|
}
|
176
|
|
177
|
|
178
|
/**
|
179
|
*
|
180
|
* FIXME:Remoting this constructor is added only to allow extension of this cntroller
|
181
|
* class. and should be removed after refactoring
|
182
|
*/
|
183
|
protected CdmApplicationController(){
|
184
|
applicationContextResource = null;
|
185
|
progressMonitor = null;
|
186
|
}
|
187
|
|
188
|
|
189
|
/**
|
190
|
* Constructor, opens an spring 2.5 ApplicationContext by using the according data
|
191
|
* source
|
192
|
*
|
193
|
* @param dataSource
|
194
|
* @param dbSchemaValidation
|
195
|
* @param omitTermLoading
|
196
|
*/
|
197
|
protected CdmApplicationController(Resource applicationContextResource, ICdmDataSource dataSource, DbSchemaValidation dbSchemaValidation,
|
198
|
boolean omitTermLoading, IProgressMonitor progressMonitor, List<ApplicationListener> listeners){
|
199
|
logger.info("Start CdmApplicationController with datasource: " + dataSource.getName());
|
200
|
|
201
|
if (dbSchemaValidation == null) {
|
202
|
dbSchemaValidation = defaultDbSchemaValidation;
|
203
|
}
|
204
|
this.applicationContextResource = applicationContextResource != null ? applicationContextResource : getClasspathResource();
|
205
|
this.progressMonitor = progressMonitor != null ? progressMonitor : new NullProgressMonitor();
|
206
|
|
207
|
setNewDataSource(dataSource, dbSchemaValidation, omitTermLoading, listeners);
|
208
|
}
|
209
|
|
210
|
|
211
|
/**
|
212
|
* Sets the application context to a new spring ApplicationContext by using the
|
213
|
* according data source and initializes the Controller.
|
214
|
*
|
215
|
* @param dataSource
|
216
|
*/
|
217
|
private boolean setNewDataSource(ICdmDataSource dataSource, DbSchemaValidation dbSchemaValidation, boolean omitTermLoading,
|
218
|
List<ApplicationListener> listeners){
|
219
|
|
220
|
if (dbSchemaValidation == null) {
|
221
|
dbSchemaValidation = defaultDbSchemaValidation;
|
222
|
}
|
223
|
logger.info("Connecting to '" + dataSource.getName() + "'");
|
224
|
|
225
|
MonitoredGenericApplicationContext applicationContext = new MonitoredGenericApplicationContext();
|
226
|
int refreshTasks = 45;
|
227
|
int nTasks = 5 + refreshTasks;
|
228
|
// nTasks += applicationContext.countTasks();
|
229
|
progressMonitor.beginTask("Connecting to '" + dataSource.getName() + "'", nTasks);
|
230
|
|
231
|
// progressMonitor.worked(1);
|
232
|
|
233
|
BeanDefinition datasourceBean = dataSource.getDatasourceBean();
|
234
|
datasourceBean.setAttribute("isLazy", false);
|
235
|
progressMonitor.subTask("Registering datasource.");
|
236
|
applicationContext.registerBeanDefinition("dataSource", datasourceBean);
|
237
|
progressMonitor.worked(1);
|
238
|
|
239
|
BeanDefinition hibernatePropBean = dataSource.getHibernatePropertiesBean(dbSchemaValidation);
|
240
|
applicationContext.registerBeanDefinition("hibernateProperties", hibernatePropBean);
|
241
|
|
242
|
XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(applicationContext);
|
243
|
progressMonitor.subTask("Registering resources.");
|
244
|
xmlReader.loadBeanDefinitions(applicationContextResource);
|
245
|
progressMonitor.worked(1);
|
246
|
|
247
|
//omitTerms
|
248
|
if (omitTermLoading == true) {
|
249
|
String initializerName = "persistentTermInitializer";
|
250
|
BeanDefinition beanDef = applicationContext.getBeanDefinition(initializerName);
|
251
|
MutablePropertyValues values = beanDef.getPropertyValues();
|
252
|
values.addPropertyValue("omit", omitTermLoading);
|
253
|
}
|
254
|
|
255
|
if (listeners != null) {
|
256
|
for (ApplicationListener listener : listeners) {
|
257
|
applicationContext.addApplicationListener(listener);
|
258
|
}
|
259
|
}
|
260
|
|
261
|
// String message = "Start application context. This might take a while ...";
|
262
|
//// progressMonitor.subTask(message);
|
263
|
// SubProgressMonitor subMonitor= new SubProgressMonitor(progressMonitor, 10);
|
264
|
// subMonitor.beginTask(message, 2);
|
265
|
// applicationContext.setProgressMonitor(subMonitor);
|
266
|
|
267
|
applicationContext.refresh(new SubProgressMonitor(progressMonitor, refreshTasks));
|
268
|
applicationContext.start();
|
269
|
// progressMonitor.worked(1);
|
270
|
|
271
|
progressMonitor.subTask("Cleaning up.");
|
272
|
setApplicationContext(applicationContext);
|
273
|
progressMonitor.worked(1);
|
274
|
|
275
|
progressMonitor.done();
|
276
|
return true;
|
277
|
}
|
278
|
|
279
|
|
280
|
/**
|
281
|
* Tests if some DefinedTermsAreMissing.
|
282
|
*
|
283
|
* @return true, if at least one is missing, else false
|
284
|
*/
|
285
|
public boolean testDefinedTermsAreMissing(){
|
286
|
UUID englishUuid = UUID.fromString("e9f8cdb7-6819-44e8-95d3-e2d0690c3523");
|
287
|
DefinedTermBase<?> english = this.getTermService().load(englishUuid);
|
288
|
if (english == null || !english.getUuid().equals(englishUuid)) {
|
289
|
return true;
|
290
|
}
|
291
|
else {
|
292
|
return false;
|
293
|
}
|
294
|
}
|
295
|
|
296
|
|
297
|
/**
|
298
|
* Changes the ApplicationContext to the new dataSource
|
299
|
*
|
300
|
* @param dataSource
|
301
|
*/
|
302
|
public boolean changeDataSource(ICdmDataSource dataSource){
|
303
|
//logger.info("Change datasource to : " + dataSource);
|
304
|
return setNewDataSource(dataSource, DbSchemaValidation.VALIDATE, false, null);
|
305
|
}
|
306
|
|
307
|
|
308
|
/**
|
309
|
* Changes the ApplicationContext to the new dataSource
|
310
|
*
|
311
|
* @param dataSource
|
312
|
* @param dbSchemaValidation
|
313
|
*/
|
314
|
public boolean changeDataSource(ICdmDataSource dataSource, DbSchemaValidation dbSchemaValidation){
|
315
|
//logger.info("Change datasource to : " + dataSource);
|
316
|
return setNewDataSource(dataSource, dbSchemaValidation, false, null);
|
317
|
}
|
318
|
|
319
|
|
320
|
/**
|
321
|
* Changes the ApplicationContext to the new dataSource
|
322
|
*
|
323
|
* @param dataSource
|
324
|
* @param dbSchemaValidation
|
325
|
* @param omitTermLoading
|
326
|
*/
|
327
|
public boolean changeDataSource(ICdmDataSource dataSource, DbSchemaValidation dbSchemaValidation, boolean omitTermLoading){
|
328
|
logger.info("Change datasource to : " + dataSource);
|
329
|
return setNewDataSource(dataSource, dbSchemaValidation, omitTermLoading, null);
|
330
|
}
|
331
|
|
332
|
|
333
|
/**
|
334
|
* Changes the ApplicationContext to the new dataSource
|
335
|
*
|
336
|
* @param dataSource
|
337
|
* @param dbSchemaValidation
|
338
|
* @param omitTermLoading
|
339
|
*/
|
340
|
public boolean changeDataSource(ICdmDataSource dataSource, DbSchemaValidation dbSchemaValidation, boolean omitTermLoading,
|
341
|
List<ApplicationListener> listeners){
|
342
|
logger.info("Change datasource to : " + dataSource);
|
343
|
return setNewDataSource(dataSource, dbSchemaValidation, omitTermLoading, listeners);
|
344
|
}
|
345
|
|
346
|
|
347
|
/**
|
348
|
* Sets a new application Context.
|
349
|
*
|
350
|
* @param ac
|
351
|
*/
|
352
|
public void setApplicationContext(AbstractApplicationContext ac){
|
353
|
closeApplicationContext(); //closes old application context if necessary
|
354
|
applicationContext = ac;
|
355
|
applicationContext.registerShutdownHook();
|
356
|
init();
|
357
|
}
|
358
|
|
359
|
|
360
|
/*
|
361
|
* (non-Javadoc)
|
362
|
*
|
363
|
* @see java.lang.Object#finalize()
|
364
|
*/
|
365
|
@Override
|
366
|
public void finalize(){
|
367
|
close();
|
368
|
}
|
369
|
|
370
|
|
371
|
/**
|
372
|
* closes the application
|
373
|
*/
|
374
|
public void close(){
|
375
|
closeApplicationContext();
|
376
|
}
|
377
|
|
378
|
|
379
|
/**
|
380
|
* closes the application context
|
381
|
*/
|
382
|
protected void closeApplicationContext(){
|
383
|
if (applicationContext != null) {
|
384
|
logger.info("Close ApplicationContext");
|
385
|
applicationContext.close();
|
386
|
}
|
387
|
}
|
388
|
|
389
|
|
390
|
protected void init(){
|
391
|
logger.debug("Init " + this.getClass().getName() + " ... ");
|
392
|
if (logger.isDebugEnabled()) {
|
393
|
for (String beanName : applicationContext.getBeanDefinitionNames()) {
|
394
|
logger.debug(beanName);
|
395
|
}
|
396
|
}
|
397
|
//TODO delete next row (was just for testing)
|
398
|
if (logger.isInfoEnabled()) {
|
399
|
logger.info("Registered Beans: ");
|
400
|
String[] beanNames = applicationContext.getBeanDefinitionNames();
|
401
|
for (String beanName : beanNames) {
|
402
|
logger.info(beanName);
|
403
|
}
|
404
|
}
|
405
|
configuration = (ICdmApplicationConfiguration) applicationContext.getBean("cdmApplicationDefaultConfiguration");
|
406
|
try {
|
407
|
//FIXME:Remoting catching exection to allow for remoting
|
408
|
getDatabaseService().setApplicationController(this);
|
409
|
}
|
410
|
catch (UnsupportedOperationException uoe) {
|
411
|
logger.warn("getDatabaseService() is not implmented for current application context");
|
412
|
}
|
413
|
}
|
414
|
|
415
|
|
416
|
/* ****** Services ******** */
|
417
|
@Override
|
418
|
public final IAnnotationService getAnnotationService(){
|
419
|
return configuration.getAnnotationService();
|
420
|
}
|
421
|
|
422
|
@Override
|
423
|
public final INameService getNameService(){
|
424
|
return configuration.getNameService();
|
425
|
}
|
426
|
|
427
|
|
428
|
@Override
|
429
|
public final ITaxonService getTaxonService(){
|
430
|
return configuration.getTaxonService();
|
431
|
}
|
432
|
|
433
|
|
434
|
@Override
|
435
|
public final IClassificationService getClassificationService(){
|
436
|
return configuration.getClassificationService();
|
437
|
}
|
438
|
|
439
|
|
440
|
@Override
|
441
|
public final ITaxonNodeService getTaxonNodeService(){
|
442
|
return configuration.getTaxonNodeService();
|
443
|
}
|
444
|
|
445
|
|
446
|
@Override
|
447
|
public final IReferenceService getReferenceService(){
|
448
|
return configuration.getReferenceService();
|
449
|
}
|
450
|
|
451
|
|
452
|
@Override
|
453
|
public final IAgentService getAgentService(){
|
454
|
return configuration.getAgentService();
|
455
|
}
|
456
|
|
457
|
|
458
|
@Override
|
459
|
public final IDatabaseService getDatabaseService(){
|
460
|
return configuration.getDatabaseService();
|
461
|
}
|
462
|
|
463
|
|
464
|
@Override
|
465
|
public final ITermService getTermService(){
|
466
|
return configuration.getTermService();
|
467
|
}
|
468
|
|
469
|
|
470
|
@Override
|
471
|
public final IDescriptionService getDescriptionService(){
|
472
|
return configuration.getDescriptionService();
|
473
|
}
|
474
|
|
475
|
|
476
|
@Override
|
477
|
public final IOccurrenceService getOccurrenceService(){
|
478
|
return configuration.getOccurrenceService();
|
479
|
}
|
480
|
|
481
|
@Override
|
482
|
public IAmplificationService getAmplificationService(){
|
483
|
return configuration.getAmplificationService();
|
484
|
}
|
485
|
|
486
|
@Override
|
487
|
public ISequenceService getSequenceService(){
|
488
|
return configuration.getSequenceService();
|
489
|
}
|
490
|
|
491
|
|
492
|
@Override
|
493
|
public final IPrimerService getPrimerService(){
|
494
|
return configuration.getPrimerService();
|
495
|
}
|
496
|
|
497
|
|
498
|
@Override
|
499
|
public final IMediaService getMediaService(){
|
500
|
return configuration.getMediaService();
|
501
|
}
|
502
|
|
503
|
|
504
|
@Override
|
505
|
public final ICommonService getCommonService(){
|
506
|
return configuration.getCommonService();
|
507
|
}
|
508
|
|
509
|
|
510
|
@Override
|
511
|
public final ILocationService getLocationService(){
|
512
|
return configuration.getLocationService();
|
513
|
}
|
514
|
|
515
|
|
516
|
@Override
|
517
|
public final IUserService getUserService(){
|
518
|
return configuration.getUserService();
|
519
|
}
|
520
|
|
521
|
|
522
|
@Override
|
523
|
public final IGrantedAuthorityService getGrantedAuthorityService(){
|
524
|
return configuration.getGrantedAuthorityService();
|
525
|
}
|
526
|
|
527
|
|
528
|
@Override
|
529
|
public IGroupService getGroupService(){
|
530
|
return configuration.getGroupService();
|
531
|
}
|
532
|
|
533
|
|
534
|
@Override
|
535
|
public final ICollectionService getCollectionService(){
|
536
|
return configuration.getCollectionService();
|
537
|
}
|
538
|
|
539
|
|
540
|
@Override
|
541
|
public final IFeatureTreeService getFeatureTreeService(){
|
542
|
return configuration.getFeatureTreeService();
|
543
|
}
|
544
|
|
545
|
|
546
|
@Override
|
547
|
public final IFeatureNodeService getFeatureNodeService(){
|
548
|
return configuration.getFeatureNodeService();
|
549
|
}
|
550
|
|
551
|
|
552
|
@Override
|
553
|
public final IVocabularyService getVocabularyService(){
|
554
|
return configuration.getVocabularyService();
|
555
|
}
|
556
|
|
557
|
|
558
|
@Override
|
559
|
public final IIdentificationKeyService getIdentificationKeyService(){
|
560
|
return configuration.getIdentificationKeyService();
|
561
|
}
|
562
|
|
563
|
|
564
|
@Override
|
565
|
public final IPolytomousKeyService getPolytomousKeyService(){
|
566
|
return configuration.getPolytomousKeyService();
|
567
|
}
|
568
|
|
569
|
|
570
|
@Override
|
571
|
public final IPolytomousKeyNodeService getPolytomousKeyNodeService(){
|
572
|
return configuration.getPolytomousKeyNodeService();
|
573
|
}
|
574
|
|
575
|
|
576
|
/**
|
577
|
* {@inheritDoc}
|
578
|
*/
|
579
|
@Override
|
580
|
public IProgressMonitorService getProgressMonitorService() {
|
581
|
return configuration.getProgressMonitorService();
|
582
|
}
|
583
|
|
584
|
|
585
|
@Override
|
586
|
public IEntityValidationService getEntityValidationService(){
|
587
|
return configuration.getEntityValidationService();
|
588
|
}
|
589
|
|
590
|
|
591
|
@Override
|
592
|
public IEntityConstraintViolationService getEntityConstraintViolationService(){
|
593
|
return configuration.getEntityConstraintViolationService();
|
594
|
}
|
595
|
|
596
|
|
597
|
@Override
|
598
|
public final IService<CdmBase> getMainService(){
|
599
|
return configuration.getMainService();
|
600
|
}
|
601
|
|
602
|
|
603
|
@Override
|
604
|
public final IWorkingSetService getWorkingSetService(){
|
605
|
return configuration.getWorkingSetService();
|
606
|
}
|
607
|
|
608
|
|
609
|
@Override
|
610
|
public final ConversationHolder NewConversation(){
|
611
|
//return (ConversationHolder)applicationContext.getBean("conversationHolder");
|
612
|
return configuration.NewConversation();
|
613
|
}
|
614
|
|
615
|
|
616
|
/* **** Security ***** */
|
617
|
|
618
|
@Override
|
619
|
public void authenticate(String username, String password){
|
620
|
UsernamePasswordAuthenticationToken tokenForUser = new UsernamePasswordAuthenticationToken(username, password);
|
621
|
Authentication authentication = this.getAuthenticationManager().authenticate(tokenForUser);
|
622
|
SecurityContext context = SecurityContextHolder.getContext();
|
623
|
context.setAuthentication(authentication);
|
624
|
}
|
625
|
|
626
|
@Override
|
627
|
public final ProviderManager getAuthenticationManager(){
|
628
|
return configuration.getAuthenticationManager();
|
629
|
}
|
630
|
|
631
|
|
632
|
@Override
|
633
|
public ICdmPermissionEvaluator getPermissionEvaluator(){
|
634
|
return configuration.getPermissionEvaluator();
|
635
|
}
|
636
|
|
637
|
/**
|
638
|
* @see org.springframework.security.access.PermissionEvaluator#hasPermission(org.springframework.security.core.Authentication,
|
639
|
* java.lang.Object, java.lang.Object)
|
640
|
*
|
641
|
* @param targetDomainObject
|
642
|
* @param permission
|
643
|
* @return
|
644
|
*/
|
645
|
public boolean currentAuthentiationHasPermissions(CdmBase targetDomainObject, EnumSet<CRUD> permission){
|
646
|
SecurityContext context = SecurityContextHolder.getContext();
|
647
|
return getPermissionEvaluator().hasPermission(context.getAuthentication(), targetDomainObject, permission);
|
648
|
}
|
649
|
|
650
|
|
651
|
@Override
|
652
|
public final PlatformTransactionManager getTransactionManager(){
|
653
|
return configuration.getTransactionManager();
|
654
|
}
|
655
|
|
656
|
|
657
|
@Override
|
658
|
public final Object getBean(String name){
|
659
|
return this.applicationContext.getBean(name);
|
660
|
}
|
661
|
|
662
|
|
663
|
/*
|
664
|
* OLD TRANSACTION STUFF
|
665
|
*/
|
666
|
|
667
|
/* **** flush ********** */
|
668
|
public void flush(){
|
669
|
SessionFactory sf = (SessionFactory) applicationContext.getBean("sessionFactory");
|
670
|
sf.getCurrentSession().flush();
|
671
|
}
|
672
|
|
673
|
|
674
|
public SessionFactory getSessionFactory(){
|
675
|
return (SessionFactory) applicationContext.getBean("sessionFactory");
|
676
|
}
|
677
|
|
678
|
|
679
|
@Override
|
680
|
public TransactionStatus startTransaction(){
|
681
|
return startTransaction(false);
|
682
|
}
|
683
|
|
684
|
|
685
|
@Override
|
686
|
public TransactionStatus startTransaction(Boolean readOnly){
|
687
|
return configuration.startTransaction(readOnly);
|
688
|
}
|
689
|
|
690
|
@Override
|
691
|
public void commitTransaction(TransactionStatus txStatus){
|
692
|
PlatformTransactionManager txManager = configuration.getTransactionManager();
|
693
|
txManager.commit(txStatus);
|
694
|
return;
|
695
|
}
|
696
|
|
697
|
}
|
698
|
|