use of com.hack23.cia.service.api.UserConfiguration in project cia by Hack23.
the class ConfigurationManagerImpl method getUserConfiguration.
@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public UserConfiguration getUserConfiguration(final String url, final String locale) {
final Agency agency = agencyDAO.getAll().get(0);
Portal usePortal = null;
final LanguageData languageData = findLanguage(locale);
for (final Portal portal : agency.getPortals()) {
if (usePortal == null && PortalType.DEFAULT == portal.getPortalType() || url.contains(portal.getPortalName())) {
usePortal = portal;
}
}
return new UserConfigurationImpl(agency, usePortal, languageData);
}
use of com.hack23.cia.service.api.UserConfiguration in project cia by Hack23.
the class ConfigurationManagerITest method getUserConfigurationSuccessTest.
/**
* Gets the user configuration success test.
*
* @return the user configuration success test
* @throws Exception
* the exception
*/
@Test
public void getUserConfigurationSuccessTest() throws Exception {
setAuthenticatedAnonymousUser();
final UserConfiguration userConfiguration = configurationManager.getUserConfiguration(WWW_HACK23_COM, "en");
assertNotNull(EXPECT_A_RESULT, userConfiguration);
assertNotNull(EXPECT_A_RESULT, userConfiguration.getAgency());
assertNotNull(EXPECT_A_RESULT, userConfiguration.getPortal());
assertNotNull(EXPECT_A_RESULT, userConfiguration.getLanguage());
}
use of com.hack23.cia.service.api.UserConfiguration in project cia by Hack23.
the class CitizenIntelligenceAgencyUI method init.
@Override
protected void init(final VaadinRequest request) {
VaadinSession.getCurrent().setErrorHandler(new UiInstanceErrorHandler(this));
setSizeFull();
springNavigator.addView(CRLF_REPLACEMENT, mainView);
setNavigator(springNavigator);
final Page currentPage = Page.getCurrent();
final String requestUrl = currentPage.getLocation().toString();
final String language = request.getLocale().getLanguage();
final UserConfiguration userConfiguration = configurationManager.getUserConfiguration(requestUrl, language);
currentPage.setTitle(userConfiguration.getAgency().getAgencyName() + ":" + userConfiguration.getPortal().getPortalName() + ":" + userConfiguration.getLanguage().getLanguageName());
if (getSession().getUIs().isEmpty()) {
final WebBrowser webBrowser = currentPage.getWebBrowser();
final CreateApplicationSessionRequest serviceRequest = new CreateApplicationSessionRequest();
serviceRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
final String ipInformation = WebBrowserUtil.getIpInformation(webBrowser);
serviceRequest.setIpInformation(ipInformation);
serviceRequest.setTimeZone(webBrowser.getTimeZoneId());
serviceRequest.setScreenSize(webBrowser.getScreenWidth() + "x" + webBrowser.getScreenHeight());
serviceRequest.setUserAgentInformation(webBrowser.getBrowserApplication());
serviceRequest.setLocale(webBrowser.getLocale().toString());
serviceRequest.setOperatingSystem(WebBrowserUtil.getOperatingSystem(webBrowser));
serviceRequest.setSessionType(ApplicationSessionType.ANONYMOUS);
final ServiceResponse serviceResponse = applicationManager.service(serviceRequest);
LOGGER.info(LOG_INFO_BROWSER_ADDRESS_APPLICATION_SESSION_ID_RESULT, requestUrl.replaceAll(CRLF, CRLF_REPLACEMENT), language.replaceAll(CRLF, CRLF_REPLACEMENT), ipInformation.replaceAll(CRLF, CRLF_REPLACEMENT), webBrowser.getBrowserApplication().replaceAll(CRLF, CRLF_REPLACEMENT), serviceRequest.getSessionId().replaceAll(CRLF, CRLF_REPLACEMENT), serviceResponse.getResult().toString().replaceAll(CRLF, CRLF_REPLACEMENT));
}
}
Aggregations