Search in sources :

Example 1 with UserConfiguration

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);
}
Also used : Agency(com.hack23.cia.model.internal.application.system.impl.Agency) LanguageData(com.hack23.cia.model.internal.application.system.impl.LanguageData) Portal(com.hack23.cia.model.internal.application.system.impl.Portal) Secured(org.springframework.security.access.annotation.Secured)

Example 2 with UserConfiguration

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());
}
Also used : UserConfiguration(com.hack23.cia.service.api.UserConfiguration) Test(org.junit.Test)

Example 3 with UserConfiguration

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));
    }
}
Also used : ServiceResponse(com.hack23.cia.service.api.action.common.ServiceResponse) WebBrowser(com.vaadin.server.WebBrowser) CreateApplicationSessionRequest(com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest) Page(com.vaadin.server.Page) UserConfiguration(com.hack23.cia.service.api.UserConfiguration)

Aggregations

UserConfiguration (com.hack23.cia.service.api.UserConfiguration)2 Agency (com.hack23.cia.model.internal.application.system.impl.Agency)1 LanguageData (com.hack23.cia.model.internal.application.system.impl.LanguageData)1 Portal (com.hack23.cia.model.internal.application.system.impl.Portal)1 CreateApplicationSessionRequest (com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest)1 ServiceResponse (com.hack23.cia.service.api.action.common.ServiceResponse)1 Page (com.vaadin.server.Page)1 WebBrowser (com.vaadin.server.WebBrowser)1 Test (org.junit.Test)1 Secured (org.springframework.security.access.annotation.Secured)1