package com.orbitz.admin.modelbean; import com.orbitz.admin.modelbean.useradmin.GroupPermissionMB; import com.orbitz.web.ChannelContext; import com.orbitz.web.FormSupport; import com.orbitz.web.ParameterBundle; import com.orbitz.web.ParameterInfoBean; import org.apache.log4j.Logger; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; /** *

Model bean for displaying an Admin Server User *

* *

(c) 2001-03 Orbitz, LLC. All Rights Reserved.

* */ public class AdminUserMB extends FormSupport { private static final Logger log = Logger.getLogger(AdminUserMB.class); private ParameterInfoBean _id = new ParameterInfoBean("Id"); private ParameterInfoBean _loginId = new ParameterInfoBean("Login Id"); private ParameterInfoBean _password = new ParameterInfoBean("Password"); private ParameterInfoBean _passwordVerify = new ParameterInfoBean("Password Verification"); private ParameterInfoBean _firstName = new ParameterInfoBean("First Name"); private ParameterInfoBean _lastName = new ParameterInfoBean("Last Name"); private HashMap _groupPermissions; public AdminUserMB() {} public ParameterInfoBean getId() { return _id; } public void setId(ParameterInfoBean value) { if (value == null) { throw new NullPointerException("Id ParameterInfoBean must not be null"); } _id = value; } public ParameterInfoBean getLoginId() { return _loginId; } public void setLoginId(ParameterInfoBean value) { if (value == null) { throw new NullPointerException("Login Id ParameterInfoBean must not be null"); } _loginId = value; } // Extra setter so password memorizing browsers don't try to store these // user ids in their caches. public void setNewLoginId(ParameterInfoBean value) { if (value == null) { throw new NullPointerException("Login Id ParameterInfoBean must not be null"); } _loginId = value; } public ParameterInfoBean getPassword() { return _password; } public void setPassword(ParameterInfoBean value) { if (value == null) { throw new NullPointerException("Password ParameterInfoBean must not be null"); } _password = value; } // Extra setter so password memorizing browsers don't try to store these // user ids in their caches. public void setNewPassword(ParameterInfoBean value) { _password = value; } public ParameterInfoBean getPasswordVerify() { return _passwordVerify; } public void setPasswordVerify(ParameterInfoBean value) { if (value == null) { throw new NullPointerException("Password Verification ParameterInfoBean must not be null"); } _passwordVerify = value; } public ParameterInfoBean getFirstName() { return _firstName; } public void setFirstName(ParameterInfoBean value) { if (value == null) { throw new NullPointerException("First Name ParameterInfoBean must not be null"); } _firstName = value; } public ParameterInfoBean getLastName() { return _lastName; } public void setLastName(ParameterInfoBean value) { if (value == null) { throw new NullPointerException("Last Name ParameterInfoBean must not be null"); } _lastName = value; } /** * Get a List of all the Admin User's Permissions for the given group. * @param group The group we want the List of permissions for. * @return A List of GroupPermissionMBs. */ public List getGroupPermissions(String group) { if (group == null) { return new ArrayList(); } ArrayList list = new ArrayList(); Iterator groupIter = getAllGroupPermissions().iterator(); GroupPermissionMB groupPermissionMB = null; while (groupIter.hasNext()) { groupPermissionMB = (GroupPermissionMB) groupIter.next(); if (groupPermissionMB.getGroupCode().equalsIgnoreCase(group)) { list.add(groupPermissionMB); } } return list; } /** * Add a Group/Permission Model Bean * @param value The Group/Permission to add. */ public void addGroupPermission(GroupPermissionMB value) { if (value != null) { getGroupPermissions().put(value.getId(), value); } } /** * Get all group permissions * @return A List of GroupPermissionMBs */ public List getAllGroupPermissions() { return new ArrayList(getGroupPermissions().values()); } /** * Accepts a parameter bundle and uses introspection * to automatically copy the values of the parameter bundle * (parameter info beans) to the proper setter in this model bean. * * @param pb the parameter bundle */ public void populate(ChannelContext context, ParameterBundle pb) { super.populate(pb); String[] permissionIds = context.getRequest().getParameterValues("permissionId"); String delete = null; String groupCode = null; String permissionCode = null; String permissionValue = null; GroupPermissionMB groupPermissionMB = null; if (permissionIds == null) { return; } for (int i=0; i