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();
}
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;
}
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));
}
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);
}
});
}
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;
}
Aggregations