renaming ICdmApplicationConfiguration to ICdmApplicationDefaultConfiguration
[cdmlib.git] / cdmlib-services / src / main / java / eu / etaxonomy / cdm / api / application / CdmApplicationConfiguration.java
1 // $Id: CdmApplicationDefaultConfiguration.java 19705 2013-12-12 14:38:11Z c.mathew $
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10
11 package eu.etaxonomy.cdm.api.application;
12
13 import org.apache.log4j.Logger;
14 import org.springframework.beans.BeansException;
15 import org.springframework.beans.factory.annotation.Autowired;
16 import org.springframework.context.ApplicationContext;
17 import org.springframework.context.ApplicationContextAware;
18 import org.springframework.security.authentication.ProviderManager;
19 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
20 import org.springframework.security.core.Authentication;
21 import org.springframework.security.core.context.SecurityContext;
22 import org.springframework.security.core.context.SecurityContextHolder;
23 import org.springframework.stereotype.Component;
24
25 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
26 import eu.etaxonomy.cdm.api.conversation.ConversationHolderMock;
27 import eu.etaxonomy.cdm.api.service.IAgentService;
28 import eu.etaxonomy.cdm.api.service.IClassificationService;
29 import eu.etaxonomy.cdm.api.service.ICollectionService;
30 import eu.etaxonomy.cdm.api.service.ICommonService;
31 import eu.etaxonomy.cdm.api.service.IDatabaseService;
32 import eu.etaxonomy.cdm.api.service.IDescriptionService;
33 import eu.etaxonomy.cdm.api.service.IFeatureNodeService;
34 import eu.etaxonomy.cdm.api.service.IFeatureTreeService;
35 import eu.etaxonomy.cdm.api.service.IGrantedAuthorityService;
36 import eu.etaxonomy.cdm.api.service.IGroupService;
37 import eu.etaxonomy.cdm.api.service.IIdentificationKeyService;
38 import eu.etaxonomy.cdm.api.service.ILocationService;
39 import eu.etaxonomy.cdm.api.service.IMediaService;
40 import eu.etaxonomy.cdm.api.service.INameService;
41 import eu.etaxonomy.cdm.api.service.IOccurrenceService;
42 import eu.etaxonomy.cdm.api.service.IPolytomousKeyNodeService;
43 import eu.etaxonomy.cdm.api.service.IPolytomousKeyService;
44 import eu.etaxonomy.cdm.api.service.IReferenceService;
45 import eu.etaxonomy.cdm.api.service.IService;
46 import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
47 import eu.etaxonomy.cdm.api.service.ITaxonService;
48 import eu.etaxonomy.cdm.api.service.ITermService;
49 import eu.etaxonomy.cdm.api.service.IUserService;
50 import eu.etaxonomy.cdm.api.service.IVocabularyService;
51 import eu.etaxonomy.cdm.api.service.IWorkingSetService;
52 import eu.etaxonomy.cdm.model.common.CdmBase;
53 import eu.etaxonomy.cdm.persistence.hibernate.permission.ICdmPermissionEvaluator;
54
55
56 /**
57 * @author a.mueller
58 * @created 21.05.2008
59 * @version 1.0
60 */
61 @Component
62 public class CdmApplicationConfiguration implements ICdmApplicationConfiguration, ApplicationContextAware {
63 @SuppressWarnings("unused")
64 private static final Logger logger = Logger.getLogger(CdmApplicationConfiguration.class);
65
66 @Autowired
67 private INameService nameService;
68 @Autowired
69 private ITaxonService taxonService;
70 @Autowired
71 private IClassificationService classificationService;
72 @Autowired
73 private IReferenceService referenceService;
74 @Autowired
75 private IAgentService agentService;
76 @Autowired
77 private ITermService termService;
78 @Autowired
79 private IDescriptionService descriptionService;
80 @Autowired
81 private IOccurrenceService occurrenceService;
82 @Autowired
83 private IMediaService mediaService;
84 @Autowired
85 private ICommonService commonService;
86 @Autowired
87 private ILocationService locationService;
88 @Autowired
89 private IUserService userService;
90 @Autowired
91 private IGroupService groupService;
92 @Autowired
93 private ICollectionService collectionService;
94 @Autowired
95 private IFeatureTreeService featureTreeService;
96 @Autowired
97 private IFeatureNodeService featureNodeService;
98 @Autowired
99 private IVocabularyService vocabularyService;
100 @Autowired
101 private ITaxonNodeService taxonNodeService;
102 @Autowired
103 private IIdentificationKeyService identificationKeyService;
104 @Autowired
105 private IPolytomousKeyService polytomousKeyService;
106 @Autowired
107 private IPolytomousKeyNodeService polytomousKeyNodeService;
108 @Autowired
109 private IGrantedAuthorityService grantedAuthorityService;
110
111 private IService<CdmBase> mainService;
112
113 @Autowired
114 private IWorkingSetService workingSetService;
115 @Autowired
116 private ProviderManager authenticationManager;
117 @Autowired
118 private ICdmPermissionEvaluator permissionEvaluator;
119
120 protected ApplicationContext applicationContext;
121
122 /**
123 *
124 */
125 public CdmApplicationConfiguration() {
126 }
127
128 /* (non-Javadoc)
129 * @see eu.etaxonomy.cdm.api.application.ICdmApplicationRemoteConfiguration#getAgentService()
130 */
131 public IAgentService getAgentService() {
132 return this.agentService;
133 }
134
135 /* (non-Javadoc)
136 * @see eu.etaxonomy.cdm.api.application.ICdmApplicationRemoteConfiguration#getNameService()
137 */
138 public INameService getNameService() {
139 return this.nameService;
140 }
141
142 /* (non-Javadoc)
143 * @see eu.etaxonomy.cdm.api.application.ICdmApplicationRemoteConfiguration#getReferenceService()
144 */
145 public IReferenceService getReferenceService() {
146 return this.referenceService;
147 }
148
149 /* (non-Javadoc)
150 * @see eu.etaxonomy.cdm.api.application.ICdmApplicationRemoteConfiguration#getTaxonService()
151 */
152 public ITaxonService getTaxonService() {
153 return this.taxonService;
154 }
155
156
157 /* (non-Javadoc)
158 * @see eu.etaxonomy.cdm.api.application.ICdmApplicationRemoteConfiguration#getClassificationService()
159 */
160 public IClassificationService getClassificationService() {
161 return this.classificationService;
162 }
163
164 public ITaxonNodeService getTaxonNodeService(){
165 return this.taxonNodeService;
166 }
167
168 /* (non-Javadoc)
169 * @see eu.etaxonomy.cdm.api.application.ICdmApplicationRemoteConfiguration#getDescriptionService()
170 */
171 public IDescriptionService getDescriptionService(){
172 return this.descriptionService;
173 }
174
175 /*
176 * (non-Javadoc)
177 * @see eu.etaxonomy.cdm.api.application.ICdmApplicationRemoteConfiguration#getOccurrenceService()
178 */
179 public IOccurrenceService getOccurrenceService(){
180 return this.occurrenceService;
181 }
182
183 /*
184 * (non-Javadoc)
185 * @see eu.etaxonomy.cdm.api.application.ICdmApplicationRemoteConfiguration#getMediaService()
186 */
187 public IMediaService getMediaService(){
188 return this.mediaService;
189 }
190
191 /* (non-Javadoc)
192 * @see eu.etaxonomy.cdm.api.application.ICdmApplicationRemoteConfiguration#getTermService()
193 */
194 public ITermService getTermService() {
195 return this.termService;
196 }
197
198 /* (non-Javadoc)
199 * @see eu.etaxonomy.cdm.api.application.ICdmApplicationRemoteConfiguration#getCommonService()
200 */
201 public ICommonService getCommonService(){
202 return this.commonService;
203 }
204
205 /* (non-Javadoc)
206 * @see eu.etaxonomy.cdm.api.application.ICdmApplicationRemoteConfiguration#getLocationService()
207 */
208 public ILocationService getLocationService() {
209 return this.locationService;
210 }
211
212 /* (non-Javadoc)
213 * @see eu.etaxonomy.cdm.api.application.ICdmApplicationRemoteConfiguration#getUserService()
214 */
215 public IUserService getUserService() {
216 return this.userService;
217 }
218
219 /* (non-Javadoc)
220 * @see eu.etaxonomy.cdm.api.application.ICdmApplicationRemoteConfiguration#getCommonService()
221 */
222 public IService<CdmBase> getMainService(){
223 return this.mainService;
224 }
225
226 /*
227 * (non-Javadoc)
228 * @see eu.etaxonomy.cdm.api.application.ICdmApplicationRemoteConfiguration#getCollectionService()
229 */
230 public ICollectionService getCollectionService() {
231 return collectionService;
232 }
233
234 /*
235 * (non-Javadoc)
236 * @see eu.etaxonomy.cdm.api.application.ICdmApplicationRemoteConfiguration#getFeatureTreeService()
237 */
238 public IFeatureTreeService getFeatureTreeService() {
239 return featureTreeService;
240 }
241
242 /*
243 * (non-Javadoc)
244 * @see eu.etaxonomy.cdm.api.application.ICdmApplicationRemoteConfiguration#getFeatureNodeService()
245 */
246 public IFeatureNodeService getFeatureNodeService(){
247 return featureNodeService;
248 }
249
250 /*
251 * (non-Javadoc)
252 * @see eu.etaxonomy.cdm.api.application.ICdmApplicationRemoteConfiguration#getVocabularyService()
253 */
254 public IVocabularyService getVocabularyService() {
255 return vocabularyService;
256 }
257
258 /* (non-Javadoc)
259 * @see eu.etaxonomy.cdm.api.application.ICdmApplicationRemoteConfiguration#getIdentificationKeyService()
260 */
261 public IIdentificationKeyService getIdentificationKeyService(){
262 return identificationKeyService;
263 }
264
265 /* (non-Javadoc)
266 * @see eu.etaxonomy.cdm.api.application.ICdmApplicationRemoteConfiguration#getPolytomousKeyService()
267 */
268 public IPolytomousKeyService getPolytomousKeyService(){
269 return polytomousKeyService;
270 }
271
272 public IPolytomousKeyNodeService getPolytomousKeyNodeService(){
273 return polytomousKeyNodeService;
274 }
275
276 /* (non-Javadoc)
277 * @see eu.etaxonomy.cdm.api.application.ICdmApplicationRemoteConfiguration#getWorkingSetService()
278 */
279 @Override
280 public IWorkingSetService getWorkingSetService() {
281 return workingSetService;
282 }
283
284 /* (non-Javadoc)
285 * @see eu.etaxonomy.cdm.api.application.ICdmApplicationRemoteConfiguration#getGroupService()
286 */
287 @Override
288 public IGroupService getGroupService() {
289 return groupService;
290 }
291
292
293 @Override
294 public ProviderManager getAuthenticationManager() {
295 return authenticationManager;
296 }
297
298 /* (non-Javadoc)
299 * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
300 */
301 @Override
302 public void setApplicationContext(ApplicationContext applicationContext)
303 throws BeansException {
304 this.applicationContext = applicationContext;
305 }
306
307
308 @Override
309 public final Object getBean(String name){
310 return this.applicationContext.getBean(name);
311 }
312
313 /* (non-Javadoc)
314 * @see eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration#authenticate(java.lang.String, java.lang.String)
315 */
316 @Override
317 public void authenticate(String username, String password){
318 UsernamePasswordAuthenticationToken tokenForUser = new UsernamePasswordAuthenticationToken(username, password);
319 Authentication authentication = this.getAuthenticationManager().authenticate(tokenForUser);
320 SecurityContext context = SecurityContextHolder.getContext();
321 context.setAuthentication(authentication);
322 }
323
324 @Override
325 public IGrantedAuthorityService getGrantedAuthorityService() {
326 return this.grantedAuthorityService;
327 }
328
329 /* (non-Javadoc)
330 * @see eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration#getPermissionEvaluator()
331 */
332 @Override
333 public ICdmPermissionEvaluator getPermissionEvaluator() {
334 return permissionEvaluator;
335 }
336
337 @Override
338 public ConversationHolder NewConversation() {
339 // TODO Auto-generated method stub
340 return null;
341 }
342 }