1 5 package org.exoplatform.services.organization.hibernate; 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 22 public class UserProfileData { 23 static transient private XStream xstream_ ; 24 25 private String userName ; 26 private String profile ; 27 28 public UserProfileData() { 29 } 30 31 public UserProfileData(String userName) { 32 StringBuffer b = new StringBuffer () ; 33 b.append("<user-profile>\n"). 34 append(" <userName>").append(userName).append("</userName>\n"); 35 b.append("</user-profile>\n"); 36 this.userName = userName ; 37 this.profile = b.toString() ; 38 } 39 40 43 public String getUserName() { return userName ; } 44 public void setUserName(String s) { this.userName = s ; } 45 46 49 public String getProfile() { return profile ; } 50 public void setProfile(String s) { profile = s; } 51 52 public org.exoplatform.services.organization.UserProfile getUserProfile() { 53 XStream xstream = getXStream() ; 54 UserProfileImpl up = (UserProfileImpl)xstream.fromXML(profile) ; 55 return up ; 56 } 57 58 public void setUserProfile(org.exoplatform.services.organization.UserProfile up) { 59 UserProfileImpl impl = (UserProfileImpl) up ; 60 userName = up.getUserName() ; 61 XStream xstream = getXStream() ; 62 profile = xstream.toXML(impl) ; 63 } 64 65 static private XStream getXStream() { 66 if (xstream_ == null) { 67 xstream_ = new XStream(new XppDriver()); 68 xstream_.alias("user-profile", UserProfileImpl.class); 69 } 70 return xstream_ ; 71 } 72 } | Popular Tags |