Revision 1d4b43d8
Added by Andreas Kohlbecker almost 7 years ago
src/main/java/eu/etaxonomy/cdm/addon/config/CdmVaadinConfiguration.java | ||
---|---|---|
15 | 15 |
import javax.servlet.annotation.WebServlet; |
16 | 16 |
|
17 | 17 |
import org.apache.log4j.Logger; |
18 |
import org.springframework.beans.BeansException; |
|
18 | 19 |
import org.springframework.beans.factory.annotation.Autowired; |
20 |
import org.springframework.context.ApplicationContext; |
|
21 |
import org.springframework.context.ApplicationContextAware; |
|
19 | 22 |
import org.springframework.context.annotation.Bean; |
20 | 23 |
import org.springframework.context.annotation.ComponentScan; |
21 | 24 |
import org.springframework.context.annotation.ComponentScan.Filter; |
22 | 25 |
import org.springframework.context.annotation.Configuration; |
23 | 26 |
import org.springframework.context.annotation.FilterType; |
24 | 27 |
import org.springframework.context.annotation.Lazy; |
28 |
import org.springframework.security.authentication.AuthenticationProvider; |
|
25 | 29 |
|
26 | 30 |
import com.vaadin.server.DeploymentConfiguration; |
27 | 31 |
import com.vaadin.server.ServiceException; |
... | ... | |
32 | 36 |
import com.vaadin.spring.server.SpringVaadinServlet; |
33 | 37 |
import com.vaadin.ui.UI; |
34 | 38 |
|
39 |
import eu.etaxonomy.cdm.api.application.CdmRepository; |
|
35 | 40 |
import eu.etaxonomy.cdm.common.ConfigFileUtil; |
41 |
import eu.etaxonomy.cdm.dataInserter.RegistrationRequiredDataInserter; |
|
36 | 42 |
import eu.etaxonomy.cdm.opt.config.DataSourceConfigurer; |
37 | 43 |
import eu.etaxonomy.cdm.vaadin.security.annotation.EnableAnnotationBasedAccessControl; |
38 | 44 |
import eu.etaxonomy.cdm.vaadin.server.CdmSpringVaadinServletService; |
... | ... | |
53 | 59 |
@ComponentScan(basePackages={ |
54 | 60 |
"eu.etaxonomy.vaadin.ui", |
55 | 61 |
"eu.etaxonomy.cdm.vaadin", |
56 |
"eu.etaxonomy.cdm.dataInserter", |
|
57 | 62 |
"eu.etaxonomy.cdm.service", |
58 |
"eu.etaxonomy.cdm.vaadin.component", // for the FieldFactories |
|
59 | 63 |
"org.springframework.context.event" |
60 | 64 |
}, |
61 | 65 |
// exclude UI classes, these are provided via the @Bean annotated methods below |
... | ... | |
67 | 71 |
@EnableVaadin // this imports VaadinConfiguration |
68 | 72 |
@EnableVaadinSpringNavigation // activate the NavigationManagerBean |
69 | 73 |
@EnableAnnotationBasedAccessControl // enable annotation based per view access control |
70 |
public class CdmVaadinConfiguration { |
|
74 |
public class CdmVaadinConfiguration implements ApplicationContextAware {
|
|
71 | 75 |
|
72 | 76 |
/** |
73 | 77 |
* |
... | ... | |
97 | 101 |
throws ServiceException { |
98 | 102 |
|
99 | 103 |
// - The SpringVaadinServletService is needed when using a custom service URL |
100 |
// - The CdmSpringVaadinServletService allows to attach listeners to the requestEnd and
|
|
101 |
// requestStart method this is important for proper unbinding of Conversations from
|
|
104 |
// - The CdmSpringVaadinServletService allows to attach listeners to the requestEnd and |
|
105 |
// requestStart method this is important for proper unbinding of Conversations from |
|
102 | 106 |
// the request threads. |
103 | 107 |
// see ViewScopeConversationHolder |
104 | 108 |
CdmSpringVaadinServletService service = new CdmSpringVaadinServletService( |
... | ... | |
160 | 164 |
return null; |
161 | 165 |
} |
162 | 166 |
|
167 |
@Bean |
|
168 |
public RegistrationRequiredDataInserter registrationRequiredDataInserter() throws BeansException, InactiveUIException{ |
|
169 |
RegistrationRequiredDataInserter inserter = null; |
|
170 |
if(isUIEnabled(RegistrationUI.class)){ |
|
171 |
inserter = new RegistrationRequiredDataInserter(); |
|
172 |
inserter.setRunAsAuthenticationProvider((AuthenticationProvider) applicationContext.getBean("runAsAuthenticationProvider")); |
|
173 |
inserter.setCdmRepository((CdmRepository) applicationContext.getBean("cdmRepository")); |
|
174 |
} |
|
175 |
return inserter; |
|
176 |
} |
|
177 |
|
|
163 | 178 |
@Bean |
164 | 179 |
@UIScope |
165 | 180 |
public DistributionStatusUI distributionStatusUI() throws InactiveUIException { |
... | ... | |
178 | 193 |
return null; |
179 | 194 |
} |
180 | 195 |
|
181 |
|
|
182 |
|
|
183 | 196 |
static final String PROPERTIES_NAME = "vaadin-apps"; |
184 | 197 |
|
185 | 198 |
private Properties appProps = null; |
186 | 199 |
|
200 |
private ApplicationContext applicationContext; |
|
201 |
|
|
187 | 202 |
//@formatter:off |
188 | 203 |
private static final String APP_FILE_CONTENT= |
189 | 204 |
"########################################################\n"+ |
... | ... | |
209 | 224 |
* @throws InactiveUIException |
210 | 225 |
*/ |
211 | 226 |
private boolean isUIEnabled(Class<? extends UI>uiClass) throws InactiveUIException { |
227 |
|
|
212 | 228 |
String path = uiClass.getAnnotation(SpringUI.class).path().trim(); |
213 | 229 |
|
214 | 230 |
try { |
... | ... | |
224 | 240 |
return true; |
225 | 241 |
} |
226 | 242 |
} |
227 |
throw new InactiveUIException(path); |
|
243 |
throw new InactiveUIException(path); // FIXME should return false instead
|
|
228 | 244 |
} catch (IOException e) { |
229 | 245 |
logger.error("Error reading the vaadin ui properties file. File corrupted?. Stopping instance ..."); |
230 | 246 |
throw new RuntimeException(e); |
231 | 247 |
} |
232 | 248 |
} |
233 | 249 |
|
250 |
/** |
|
251 |
* {@inheritDoc} |
|
252 |
*/ |
|
253 |
@Override |
|
254 |
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { |
|
255 |
this.applicationContext = applicationContext; |
|
256 |
|
|
257 |
} |
|
258 |
|
|
234 | 259 |
|
235 | 260 |
} |
Also available in: Unified diff
fix #6852 data insterter to create Group 'Curation' and to extend 'Editor' for phycobank