public void setUserProfile(org.exoplatform.services.organization.UserProfile up) { if (up == null) { profile = ""; userName = null; return; } UserProfileImpl impl = (UserProfileImpl)up; userName = up.getUserName(); XStream xstream = getXStream(); profile = xstream.toXML(impl); }
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(); } }
@SuppressWarnings("deprecation") public void setUserProfile(String user) throws Exception { user_ = user; if (user == null) return; OrganizationService service = getApplicationComponent(OrganizationService.class); UserProfile userProfile = service.getUserProfileHandler().findUserProfileByName(user); if (userProfile == null) { userProfile = service.getUserProfileHandler().createUserProfileInstance(); userProfile.setUserName(user); } if (userProfile.getUserInfoMap() == null) return; for (UIComponent set : getChildren()) { UIFormInputSet inputSet = (UIFormInputSet)set; for (UIComponent uiComp : inputSet.getChildren()) { UIFormStringInput uiInput = (UIFormStringInput)uiComp; uiInput.setValue(userProfile.getAttribute(uiInput.getName())); } } }
userProfile.setUserName(user_); userProfile.getUserInfoMap().put(uiInput.getName(), uiInput.getValue());
Collection<UserProfileEventListener> userProfileListeners = userProfileListeners_.values(); for (UserProfileEventListener userProfileEventListener : userProfileListeners) { if (userProfile.getUserInfoMap() == null) { userProfile.setUserInfoMap(new HashMap<String, String>()); LOG.info("Invoke " + username + " user profile deletion listeners."); userProfile = new UserProfileImpl(username); userProfile.setUserInfoMap(new HashMap<String, String>()); Collection<UserProfileEventListener> userProfileListeners = userProfileListeners_.values(); for (UserProfileEventListener userProfileEventListener : userProfileListeners) {
public void removeProfile(String userName, UserProfile profile) { Map<String, String> profileAttrs = profile.getUserInfoMap(); String[] attrKeys = new String[profileAttrs.keySet().size()]; attrKeys = profileAttrs.keySet().toArray(attrKeys); try { getIdentitySession().getAttributesManager().removeAttributes(userName, attrKeys); } catch (Exception e) { // TODO: handleException("Identity operation error: ", e); } } }
newUserProfile.setAttribute(providerType.getUserNameAttrName(), principal.getUserName()); profileHandler.saveUserProfile(newUserProfile, true);
public void setProfile(String userName, UserProfile profile) { Map<String, String> profileAttrs = profile.getUserInfoMap(); Set<Attribute> attrs = new HashSet<Attribute>(); for (Map.Entry<String, String> entry : profileAttrs.entrySet()) { String attrValue = entry.getValue(); // Treat empty strings as null (needed for compatibility with Oracle as Oracle always treats empty strings as null) if ("".equals(attrValue)) { attrValue = null; } attrs.add(new SimpleAttribute(entry.getKey(), attrValue)); } Attribute[] attrArray = new Attribute[attrs.size()]; attrArray = attrs.toArray(attrArray); try { getIdentitySession().getAttributesManager().updateAttributes(userName, attrArray); } catch (Exception e) { // TODO: handleException("Identity operation error: ", e); } }
newUserProfile.setAttribute(oauthPrincipal.getOauthProviderType().getUserNameAttrName(), oauthPrincipal.getUserName());
/** * {@inheritDoc} */ public void postDelete(UserProfile user) throws Exception { if (!getOrganizationIntegrationService().isEnabled()) { return; } Session session = null; try { session = repositoryService.getCurrentRepository().getSystemSession(Util.WORKSPACE); if (Util.hasProfileFolder(session, user.getUserName())) { Util.deleteProfileFolder(session, user.getUserName()); } } finally { if (session != null) { session.logout(); } } }
newUserProfile.setAttribute(providerType.getUserNameAttrName(), principal.getUserName()); profileHandler.saveUserProfile(newUserProfile, true);
public void saveUserProfile(UserProfile profile, boolean broadcast) throws Exception { // We need to check if userProfile exists, because organization API is limited and it doesn't have separate methods for // "creation" and for "update" of user profile :/ String username = profile.getUserName(); UserHandler userHandler = this.orgService.getUserHandler(); User user = userHandler.findUserByName(username, UserStatus.ANY); if(user == null) { throw new InvalidNameException("User " + username + " not exists"); } boolean isNew = true; if (broadcast) { UserProfile found = getProfile(profile.getUserName()); isNew = found == null; } if (broadcast) { preSave(profile, isNew); } setProfile(profile.getUserName(), profile); if (broadcast) { postSave(profile, isNew); } }
newUserProfile.setAttribute(providerType.getUserNameAttrName(), principal.getUserName()); profileHandler.saveUserProfile(newUserProfile, true);
/** * {@inheritDoc} */ public void postSave(UserProfile user, boolean isNew) throws Exception { if (!getOrganizationIntegrationService().isEnabled()) { return; } if (!isNew) { return; } Session session = null; try { session = repositoryService.getCurrentRepository().getSystemSession(Util.WORKSPACE); if (!Util.hasProfileFolder(session, user.getUserName())) { Util.createProfileFolder(session, user.getUserName()); } } finally { if (session != null) { session.logout(); } } }
newUserProfile = orgService.getUserProfileHandler().createUserProfileInstance(newUser.getUserName()); newUserProfile.setAttribute(oauthPrincipal.getOauthProviderType().getUserNameAttrName(), oauthPrincipal.getUserName()); try { profileHandler.saveUserProfile(newUserProfile, true);
ldapAttrMapping.membershipTypeNameAttr + "=" + profile.getUserName() + "," + ldapAttrMapping.profileURL; LdapContext ctx = ldapService.getLdapContext(); try
/** * Create LDAP attributes that represents UserProfile in LDAP context. * * @param profile UserProfile * @return LDAP attributes. */ public final Attributes profileToAttributes(UserProfile profile) { BasicAttributes attrs = new BasicAttributes(); if (PROFILE_LDAP_CLASSES == null) PROFILE_LDAP_CLASSES = profileLDAPClasses.split(","); attrs.put(new ObjectClassAttribute(PROFILE_LDAP_CLASSES)); attrs.put("sn", profile.getUserName()); UserProfileData upd = new UserProfileData(); upd.setUserProfile(profile); attrs.put(ldapDescriptionAttr, upd.getProfile()); return attrs; }
String userName = profile.getUserName(); Session session = service_.openSession(); UserProfileData upd = (UserProfileData)service_.findOne(session, queryFindUserProfileByName, userName);
public void saveUserProfile(UserProfile profile, boolean broadcast) throws Exception { String userName = profile.getUserName(); UserProfileData userImpl = findUserProfileDataByName(userName); User user = userDAO.findUserByName(userName); if (user == null) { throw new InvalidNameException("User " + userName + " not exists"); } if (userImpl == null) { userImpl = new UserProfileData(userName); userImpl.setUserProfile(profile); if (broadcast) listenerService_.broadcast("organization.userProfile.preCreate", this, userImpl); super.save(userImpl); if (broadcast) listenerService_.broadcast("organization.userProfile.postCreate", this, userImpl); } else { if (broadcast) listenerService_.broadcast("organization.userProfile.preUpdate", this, userImpl); userImpl.setUserProfile(profile); super.update(userImpl); if (broadcast) listenerService_.broadcast("organization.userProfile.postUpdate", this, userImpl); } }
ldapAttrMapping.membershipTypeNameAttr + "=" + profile.getUserName() + "," + ldapAttrMapping.profileURL; LdapContext ctx = ldapService.getLdapContext(); try