Search in sources :

Example 11 with ServiceResponse

use of com.hack23.cia.service.api.action.common.ServiceResponse in project cia by Hack23.

the class UpdateApplicationConfigurationClickListener method buttonClick.

@Override
public void buttonClick(final ClickEvent event) {
    final ServiceResponse response = ApplicationMangerAccess.getApplicationManager().service(request);
    if (ServiceResult.SUCCESS == response.getResult()) {
        LOGGER.info(LOG_UPDATE_APPLICATION_CONFIGURATION, request.getApplicationConfigurationId());
        UI.getCurrent().getNavigator().navigateTo(AdminViews.ADMIN_APPLICATIONS_CONFIGURATION_VIEW_NAME + "/" + request.getApplicationConfigurationId());
    } else {
        Notification.show(UPDATE_APPLICATION_CONFIGURATION_FAILED, ERROR_MESSAGE, Notification.Type.WARNING_MESSAGE);
        LOGGER.info(LOG_MSG_UPDATE_APPLICATION_CONFIGURATION_FAILURE, request.getApplicationConfigurationId());
    }
}
Also used : ServiceResponse(com.hack23.cia.service.api.action.common.ServiceResponse)

Example 12 with ServiceResponse

use of com.hack23.cia.service.api.action.common.ServiceResponse in project cia by Hack23.

the class RegisterUserClickListener method buttonClick.

@Override
public void buttonClick(final ClickEvent event) {
    final ServiceResponse response = ApplicationMangerAccess.getApplicationManager().service(reqisterRequest);
    if (ServiceResult.SUCCESS == response.getResult()) {
        LOGGER.info(LOG_MSG_REGISTER_USER, reqisterRequest.getUsername());
        UI.getCurrent().getNavigator().navigateTo(UserViews.USERHOME_VIEW_NAME);
    } else {
        Notification.show(REGISTER_FAILED, response.getErrorMessage(), Notification.Type.WARNING_MESSAGE);
        LOGGER.info(REGISTER_USER_FAILURE, reqisterRequest.getUsername());
    }
}
Also used : ServiceResponse(com.hack23.cia.service.api.action.common.ServiceResponse)

Example 13 with ServiceResponse

use of com.hack23.cia.service.api.action.common.ServiceResponse 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)

Example 14 with ServiceResponse

use of com.hack23.cia.service.api.action.common.ServiceResponse in project cia by Hack23.

the class ParliamentRuleViolationsPageModContentFactoryImpl method createContent.

@Secured({ "ROLE_ANONYMOUS", "ROLE_USER", "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
    final VerticalLayout panelContent = createPanelContent();
    getParliamentMenuItemFactory().createParliamentTopicMenu(menuBar);
    final ComplianceCheckRequest serviceRequest = new ComplianceCheckRequest();
    serviceRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
    final ComplianceCheckResponse serviceResponse = (ComplianceCheckResponse) getApplicationManager().service(serviceRequest);
    final HorizontalLayout horizontalLayout = new HorizontalLayout();
    for (final Entry<Status, List<RuleViolation>> statusEntry : serviceResponse.getStatusMap().entrySet()) {
        horizontalLayout.addComponent(new CounterStatisticsCard(VaadinIcons.WARNING, new CounterStatisticModel("ALL:" + statusEntry.getKey(), statusEntry.getValue().size()).withShow(StatisticShow.Sum).withIconHidden().withShowOnlyStatistic(true), "ALL:" + statusEntry.getKey()));
    }
    final List<RuleViolation> ruleViolations = new ArrayList<>();
    for (final Entry<ResourceType, List<RuleViolation>> statusEntry : serviceResponse.getResourceTypeMap().entrySet()) {
        horizontalLayout.addComponent(new CounterStatisticsCard(VaadinIcons.WARNING, new CounterStatisticModel("ALL:" + statusEntry.getKey(), statusEntry.getValue().size()).withShow(StatisticShow.Sum).withIconHidden().withShowOnlyStatistic(true), "ALL:" + statusEntry.getKey()));
        ruleViolations.addAll(statusEntry.getValue());
    }
    panelContent.addComponent(horizontalLayout);
    Collections.sort(ruleViolations, new Comparator<RuleViolation>() {

        @Override
        public int compare(final RuleViolation o1, final RuleViolation o2) {
            return o2.getStatus().compareTo(o1.getStatus());
        }
    });
    getGridFactory().createBasicBeanItemGrid(panelContent, RuleViolation.class, ruleViolations, "Risk", new String[] { "name", "status", "resourceType", "ruleName", "ruleGroup", "ruleDescription", "positive" }, new String[] { "id" }, CLICK_LISTENER, null, null);
    final String pageId = getPageId(parameters);
    getPageActionEventHelper().createPageEvent(ViewAction.VISIT_PARLIAMENT_RANKING_VIEW, ApplicationEventGroup.USER, NAME, parameters, pageId);
    panel.setCaption(new StringBuilder().append(NAME).append("::").append(PARLIAMENT_RULE_VIOLATIONS).toString());
    return panelContent;
}
Also used : Status(com.hack23.cia.service.api.action.kpi.Status) CounterStatisticsCard(com.github.markash.ui.component.card.CounterStatisticsCard) ArrayList(java.util.ArrayList) ComplianceCheckResponse(com.hack23.cia.service.api.action.kpi.ComplianceCheckResponse) ResourceType(com.hack23.cia.service.api.action.kpi.ResourceType) RuleViolation(com.hack23.cia.service.api.action.kpi.RuleViolation) HorizontalLayout(com.vaadin.ui.HorizontalLayout) VerticalLayout(com.vaadin.ui.VerticalLayout) ArrayList(java.util.ArrayList) List(java.util.List) CounterStatisticModel(com.github.markash.ui.component.card.CounterStatisticModel) ComplianceCheckRequest(com.hack23.cia.service.api.action.kpi.ComplianceCheckRequest) Secured(org.springframework.security.access.annotation.Secured)

Aggregations

ServiceResponse (com.hack23.cia.service.api.action.common.ServiceResponse)12 CreateApplicationSessionRequest (com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest)5 AbstractServiceFunctionalIntegrationTest (com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)4 PerfTest (org.databene.contiperf.PerfTest)4 Required (org.databene.contiperf.Required)4 Test (org.junit.Test)4 Secured (org.springframework.security.access.annotation.Secured)4 UserAccount (com.hack23.cia.model.internal.application.user.impl.UserAccount)3 LoginRequest (com.hack23.cia.service.api.action.application.LoginRequest)3 LoginResponse (com.hack23.cia.service.api.action.application.LoginResponse)3 LogoutRequest (com.hack23.cia.service.api.action.application.LogoutRequest)3 RegisterUserRequest (com.hack23.cia.service.api.action.application.RegisterUserRequest)3 RegisterUserResponse (com.hack23.cia.service.api.action.application.RegisterUserResponse)3 CounterStatisticModel (com.github.markash.ui.component.card.CounterStatisticModel)2 CounterStatisticsCard (com.github.markash.ui.component.card.CounterStatisticsCard)2 ComplianceCheckRequest (com.hack23.cia.service.api.action.kpi.ComplianceCheckRequest)2 ComplianceCheckResponse (com.hack23.cia.service.api.action.kpi.ComplianceCheckResponse)2 ResourceType (com.hack23.cia.service.api.action.kpi.ResourceType)2 Status (com.hack23.cia.service.api.action.kpi.Status)2 SetGoogleAuthenticatorCredentialRequest (com.hack23.cia.service.api.action.user.SetGoogleAuthenticatorCredentialRequest)2