1 package org.tigris.scarab.attribute; 2 3 48 49 51 import org.apache.torque.TorqueException; 52 53 import org.tigris.scarab.om.AttributeValue; 55 import org.tigris.scarab.om.ScarabUser; 56 import org.tigris.scarab.om.ScarabUserManager; 57 58 63 public class UserAttribute extends AttributeValue 64 { 65 66 70 public String getUserName() 71 { 72 return getValue(); 73 } 74 75 public void setUser(ScarabUser user) 76 throws Exception 77 { 78 setValueOnly(user.getUserName()); 79 setUserIdOnly(user.getUserId()); 80 } 81 82 public void setValue(String username) 83 { 84 try 86 { 87 if (username != null) 88 { 89 ScarabUser user = ScarabUserManager 90 .getInstance(username, getIssue().getIdDomain()); 91 if (user != null) 92 { 93 setUserIdOnly(user.getUserId()); 94 } 95 } 96 else 97 { 98 setUserIdOnly(null); 100 } 101 102 setValueOnly(username); 103 } 104 catch (Exception e) 105 { 106 e.printStackTrace(); 107 getLog().error(e); 108 } 109 } 110 111 112 115 public String getValue() 116 { 117 String value = null; 118 try 119 { 120 if (getUserId() != null) 121 { 122 ScarabUser user = ScarabUserManager.getInstance(getUserId()); 123 value = user.getUserName(); 124 } 125 else 126 { 127 value = super.getValue(); 128 } 129 } 130 catch (TorqueException e) 131 { 132 getLog().error(e); 133 value="Error. Please see logs."; 134 } 135 return value; 136 } 137 138 139 public void init() throws Exception 140 { 141 } 142 143 public void setResources(Object resources) 144 { 145 } 146 147 150 public Object loadResources() throws Exception 151 { 152 return null; 153 } 154 } 155 | Popular Tags |