1 25 package org.ofbiz.shark.user; 26 27 import java.util.List ; 28 import java.util.ArrayList ; 29 import java.util.Iterator ; 30 31 import org.ofbiz.entity.GenericDelegator; 32 import org.ofbiz.entity.GenericEntityException; 33 import org.ofbiz.entity.GenericValue; 34 import org.ofbiz.shark.container.SharkContainer; 35 import org.ofbiz.base.util.UtilMisc; 36 37 import org.enhydra.shark.api.internal.usergroup.UserGroupManager; 38 import org.enhydra.shark.api.internal.working.CallbackUtilities; 39 import org.enhydra.shark.api.RootException; 40 import org.enhydra.shark.api.UserTransaction; 41 42 48 public class PartyUserGroupMgr implements UserGroupManager { 49 50 public static final String module = PartyUserGroupMgr.class.getName(); 51 protected CallbackUtilities callBack = null; 52 protected GenericDelegator delegator = null; 53 54 public void configure(CallbackUtilities cb) throws RootException { 55 this.delegator = SharkContainer.getDelegator(); 56 this.callBack = cb; 57 } 58 59 public List getAllGroupnames(UserTransaction trans) throws RootException { 60 return null; } 62 63 public List getAllUsers(UserTransaction trans) throws RootException { 64 List userLogins = null; 65 List allUsers = null; 66 try { 67 userLogins = delegator.findAll("UserLogin", UtilMisc.toList("userLoginId")); 68 } catch (GenericEntityException e) { 69 throw new RootException(e); 70 } 71 72 if (userLogins != null) { 73 allUsers = new ArrayList (); 74 Iterator i = userLogins.iterator(); 75 while (i.hasNext()) { 76 GenericValue userLogin = (GenericValue) i.next(); 77 allUsers.add(userLogin.getString("userLoginId")); 78 } 79 } 80 return allUsers; 81 } 82 83 public List getAllUsers(UserTransaction trans, String groupName) throws RootException { 84 return this.getAllUsers(trans); 86 } 87 88 public List getAllUsers(UserTransaction trans, List groupNames) throws RootException { 89 return null; } 92 93 public List getAllImmediateUsers(UserTransaction trans, String groupName) throws RootException { 94 return this.getAllUsers(trans); 96 } 97 98 public List getAllSubgroups(UserTransaction trans, String groupName) throws RootException { 99 return null; 101 } 102 103 public List getAllSubgroups(UserTransaction trans, List groupNames) throws RootException { 104 return null; 106 } 107 108 public List getAllImmediateSubgroups(UserTransaction trans, String groupName) throws RootException { 109 return null; 111 } 112 113 public void createGroup(UserTransaction trans, String s, String s1) throws RootException { 114 throw new RootException("PartyUserGroupMgr does not implement create/update/remove methods. Use the party manager instead!"); 115 } 116 117 public void removeGroup(UserTransaction trans, String groupName) throws RootException { 118 throw new RootException("PartyUserGroupMgr does not implement create/update/remove methods. Use the party manager instead!"); 119 } 120 121 public boolean doesGroupExist(UserTransaction trans, String groupName) throws RootException { 122 return false; } 124 125 public boolean doesGroupBelongToGroup(UserTransaction trans, String groupName, String subGroupName) throws RootException { 126 return false; } 128 129 public void updateGroup(UserTransaction trans, String s, String s1) throws RootException { 130 throw new RootException("PartyUserGroupMgr does not implement create/update/remove methods. Use the party manager instead!"); 131 } 132 133 public void addGroupToGroup(UserTransaction trans, String s, String s1) throws RootException { 134 throw new RootException("PartyUserGroupMgr does not implement create/update/remove methods. Use the party manager instead!"); 135 } 136 137 public void removeGroupFromGroup(UserTransaction trans, String s, String s1) throws RootException { 138 throw new RootException("PartyUserGroupMgr does not implement create/update/remove methods. Use the party manager instead!"); 139 } 140 141 public void removeGroupTree(UserTransaction trans, String s) throws RootException { 142 throw new RootException("PartyUserGroupMgr does not implement create/update/remove methods. Use the party manager instead!"); 143 } 144 145 public void removeUsersFromGroupTree(UserTransaction trans, String s) throws RootException { 146 throw new RootException("PartyUserGroupMgr does not implement create/update/remove methods. Use the party manager instead!"); 147 } 148 149 public void moveGroup(UserTransaction trans, String s, String s1, String s2) throws RootException { 150 throw new RootException("PartyUserGroupMgr does not implement create/update/remove methods. Use the party manager instead!"); 151 } 152 153 public String getGroupDescription(UserTransaction trans, String s) throws RootException { 154 throw new RootException("PartyUserGroupMgr does not implement create/update/remove methods. Use the party manager instead!"); 155 } 156 157 public void addUserToGroup(UserTransaction trans, String s, String s1) throws RootException { 158 throw new RootException("PartyUserGroupMgr does not implement create/update/remove methods. Use the party manager instead!"); 159 } 160 161 public void removeUserFromGroup(UserTransaction trans, String s, String s1) throws RootException { 162 throw new RootException("PartyUserGroupMgr does not implement create/update/remove methods. Use the party manager instead!"); 163 } 164 165 public void moveUser(UserTransaction trans, String s, String s1, String s2) throws RootException { 166 throw new RootException("PartyUserGroupMgr does not implement create/update/remove methods. Use the party manager instead!"); 167 } 168 169 public boolean doesUserBelongToGroup(UserTransaction trans, String groupName, String username) throws RootException { 170 return false; } 172 173 public void createUser(UserTransaction trans, String groupName, String username, String password, String firstname, String lastname, String email) throws RootException { 174 throw new RootException("PartyUserGroupMgr does not implement create/update/remove methods. Use the party manager instead!"); 175 } 176 177 public void updateUser(UserTransaction trans, String username, String firstname, String lastname, String email) throws RootException { 178 throw new RootException("PartyUserGroupMgr does not implement create/update/remove methods. Use the party manager instead!"); 179 } 180 181 public void removeUser(UserTransaction trans, String username) throws RootException { 182 throw new RootException("PartyUserGroupMgr does not implement create/update/remove methods. Use the party manager instead!"); 183 } 184 185 public boolean doesUserExist(UserTransaction trans, String username) throws RootException { 186 GenericValue userLogin = this.getUserLogin(username); 187 return (userLogin != null); 188 } 189 190 public void setPassword(UserTransaction trans, String username, String password) throws RootException { 191 throw new RootException("PartyUserGroupMgr does not implement create/update/remove methods. Use the party manager instead!"); 192 } 193 194 public String getUserRealName(UserTransaction trans, String username) throws RootException { 195 return username; 196 } 197 198 public String getUserFirstName(UserTransaction trans, String username) throws RootException { 199 return username; 200 } 201 202 public String getUserLastName(UserTransaction trans, String username) throws RootException { 203 return username; 204 } 205 206 public String getUserEMailAddress(UserTransaction trans, String username) throws RootException { 207 return username; 208 } 209 210 protected GenericValue getUserLogin(String username) throws RootException { 211 GenericValue userLogin = null; 212 try { 213 userLogin = delegator.findByPrimaryKey("UserLogin", UtilMisc.toMap("userLoginId", username)); 214 } catch (GenericEntityException e) { 215 throw new RootException(e); 216 } 217 return userLogin; 218 } 219 } 220 | Popular Tags |