Cognos 8 SDK简介

try { //将用户添加到角色下面 addToRole(connection, pathOfRole, user); } catch (java.rmi.RemoteException remoteEx) { remoteEx.printStackTrace(); return \ } return ( \ }

/**

* 将用户或者用户组添加到用户组下. *

* @param connection Cognos 8 连接实例 * @param pathOfGroup 用户组的搜索路径. * @param member 被添加的用户或组. * */

public void addToGroup( CRNConnect connection, String pathOfGroup, BaseClass[] member) throws java.rmi.RemoteException { // 得到当前组的成员. PropEnum[] props = { PropEnum.defaultName, PropEnum.searchPath, PropEnum.members }; Group group = (Group)csHandler.queryObjectInCS(connection, pathOfGroup, props)[0]; //如果当前组没有成员,则直接添加 if (group.getMembers().getValue() == null) { group.setMembers(new BaseClassArrayProp()); group.getMembers().setValue(member); csHandler.updateObjectInCS(connection, new BaseClass[] { group }); } //否则保存所有原有的成员

}

else { // Preserve all the existing members. BaseClass[] newMembers = new BaseClass[group.getMembers().getValue().length + 1]; int index = 0; BaseClass obj = null; for (int i = 0; i < group.getMembers().getValue().length; i++) { obj = group.getMembers().getValue()[i]; }

}

//BaseClass[] memberProps = csHandler.queryObjectInCS( connection, obj.getSearchPath().getValue()); newMembers[index] = obj; index++;

newMembers[index] = member[0];

group.setMembers(new BaseClassArrayProp()); group.getMembers().setValue(newMembers);

// Update the membership.

csHandler.updateObjectInCS(connection, new BaseClass[] { group });

/**

* 给指定角色添加成员. *

* @param connection Cognos 8 连接

* @param pathOfRole 角色的搜索路径. * @param member 用户,组或角色. * */

public void addToRole( CRNConnect connection, String pathOfRole, BaseClass[] member) throws java.rmi.RemoteException {

// 得到当前角色下的成员. PropEnum[] props = { PropEnum.defaultName, PropEnum.searchPath, PropEnum.members }; Role role = (Role)csHandler.queryObjectInCS(connection, pathOfRole, props)[0]; //如果没有成员则直接update if (role.getMembers().getValue() == null) { role.setMembers(new BaseClassArrayProp()); role.getMembers().setValue(member); csHandler.updateObjectInCS(connection, new BaseClass[] { role }); } //保留原有的成员 else { // Preserve all the existing members. BaseClass[] newMembers = new BaseClass[role.getMembers().getValue().length + 1]; int index = 0; BaseClass obj = null; for (int i = 0; i < role.getMembers().getValue().length; i++) { obj = role.getMembers().getValue()[i]; csHandler.queryObjectInCS( connection, obj.getSearchPath().getValue()); newMembers[index] = obj; index++; } newMembers[index] = member[0]; role.setMembers(new BaseClassArrayProp()); role.getMembers().setValue(newMembers); // Update the membership. csHandler.updateObjectInCS(connection, new BaseClass[] { role }); } }

/**

* 从组中删除用户. *

* @param connection Cognos 8连接

* @param groupSearchPath 组的搜索路径. * @param userSearchPath 用户的搜索路径. *

* @return 返回成功添加的信息. * */

public String deleteUserFromGroup( CRNConnect connection, String groupSearchPath, String userSearchPath) throws java.rmi.RemoteException { //根据搜索路径找到用户对象再直接删除 removeFromGroup( connection, groupSearchPath, (csHandler.queryObjectInCS( connection, userSearchPath))[0]); }

return ( \ + userSearchPath + \ + groupSearchPath);

/**

* 从角色中删除用户对象. *

* @param connection Cognos 8 连接对象 * @param roleSearchPath 角色的搜索路径.

* @param memberSearchPath 用户对象的搜索路径 *

* @return 返回成功添加的信息. * */

public String deleteUserFromRole( CRNConnect connection, String roleSearchPath,

String memberSearchPath) throws java.rmi.RemoteException { //根据搜索路径找到用户对象并直接删除 removeFromRole( connection, roleSearchPath, (csHandler .queryObjectInCS( connection, memberSearchPath))[0]); return ( \ + memberSearchPath + \ + roleSearchPath); }

/**

* 从指定的组中删除指定的成员. *

* @param connection Cognos 8 连接 * @param pathOfGroup 组的搜多路径. * @param member 组成员. * */

public void removeFromGroup( CRNConnect connection, String pathOfGroup, BaseClass member) throws java.rmi.RemoteException { // 得到当前组中的成员. PropEnum[] props = { PropEnum.defaultName, PropEnum.searchPath, PropEnum.members }; BaseClass[] objects = csHandler.queryObjectInCS(connection, pathOfGroup, props); Group group = (Group)objects[0]; //保留除待删除成员外的所有成员. BaseClass[] newMembers =

联系客服:779662525#qq.com(#替换为@) 苏ICP备20003344号-4