1 5 package org.exoplatform.services.organization.ldap; 6 7 import org.exoplatform.services.organization.impl.UserProfileImpl; 8 9 import com.thoughtworks.xstream.XStream; 10 import com.thoughtworks.xstream.io.xml.XppDriver; 11 12 13 19 public class UserProfileLDAPData { 20 static transient private XStream xstream_ ; 21 22 private String userName ; 23 private String profile ; 24 25 public UserProfileLDAPData() { 26 } 27 28 public UserProfileLDAPData(String userName) { 29 StringBuffer b = new StringBuffer () ; 30 b.append("<user-profile>\n"). 31 append(" <userName>").append(userName).append("</userName>\n"); 32 b.append("</user-profile>\n"); 33 this.userName = userName ; 34 this.profile = b.toString() ; 35 } 36 37 40 public String getUserName() { return userName ; } 41 public void setUserName(String s) { this.userName = s ; } 42 43 46 public String getProfile() { return profile ; } 47 public void setProfile(String s) { profile = s; } 48 49 public org.exoplatform.services.organization.UserProfile getUserProfile() { 50 XStream xstream = getXStream() ; 51 UserProfileImpl up = (UserProfileImpl)xstream.fromXML(profile) ; 52 return up ; 53 } 54 55 public void setUserProfile(org.exoplatform.services.organization.UserProfile up) { 56 UserProfileImpl impl = (UserProfileImpl) up ; 57 userName = up.getUserName() ; 58 XStream xstream = getXStream() ; 59 profile = xstream.toXML(impl) ; 60 } 61 62 static private XStream getXStream() { 63 if (xstream_ == null) { 64 xstream_ = new XStream(new XppDriver()); 65 xstream_.alias("user-profile", UserProfileImpl.class); 66 } 67 return xstream_ ; 68 } 69 } | Popular Tags |