Revision 73de892e
Added by Cherian Mathew about 10 years ago
.gitattributes | ||
---|---|---|
333 | 333 |
eu.etaxonomy.taxeditor.cdmlib/lib/xstream-1.4.4.jar -text |
334 | 334 |
eu.etaxonomy.taxeditor.cdmlib/lib/yjp-controller-api-redist-9.0.8.jar -text |
335 | 335 |
eu.etaxonomy.taxeditor.cdmlib/pom.xml -text |
336 |
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteConfiguration.java -text |
|
337 |
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteController.java -text |
|
338 |
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/ICdmApplicationRemoteConfiguration.java -text |
|
336 | 339 |
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/lazyloading/CdmLazyLoader.java -text |
337 |
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/remote/api/application/CdmApplicationRemoteConfiguration.java -text |
|
338 |
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/remote/api/application/CdmApplicationRemoteController.java -text |
|
339 |
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/remote/api/application/ICdmApplicationRemoteConfiguration.java -text |
|
340 | 340 |
eu.etaxonomy.taxeditor.cdmlib/src/main/java/org/hibernate/collection/internal/AbstractPersistentCollection.java -text |
341 | 341 |
eu.etaxonomy.taxeditor.cdmlib/src/main/java/org/hibernate/proxy/AbstractLazyInitializer.java -text |
342 |
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/config.properties -text |
|
342 | 343 |
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/httpInvokerServiceClients.xml -text |
343 | 344 |
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/remotingApplicationContext.xml -text |
344 | 345 |
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/remoting_persistence_security.xml -text |
eu.etaxonomy.taxeditor.cdmlib/.classpath | ||
---|---|---|
1 | 1 |
<?xml version="1.0" encoding="UTF-8"?> |
2 | 2 |
<classpath> |
3 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> |
|
4 |
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> |
|
3 | 5 |
<classpathentry kind="src" path="src/main/java"/> |
4 | 6 |
<classpathentry kind="src" path="src/test/java"/> |
5 | 7 |
<classpathentry kind="src" path="src/main/resources"/> |
6 |
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> |
|
7 |
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> |
|
8 | 8 |
<classpathentry exported="true" kind="lib" path="lib/activation-1.1.1.jar"/> |
9 | 9 |
<classpathentry exported="true" kind="lib" path="lib/antlr-2.7.7.jar"/> |
10 | 10 |
<classpathentry exported="true" kind="lib" path="lib/aopalliance-1.0.jar"/> |
eu.etaxonomy.taxeditor.cdmlib/.project | ||
---|---|---|
6 | 6 |
</projects> |
7 | 7 |
<buildSpec> |
8 | 8 |
<buildCommand> |
9 |
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
9 |
<name>org.eclipse.ajdt.core.ajbuilder</name>
|
|
10 | 10 |
<arguments> |
11 | 11 |
</arguments> |
12 | 12 |
</buildCommand> |
... | ... | |
22 | 22 |
</buildCommand> |
23 | 23 |
</buildSpec> |
24 | 24 |
<natures> |
25 |
<nature>org.eclipse.ajdt.ui.ajnature</nature> |
|
25 | 26 |
<nature>org.eclipse.jdt.core.javanature</nature> |
26 | 27 |
<nature>org.eclipse.pde.PluginNature</nature> |
27 | 28 |
</natures> |
eu.etaxonomy.taxeditor.cdmlib/META-INF/MANIFEST.MF | ||
---|---|---|
124 | 124 |
eu.etaxonomy.cdm.print.out.pdf, |
125 | 125 |
eu.etaxonomy.cdm.print.out.taxpub, |
126 | 126 |
eu.etaxonomy.cdm.print.out.xml, |
127 |
eu.etaxonomy.cdm.remote.api.application, |
|
128 | 127 |
eu.etaxonomy.cdm.remote.config, |
129 | 128 |
eu.etaxonomy.cdm.remote.controller, |
130 | 129 |
eu.etaxonomy.cdm.remote.controller.csv, |
... | ... | |
398 | 397 |
Bundle-Vendor: EDIT |
399 | 398 |
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 |
400 | 399 |
Require-Bundle: org.eclipse.osgi, |
401 |
org.eclipse.equinox.common |
|
400 |
org.eclipse.equinox.common, |
|
401 |
org.aspectj.runtime |
|
402 | 402 |
Bundle-ClassPath: ., |
403 | 403 |
lib/activation-1.1.1.jar, |
404 | 404 |
lib/antlr-2.7.7.jar, |
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteConfiguration.java | ||
---|---|---|
1 |
// $Id: CdmApplicationDefaultConfiguration.java 11680 2011-04-04 17:07:39Z a.mueller $ |
|
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.context.ApplicationContextAware; |
|
15 |
import org.springframework.stereotype.Component; |
|
16 |
|
|
17 |
import eu.etaxonomy.cdm.api.application.CdmApplicationDefaultConfiguration; |
|
18 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
|
19 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolderMock; |
|
20 |
|
|
21 |
/** |
|
22 |
* @author a.mueller |
|
23 |
* @created 21.05.2008 |
|
24 |
* @version 1.0 |
|
25 |
*/ |
|
26 |
/** |
|
27 |
* @author a.mueller |
|
28 |
* @author j.koch |
|
29 |
*/ |
|
30 |
@Component |
|
31 |
public class CdmApplicationRemoteConfiguration extends CdmApplicationConfiguration implements ICdmApplicationRemoteConfiguration, ApplicationContextAware { |
|
32 |
|
|
33 |
@SuppressWarnings("unused") |
|
34 |
private static final Logger logger = Logger.getLogger(CdmApplicationRemoteConfiguration.class); |
|
35 |
|
|
36 |
public CdmApplicationRemoteConfiguration() { |
|
37 |
} |
|
38 |
|
|
39 |
@Override |
|
40 |
public ConversationHolder NewConversation() { |
|
41 |
// TODO Auto-generated method stub |
|
42 |
return new ConversationHolderMock(); |
|
43 |
} |
|
44 |
} |
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/CdmApplicationRemoteController.java | ||
---|---|---|
1 |
// $Id: CdmApplicationController.java 11680 2011-04-04 17:07:39Z a.mueller $ |
|
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 |
|
|
12 |
package eu.etaxonomy.cdm.api.application; |
|
13 |
|
|
14 |
import java.util.UUID; |
|
15 |
|
|
16 |
import org.apache.log4j.Logger; |
|
17 |
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; |
|
18 |
import org.springframework.context.support.AbstractApplicationContext; |
|
19 |
import org.springframework.context.support.GenericApplicationContext; |
|
20 |
import org.springframework.core.io.ClassPathResource; |
|
21 |
import org.springframework.core.io.Resource; |
|
22 |
import org.springframework.security.access.PermissionEvaluator; |
|
23 |
import org.springframework.security.authentication.ProviderManager; |
|
24 |
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
|
25 |
import org.springframework.security.core.Authentication; |
|
26 |
import org.springframework.security.core.context.SecurityContext; |
|
27 |
import org.springframework.security.core.context.SecurityContextHolder; |
|
28 |
import org.springframework.transaction.PlatformTransactionManager; |
|
29 |
//import org.springframework.transaction.PlatformTransactionManager; |
|
30 |
import org.springframework.transaction.TransactionStatus; |
|
31 |
|
|
32 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
|
33 |
import eu.etaxonomy.cdm.api.service.IAgentService; |
|
34 |
import eu.etaxonomy.cdm.api.service.IClassificationService; |
|
35 |
import eu.etaxonomy.cdm.api.service.ICollectionService; |
|
36 |
import eu.etaxonomy.cdm.api.service.ICommonService; |
|
37 |
import eu.etaxonomy.cdm.api.service.IDatabaseService; |
|
38 |
import eu.etaxonomy.cdm.api.service.IDescriptionService; |
|
39 |
import eu.etaxonomy.cdm.api.service.IFeatureNodeService; |
|
40 |
import eu.etaxonomy.cdm.api.service.IFeatureTreeService; |
|
41 |
import eu.etaxonomy.cdm.api.service.IGrantedAuthorityService; |
|
42 |
import eu.etaxonomy.cdm.api.service.IGroupService; |
|
43 |
import eu.etaxonomy.cdm.api.service.IIdentificationKeyService; |
|
44 |
import eu.etaxonomy.cdm.api.service.ILocationService; |
|
45 |
import eu.etaxonomy.cdm.api.service.IMediaService; |
|
46 |
import eu.etaxonomy.cdm.api.service.INameService; |
|
47 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService; |
|
48 |
import eu.etaxonomy.cdm.api.service.IPolytomousKeyNodeService; |
|
49 |
import eu.etaxonomy.cdm.api.service.IPolytomousKeyService; |
|
50 |
import eu.etaxonomy.cdm.api.service.IReferenceService; |
|
51 |
import eu.etaxonomy.cdm.api.service.IService; |
|
52 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
|
53 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
|
54 |
import eu.etaxonomy.cdm.api.service.ITermService; |
|
55 |
import eu.etaxonomy.cdm.api.service.IUserService; |
|
56 |
import eu.etaxonomy.cdm.api.service.IVocabularyService; |
|
57 |
import eu.etaxonomy.cdm.api.service.IWorkingSetService; |
|
58 |
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor; |
|
59 |
import eu.etaxonomy.cdm.common.monitor.NullProgressMonitor; |
|
60 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
61 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
|
62 |
import eu.etaxonomy.cdm.persistence.hibernate.permission.ICdmPermissionEvaluator; |
|
63 |
|
|
64 |
|
|
65 |
/** |
|
66 |
* @author a.mueller |
|
67 |
* @author j.koch |
|
68 |
* |
|
69 |
*/ |
|
70 |
public class CdmApplicationRemoteController implements ICdmApplicationRemoteConfiguration { |
|
71 |
private static final Logger logger = Logger.getLogger(CdmApplicationRemoteController.class); |
|
72 |
|
|
73 |
public static final String DEFAULT_APPLICATION_CONTEXT_RESOURCE = "/eu/etaxonomy/cdm/remotingApplicationContext.xml"; |
|
74 |
|
|
75 |
public AbstractApplicationContext applicationContext; |
|
76 |
private ICdmApplicationRemoteConfiguration configuration; |
|
77 |
private Resource applicationContextResource; |
|
78 |
private IProgressMonitor progressMonitor; |
|
79 |
|
|
80 |
/** |
|
81 |
* Constructor, opens a spring ApplicationContext with defaults |
|
82 |
*/ |
|
83 |
public static CdmApplicationRemoteController NewInstance() { |
|
84 |
logger.info("Configure CdmApplicationRemoteController with defaults"); |
|
85 |
return new CdmApplicationRemoteController(null, null); |
|
86 |
} |
|
87 |
|
|
88 |
/** |
|
89 |
* Constructor, opens a spring ApplicationContext with given application context |
|
90 |
* @param applicationContextResource |
|
91 |
*/ |
|
92 |
public static CdmApplicationRemoteController NewInstance(Resource applicationContextResource, IProgressMonitor progressMonitor) { |
|
93 |
logger.info("Configure CdmApplicationRemoteController with given application context"); |
|
94 |
return new CdmApplicationRemoteController(applicationContextResource, progressMonitor); |
|
95 |
} |
|
96 |
|
|
97 |
/** |
|
98 |
* Constructor, starts the application remote controller |
|
99 |
* @param applicationContextResource |
|
100 |
*/ |
|
101 |
private CdmApplicationRemoteController(Resource applicationContextResource, IProgressMonitor progressMonitor){ |
|
102 |
logger.info("Start CdmApplicationRemoteController"); |
|
103 |
this.applicationContextResource = applicationContextResource != null ? applicationContextResource : new ClassPathResource(DEFAULT_APPLICATION_CONTEXT_RESOURCE); |
|
104 |
this.progressMonitor = progressMonitor != null ? progressMonitor : new NullProgressMonitor(); |
|
105 |
setNewApplicationContext(); |
|
106 |
} |
|
107 |
|
|
108 |
/** |
|
109 |
* Sets the application context to a new spring ApplicationContext and initializes the Controller |
|
110 |
*/ |
|
111 |
private boolean setNewApplicationContext(){ |
|
112 |
logger.info("Set new application context"); |
|
113 |
progressMonitor.beginTask("Start application context.", 6); |
|
114 |
progressMonitor.worked(1); |
|
115 |
|
|
116 |
GenericApplicationContext applicationContext = new GenericApplicationContext(); |
|
117 |
|
|
118 |
XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(applicationContext); |
|
119 |
progressMonitor.subTask("Registering resources."); |
|
120 |
xmlReader.loadBeanDefinitions(applicationContextResource); |
|
121 |
progressMonitor.worked(1); |
|
122 |
|
|
123 |
progressMonitor.subTask("This might take a while ..."); |
|
124 |
applicationContext.refresh(); |
|
125 |
applicationContext.start(); |
|
126 |
progressMonitor.worked(1); |
|
127 |
|
|
128 |
progressMonitor.subTask("Cleaning up."); |
|
129 |
setApplicationContext(applicationContext); |
|
130 |
progressMonitor.done(); |
|
131 |
return true; |
|
132 |
} |
|
133 |
|
|
134 |
/** |
|
135 |
* Tests if some DefinedTermsAreMissing. |
|
136 |
* @return true, if at least one is missing, else false |
|
137 |
*/ |
|
138 |
public boolean testDefinedTermsAreMissing(){ |
|
139 |
UUID englishUuid = UUID.fromString("e9f8cdb7-6819-44e8-95d3-e2d0690c3523"); |
|
140 |
DefinedTermBase<?> english = this.getTermService().find(englishUuid); |
|
141 |
if ( english == null || ! english.getUuid().equals(englishUuid)){ |
|
142 |
return true; |
|
143 |
}else{ |
|
144 |
return false; |
|
145 |
} |
|
146 |
} |
|
147 |
|
|
148 |
/** |
|
149 |
* Sets a new application Context. |
|
150 |
* @param ac |
|
151 |
*/ |
|
152 |
public void setApplicationContext(AbstractApplicationContext ac){ |
|
153 |
closeApplicationContext(); //closes old application context if necessary |
|
154 |
applicationContext = ac; |
|
155 |
applicationContext.registerShutdownHook(); |
|
156 |
init(); |
|
157 |
} |
|
158 |
|
|
159 |
/* (non-Javadoc) |
|
160 |
* @see java.lang.Object#finalize() |
|
161 |
*/ |
|
162 |
public void finalize(){ |
|
163 |
close(); |
|
164 |
} |
|
165 |
|
|
166 |
/** |
|
167 |
* closes the application |
|
168 |
*/ |
|
169 |
public void close(){ |
|
170 |
closeApplicationContext(); |
|
171 |
} |
|
172 |
|
|
173 |
/** |
|
174 |
* closes the application context |
|
175 |
*/ |
|
176 |
private void closeApplicationContext(){ |
|
177 |
if (applicationContext != null){ |
|
178 |
logger.info("Close ApplicationContext"); |
|
179 |
applicationContext.close(); |
|
180 |
} |
|
181 |
} |
|
182 |
|
|
183 |
private void init(){ |
|
184 |
logger.info("Init " + this.getClass().getName() + " ... "); |
|
185 |
//if (logger.isInfoEnabled()){ |
|
186 |
for (String beanName : applicationContext.getBeanDefinitionNames()){ |
|
187 |
logger.debug(beanName);} |
|
188 |
//} |
|
189 |
//TODO delete next row (was just for testing) |
|
190 |
//if (logger.isInfoEnabled()){ |
|
191 |
logger.info("Registered Beans: "); |
|
192 |
String[] beanNames = applicationContext.getBeanDefinitionNames(); |
|
193 |
for (String beanName : beanNames){ |
|
194 |
logger.info(beanName); |
|
195 |
} |
|
196 |
//} |
|
197 |
//configuration = new CdmApplicationRemoteConfiguration(); |
|
198 |
configuration = (ICdmApplicationRemoteConfiguration) applicationContext.getBean("cdmApplicationRemoteConfiguration"); |
|
199 |
} |
|
200 |
|
|
201 |
|
|
202 |
|
|
203 |
/* ****** Services *********/ |
|
204 |
|
|
205 |
public final INameService getNameService(){ |
|
206 |
return configuration.getNameService(); |
|
207 |
} |
|
208 |
|
|
209 |
public final ITaxonService getTaxonService(){ |
|
210 |
return configuration.getTaxonService(); |
|
211 |
} |
|
212 |
|
|
213 |
public final IClassificationService getClassificationService(){ |
|
214 |
return configuration.getClassificationService(); |
|
215 |
} |
|
216 |
|
|
217 |
public final ITaxonNodeService getTaxonNodeService(){ |
|
218 |
return configuration.getTaxonNodeService(); |
|
219 |
} |
|
220 |
|
|
221 |
public final IReferenceService getReferenceService(){ |
|
222 |
return configuration.getReferenceService(); |
|
223 |
} |
|
224 |
|
|
225 |
public final IAgentService getAgentService(){ |
|
226 |
return configuration.getAgentService(); |
|
227 |
} |
|
228 |
|
|
229 |
public final ITermService getTermService(){ |
|
230 |
return configuration.getTermService(); |
|
231 |
} |
|
232 |
|
|
233 |
public final IDescriptionService getDescriptionService(){ |
|
234 |
return configuration.getDescriptionService(); |
|
235 |
} |
|
236 |
|
|
237 |
public final IOccurrenceService getOccurrenceService(){ |
|
238 |
return configuration.getOccurrenceService(); |
|
239 |
} |
|
240 |
|
|
241 |
public final IMediaService getMediaService(){ |
|
242 |
return configuration.getMediaService(); |
|
243 |
} |
|
244 |
|
|
245 |
public final ICommonService getCommonService(){ |
|
246 |
return configuration.getCommonService(); |
|
247 |
} |
|
248 |
|
|
249 |
public final ILocationService getLocationService(){ |
|
250 |
return configuration.getLocationService(); |
|
251 |
} |
|
252 |
|
|
253 |
public final IUserService getUserService(){ |
|
254 |
return configuration.getUserService(); |
|
255 |
} |
|
256 |
|
|
257 |
public IGroupService getGroupService() { |
|
258 |
return configuration.getGroupService(); |
|
259 |
} |
|
260 |
|
|
261 |
public final ICollectionService getCollectionService(){ |
|
262 |
return configuration.getCollectionService(); |
|
263 |
} |
|
264 |
|
|
265 |
public final IFeatureTreeService getFeatureTreeService(){ |
|
266 |
return configuration.getFeatureTreeService(); |
|
267 |
} |
|
268 |
|
|
269 |
public final IFeatureNodeService getFeatureNodeService(){ |
|
270 |
return configuration.getFeatureNodeService(); |
|
271 |
} |
|
272 |
|
|
273 |
public final IVocabularyService getVocabularyService(){ |
|
274 |
return configuration.getVocabularyService(); |
|
275 |
} |
|
276 |
|
|
277 |
public final IIdentificationKeyService getIdentificationKeyService(){ |
|
278 |
return configuration.getIdentificationKeyService(); |
|
279 |
} |
|
280 |
|
|
281 |
public final IPolytomousKeyService getPolytomousKeyService(){ |
|
282 |
return configuration.getPolytomousKeyService(); |
|
283 |
} |
|
284 |
|
|
285 |
public final IPolytomousKeyNodeService getPolytomousKeyNodeService(){ |
|
286 |
return configuration.getPolytomousKeyNodeService(); |
|
287 |
} |
|
288 |
|
|
289 |
public final IService<CdmBase> getMainService(){ |
|
290 |
return configuration.getMainService(); |
|
291 |
} |
|
292 |
|
|
293 |
public final IWorkingSetService getWorkingSetService(){ |
|
294 |
return configuration.getWorkingSetService(); |
|
295 |
} |
|
296 |
|
|
297 |
|
|
298 |
@Override |
|
299 |
public ProviderManager getAuthenticationManager() { |
|
300 |
return configuration.getAuthenticationManager(); |
|
301 |
} |
|
302 |
|
|
303 |
|
|
304 |
|
|
305 |
@Override |
|
306 |
public ConversationHolder NewConversation() { |
|
307 |
return configuration.NewConversation(); |
|
308 |
} |
|
309 |
|
|
310 |
@Override |
|
311 |
public Object getBean(String name) { |
|
312 |
return configuration.getBean(name); |
|
313 |
} |
|
314 |
|
|
315 |
@Override |
|
316 |
public IGrantedAuthorityService getGrantedAuthorityService() { |
|
317 |
return configuration.getGrantedAuthorityService(); |
|
318 |
} |
|
319 |
|
|
320 |
@Override |
|
321 |
public ICdmPermissionEvaluator getPermissionEvaluator() { |
|
322 |
return configuration.getPermissionEvaluator(); |
|
323 |
} |
|
324 |
|
|
325 |
@Override |
|
326 |
public void authenticate(String username, String password) { |
|
327 |
configuration.authenticate(username, password); |
|
328 |
|
|
329 |
} |
|
330 |
|
|
331 |
|
|
332 |
} |
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/api/application/ICdmApplicationRemoteConfiguration.java | ||
---|---|---|
1 |
package eu.etaxonomy.cdm.api.application; |
|
2 |
|
|
3 |
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration; |
|
4 |
|
|
5 |
|
|
6 |
public interface ICdmApplicationRemoteConfiguration extends ICdmApplicationConfiguration { |
|
7 |
|
|
8 |
|
|
9 |
} |
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/remote/api/application/CdmApplicationRemoteConfiguration.java | ||
---|---|---|
1 |
// $Id: CdmApplicationDefaultConfiguration.java 11680 2011-04-04 17:07:39Z a.mueller $ |
|
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.remote.api.application; |
|
12 |
|
|
13 |
import org.apache.log4j.Logger; |
|
14 |
import org.springframework.context.ApplicationContextAware; |
|
15 |
import org.springframework.stereotype.Component; |
|
16 |
|
|
17 |
import eu.etaxonomy.cdm.api.application.CdmApplicationConfiguration; |
|
18 |
import eu.etaxonomy.cdm.api.application.CdmApplicationDefaultConfiguration; |
|
19 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
|
20 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolderMock; |
|
21 |
|
|
22 |
/** |
|
23 |
* @author a.mueller |
|
24 |
* @created 21.05.2008 |
|
25 |
* @version 1.0 |
|
26 |
*/ |
|
27 |
/** |
|
28 |
* @author a.mueller |
|
29 |
* @author j.koch |
|
30 |
*/ |
|
31 |
@Component |
|
32 |
public class CdmApplicationRemoteConfiguration extends CdmApplicationConfiguration implements ICdmApplicationRemoteConfiguration, ApplicationContextAware { |
|
33 |
|
|
34 |
@SuppressWarnings("unused") |
|
35 |
private static final Logger logger = Logger.getLogger(CdmApplicationRemoteConfiguration.class); |
|
36 |
|
|
37 |
public CdmApplicationRemoteConfiguration() { |
|
38 |
} |
|
39 |
|
|
40 |
@Override |
|
41 |
public ConversationHolder NewConversation() { |
|
42 |
// TODO Auto-generated method stub |
|
43 |
return new ConversationHolderMock(); |
|
44 |
} |
|
45 |
} |
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/remote/api/application/CdmApplicationRemoteController.java | ||
---|---|---|
1 |
// $Id: CdmApplicationController.java 11680 2011-04-04 17:07:39Z a.mueller $ |
|
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 |
|
|
12 |
package eu.etaxonomy.cdm.remote.api.application; |
|
13 |
|
|
14 |
import java.util.UUID; |
|
15 |
|
|
16 |
import org.apache.log4j.Logger; |
|
17 |
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; |
|
18 |
import org.springframework.context.support.AbstractApplicationContext; |
|
19 |
import org.springframework.context.support.GenericApplicationContext; |
|
20 |
import org.springframework.core.io.ClassPathResource; |
|
21 |
import org.springframework.core.io.Resource; |
|
22 |
import org.springframework.security.access.PermissionEvaluator; |
|
23 |
import org.springframework.security.authentication.ProviderManager; |
|
24 |
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
|
25 |
import org.springframework.security.core.Authentication; |
|
26 |
import org.springframework.security.core.context.SecurityContext; |
|
27 |
import org.springframework.security.core.context.SecurityContextHolder; |
|
28 |
import org.springframework.transaction.PlatformTransactionManager; |
|
29 |
//import org.springframework.transaction.PlatformTransactionManager; |
|
30 |
import org.springframework.transaction.TransactionStatus; |
|
31 |
|
|
32 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
|
33 |
import eu.etaxonomy.cdm.api.service.IAgentService; |
|
34 |
import eu.etaxonomy.cdm.api.service.IClassificationService; |
|
35 |
import eu.etaxonomy.cdm.api.service.ICollectionService; |
|
36 |
import eu.etaxonomy.cdm.api.service.ICommonService; |
|
37 |
import eu.etaxonomy.cdm.api.service.IDatabaseService; |
|
38 |
import eu.etaxonomy.cdm.api.service.IDescriptionService; |
|
39 |
import eu.etaxonomy.cdm.api.service.IFeatureNodeService; |
|
40 |
import eu.etaxonomy.cdm.api.service.IFeatureTreeService; |
|
41 |
import eu.etaxonomy.cdm.api.service.IGrantedAuthorityService; |
|
42 |
import eu.etaxonomy.cdm.api.service.IGroupService; |
|
43 |
import eu.etaxonomy.cdm.api.service.IIdentificationKeyService; |
|
44 |
import eu.etaxonomy.cdm.api.service.ILocationService; |
|
45 |
import eu.etaxonomy.cdm.api.service.IMediaService; |
|
46 |
import eu.etaxonomy.cdm.api.service.INameService; |
|
47 |
import eu.etaxonomy.cdm.api.service.IOccurrenceService; |
|
48 |
import eu.etaxonomy.cdm.api.service.IPolytomousKeyNodeService; |
|
49 |
import eu.etaxonomy.cdm.api.service.IPolytomousKeyService; |
|
50 |
import eu.etaxonomy.cdm.api.service.IReferenceService; |
|
51 |
import eu.etaxonomy.cdm.api.service.IService; |
|
52 |
import eu.etaxonomy.cdm.api.service.ITaxonNodeService; |
|
53 |
import eu.etaxonomy.cdm.api.service.ITaxonService; |
|
54 |
import eu.etaxonomy.cdm.api.service.ITermService; |
|
55 |
import eu.etaxonomy.cdm.api.service.IUserService; |
|
56 |
import eu.etaxonomy.cdm.api.service.IVocabularyService; |
|
57 |
import eu.etaxonomy.cdm.api.service.IWorkingSetService; |
|
58 |
import eu.etaxonomy.cdm.common.monitor.IProgressMonitor; |
|
59 |
import eu.etaxonomy.cdm.common.monitor.NullProgressMonitor; |
|
60 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
61 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
|
62 |
import eu.etaxonomy.cdm.persistence.hibernate.permission.ICdmPermissionEvaluator; |
|
63 |
|
|
64 |
|
|
65 |
/** |
|
66 |
* @author a.mueller |
|
67 |
* @author j.koch |
|
68 |
* |
|
69 |
*/ |
|
70 |
public class CdmApplicationRemoteController implements ICdmApplicationRemoteConfiguration { |
|
71 |
private static final Logger logger = Logger.getLogger(CdmApplicationRemoteController.class); |
|
72 |
|
|
73 |
public static final String DEFAULT_APPLICATION_CONTEXT_RESOURCE = "/eu/etaxonomy/cdm/remotingApplicationContext.xml"; |
|
74 |
|
|
75 |
public AbstractApplicationContext applicationContext; |
|
76 |
private ICdmApplicationRemoteConfiguration configuration; |
|
77 |
private Resource applicationContextResource; |
|
78 |
private IProgressMonitor progressMonitor; |
|
79 |
|
|
80 |
/** |
|
81 |
* Constructor, opens a spring ApplicationContext with defaults |
|
82 |
*/ |
|
83 |
public static CdmApplicationRemoteController NewInstance() { |
|
84 |
logger.info("Configure CdmApplicationRemoteController with defaults"); |
|
85 |
return new CdmApplicationRemoteController(null, null); |
|
86 |
} |
|
87 |
|
|
88 |
/** |
|
89 |
* Constructor, opens a spring ApplicationContext with given application context |
|
90 |
* @param applicationContextResource |
|
91 |
*/ |
|
92 |
public static CdmApplicationRemoteController NewInstance(Resource applicationContextResource, IProgressMonitor progressMonitor) { |
|
93 |
logger.info("Configure CdmApplicationRemoteController with given application context"); |
|
94 |
return new CdmApplicationRemoteController(applicationContextResource, progressMonitor); |
|
95 |
} |
|
96 |
|
|
97 |
/** |
|
98 |
* Constructor, starts the application remote controller |
|
99 |
* @param applicationContextResource |
|
100 |
*/ |
|
101 |
private CdmApplicationRemoteController(Resource applicationContextResource, IProgressMonitor progressMonitor){ |
|
102 |
logger.info("Start CdmApplicationRemoteController"); |
|
103 |
this.applicationContextResource = applicationContextResource != null ? applicationContextResource : new ClassPathResource(DEFAULT_APPLICATION_CONTEXT_RESOURCE); |
|
104 |
this.progressMonitor = progressMonitor != null ? progressMonitor : new NullProgressMonitor(); |
|
105 |
setNewApplicationContext(); |
|
106 |
} |
|
107 |
|
|
108 |
/** |
|
109 |
* Sets the application context to a new spring ApplicationContext and initializes the Controller |
|
110 |
*/ |
|
111 |
private boolean setNewApplicationContext(){ |
|
112 |
logger.info("Set new application context"); |
|
113 |
progressMonitor.beginTask("Start application context.", 6); |
|
114 |
progressMonitor.worked(1); |
|
115 |
|
|
116 |
GenericApplicationContext applicationContext = new GenericApplicationContext(); |
|
117 |
|
|
118 |
XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(applicationContext); |
|
119 |
progressMonitor.subTask("Registering resources."); |
|
120 |
xmlReader.loadBeanDefinitions(applicationContextResource); |
|
121 |
progressMonitor.worked(1); |
|
122 |
|
|
123 |
progressMonitor.subTask("This might take a while ..."); |
|
124 |
applicationContext.refresh(); |
|
125 |
applicationContext.start(); |
|
126 |
progressMonitor.worked(1); |
|
127 |
|
|
128 |
progressMonitor.subTask("Cleaning up."); |
|
129 |
setApplicationContext(applicationContext); |
|
130 |
progressMonitor.done(); |
|
131 |
return true; |
|
132 |
} |
|
133 |
|
|
134 |
/** |
|
135 |
* Tests if some DefinedTermsAreMissing. |
|
136 |
* @return true, if at least one is missing, else false |
|
137 |
*/ |
|
138 |
public boolean testDefinedTermsAreMissing(){ |
|
139 |
UUID englishUuid = UUID.fromString("e9f8cdb7-6819-44e8-95d3-e2d0690c3523"); |
|
140 |
DefinedTermBase<?> english = this.getTermService().find(englishUuid); |
|
141 |
if ( english == null || ! english.getUuid().equals(englishUuid)){ |
|
142 |
return true; |
|
143 |
}else{ |
|
144 |
return false; |
|
145 |
} |
|
146 |
} |
|
147 |
|
|
148 |
/** |
|
149 |
* Sets a new application Context. |
|
150 |
* @param ac |
|
151 |
*/ |
|
152 |
public void setApplicationContext(AbstractApplicationContext ac){ |
|
153 |
closeApplicationContext(); //closes old application context if necessary |
|
154 |
applicationContext = ac; |
|
155 |
applicationContext.registerShutdownHook(); |
|
156 |
init(); |
|
157 |
} |
|
158 |
|
|
159 |
/* (non-Javadoc) |
|
160 |
* @see java.lang.Object#finalize() |
|
161 |
*/ |
|
162 |
public void finalize(){ |
|
163 |
close(); |
|
164 |
} |
|
165 |
|
|
166 |
/** |
|
167 |
* closes the application |
|
168 |
*/ |
|
169 |
public void close(){ |
|
170 |
closeApplicationContext(); |
|
171 |
} |
|
172 |
|
|
173 |
/** |
|
174 |
* closes the application context |
|
175 |
*/ |
|
176 |
private void closeApplicationContext(){ |
|
177 |
if (applicationContext != null){ |
|
178 |
logger.info("Close ApplicationContext"); |
|
179 |
applicationContext.close(); |
|
180 |
} |
|
181 |
} |
|
182 |
|
|
183 |
private void init(){ |
|
184 |
logger.info("Init " + this.getClass().getName() + " ... "); |
|
185 |
if (logger.isInfoEnabled()){for (String beanName : applicationContext.getBeanDefinitionNames()){ logger.debug(beanName);}} |
|
186 |
//TODO delete next row (was just for testing) |
|
187 |
if (logger.isInfoEnabled()){ |
|
188 |
logger.info("Registered Beans: "); |
|
189 |
String[] beanNames = applicationContext.getBeanDefinitionNames(); |
|
190 |
for (String beanName : beanNames){ |
|
191 |
logger.info(beanName); |
|
192 |
} |
|
193 |
} |
|
194 |
configuration = new CdmApplicationRemoteConfiguration(); |
|
195 |
} |
|
196 |
|
|
197 |
|
|
198 |
|
|
199 |
/* ****** Services *********/ |
|
200 |
|
|
201 |
public final INameService getNameService(){ |
|
202 |
return configuration.getNameService(); |
|
203 |
} |
|
204 |
|
|
205 |
public final ITaxonService getTaxonService(){ |
|
206 |
return configuration.getTaxonService(); |
|
207 |
} |
|
208 |
|
|
209 |
public final IClassificationService getClassificationService(){ |
|
210 |
return configuration.getClassificationService(); |
|
211 |
} |
|
212 |
|
|
213 |
public final ITaxonNodeService getTaxonNodeService(){ |
|
214 |
return configuration.getTaxonNodeService(); |
|
215 |
} |
|
216 |
|
|
217 |
public final IReferenceService getReferenceService(){ |
|
218 |
return configuration.getReferenceService(); |
|
219 |
} |
|
220 |
|
|
221 |
public final IAgentService getAgentService(){ |
|
222 |
return configuration.getAgentService(); |
|
223 |
} |
|
224 |
|
|
225 |
public final ITermService getTermService(){ |
|
226 |
return configuration.getTermService(); |
|
227 |
} |
|
228 |
|
|
229 |
public final IDescriptionService getDescriptionService(){ |
|
230 |
return configuration.getDescriptionService(); |
|
231 |
} |
|
232 |
|
|
233 |
public final IOccurrenceService getOccurrenceService(){ |
|
234 |
return configuration.getOccurrenceService(); |
|
235 |
} |
|
236 |
|
|
237 |
public final IMediaService getMediaService(){ |
|
238 |
return configuration.getMediaService(); |
|
239 |
} |
|
240 |
|
|
241 |
public final ICommonService getCommonService(){ |
|
242 |
return configuration.getCommonService(); |
|
243 |
} |
|
244 |
|
|
245 |
public final ILocationService getLocationService(){ |
|
246 |
return configuration.getLocationService(); |
|
247 |
} |
|
248 |
|
|
249 |
public final IUserService getUserService(){ |
|
250 |
return configuration.getUserService(); |
|
251 |
} |
|
252 |
|
|
253 |
public IGroupService getGroupService() { |
|
254 |
return configuration.getGroupService(); |
|
255 |
} |
|
256 |
|
|
257 |
public final ICollectionService getCollectionService(){ |
|
258 |
return configuration.getCollectionService(); |
|
259 |
} |
|
260 |
|
|
261 |
public final IFeatureTreeService getFeatureTreeService(){ |
|
262 |
return configuration.getFeatureTreeService(); |
|
263 |
} |
|
264 |
|
|
265 |
public final IFeatureNodeService getFeatureNodeService(){ |
|
266 |
return configuration.getFeatureNodeService(); |
|
267 |
} |
|
268 |
|
|
269 |
public final IVocabularyService getVocabularyService(){ |
|
270 |
return configuration.getVocabularyService(); |
|
271 |
} |
|
272 |
|
|
273 |
public final IIdentificationKeyService getIdentificationKeyService(){ |
|
274 |
return configuration.getIdentificationKeyService(); |
|
275 |
} |
|
276 |
|
|
277 |
public final IPolytomousKeyService getPolytomousKeyService(){ |
|
278 |
return configuration.getPolytomousKeyService(); |
|
279 |
} |
|
280 |
|
|
281 |
public final IPolytomousKeyNodeService getPolytomousKeyNodeService(){ |
|
282 |
return configuration.getPolytomousKeyNodeService(); |
|
283 |
} |
|
284 |
|
|
285 |
public final IService<CdmBase> getMainService(){ |
|
286 |
return configuration.getMainService(); |
|
287 |
} |
|
288 |
|
|
289 |
public final IWorkingSetService getWorkingSetService(){ |
|
290 |
return configuration.getWorkingSetService(); |
|
291 |
} |
|
292 |
|
|
293 |
|
|
294 |
@Override |
|
295 |
public ProviderManager getAuthenticationManager() { |
|
296 |
return configuration.getAuthenticationManager(); |
|
297 |
} |
|
298 |
|
|
299 |
|
|
300 |
|
|
301 |
@Override |
|
302 |
public ConversationHolder NewConversation() { |
|
303 |
return configuration.NewConversation(); |
|
304 |
} |
|
305 |
|
|
306 |
@Override |
|
307 |
public Object getBean(String name) { |
|
308 |
return configuration.getBean(name); |
|
309 |
} |
|
310 |
|
|
311 |
@Override |
|
312 |
public IGrantedAuthorityService getGrantedAuthorityService() { |
|
313 |
return configuration.getGrantedAuthorityService(); |
|
314 |
} |
|
315 |
|
|
316 |
@Override |
|
317 |
public ICdmPermissionEvaluator getPermissionEvaluator() { |
|
318 |
return configuration.getPermissionEvaluator(); |
|
319 |
} |
|
320 |
|
|
321 |
@Override |
|
322 |
public void authenticate(String username, String password) { |
|
323 |
configuration.authenticate(username, password); |
|
324 |
|
|
325 |
} |
|
326 |
|
|
327 |
|
|
328 |
} |
eu.etaxonomy.taxeditor.cdmlib/src/main/java/eu/etaxonomy/cdm/remote/api/application/ICdmApplicationRemoteConfiguration.java | ||
---|---|---|
1 |
package eu.etaxonomy.cdm.remote.api.application; |
|
2 |
|
|
3 |
import eu.etaxonomy.cdm.api.application.ICdmApplicationConfiguration; |
|
4 |
|
|
5 |
|
|
6 |
public interface ICdmApplicationRemoteConfiguration extends ICdmApplicationConfiguration { |
|
7 |
|
|
8 |
|
|
9 |
} |
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/config.properties | ||
---|---|---|
1 |
serverName=localhost:8080 |
|
2 |
contextPath= |
eu.etaxonomy.taxeditor.cdmlib/src/main/resources/eu/etaxonomy/cdm/remotingApplicationContext.xml | ||
---|---|---|
7 | 7 |
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd |
8 | 8 |
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> |
9 | 9 |
|
10 |
<!-- Remoting Aspect --> |
|
11 |
<!--context:spring-configured /> |
|
12 |
<bean id="cdmlazyLoader" class="eu.etaxonomy.cdm.api.lazyloading.CdmLazyLoader" |
|
13 |
factory-method="aspectOf" /--> |
|
14 |
|
|
15 |
<import resource="classpath:/eu/etaxonomy/cdm/remoting_services_security.xml"/> |
|
10 |
<import resource="classpath:/eu/etaxonomy/cdm/remoting_services_security.xml"/> |
|
16 | 11 |
|
17 | 12 |
<import resource="classpath:/eu/etaxonomy/cdm/httpInvokerServiceClients.xml"/> |
18 | 13 |
|
19 | 14 |
<context:component-scan base-package="eu/etaxonomy/cdm/api/application"> |
20 |
<context:exclude-filter type="regex" expression="eu\.etaxonomy\.cdm\.api\.application\.CdmApplicationController"/> |
|
21 |
<context:exclude-filter type="regex" expression="eu\.etaxonomy\.cdm\.api\.application\.CdmApplicationDefaultConfiguration"/> |
|
22 |
<context:exclude-filter type="regex" expression="eu\.etaxonomy\.cdm\.remote\.api\.application\.CdmApplicationRemoteController"/> |
|
23 |
<context:exclude-filter type="regex" expression="eu\.etaxonomy\.cdm\.remote\.api\.application\.CdmApplicationRemoteDefaultConfiguration"/> |
|
15 |
<context:exclude-filter type="regex" expression="eu\.etaxonomy\.cdm\.api\.application\.CdmApplicationDefaultController"/> |
|
16 |
<context:exclude-filter type="regex" expression="eu\.etaxonomy\.cdm\.api\.application\.CdmApplicationDefaultConfiguration"/> |
|
24 | 17 |
</context:component-scan> |
25 |
<!--bean id="persistentTermInitializer" class="eu.etaxonomy.cdm.database.PersistentTermInitializer"> |
|
26 |
<property name="omit" value="false" /> |
|
27 |
</bean--> |
|
28 |
<!--bean id="remoteTermInitializer" class="eu.etaxonomy.cdm.remote.service.RemoteTermInitializer"> |
|
29 |
<property name="omit" value="false" /> |
|
30 |
</bean--> |
|
18 |
|
|
31 | 19 |
|
32 | 20 |
<!-- EditGeoService was moved to ext. Therefore it will not be found by the default component scan. |
33 | 21 |
We added it here because the Editor needs it. However, this is only a temporary solution. |
eu.etaxonomy.taxeditor.cdmlib/src/test/java/eu/etaxonomy/taxeditor/remoting/CdmApplicationRemoteControllerTest.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import org.junit.Test; |
4 | 4 |
|
5 |
import eu.etaxonomy.cdm.remote.api.application.CdmApplicationRemoteController;
|
|
5 |
import eu.etaxonomy.cdm.api.application.CdmApplicationRemoteController; |
|
6 | 6 |
|
7 | 7 |
public class CdmApplicationRemoteControllerTest { |
8 | 8 |
|
Also available in: Unified diff
changed package name to be consistent with cdmlib
remotingApplicationContext.xml : cleaning up component scan