package com.vci.client.framework.delegate; import java.text.Collator; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.LinkedList; import java.util.List; import java.util.Locale; import org.apache.commons.lang3.StringUtils; import com.vci.mw.ClientContextVariable; import com.vci.mw.InvocationUtility; import com.vci.client.ClientSession; import com.vci.client.LogonApplication; import com.vci.client.common.objects.ClientInfo; import com.vci.client.common.objects.DeptObject; import com.vci.client.common.objects.RoleObject; import com.vci.client.common.objects.UserEntityObject; import com.vci.client.common.objects.UserLogonObject; import com.vci.client.common.objects.UserObject; import com.vci.client.common.providers.ServiceProvider; import com.vci.client.framework.appConfig.object.AppConfigDetailObject; import com.vci.client.framework.systemConfig.object.CombinationObject; import com.vci.client.framework.systemConfig.object.CombinationValueObject; import com.vci.client.framework.systemConfig.object.PasswordStrategyObject; import com.vci.client.ui.exception.VCIException; import com.vci.corba.common.VCIError; import com.vci.corba.common.data.VCIInvocationInfo; import com.vci.corba.framework.data.CombinationInfo; import com.vci.corba.framework.data.CombinationValueInfo; import com.vci.corba.framework.data.DeptInfo; import com.vci.corba.framework.data.PasswordStrategyInfo; import com.vci.corba.framework.data.RoleInfo; import com.vci.corba.framework.data.UserInfo; import com.vci.corba.framework.data.UserLogonInfo; import com.vci.corba.omd.etm.EnumChild; import com.vci.corba.omd.etm.EnumItem; import com.vci.corba.log.data.LogType; public class RightManagementClientDelegate extends ClientBaseDelegate { /** * */ private static final long serialVersionUID = 2416956441616227002L; public RightManagementClientDelegate(UserEntityObject userEntityObject) { super(userEntityObject); } public RightManagementClientDelegate() { } /** *
Description:获取所有部门
* * @author wangxl * @time 2012-5-10 * @return * @throws VCIError */ public DeptObject[] fetchDepartmentInfo() throws VCIException { DeptObject[] deptObj = null ; try { DeptInfo[] departmentInfo = ClientSession.getFrameworkService().fetchDepartmentInfo(); if (departmentInfo != null && departmentInfo.length > 0) { deptObj = changeDepartmentInfoToDeptObjects(departmentInfo); } return deptObj; }catch(VCIError e){ throw new VCIException(String.valueOf(e.code), e.messages); } } public UserObject[] getUserByDeptId(String deptId) throws VCIException { UserObject[] objs = null; try{ UserInfo[] infos = ClientSession.getFrameworkService().getUserByDeptId(deptId); objs = new UserObject[infos.length]; for(int i=0;iDescription:用于验证角色是否被引用
* * @author wangxl * @time 2012-5-10 * @param id * @return * @throws VCIError */ public int checkRoleIsquotedCount(String id) throws VCIException{ try{ return (int)ClientSession.getFrameworkService().checkRoleIsquotedCount(id); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } /*** * 获取普通用户所属的角色 * * @return * @throws VCIError */ public RoleObject[] fetchNormalRoles() throws VCIException { try { RoleInfo[] roleInfo = ClientSession.getFrameworkService().fetchRoleInfo(); int length = roleInfo.length; RoleObject[] roleObject = new RoleObject[length]; for (int i = 0; i < length; i++) { roleObject[i] = changeRoleInfoToRoleObject(roleInfo[i]); } List获取该型号下的型号总师:
* * @time 2013-3-28 * @param modelId 型号ID * @return * @throws VCIException */ public UserObject[] fetchUserInfoByModelId(String modelId) throws VCIException { try{ UserInfo[] userInfo = ClientSession.getFrameworkService().fetchUserInfoByModelId(modelId); int length = userInfo.length; UserObject[] userObject = new UserObject[length]; for (int i = 0; i < length; i++) { userObject[i] = changeUserInfoToUserObject(userInfo[i]); } return userObject; }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } /** * 通过型号获取型号总师 *Description:
* * @author wangxl * @time 2013-3-30 * @param model * @return * @throws VCIException */ public UserObject[] fetchUserInfoByModel(String model) throws VCIException { try{ UserInfo[] userInfo = ClientSession.getFrameworkService().fetchUserInfoByModel(model); int length = userInfo.length; UserObject[] userObject = new UserObject[length]; for (int i = 0; i < length; i++) { userObject[i] = changeUserInfoToUserObject(userInfo[i]); } return userObject; }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } /*** * 得到所有成员 * * @return * @throws VCIError */ public UserObject[] fetchUserInfo() throws VCIException { try{ UserInfo[] userInfo = ClientSession.getFrameworkService().fetchUserInfo(); int length = userInfo.length; UserObject[] userObject = new UserObject[length]; for (int i = 0; i < length; i++) { userObject[i] = changeUserInfoToUserObject(userInfo[i]); } return userObject; }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } /*** * 得到除 三员,admin,developer外的所有成员 * * @return * @throws VCIError */ public UserObject[] fetchUserInfoWithOutSanYuan() throws VCIException { try{ UserInfo[] userInfo = ClientSession.getFrameworkService().fetchUserInfoWithOutSanYuan(); int length = userInfo.length; UserObject[] userObject = new UserObject[length]; for (int i = 0; i < length; i++) { userObject[i] = changeUserInfoToUserObject(userInfo[i]); } return userObject; }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } public UserObject[] fetchUserInfoByCondition(String searchName , String searchUserName , String deptId, String roleId,String userName,int pageNo,int pageSize) throws VCIException { try{ UserInfo[] userInfo = ClientSession.getFrameworkService().fetchUserInfoByCondition(searchName ,searchUserName , deptId, roleId ,userName,pageNo,pageSize); int length = userInfo.length; UserObject[] userObject = new UserObject[length]; for (int i = 0; i < length; i++) { userObject[i] = changeUserInfoToUserObject(userInfo[i]); } ListDescription: 根据用户名获取将要被锁定的用户
* * @author wangxl * @time 2012-5-24 * @param userName * @return * @throws VCIError */ public UserObject getUserObjToLock(String userName) throws VCIException { return this.fetchUserInfoByName(userName); } /*** * 根据用户名获取成员 * * @return * @throws VCIError */ public UserObject fetchUserInfoByName(String userName) throws VCIException { try{ UserInfo userInfo = ClientSession.getFrameworkService().fetchUserInfoByName(userName); UserObject userObject = new UserObject(); userObject = changeUserInfoToUserObject(userInfo); return userObject; }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } public UserLogonObject getUserLogonObj(String userId) throws VCIException { try{ UserLogonInfo info = ClientSession.getFrameworkService().fetchUserLogonObj(userId); return transferCorbaObjToUserLogonObj(info); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } /** * 根据角色id和用户类型获取成员 * @param roleId * @param type * @return * @throws VCIError */ public UserObject[] fetchUserInfoByRoleId(String roleId , int type ) throws VCIException { try{ UserInfo[] userInfo = ClientSession.getFrameworkService().fetchUserInfoByRoleId( roleId ,(short)type); int length = userInfo.length; UserObject[] userObject = new UserObject[length]; for (int i = 0; i < length; i++) { userObject[i] = changeUserInfoToUserObject(userInfo[i]); } return userObject; }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } public UserObject[] fetchUserInfoByDeptAndRole(String[] deptIds , String[] roleIds ) throws VCIException { try{ UserInfo[] userInfo = ClientSession.getFrameworkService().fetchUserInfoByDeptAndRole( deptIds ,roleIds); int length = userInfo.length; UserObject[] userObject = new UserObject[length]; for (int i = 0; i < length; i++) { userObject[i] = changeUserInfoToUserObject(userInfo[i]); } return userObject; }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } /** * 创建角色和用户的关系 * @param roleId * @param userIds * @return * @throws VCIError */ public boolean saveRight(String roleId ,String[] userIds) throws VCIException{ try{ return ClientSession.getFrameworkService().saveRight(roleId , userIds , userEntityInfo); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } /** * 保存三员的成员 * @param roleId * @param userIds * @return * @throws VCIException */ public boolean saveSpecialRole(String roleId ,String[] userIds) throws VCIException{ try{ return ClientSession.getFrameworkService().saveSpecialRole(roleId , userIds , userEntityInfo); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } public boolean saveRighForDept(String deptId ,String[] userIds) throws VCIException{ try{ return ClientSession.getFrameworkService().saveRighForDept(deptId , userIds , userEntityInfo); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } /** * 创建角色和用户的关系 * @param roleId * @param userIds * @return * @throws VCIError */ public boolean saveRights(String[] roleIds ,String[] userIds) throws VCIException{ try{ return ClientSession.getFrameworkService().saveRights(roleIds , userIds , userEntityInfo); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } public boolean saveUserDept(String[] userIds ,String deptId) throws VCIException{ try{ return ClientSession.getFrameworkService().saveUserDept(userIds , deptId , userEntityInfo); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } /*** * 增加部门 * * @param * @return * @throws VCIError */ public String saveDepartment(DeptObject DeptObject) throws VCIException { try{ DeptInfo departmentInfo = changeDeptObjectToDepartmentInfo(DeptObject); String id = ClientSession.getFrameworkService().saveDepartment(departmentInfo,userEntityInfo); return id; }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } /** * 批量保存部门 * @param deptObjects * @return * @throws VCIException */ public boolean batchsaveDepartment(DeptObject[] deptObjects) throws VCIException { boolean rs = false; try{ DeptInfo[] depts = new DeptInfo[deptObjects.length]; for (int i = 0; i < depts.length; i++) { depts[i] = changeDeptObjectToDepartmentInfo(deptObjects[i]); } rs = ClientSession.getFrameworkService().batchSaveDepart(depts, userEntityInfo); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } return rs; } //add by caill start 2016.1.20 /*** * 增加角色 * * @param * @return * @throws VCIError */ public boolean batchSaveRoles(RoleObject[] roleObjects) throws VCIError { try{ int len = roleObjects.length; RoleInfo[] roleInfos = new RoleInfo[len]; for(int i = 0 ; iDescription:获取所有密级策略
* * @author wangxl * @time 2012-5-21 * @return * @throws VCIError */ public PasswordStrategyObject[] fetchAllPasswordStrategy() throws VCIException { try{ PasswordStrategyInfo[] psdStgIndo = ClientSession.getFrameworkService().fetchAllPasswordStrategy(); return this.changePasswordStrategyInfoToObjs(psdStgIndo); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } public PasswordStrategyObject[] fetchAllPasswordStrategy(int pageNo,int pageSize) throws VCIException { try{ PasswordStrategyInfo[] psdStgIndo = ClientSession.getFrameworkService().fetchAllPasswordStrategyByPage(pageNo, pageSize); return this.changePasswordStrategyInfoToObjs(psdStgIndo); }catch(VCIError e){ this.convertVCIErrorToVCIException(e); } return null; } public int getPasswordStrategyTotal() throws VCIException { int total = 0; try { total = (int)ClientSession.getFrameworkService().getPasswordStrategyTotal(); }catch(VCIError e){ this.convertVCIErrorToVCIException(e); } return total; } public boolean savePasswordStrategy(PasswordStrategyObject obj) throws VCIException { try{ PasswordStrategyInfo info = new PasswordStrategyInfo(); info = this.changePasswordStrategyObjToInfo(obj); return ClientSession.getFrameworkService().savePasswordStrategy(info, userEntityInfo); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } public boolean editPasswordStrategy(PasswordStrategyObject obj) throws VCIException { try{ PasswordStrategyInfo info = new PasswordStrategyInfo(); info = this.changePasswordStrategyObjToInfo(obj); return ClientSession.getFrameworkService().editPasswordStrategy(info, userEntityInfo); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } public boolean deletePasswordStrategy(String ids[]) throws VCIException { try{ return ClientSession.getFrameworkService().deletePasswordStrategy(ids, userEntityInfo); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } public int checkPasswordStrategyIsquotedCount(String id )throws VCIException { try{ return (int)ClientSession.getFrameworkService().checkPasswordStrategyIsquotedCount(id); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code), e.messages); } } public PasswordStrategyObject fetchPasswordStrategyByUserId(String userId) throws VCIException { try{ return this.changePasswordStrategyInfoToObj(ClientSession.getFrameworkService().fetchPasswordStrategyByUserId(userId)); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code), e.messages); } } public boolean saveUserPasswordStrateg(String[] userIds ,String passwordStrategId) throws VCIException{ try{ return ClientSession.getFrameworkService().saveUserPasswordStrateg(userIds , passwordStrategId , userEntityInfo); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code), e.messages); } } public String checkPasswordStrategyByUserId(String userId, String password) throws VCIException { try{ return ClientSession.getFrameworkService().checkPasswordStrategyByUserId(userId, password, userEntityInfo); } catch(VCIError e){ throw new VCIException(String.valueOf(e.code), e.messages); } } public void updateLogonInfo(String userId,boolean flag) throws VCIException{ try{ ClientSession.getFrameworkService().updateLogonInfo(userId,flag); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code), e.messages); } } public UserObject getUserObjectByUserName(String userName) throws VCIException{ UserObject userObj = null; try{ UserInfo info = ClientSession.getFrameworkService().getUserObjectByUserName(userName); if (!"".equals(info.id)){ userObj = changeUserInfoToUserObject(info); } }catch(VCIError e){ throw new VCIException(String.valueOf(e.code), e.messages); } if (userObj != null && !checkAdminLogin(userObj)) throw new VCIException("120414"); return userObj; } public UserObject checkLogin(String userName ,String password, ClientInfo clientInfo)throws VCIException{ UserObject userObj = null; try{ UserInfo info = ClientSession.getFrameworkService().checkLogin(userName , password); if (!"".equals(info.id)){ userObj = changeUserInfoToUserObject(info); String ip = clientInfo.getIp(); UserEntityObject entityObj = new UserEntityObject(userName, ip); LogonApplication.userEntityObject = entityObj; initContextInfo(info, clientInfo, false); } }catch(VCIError e){ throw new VCIException(String.valueOf(e.code), e.messages); } if (userObj != null && !checkAdminLogin(userObj)) throw new VCIException("120414"); return userObj; } /** * 获取已登录用户的VCIInvocation对象实例 *每次调用都将返回一个新实例
* @param userObj * @param clientInfo * @return * @throws VCIException * @author xiongchao * @since 2017.12.13 */ @Deprecated public VCIInvocationInfo getLogonedUserInvocationInfo(UserObject userObj, ClientInfo clientInfo) throws VCIException { return getLogonedUserInvocationInfo(userObj, clientInfo, false); } /** * 获取已登录用户的VCIInvocation对象实例 *每次调用都将返回一个新实例
* @param userObj * @param clientInfo * @param forBS 是否是来自Web端中执行登录后,返回已登录用户的VCIInvocationInfo, *当是来自于Web端时,每次返回的 VCIInvocationInfo 都是全新的实例
*当是来自富客户端时,每个富客户端应用都是在单独的进程中,所以classpath都是单独的JVM中,
*因此此时返回的VCIInvocationInfo是InvocationUtility.initInvocationInfo()
* * @return * @throws VCIException * @author xiongchao * @since 2017.12.13 * @last_update_date 2018.01.23 */ public VCIInvocationInfo getLogonedUserInvocationInfo(UserObject userObj, ClientInfo clientInfo, boolean forBS) throws VCIException { UserInfo user = changeUserObjectToUserInfo(userObj); //登陆用户角色信息 RoleObject[] roles = new RightManagementClientDelegate().fetchRoleInfoByUserId(user.id); //登陆用户组信息 DeptObject groupInfo = new RightManagementClientDelegate().fetchDeptByUserId(user.id); ListDescription:获取服务器端状态
* * @author wangxl * @time 2012-5-24 * @return * @throws VCIError */ public long getSystemTime() throws VCIException{ try{ return ClientSession.getFrameworkService().getSystemTime(); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code), e.messages); } } /** * 简单记录系统登入、登出日志 *Description:
* * @author wangxl * @time 2012-12-27 * @param message * @throws VCIError */ public void savelog(String content) throws VCIException{ try{ ServiceProvider.getLogService().saveLoginLog(true, content, userEntityInfo); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code), e.messages); } } public void saveLogV2(String result, String content, String type, int logTypeIntVal, String dataObjOid) throws VCIException{ try{ ServiceProvider.getLogService().saveLog(result, content, type, LogType.valueOf(logTypeIntVal), dataObjOid, userEntityInfo); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code), e.messages); } } //add by caill start 2016.9.13用户被锁定的日志 /** * *记录身份验证过程中登陆失败的日志信息
* * @author caill * @time 2016-9-13 * @param message * @throws VCIException */ public void blocklog(String userId) throws VCIException{ try{ ServiceProvider.getLogService().saveLockLog(userId, userEntityInfo); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code), e.messages); } } /** * *记录身份验证过程中登陆失败的日志信息
* * @author llb * @time 2013-2-18 * @param message * @throws VCIException */ public void savelogFail(String message) throws VCIException{ try{ ServiceProvider.getLogService().saveLoginLog(false, message, userEntityInfo); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code), e.messages); } } /** * 分页查询密码组合方式 *Description:
* * @author llb * @time 2013-1-4 * @param id * @return * @throws VCIException */ public CombinationObject[] fetchCombinationsToPage (int pageIndex, int pageSize) throws VCIException { try{ CombinationInfo[] info = ClientSession.getFrameworkService().fetchCombinationsToPage( (long)pageIndex, (long)pageSize); int length = info.length; CombinationObject[] combinationObject = new CombinationObject[length]; for (int i = 0; i < length; i++) { combinationObject[i] = changeCombinationInfoToObject(info[i]); } return combinationObject; }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } public CombinationObject[] fetchAllCombinations () throws VCIException { try{ CombinationInfo[] info = ClientSession.getFrameworkService().fetchAllCombinations(); int length = info.length; CombinationObject[] combinationObject = new CombinationObject[length]; for (int i = 0; i < length; i++) { combinationObject[i] = changeCombinationInfoToObject(info[i]); } return combinationObject; }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } /** * 添加密码组合方式 *Description:
* * @author wangxl * @time 2013-1-3 * @param obj * @return * @throws VCIException */ public String saveCombination(CombinationObject obj)throws VCIException { try{ CombinationInfo info = changeCombinationObjectToInfo(obj); String id = ClientSession.getFrameworkService().saveCombination(info,userEntityInfo); return id; }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } /** * 修改密码组合方式 *Description:
* * @author wangxl * @time 2013-1-3 * @param obj * @return * @throws VCIException */ public boolean updateCombination(CombinationObject obj)throws VCIException { try{ CombinationInfo info = changeCombinationObjectToInfo(obj); return ClientSession.getFrameworkService().updateCombination(info,userEntityInfo); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } /** * 删除密码组合方式 *Description:
* * @author wangxl * @time 2013-1-3 * @param id * @return * @throws VCIException */ public boolean deleteCombination(String[] id) throws VCIException { try{ return ClientSession.getFrameworkService().deleteCombination(id, userEntityInfo); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } /** * 根据密码组合方式id获取组合方式取值范围 *Description:
* * @author wangxl * @time 2013-1-3 * @param parentId * @return * @throws VCIException */ public CombinationValueObject[] fetchCombinationValuesByParentId(String parentId) throws VCIException { try{ CombinationValueInfo[] info = ClientSession.getFrameworkService().fetchCombinationValuesByParentId(parentId); int length = info.length; CombinationValueObject[] combValObject = new CombinationValueObject[length]; for (int i = 0; i < length; i++) { combValObject[i] = changeCombinationValueInfoToObject(info[i]); } return combValObject; }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } /** * 添加密码组合方式取值范围 *Description:
* * @author wangxl * @time 2013-1-3 * @param valueObj * @return * @throws VCIException */ public String saveCombinationValue(CombinationValueObject[] valueObj)throws VCIException { try{ int length = valueObj.length; CombinationValueInfo[] infos = new CombinationValueInfo[length]; for (int i = 0; i < length; i++) { infos[i] = changeCombinationValueObjectToInfo(valueObj[i]); } return ClientSession.getFrameworkService().saveCombinationValue(infos,userEntityInfo); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } /** * 修改密码组合方式取值范围 *Description:
* * @author wangxl * @time 2013-1-3 * @param valueObj * @return * @throws VCIException */ public boolean updateCombinationValue(CombinationValueObject valueObj)throws VCIException { try{ CombinationValueInfo info = changeCombinationValueObjectToInfo(valueObj); return ClientSession.getFrameworkService().updateCombinationValue(info,userEntityInfo); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } public boolean deletCombinationValues(String[] puids)throws VCIException { try{ return ClientSession.getFrameworkService().deletCombinationValues(puids, userEntityInfo); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } /** * 根据密码策略id 获取关联的密码组合方式 *Description:
* * @author wangxl * @time 2013-1-4 * @param pstId * @return * @throws VCIException */ public CombinationObject[] fetchCombinationsByPstId(String pstId)throws VCIException{ try{ CombinationInfo[] info = ClientSession.getFrameworkService().fetchCombinationsByPstId(pstId); int length = info.length; CombinationObject[] combinationObject = new CombinationObject[length]; for (int i = 0; i < length; i++) { combinationObject[i] = changeCombinationInfoToObject(info[i]); } return combinationObject; }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } /** * 检验密码组合方式是否被密码策略引用 *Description:
* * @author wangxl * @time 2013-1-4 * @param id * @return * @throws VCIException */ public int checkCombinationIsquotedCount(String combinationd) throws VCIException{ try{ return (int)ClientSession.getFrameworkService().checkCombinationIsquotedCount(combinationd); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } /** * 根据部门角色串获取用户名 *Description:
* * @author wangxl * @time 2013-3-27 * @param deptRole * @return * @throws VCIException */ public String[] getUsersByDetpAndRole(String deptRole)throws VCIException { String[] userNames = null; if ("".equals(deptRole)){ return userNames; } String deptNames = deptRole.substring(deptRole.indexOf("'")+1, deptRole.indexOf("&")-1); String roleName = deptRole.substring(deptRole.lastIndexOf("=")+2, deptRole.length()-1); String[] depts = deptNames.split("\\."); String deptId = ""; DeptObject toopObj = null; DeptObject deptObj = null; for (int i = 0 ; i < depts.length ; i ++){ if (i == 0){ toopObj =this.fetchDeptByParentIdAndName("", depts[i]); if (depts.length == 1){ deptObj = toopObj; } }else if(i ==1){ deptObj = this.fetchDeptByParentIdAndName(toopObj.getId (), depts[i]); }else { deptObj = this.fetchDeptByParentIdAndName(deptObj.getId() , depts[i]); } if (i == depts.length -1){ if (deptObj != null && !"".equals(deptObj.getId())){ deptId = deptObj.getId(); }else { deptId = ""; } } } String roleId = ""; RoleObject roleObj = this.fetchRoleByName(roleName); if (roleObj != null && !"".equals(roleObj.getId())){ roleId = roleObj.getId(); } UserObject[] userObjs = this.fetchUserInfoByDeptAndRole(new String[]{deptId}, new String[]{roleId}); if (userObjs != null && userObjs.length > 0){ userNames = new String[userObjs.length]; for (int i = 0 ; i < userObjs.length ; i ++){ userNames[i] = userObjs[i].getUserName(); } } return userNames; } private DeptObject fetchDeptByParentIdAndName(String parentId , String deptName)throws VCIException { DeptObject deptObj = null; try { DeptInfo departmentInfo = ClientSession.getFrameworkService().fetchDeptByParentIdAndName(parentId,deptName); if (departmentInfo != null) { deptObj = changeDepartmentInfoToDeptObject(departmentInfo); } return deptObj; }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } public DeptInfo changeDeptObjectToDepartmentInfo(DeptObject DeptObject) { DeptInfo departmentInfo = new DeptInfo(); departmentInfo.id = DeptObject.getId() == null ? "" : DeptObject.getId(); departmentInfo.name = DeptObject.getName() == null ? "" : DeptObject.getName(); departmentInfo.num = DeptObject.getNum() == null ? "" : DeptObject.getNum(); departmentInfo.code = DeptObject.getCode() == null ? "" : DeptObject.getCode(); departmentInfo.specialties = DeptObject.getSpecialties() == null ? "" : DeptObject.getSpecialties(); departmentInfo.status = DeptObject.getStatus() == 0 ? 0 : DeptObject.getStatus(); departmentInfo.description = DeptObject.getDescription() == null ? "" : DeptObject.getDescription(); departmentInfo.parentId = DeptObject.getParentId() == null ? "" : DeptObject.getParentId(); departmentInfo.createUser = DeptObject.getCreateUser() == null ? "" : DeptObject.getCreateUser(); departmentInfo.createTime = DeptObject.getCreateTime(); departmentInfo.updateTime = System.currentTimeMillis(); departmentInfo.updateUser = DeptObject.getUpdateUser() == null ? "" : DeptObject.getUpdateUser(); departmentInfo.grantor = DeptObject.getGrantor() == null ? "" : DeptObject.getGrantor(); return departmentInfo; } public DeptObject[] changeDepartmentInfoToDeptObjects(DeptInfo[] departmentInfos) { int length = departmentInfos.length; DeptObject[] DeptObject = new DeptObject[length]; for (int i = 0; i < length; i++) { DeptObject[i] = changeDepartmentInfoToDeptObject(departmentInfos[i]); } return DeptObject; } public DeptObject changeDepartmentInfoToDeptObject(DeptInfo departmentInfo) { DeptObject department = new DeptObject(); department.setId(departmentInfo.id); department.setDescription(departmentInfo.description); department.setName(departmentInfo.name); department.setNum(departmentInfo.num); department.setCode(departmentInfo.code); department.setStatus(departmentInfo.status); department.setSpecialties(departmentInfo.specialties); department.setParentId(departmentInfo.parentId); department.setCreateTime(departmentInfo.createTime); department.setCreateUser(departmentInfo.createUser); department.setUpdateTime(departmentInfo.updateTime); department.setUpdateUser(departmentInfo.updateUser); department.setGrantor(departmentInfo.grantor); return department; } public RoleInfo changeRoleObjectToRoleInfo(RoleObject role) { RoleInfo roleInfo = new RoleInfo(); roleInfo.id = role.getId() == null ? "" : role.getId(); roleInfo.name = role.getName(); roleInfo.description = role.getDescription() == null ? "" : role.getDescription(); roleInfo.type = role.getType(); roleInfo.createTime = role.getCreateTime(); roleInfo.createUser = role.getCreateUser() == null ? "" : role.getCreateUser(); roleInfo.updateTime = role.getUpdateTime(); roleInfo.updateUser = role.getUpdateUser() == null ? "" : role.getUpdateUser(); roleInfo.grantor = role.getGrantor() == null ? "" : role.getGrantor(); return roleInfo; } public RoleObject changeRoleInfoToRoleObject(RoleInfo roleInfo) { RoleObject role = new RoleObject(); role.setId(roleInfo.id); role.setDescription(roleInfo.description); role.setName(roleInfo.name); role.setType(roleInfo.type); role.setCreateTime(roleInfo.createTime); role.setCreateUser(roleInfo.createUser); role.setUpdateTime(roleInfo.updateTime); role.setUpdateUser(roleInfo.updateUser); role.setGrantor(roleInfo.grantor); return role; } public CombinationObject changeCombinationInfoToObject(CombinationInfo info) { CombinationObject obj = new CombinationObject(); obj.setId(info.id); obj.setDescription(info.description); obj.setName(info.name); obj.setCreateTime(info.createTime); obj.setCreateUser(info.createUser); obj.setUpdateTime(info.updateTime); obj.setUpdateUser(info.updateUser); obj.setGrantor(info.grantor); return obj; } public CombinationValueObject changeCombinationValueInfoToObject(CombinationValueInfo info) { CombinationValueObject obj = new CombinationValueObject(); obj.setId(info.id); obj.setParentId(info.parentId); obj.setValue(info.value); return obj; } public CombinationInfo changeCombinationObjectToInfo(CombinationObject obj) { CombinationInfo info = new CombinationInfo(); info.id = obj.getId() == null ? "" : obj.getId(); info.name = obj.getName(); info.description = obj.getDescription() == null ? "" : obj.getDescription(); info.createTime = obj.getCreateTime(); info.createUser =obj.getCreateUser() == null ? "" : obj.getCreateUser(); info.updateTime = obj.getUpdateTime(); info.updateUser = obj.getUpdateUser() == null ? "" : obj.getUpdateUser(); info.grantor = obj.getGrantor() == null ? "" : obj.getGrantor(); return info; } public CombinationValueInfo changeCombinationValueObjectToInfo(CombinationValueObject obj) { CombinationValueInfo info = new CombinationValueInfo(); info.id = obj.getId() == null ? "" : obj.getId(); info.parentId = obj.getParentId() == null ? "" : obj.getParentId(); info.value = obj.getValue() == null ? "" : obj.getValue(); return info; } public UserObject changeUserInfoToUserObject(UserInfo userInfo) { UserObject user = new UserObject(); user.setId(userInfo.id); user.setUserName(userInfo.userName); user.setPwd(userInfo.pwd); user.setEmail(userInfo.email); user.setTrueName(userInfo.trueName); user.setSpecialties(userInfo.specialties); user.setDesc(userInfo.desc); user.setUserType(userInfo.userType); user.setStatus(userInfo.status); user.setCreateTime(userInfo.createTime); user.setCreateUser(userInfo.createUser); user.setUpdateTime(userInfo.updateTime); user.setUpdateUser(userInfo.updateUser); user.setPwdUpdateTime(userInfo.pwdUpdateTime); user.setGrantor(userInfo.grantor); user.setSecretGrade(userInfo.secretGrade); user.setIsDeptLeader(userInfo.isDeptLeader); return user; } /*** * 用户从客户端对象到corba对象 * * @param UserObject * @return */ public UserInfo changeUserObjectToUserInfo(UserObject user) { UserInfo userInfo = new UserInfo(); userInfo.id = user.getId() == null ? "" : user.getId(); userInfo.userName = user.getUserName() == null ? "" : user.getUserName(); userInfo.pwd = user.getPwd() == null ? "" : user.getPwd(); userInfo.trueName = user.getTrueName() == null ? "" : user.getTrueName(); userInfo.specialties = user.getSpecialties() == null ? "" : user.getSpecialties(); userInfo.email = user.getEmail() == null ? "" : user.getEmail(); userInfo.desc = user.getDesc() == null ? "" : user.getDesc(); userInfo.userType = user.getUserType(); userInfo.status = user.getStatus(); userInfo.createTime = user.getCreateTime(); userInfo.createUser = user.getCreateUser() == null ? "" : user.getCreateUser(); userInfo.updateTime = user.getUpdateTime(); userInfo.updateUser = user.getUpdateUser() == null ? "" : user.getUpdateUser(); userInfo.pwdUpdateTime = user.getPwdUpdateTime(); userInfo.grantor = user.getGrantor() == null ? "" : user.getGrantor(); userInfo.secretGrade = user.getSecretGrade() == null ? "" : user.getSecretGrade(); userInfo.isDeptLeader = user.getIsDeptLeader() == null ? "0" : user.getIsDeptLeader(); return userInfo; } public PasswordStrategyObject[] changePasswordStrategyInfoToObjs(PasswordStrategyInfo[] pwdStgInfos){ PasswordStrategyObject[] objs = new PasswordStrategyObject[pwdStgInfos.length]; for (int i = 0 ; i < pwdStgInfos.length ; i ++){ objs[i] = this.changePasswordStrategyInfoToObj(pwdStgInfos[i]); } return objs; } public PasswordStrategyObject changePasswordStrategyInfoToObj(PasswordStrategyInfo info){ PasswordStrategyObject obj = new PasswordStrategyObject(); obj.setId(info.id ); obj.setName(info.name); obj.setPasswordLen(info.passwordLen); obj.setPasswordMaxLen(info.passwordMaxLen); obj.setCharTypes(info.charTypes); obj.setRequiredType(info.requiredType); obj.setOverdueDay(info.overdueDay); obj.setRemideDay(info.remideDay); obj.setRetryTime(info.retryTime); obj.setLockTime(info.lockTime); obj.setIsDefault(info.isDefault); obj.setDesc(info.desc == "" ? null : info.desc); obj.setCreateTime(info.createTime); obj.setCreateUser(info.createUser); obj.setUpdateTime(info.updateTime); obj.setUpdateTime(info.updateTime); obj.setGrantor(info.grantor == null ? "" : info.grantor); return obj; } private PasswordStrategyInfo changePasswordStrategyObjToInfo(PasswordStrategyObject obj){ PasswordStrategyInfo info = new PasswordStrategyInfo(); info.id = obj.getId(); info.name = obj.getName(); info.passwordLen = obj.getPasswordLen(); info.passwordMaxLen = obj.getPasswordMaxLen(); info.charTypes = obj.getCharTypes(); info.requiredType = obj.getRequiredType(); info.overdueDay = obj.getOverdueDay(); info.remideDay = obj.getRemideDay(); info.retryTime = obj.getRetryTime(); info.lockTime = obj.getLockTime(); info.isDefault = obj.getIsDefault(); info.desc = obj.getDesc() == null ? "" : obj.getDesc(); info.createTime = obj.getCreateTime(); info.createUser = obj.getCreateUser() == null ? "" : obj.getCreateUser(); info.updateTime = obj.getUpdateTime(); info.updateUser = obj.getUpdateUser() == null ? "" : obj.getUpdateUser(); info.grantor = obj.getGrantor() == null ? "" : obj.getGrantor(); return info; } private UserLogonObject transferCorbaObjToUserLogonObj(UserLogonInfo info){ UserLogonObject obj = new UserLogonObject(); if (!StringUtils.isEmpty(info.pluserOid)) { obj.setPluserOid(info.pluserOid); obj.setPlWrongNum(info.plWrongNum); obj.setPlLogonTime(info.plLogonTime); } return obj; } /** * 根据文件柜id和用户类型获取成员 * @param roleId * @param type * @return * @throws VCIError */ public UserObject[] fetchUserInfoByPvolumeId(String pvolumeId , short type ) throws VCIException { try{ UserInfo[] userInfo = ClientSession.getFrameworkService().fetchUserInfoByPvolumeId(pvolumeId ,type); int length = userInfo.length; UserObject[] userObject = new UserObject[length]; for (int i = 0; i < length; i++) { userObject[i] = changeUserInfoToUserObject(userInfo[i]); } return userObject; }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } /** * 创建文件柜和用户的关系 * @param roleId * @param userIds * @return * @throws VCIError */ public boolean savePvolume(String pvolumId ,String[] userIds) throws VCIException{ try{ return ClientSession.getFrameworkService().savePvolumeUser(pvolumId, userIds, userEntityInfo); }catch(VCIError e){ throw new VCIException(String.valueOf(e.code),e.messages); } } static class NameComparator implements Comparator