43 |
43 |
import eu.etaxonomy.cdm.api.application.CdmRepository;
|
44 |
44 |
import eu.etaxonomy.cdm.api.application.DummyDataInserter;
|
45 |
45 |
import eu.etaxonomy.cdm.api.cache.CdmCacher;
|
|
46 |
import eu.etaxonomy.cdm.api.config.ApplicationConfiguration;
|
|
47 |
import eu.etaxonomy.cdm.api.config.ApplicationConfigurationFile;
|
46 |
48 |
import eu.etaxonomy.cdm.api.service.idminter.RegistrationIdentifierMinter;
|
47 |
49 |
import eu.etaxonomy.cdm.cache.CdmTransientEntityCacher;
|
48 |
|
import eu.etaxonomy.cdm.common.ConfigFileUtil;
|
49 |
50 |
import eu.etaxonomy.cdm.dataInserter.RegistrationRequiredDataInserter;
|
50 |
|
import eu.etaxonomy.cdm.opt.config.DataSourceConfigurer;
|
51 |
51 |
import eu.etaxonomy.cdm.persistence.hibernate.GrantedAuthorityRevokingRegistrationUpdateLister;
|
52 |
52 |
import eu.etaxonomy.cdm.vaadin.security.annotation.EnableAnnotationBasedAccessControl;
|
53 |
53 |
import eu.etaxonomy.cdm.vaadin.ui.ConceptRelationshipUI;
|
... | ... | |
81 |
81 |
@EnableEventBus // enable the vaadin spring event bus
|
82 |
82 |
public class CdmVaadinConfiguration implements ApplicationContextAware {
|
83 |
83 |
|
84 |
|
|
85 |
|
public static final String CDM_DATA_SOURCE_ID = DataSourceConfigurer.CDM_DATA_SOURCE_ID;
|
86 |
|
|
87 |
84 |
public static final String CDM_VAADIN_UI_ACTIVATED = "cdm-vaadin.ui.activated";
|
88 |
85 |
public static final String CDM_SERVICE_MINTER_REGSTRATION_MINID = "cdm.service.minter.registration.minLocalId";
|
89 |
86 |
public static final String CDM_SERVICE_MINTER_REGSTRATION_MAXID = "cdm.service.minter.registration.maxLocalId";
|
... | ... | |
97 |
94 |
@Autowired
|
98 |
95 |
private SessionFactory sessionFactory;
|
99 |
96 |
|
|
97 |
@Autowired
|
|
98 |
private ApplicationConfiguration appConfig;
|
|
99 |
|
100 |
100 |
@Autowired
|
101 |
101 |
private void setTermCacher(CdmCacher termCacher){
|
102 |
102 |
CdmTransientEntityCacher.setDefaultCacher(termCacher);
|
... | ... | |
104 |
104 |
|
105 |
105 |
private boolean registrationUiHibernateEventListenersDone = false;
|
106 |
106 |
|
|
107 |
|
|
108 |
ApplicationConfigurationFile configFile = new ApplicationConfigurationFile(PROPERTIES_FILE_NAME, APP_FILE_CONTENT);
|
|
109 |
|
107 |
110 |
/*
|
108 |
111 |
* NOTE: It is necessary to map the URLs starting with /VAADIN/* since none of the
|
109 |
112 |
* @WebServlets is mapped to the root path. It is sufficient to configure one of the
|
... | ... | |
198 |
201 |
@Bean
|
199 |
202 |
public RegistrationIdentifierMinter registrationIdentifierMinter() throws IOException {
|
200 |
203 |
RegistrationIdentifierMinter minter = new RegistrationIdentifierMinter();
|
201 |
|
ensureVaadinAppPropertiesLoaded();
|
202 |
|
minter.setMinLocalId(appProps.getProperty(CDM_SERVICE_MINTER_REGSTRATION_MINID));
|
203 |
|
minter.setMaxLocalId(appProps.getProperty(CDM_SERVICE_MINTER_REGSTRATION_MAXID));
|
204 |
|
minter.setIdentifierFormatString(appProps.getProperty(CDM_SERVICE_MINTER_REGSTRATION_IDFORMAT));
|
|
204 |
|
|
205 |
minter.setMinLocalId(appConfig.getProperty(configFile , CDM_SERVICE_MINTER_REGSTRATION_MINID));
|
|
206 |
minter.setMaxLocalId(appConfig.getProperty(configFile , CDM_SERVICE_MINTER_REGSTRATION_MAXID));
|
|
207 |
minter.setIdentifierFormatString(appConfig.getProperty(configFile , CDM_SERVICE_MINTER_REGSTRATION_IDFORMAT));
|
205 |
208 |
return minter;
|
206 |
209 |
}
|
207 |
210 |
|
... | ... | |
264 |
267 |
String path = uiClass.getAnnotation(SpringUI.class).path().trim();
|
265 |
268 |
|
266 |
269 |
if(activeUIpaths == null){
|
267 |
|
try {
|
268 |
|
|
269 |
|
String activatedVaadinUIs = env.getProperty(CDM_VAADIN_UI_ACTIVATED);
|
270 |
|
if(activatedVaadinUIs == null){
|
271 |
|
// not in environment? Read it from the config file!
|
272 |
|
ensureVaadinAppPropertiesLoaded();
|
273 |
|
if(appProps.get(CDM_VAADIN_UI_ACTIVATED) != null){
|
274 |
|
activatedVaadinUIs = appProps.get(CDM_VAADIN_UI_ACTIVATED).toString();
|
275 |
|
}
|
276 |
|
}
|
277 |
|
|
278 |
|
if(activatedVaadinUIs != null) {
|
279 |
|
String[] uiPaths = activatedVaadinUIs.split("\\s*,\\s*");
|
280 |
|
this.activeUIpaths = Arrays.asList(uiPaths);
|
281 |
|
}
|
282 |
|
} catch (IOException e) {
|
283 |
|
logger.error("Error reading the vaadin ui properties file. File corrupted?. Stopping instance ...");
|
284 |
|
throw new RuntimeException(e);
|
|
270 |
String activatedVaadinUIs = env.getProperty(CDM_VAADIN_UI_ACTIVATED);
|
|
271 |
if(activatedVaadinUIs == null){
|
|
272 |
// not in environment? Read it from the config file!
|
|
273 |
activatedVaadinUIs = appConfig.getProperty(configFile , CDM_VAADIN_UI_ACTIVATED);
|
|
274 |
}
|
|
275 |
|
|
276 |
if(activatedVaadinUIs != null) {
|
|
277 |
String[] uiPaths = activatedVaadinUIs.split("\\s*,\\s*");
|
|
278 |
this.activeUIpaths = Arrays.asList(uiPaths);
|
285 |
279 |
}
|
286 |
280 |
}
|
287 |
281 |
if(activeUIpaths.stream().anyMatch(p -> p.trim().equals(path))){
|
... | ... | |
291 |
285 |
|
292 |
286 |
}
|
293 |
287 |
|
294 |
|
/**
|
295 |
|
* @param currentDataSourceId
|
296 |
|
* @throws IOException
|
297 |
|
*/
|
298 |
|
protected void ensureVaadinAppPropertiesLoaded() throws IOException {
|
299 |
288 |
|
300 |
|
String currentDataSourceId = env.getProperty(CDM_DATA_SOURCE_ID);
|
301 |
|
if(appProps == null){
|
302 |
|
appProps = new ConfigFileUtil()
|
303 |
|
.setDefaultContent(APP_FILE_CONTENT)
|
304 |
|
.getProperties(currentDataSourceId, PROPERTIES_FILE_NAME);
|
305 |
|
}
|
306 |
|
}
|
307 |
289 |
|
308 |
290 |
/**
|
309 |
291 |
* {@inheritDoc}
|
using ApplicationConfiguration in CdmVaadinConfiguration