Search in sources :

Example 16 with UserAccount

use of com.hack23.cia.model.internal.application.user.impl.UserAccount in project cia by Hack23.

the class UserRoleSystemTest method siteLoginUserCheckUserEventsTest.

/**
 * Site login user check user events test.
 *
 * @throws Exception
 *             the exception
 */
@Test
public void siteLoginUserCheckUserEventsTest() throws Exception {
    final WebDriver driver = getWebDriver();
    assertNotNull(NO_WEBDRIVER_EXIST_FOR_BROWSER + browser, driver);
    final UserPageVisit userPageVisit = new UserPageVisit(driver, browser);
    userPageVisit.visitDirectPage(new PageModeMenuCommand(CommonsViews.MAIN_VIEW_NAME, ApplicationPageMode.REGISTER.toString()));
    final String username = UUID.randomUUID().toString();
    final String password = generatePassword();
    userPageVisit.registerNewUser(username, password);
    userPageVisit.logoutUser();
    driver.quit();
    final WebDriver loginDriver = getWebDriver();
    final UserPageVisit userLoginPageVisit = new UserPageVisit(loginDriver, browser);
    userLoginPageVisit.visitDirectPage(new PageModeMenuCommand(CommonsViews.MAIN_VIEW_NAME, ApplicationPageMode.LOGIN.toString()));
    userLoginPageVisit.loginUser(username + "@test.com", password);
    final WebElement useraccountMenuItem = userLoginPageVisit.getMenuItem("Useraccount");
    assertNotNull(useraccountMenuItem);
    userLoginPageVisit.performClickAction(useraccountMenuItem);
    Thread.sleep(1000);
    final WebElement userEventsMenuItem = userLoginPageVisit.getMenuItem("User Events");
    assertNotNull(userEventsMenuItem);
    userLoginPageVisit.performClickAction(userEventsMenuItem);
    userLoginPageVisit.logoutUser();
}
Also used : WebDriver(org.openqa.selenium.WebDriver) PageModeMenuCommand(com.hack23.cia.web.impl.ui.application.views.common.pagelinks.api.PageModeMenuCommand) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test)

Example 17 with UserAccount

use of com.hack23.cia.model.internal.application.user.impl.UserAccount in project cia by Hack23.

the class AdminUserAccountPageModContentFactoryImpl method createContent.

@Secured({ "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
    final VerticalLayout content = createPanelContent();
    final String pageId = getPageId(parameters);
    final int pageNr = getPageNr(parameters);
    getMenuItemFactory().createMainPageMenuBar(menuBar);
    LabelFactory.createHeader2Label(content, ADMIN_USERACCOUNT);
    final DataContainer<UserAccount, Long> dataContainer = getApplicationManager().getDataContainer(UserAccount.class);
    final List<UserAccount> pageOrderBy = dataContainer.getPageOrderBy(pageNr, DEFAULT_RESULTS_PER_PAGE, UserAccount_.createdDate);
    createPagingControls(content, NAME, pageId, dataContainer.getSize(), pageNr, DEFAULT_RESULTS_PER_PAGE);
    getGridFactory().createBasicBeanItemGrid(content, UserAccount.class, pageOrderBy, USER_ACCOUNT, COLUMN_ORDER, HIDE_COLUMNS, LISTENER, null, null);
    if (pageId != null && !pageId.isEmpty()) {
        final UserAccount userAccount = dataContainer.load(Long.valueOf(pageId));
        if (userAccount != null) {
            getFormFactory().addFormPanelTextFields(content, userAccount, UserAccount.class, AS_LIST);
            final VerticalLayout overviewLayout = new VerticalLayout();
            overviewLayout.setSizeFull();
            content.addComponent(overviewLayout);
            content.setExpandRatio(overviewLayout, ContentRatio.LARGE);
            final ResponsiveRow grid = createGridLayout(overviewLayout);
            for (final AccountOperation accountOperation : ManageUserAccountRequest.AccountOperation.values()) {
                final ManageUserAccountRequest request = new ManageUserAccountRequest();
                request.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
                request.setAccountOperation(accountOperation);
                request.setUserAcountId(userAccount.getUserId());
                final Button accountOperationButton = new Button(MessageFormat.format(BUTTON_PATTERN, accountOperation), VaadinIcons.BULLSEYE);
                accountOperationButton.addClickListener(new ManageUserAccountClickListener(request));
                accountOperationButton.setId(MessageFormat.format(BUTTON_ID_PATTERN, ViewAction.START_AGENT_BUTTON, accountOperation));
                createRowItem(grid, accountOperationButton, "Will perform useraccount action");
            }
        }
    }
    getPageActionEventHelper().createPageEvent(ViewAction.VISIT_ADMIN_USERACCOUNT_VIEW, ApplicationEventGroup.ADMIN, NAME, null, pageId);
    return content;
}
Also used : Button(com.vaadin.ui.Button) ResponsiveRow(com.jarektoro.responsivelayout.ResponsiveRow) ManageUserAccountClickListener(com.hack23.cia.web.impl.ui.application.views.pageclicklistener.ManageUserAccountClickListener) ManageUserAccountRequest(com.hack23.cia.service.api.action.admin.ManageUserAccountRequest) VerticalLayout(com.vaadin.ui.VerticalLayout) AccountOperation(com.hack23.cia.service.api.action.admin.ManageUserAccountRequest.AccountOperation) UserAccount(com.hack23.cia.model.internal.application.user.impl.UserAccount) Secured(org.springframework.security.access.annotation.Secured)

Example 18 with UserAccount

use of com.hack23.cia.model.internal.application.user.impl.UserAccount in project cia by Hack23.

the class UserHomeMenuItemFactoryImpl method createUserHomeMenuBar.

@Override
public void createUserHomeMenuBar(final MenuBar menuBar, final String pageId) {
    initApplicationMenuBar(menuBar);
    applicationMenuItemFactory.addRankingMenu(menuBar);
    final MenuItem accountItem = menuBar.addItem("Useraccount", VaadinIcons.USER, null);
    accountItem.addItem(OVERVIEW_TEXT, VaadinIcons.USER, new PageModeMenuCommand(UserViews.USERHOME_VIEW_NAME, PageMode.OVERVIEW, pageId));
    accountItem.addItem(SECURITY_SETTING_TEXT, VaadinIcons.USER, new PageModeMenuCommand(UserViews.USERHOME_VIEW_NAME, UserHomePageMode.SECURITY_SETTINGS.toString(), pageId));
    accountItem.addItem(USER_VISITS, VaadinIcons.USER, new PageModeMenuCommand(UserViews.USERHOME_VIEW_NAME, UserHomePageMode.USER_VISITS.toString(), pageId));
    accountItem.addItem(USER_EVENTS, VaadinIcons.USER, new PageModeMenuCommand(UserViews.USERHOME_VIEW_NAME, UserHomePageMode.USER_EVENTS.toString(), pageId));
}
Also used : PageModeMenuCommand(com.hack23.cia.web.impl.ui.application.views.common.pagelinks.api.PageModeMenuCommand) MenuItem(com.vaadin.ui.MenuBar.MenuItem)

Example 19 with UserAccount

use of com.hack23.cia.model.internal.application.user.impl.UserAccount in project cia by Hack23.

the class ManageUserAccountService method initUserCommandMap.

/**
 * Inits the user command map.
 */
@PostConstruct
public void initUserCommandMap() {
    userCommandMap.put(ManageUserAccountRequest.AccountOperation.DELETE, new UserCommand() {

        @Override
        public ManageUserAccountResponse execute(UserAccount account) {
            removeDataManager.removeUserAccountApplicationHistory(account.getUserId());
            userDAO.delete(account);
            return new ManageUserAccountResponse(ServiceResult.SUCCESS);
        }
    });
    userCommandMap.put(ManageUserAccountRequest.AccountOperation.UNLOCK, new UserCommand() {

        @Override
        public ManageUserAccountResponse execute(UserAccount account) {
            account.setUserLockStatus(UserLockStatus.UNLOCKED);
            userDAO.persist(account);
            return new ManageUserAccountResponse(ServiceResult.SUCCESS);
        }
    });
    userCommandMap.put(ManageUserAccountRequest.AccountOperation.LOCK, new UserCommand() {

        @Override
        public ManageUserAccountResponse execute(UserAccount account) {
            account.setUserLockStatus(UserLockStatus.LOCKED);
            userDAO.persist(account);
            return new ManageUserAccountResponse(ServiceResult.SUCCESS);
        }
    });
}
Also used : ManageUserAccountResponse(com.hack23.cia.service.api.action.admin.ManageUserAccountResponse) UserAccount(com.hack23.cia.model.internal.application.user.impl.UserAccount) PostConstruct(javax.annotation.PostConstruct)

Example 20 with UserAccount

use of com.hack23.cia.model.internal.application.user.impl.UserAccount in project cia by Hack23.

the class ManageUserAccountService method processService.

@Override
@Secured({ "ROLE_ADMIN" })
public ManageUserAccountResponse processService(final ManageUserAccountRequest serviceRequest) {
    final ManageUserAccountResponse inputValidation = inputValidation(serviceRequest);
    if (inputValidation != null) {
        return inputValidation;
    }
    final CreateApplicationEventRequest eventRequest = createApplicationEventForService(serviceRequest);
    final UserAccount userAccount = getUserAccountFromSecurityContext();
    if (userAccount != null) {
        eventRequest.setUserId(userAccount.getUserId());
    }
    ManageUserAccountResponse response;
    final Set<ConstraintViolation<ManageUserAccountRequest>> requestConstraintViolations = validateRequest(serviceRequest);
    if (!requestConstraintViolations.isEmpty()) {
        response = new ManageUserAccountResponse(ServiceResult.FAILURE);
        final String errorMessage = requestConstraintViolations.stream().sorted((p1, p2) -> p1.getPropertyPath().toString().compareTo(p2.getPropertyPath().toString())).map(p -> p.getPropertyPath().toString() + " " + p.getMessage()).collect(Collectors.joining(", "));
        response.setErrorMessage(errorMessage);
        eventRequest.setErrorMessage(errorMessage);
    } else {
        response = performOperation(serviceRequest, eventRequest);
    }
    createApplicationEventService.processService(eventRequest);
    return response;
}
Also used : ApplicationOperationType(com.hack23.cia.model.internal.application.system.impl.ApplicationOperationType) BusinessService(com.hack23.cia.service.impl.action.common.BusinessService) ManageUserAccountRequest(com.hack23.cia.service.api.action.admin.ManageUserAccountRequest) ServiceResult(com.hack23.cia.service.api.action.common.ServiceResponse.ServiceResult) EnumMap(java.util.EnumMap) ApplicationEventGroup(com.hack23.cia.model.internal.application.system.impl.ApplicationEventGroup) RemoveDataManager(com.hack23.cia.service.data.api.RemoveDataManager) Set(java.util.Set) Autowired(org.springframework.beans.factory.annotation.Autowired) Collectors(java.util.stream.Collectors) Secured(org.springframework.security.access.annotation.Secured) AbstractBusinessServiceImpl(com.hack23.cia.service.impl.action.common.AbstractBusinessServiceImpl) ManageUserAccountResponse(com.hack23.cia.service.api.action.admin.ManageUserAccountResponse) Propagation(org.springframework.transaction.annotation.Propagation) UserLockStatus(com.hack23.cia.model.internal.application.user.impl.UserLockStatus) Service(org.springframework.stereotype.Service) Map(java.util.Map) UserAccount(com.hack23.cia.model.internal.application.user.impl.UserAccount) PostConstruct(javax.annotation.PostConstruct) UserAccount_(com.hack23.cia.model.internal.application.user.impl.UserAccount_) CreateApplicationEventRequest(com.hack23.cia.service.api.action.application.CreateApplicationEventRequest) ConstraintViolation(javax.validation.ConstraintViolation) UserDAO(com.hack23.cia.service.data.api.UserDAO) Transactional(org.springframework.transaction.annotation.Transactional) ConstraintViolation(javax.validation.ConstraintViolation) ManageUserAccountResponse(com.hack23.cia.service.api.action.admin.ManageUserAccountResponse) CreateApplicationEventRequest(com.hack23.cia.service.api.action.application.CreateApplicationEventRequest) UserAccount(com.hack23.cia.model.internal.application.user.impl.UserAccount) Secured(org.springframework.security.access.annotation.Secured)

Aggregations

UserAccount (com.hack23.cia.model.internal.application.user.impl.UserAccount)37 Test (org.junit.Test)19 Secured (org.springframework.security.access.annotation.Secured)18 CreateApplicationEventRequest (com.hack23.cia.service.api.action.application.CreateApplicationEventRequest)14 RegisterUserResponse (com.hack23.cia.service.api.action.application.RegisterUserResponse)14 CreateApplicationSessionRequest (com.hack23.cia.service.api.action.application.CreateApplicationSessionRequest)13 RegisterUserRequest (com.hack23.cia.service.api.action.application.RegisterUserRequest)13 AbstractServiceFunctionalIntegrationTest (com.hack23.cia.service.impl.AbstractServiceFunctionalIntegrationTest)13 PerfTest (org.databene.contiperf.PerfTest)10 LoginResponse (com.hack23.cia.service.api.action.application.LoginResponse)8 LoginRequest (com.hack23.cia.service.api.action.application.LoginRequest)7 PageModeMenuCommand (com.hack23.cia.web.impl.ui.application.views.common.pagelinks.api.PageModeMenuCommand)7 ManageUserAccountResponse (com.hack23.cia.service.api.action.admin.ManageUserAccountResponse)6 ArrayList (java.util.ArrayList)6 WebDriver (org.openqa.selenium.WebDriver)6 ManageUserAccountRequest (com.hack23.cia.service.api.action.admin.ManageUserAccountRequest)5 Required (org.databene.contiperf.Required)5 LogoutRequest (com.hack23.cia.service.api.action.application.LogoutRequest)4 VerticalLayout (com.vaadin.ui.VerticalLayout)4 WebElement (org.openqa.selenium.WebElement)4