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