@Override public void processUpgrade(String oldVersion, String newVersion) { try { int totalFoldersCountApproximation = organizationService.getUserHandler().findAllUsers(UserStatus.ANY).getSize(); // Number of users + Number of user profile + three memberships per user totalFoldersCountApproximation = totalFoldersCountApproximation * 5; LOG.info("Attempt to delete JCR folders of Organization Integration service (approximatively {} folders)", totalFoldersCountApproximation); super.processUpgrade(oldVersion, newVersion); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new RuntimeException("An error occurred while Deleting Organization Integration service folders"); } }
JSONObject jsonObject = new JSONObject(); OrganizationService orgService = (OrganizationService) PortalContainer.getInstance().getComponentInstanceOfType(OrganizationService.class); UserHandler userHandler = orgService.getUserHandler(); try { if (userHandler.findUserByName(username) != null) {
/** * Create basic LDAP structure. {@inheritDoc} */ public void init(OrganizationService service) throws Exception { baseHandler = (BaseDAO)service.getUserHandler(); createSubContextNew(baseHandler.ldapAttrMapping.baseURL, baseHandler.ldapAttrMapping.groupsURL); createSubContextNew(baseHandler.ldapAttrMapping.baseURL, baseHandler.ldapAttrMapping.userURL); createSubContextNew(baseHandler.ldapAttrMapping.baseURL, baseHandler.ldapAttrMapping.membershipTypeURL); createSubContextNew(baseHandler.ldapAttrMapping.baseURL, baseHandler.ldapAttrMapping.profileURL); }
private String getUserFullName(String userId) { try { OrganizationService service = (OrganizationService) ExoContainerContext.getCurrentContainer() .getComponentInstanceOfType(OrganizationService.class); return service.getUserHandler().findUserByName(userId).getFullName(); } catch (Exception e) { return userId; } }
results.addAll(service.getUserHandler().findUsers(q).getAll());
LOG.debug("Adding entries for each user, additional fields are missing: LastLoginTime & CreatedDate"); ListAccess<User> usersListAccess = organizationService.getUserHandler().findAllUsers(); XStream xstream_ = new XStream(new XppDriver()); int i = 0;
public void writeProfiles(ZipOutputStream zos) throws Exception { RequestLifeCycle.begin(PortalContainer.getInstance()); try { ListAccess<User> usersListAccess = organizationService.getUserHandler().findAllUsers(); XStream xstream_ = new XStream(new XppDriver()); int i = 0; while (i <= usersListAccess.getSize()) { int length = i + SerializationUtils.MAX_USERS_IN_FILE_PARAM_NAME <= usersListAccess.getSize() ? SerializationUtils.MAX_USERS_IN_FILE_PARAM_NAME : usersListAccess.getSize() - i; User[] users = usersListAccess.load(i, length); for (User user : users) { UserProfile userProfile = organizationService.getUserProfileHandler().findUserProfileByName(user.getUserName()); if ((userProfile != null) && (userProfile.getUserInfoMap() != null) && !userProfile.getUserInfoMap().isEmpty()) { xstream_.alias("user-profile", userProfile.getClass()); String xml = xstream_.toXML(userProfile); zos.putNextEntry(new ZipEntry(SerializationUtils.PROFILES_FOLDER_NAME + userProfile.getUserName() + SerializationUtils.PROFILE_FILE_SUFFIX)); zos.write(xml.getBytes()); zos.closeEntry(); if (LOG.isDebugEnabled()) { LOG.debug("Adding entry for userProfile: " + userProfile.getUserName()); } } } i += SerializationUtils.MAX_USERS_IN_FILE_PARAM_NAME; } } finally { RequestLifeCycle.end(); } }
public void execute(Event<UIUserSelector> event) throws Exception { UIUserSelector uiSelectUserForm = event.getSource(); String groupId = uiSelectUserForm.getSelectedGroup(); OrganizationService service = uiSelectUserForm.getApplicationComponent(OrganizationService.class); PageList users = PageList.EMPTY_LIST; if (groupId != null && groupId.trim().length() != 0) { if (service.getGroupHandler().findGroupById(groupId) != null) { users = uiSelectUserForm.removeDuplicate(service.getUserHandler().findUsersByGroup(groupId)); } } else { users = service.getUserHandler().findUsers(new Query()); } users.setPageSize(10); uiSelectUserForm.uiIterator_.setPageList(users); uiSelectUserForm.setKeyword(null); event.getRequestContext().addUIComponentToUpdateByAjax(uiSelectUserForm); } }
public void save(OrganizationService service, boolean broadcast) throws Exception { GroupHandler groupHandler = service.getGroupHandler(); MembershipTypeHandler mtHandler = service.getMembershipTypeHandler(); User user = service.getUserHandler().findUserByName(user_); for (Membership membership : membership_) { if (user == null) user = service.getUserHandler().findUserByName(membership.getUserName()); Group group = groupHandler.findGroupById(membership.getGroupId()); MembershipType mt = mtHandler.findMembershipType(membership.getMembershipType()); if (service.getMembershipHandler() != null) { service.getMembershipHandler().linkMembership(user, group, mt, broadcast); } } }
if (newUser) User user = service.getUserHandler().createUserInstance(username); invokeSetBindingField(user); if (service.getUserHandler().findUserByName(user.getUserName()) != null) if (service.getUserHandler().findUsers(query).getAll().size() > 0) service.getUserHandler().createUser(user, true); reset(); return true; User user = service.getUserHandler().findUserByName(username); invokeSetBindingField(user); service.getUserHandler().saveUser(user, true); return true;
@Override public void preSave(User user, boolean isNew) throws Exception { if (passwordEncrypter != null && user.getPassword() != null) { User persistedUser = organizationService.getUserHandler().findUserByName(user.getUserName()); if (persistedUser == null || persistedUser.getPassword() == null) { if (LOG.isDebugEnabled()) { LOG.debug("Encrypting password for a new user " + user.getUserName()); } String encodedPassword = new String(passwordEncrypter.encrypt(user.getPassword().getBytes())); user.setPassword(encodedPassword); } else if (!user.getPassword().equals(persistedUser.getPassword())) { if (LOG.isDebugEnabled()) { LOG.debug("Encrypting changed password for user " + user.getUserName()); } String encodedPassword = new String(passwordEncrypter.encrypt(user.getPassword().getBytes())); user.setPassword(encodedPassword); } else { if (LOG.isDebugEnabled()) { LOG.debug("Nothing to encrypt for user " + user.getUserName() + ": password no changed."); } } } } }
for (int i = 0; i < users.size(); i++) { OrganizationConfig.User data = (OrganizationConfig.User) users.get(i); User user = organizationService.getUserHandler().createUserInstance(data.getUserName()); user.setPassword(data.getPassword()); user.setFirstName(data.getFirstName()); user.setEmail(data.getEmail()); if (organizationService.getUserHandler().findUserByName(data.getUserName()) == null) { LOG.info(" Creating user " + data.getUserName()); organizationService.getUserHandler().createUser(user, false); } else { LOG.info(" Ignoring existing User " + data.getUserName());
public void execute(Event<UIGroupSelector> event) throws Exception { UIGroupSelector uiSelectGroupForm = event.getSource(); UIUserSelector uiSelectUserForm = uiSelectGroupForm.<UIComponent> getParent().getParent(); String groupId = event.getRequestContext().getRequestParameter(OBJECTID); uiSelectUserForm.setSelectedGroup(groupId); OrganizationService service = uiSelectGroupForm.getApplicationComponent(OrganizationService.class); PageList users = uiSelectUserForm.removeDuplicate(service.getUserHandler().findUsersByGroup(groupId)); users.setPageSize(10); uiSelectUserForm.uiIterator_.setPageList(users); uiSelectUserForm.setKeyword(null); event.getRequestContext().addUIComponentToUpdateByAjax(uiSelectUserForm); } }
/** * Add given user to our group with given membershipType. * * @param userId */ private void addUserToPlatformUsers(String userId) throws Exception { OrganizationService orgService = (OrganizationService) getContainer().getComponentInstanceOfType( OrganizationService.class); try { begin(orgService); User user = orgService.getUserHandler().findUserByName(userId); MembershipType memberType = orgService.getMembershipTypeHandler().findMembershipType(membershipType); Group platformUsersGroup = orgService.getGroupHandler().findGroupById(groupId); orgService.getMembershipHandler().linkMembership(user, platformUsersGroup, memberType, true); } catch (Exception e) { log.error("Failed to add user " + userId + " to group " + groupId + ".", e); // don't rethrow login exception in case of failure. // throw e; } finally { end(orgService); } }
public void execute(Event<UIUserMembershipSelector> event) throws Exception { UIUserMembershipSelector uiUserMembershipSelector = event.getSource(); String id = event.getRequestContext().getRequestParameter(OBJECTID); UIPageIterator pageIterator = uiUserMembershipSelector.getChild(UIGrid.class).getUIPageIterator(); int currentPage = pageIterator.getCurrentPage(); OrganizationService service = uiUserMembershipSelector.getApplicationComponent(OrganizationService.class); service.getMembershipHandler().removeMembership(id, true); User user = service.getUserHandler().findUserByName(uiUserMembershipSelector.getUser()); uiUserMembershipSelector.setUser(user); while (currentPage > pageIterator.getAvailablePage()) currentPage--; pageIterator.setCurrentPage(currentPage); } }
ListAccess<User> usersListAccess = organizationService.getUserHandler().findAllUsers(); List<OrganizationConfig.User> orgConfigUsersInSigleFile = new ArrayList<OrganizationConfig.User>(); int i = 0;
if (orgService.getUserHandler().findUserByName(m.getUserName()) == null)
public void execute(Event<UIAccountForm> event) throws Exception { UIAccountForm uiForm = event.getSource(); WebuiRequestContext context = WebuiRequestContext.getCurrentInstance(); UIApplication uiApp = context.getUIApplication(); OrganizationService service = uiForm.getApplicationComponent(OrganizationService.class); UIFormStringInput usernameInput = uiForm.getChild(UIAccountInputSet.class).getUIStringInput(UIAccountInputSet.USERNAME); for (Validator validator : usernameInput.getValidators()) { try { validator.validate(usernameInput); } catch (MessageException e) { uiApp.addMessage(e.getDetailMessage()); return; } } String userName = usernameInput.getValue(); if (service.getUserHandler().findUserByName(userName) != null) { uiApp.addMessage(new ApplicationMessage("UIAccountInputSet.msg.user-exist", null, ApplicationMessage.WARNING)); return; } uiApp.addMessage(new ApplicationMessage("UIAccountInputSet.msg.user-not-exist", null, ApplicationMessage.INFO)); } }
public UIUserSelector() throws Exception { addUIFormInput(new UIFormStringInput(FIELD_KEYWORD, FIELD_KEYWORD, null)); addUIFormInput(new UIFormSelectBox(FIELD_FILTER, FIELD_FILTER, getFilters())); addUIFormInput(new UIFormStringInput(FIELD_GROUP, FIELD_GROUP, null)); isShowSearch_ = true; OrganizationService service = getApplicationComponent(OrganizationService.class); ObjectPageList objPageList = new ObjectPageList(service.getUserHandler().findUsers(new Query()).getAll(), 10); uiIterator_ = new UIPageIterator(); uiIterator_.setPageList(objPageList); uiIterator_.setId("UISelectUserPage"); // create group selector UIPopupWindow uiPopup = addChild(UIPopupWindow.class, null, "UIPopupGroupSelector"); uiPopup.setWindowSize(540, 0); UIGroupSelector uiGroup = createUIComponent(UIGroupSelector.class, null, null); uiPopup.setUIComponent(uiGroup); uiGroup.setId("GroupSelector"); uiGroup.getChild(UITree.class).setId("TreeGroupSelector"); uiGroup.getChild(UIBreadcumbs.class).setId("BreadcumbsGroupSelector"); }
if (service.getUserHandler().findUserByName(membership.getUserName()) == null)