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); }
/** * {@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(); } } }
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); } }
/** * {@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(); } } }
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(); } }
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