<%@ page contentType="text/html;charset=UTF-8" pageEncoding="ISO-8859-1" session="true" %>
<%@ page errorPage="AdminException.jsp"
%><%@ page import="com.fujitsu.iflow.model.workflow.WFAdminSession"
%><%@ page import="com.fujitsu.iflow.model.wfcore.WFAdminSessionImpl"
%><%@ page import="com.fujitsu.iflow.model.workflow.Plan"
%><%@ page import="com.fujitsu.iflow.model.workflow.WFObjectList"
%><%@ page import="com.fujitsu.iflow.model.workflow.WFObjectFactory"
%><%@ page import="com.fujitsu.iflow.server.dataobjects.ProcessDefinitionStatesEnum"
%><%@ page import="com.fujitsu.iflow.server.dataobjects.FilterEnum"
%><%@ page import="com.fujitsu.iflow.model.workflow.Filter"
%><%@ page import="com.fujitsu.iflow.model.util.QuickForm"
%><%@ page import="java.util.Date"
%><%@ page import="com.fujitsu.iflow.model.workflow.DirectoryServices"
%><%@ page import="java.util.Enumeration"
%><%@ page import="java.text.SimpleDateFormat"
%><%@ page import="com.fujitsu.iflow.model.util.URLEncoder"
%><%@page import="com.fujitsu.iflow.model.bpm.BPMAdmin"
%><%@page import="com.fujitsu.iflow.model.bpm.BPMSession"
%><%@page import="com.fujitsu.iflow.model.bpmcore.BPMAdminImpl"
%><%
    request.setCharacterEncoding("UTF-8");request.getParameterNames(); //Need dummy call for WL9.1
    BPMSession bps = (BPMSession) session.getAttribute("BPMSession");
    if (bps == null) {
        %><jsp:include page="PasswordPanel.jsp" flush="true"/><%
        return;
    }

    BPMAdmin bpas = bps.getAdmin();
    WFAdminSessionImpl wfSession = ((BPMAdminImpl)bpas)._wfas;

    String[] bcolor = {"evenrow","oddrow"};
    int nextColor = 0;
    String rowColor = bcolor[nextColor];
    session.setAttribute("TabIndex","3");

    long id = -1;

    String[] roles = (String[]) session.getAttribute("roles");
    String roleName = (String) request.getParameter("roleName");
    String password = (String) session.getAttribute("password");
    String[] members = getMembers(wfSession, roleName, password);
    session.setAttribute("members",members);

    String memberMgmtURL ="";

%>
<html>
<head>
<title>Interstage Business Process Manager | User Management</title>
<jsp:include page="StyleSheet.jsp" flush="true"/>
<script language="javascript" src="styles/clockscripts.js"></script>
<script>
function setSelection(wiForm, selPage)
{
    wiForm.wPageId.value = selPage
    wiForm.submit()
}

function setUserProfile(id, memberForm)
{
    memberForm.member.value= id
    memberForm.submit()
}



</script>
</head>

<body class="adminBodyClass">
<center>

<jsp:include page="AdminHeader.jsp" flush="true"/>
<form name="memberForm" method="get" action="UserWorkitemList.jsp">
  <input type="hidden" name="member" value="-1">
<br><br>
<table bgcolor="#CCCCCC" width="25%" border="0" cellpadding="4" cellspacing="1" align="center" class="tableclass">
<tr align="center" class="headrow">
    <td bgcolor="#EEEEEE" style="filter:progid:DXImageTransform.Microsoft.Gradient(startColorStr='#FFFFFF', endColorStr='#6699CC', gradientType='1')"><font color="#000000" size="2">List of members for <%= roleName %></font></td>
</tr>

    <%
    for(int j=0; j < members.length; j++)
    {
        rowColor = bcolor[nextColor];
        nextColor = (nextColor +1)%2;
        memberMgmtURL = "UserWorkitemList.jsp?memberNum="+j;
    %>
    <tr class="<%= rowColor %>">
      <td>
        <a href="<%= memberMgmtURL %>"><%= members[j] %></a>
      </td>
    </tr>
    <%
    }
    %>


</table>

</form>
</center>
</BODY>
</html>

<%!

    public
    String[]
    getMembers(WFAdminSession wfSession, String role, String password)
        throws Exception
    {
    String[] members = null;
        try {
            DirectoryServices ds = WFObjectFactory.getDirectoryServices(wfSession,wfSession.getUserName(),password);
        members = ds.getUserList(role);
        }
        finally {
        }

        return members;
    }

    public WFAdminSessionImpl getiFlowSession(Object modelObject)
    {
            return (WFAdminSessionImpl)(modelObject);
    }
%>
