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); } } }
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); } }
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(); } }
userProfile.getUserInfoMap().put(uiInput.getName(), uiInput.getValue());
@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())); } } }
Collection<UserProfileEventListener> userProfileListeners = userProfileListeners_.values(); for (UserProfileEventListener userProfileEventListener : userProfileListeners) { if (userProfile.getUserInfoMap() == null) { userProfile.setUserInfoMap(new HashMap<String, String>());