Example usage for java.util HashSet toString

List of usage examples for java.util HashSet toString

Introduction

In this page you can find the example usage for java.util HashSet toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.docrj.smartcard.reader.AppViewActivity.java

private void updateGroups(HashSet<String> appGroups) {
    String grpText = getString(R.string.none);
    if (appGroups.size() == 0) {
        if (!mReadOnly) {
            grpText += " - " + getString(R.string.edit_to_add_groups);
        }//  w w w . ja v a 2  s.c o  m
    } else if (appGroups.size() == 1) {
        grpText = appGroups.toString().replaceAll("[\\[\\]]", "");
        ;
        if (!mReadOnly) {
            grpText += " - " + getString(R.string.edit_to_add_groups);
        }
    } else {
        grpText = appGroups.toString().replaceAll("[\\[\\]]", "");
        grpText = grpText.replace(", ", ",\n");
    }
    mGroups.setText(grpText);
}

From source file:edu.harvard.i2b2.fhir.oauth2.ws.OAuth2AuthzEndpoint.java

@Path("processScope")
@GET/*from www .  j  a va 2s  .c om*/
public Response processResourceOwnerScopeChoice(@Context HttpServletRequest request) {
    try {
        logger.trace("processing scope: sessionid:" + request.getSession().getId());
        // save scope to session and
        // redirect to client uri
        HttpSession session = request.getSession();
        session.setAttribute("permittedScopes", "user/*.*");

        String msg = "";
        Enumeration x = session.getAttributeNames();
        while (x.hasMoreElements()) {
            String p = (String) x.nextElement();
            msg = msg + p + "=" + session.getAttribute(p).toString() + "\n";
        }
        logger.trace("sessionAttributes:" + msg);
        // create AuthToken in Database;

        String pmResponseXml = (String) session.getAttribute("pmResponseXml");
        if (pmResponseXml == null)
            throw new RuntimeException("PMRESPONSE NOT FOUND");

        String resourceUserId = (String) session.getAttribute("i2b2User");
        String i2b2Token = (String) I2b2Util.getToken(pmResponseXml);
        String authorizationCode = (String) session.getAttribute("authorizationCode");
        String clientRedirectUri = (String) session.getAttribute("redirectUri");
        String clientId = (String) session.getAttribute("clientId");
        String i2b2Project = (String) session.getAttribute("i2b2Project");
        String state = (String) session.getAttribute("state");
        String patientId = (String) session.getAttribute("patientId");

        HashSet<String> scopeHashSet = (HashSet<String>) session.getAttribute("scope");
        String scope = "";
        for (String s : scopeHashSet) {
            scope += "," + s;
        }
        scope = scope.substring(1);
        logger.debug(">>scopeHS=" + scopeHashSet.toString());
        //String scope = "user/*.*";//(String) session.getAttribute("scope");//"user/*.*";// 
        AuthToken authToken = authTokenBean.find(authorizationCode);
        if (authToken == null)
            authToken = authTokenBean.createAuthToken(authorizationCode, resourceUserId, i2b2Token,
                    clientRedirectUri, clientId, state, scope, i2b2Project, patientId);

        session.setAttribute("msg", "");

        //String finalUri = successfulResponse((HttpServletRequest) session.getAttribute("request"),scope,patientId,state);
        String finalUri = (String) session.getAttribute("finalUri");
        //+"&patient="+patientId.trim()   +"&scope="+patientId.trim();
        logger.trace("finalUri:" + finalUri);
        return Response.status(Status.MOVED_PERMANENTLY).location(new URI(finalUri))
                .header("session_id", session.getId()).build();
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
        e.printStackTrace();
        return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e.getMessage()).build();
    }
}

From source file:dao.DirectoryUserDaoDb.java

/**
 *  Adds the users in directory for access list
 *  @param memberList memberList//from  w w  w.  j  a  v  a 2  s  .  c o m
 *  @param directoryId  directoryId 
 *  @param userId  the user Login is used to check if this user has the permission to add user
 *  @param userLogin  the user Login is used to check if this user has the permission to add user
 *  @return List - list of users who are not members
 *  @throws BaseDaoException
 */
public String addUsers(List memberList, String directoryId, String userId, String userLogin)
        throws BaseDaoException {

    if ((memberList == null) || RegexStrUtil.isNull(directoryId) || RegexStrUtil.isNull(userId)
            || RegexStrUtil.isNull(userLogin)) {
        throw new BaseDaoException("params are null");
    }

    /* get existing users */
    List userList = listUsers(directoryId, DbConstants.READ_FROM_SLAVE);
    List existingUserList = null;
    if (userList != null) {
        existingUserList = new ArrayList();
        for (int i = 0; i < userList.size(); i++) {
            if ((Directory) userList.get(i) != null) {
                existingUserList.add(((Directory) userList.get(i)).getValue(DbConstants.LOGIN));
            }
        }
    }

    logger.info("memberList = " + memberList.toString());
    logger.info("existingUserList = " + existingUserList.toString());

    /* remove existing users from the memberList */
    List idList = null;
    if ((existingUserList != null) && (existingUserList.size() > 0)) {
        HashSet hs1 = new HashSet(memberList);
        HashSet hs2 = new HashSet(existingUserList);
        if (hs1.removeAll(hs2)) {
            if (hs1 != null) {
                logger.info("hs1 = " + hs1.toString());
            }
            idList = new ArrayList(hs1);
        } else {
            idList = memberList;
        }
    } else {
        idList = memberList;
    }

    /* add only new valid users in the directory */
    StringBuffer notMembers = new StringBuffer();
    try {
        if (idList != null && idList.size() > 0) {
            logger.info("idList = " + idList.toString());
            for (int i = 0; i < idList.size(); i++) {
                if (idList.get(i) != null) {
                    logger.info("idList.get(i)=" + idList.get(i) + " i = " + i);
                    String mLogin = (String) idList.get(i);
                    Hdlogin hdlogin = getLoginid(mLogin);
                    if (hdlogin == null) {
                        notMembers.append(mLogin);
                        notMembers.append(" ");
                    } else {
                        addUser(directoryId, mLogin, userId, userLogin);
                    }
                }
            }
        }
    } catch (BaseDaoException e) {
        throw new BaseDaoException(
                "Exception occured in addUser(), DirectoryAddUser for userLogin " + userLogin, e);
    }

    logger.info("notMembers = " + notMembers);
    if (notMembers != null) {
        return notMembers.toString();
    } else {
        return null;
    }
}

From source file:alma.acs.tmcdb.compare.TestHighLevelNodes.java

public void testMACI_Managers() throws Exception {
    HashSet<String> xmlNodes = new HashSet<String>(
            Arrays.asList(xmlDAL.list_nodes("MACI/Managers").split(" ")));
    HashSet<String> rdbNodes = new HashSet<String>(
            Arrays.asList(rdbDAL.list_nodes("MACI/Managers").split(" ")));
    logger.info("XML: " + xmlNodes.toString() + "; TMCDB: " + rdbNodes.toString());
    assertEquals(xmlNodes, rdbNodes);//from   w w  w  .j  a  v  a  2  s . c o  m
    for (Iterator<String> iterator = xmlNodes.iterator(); iterator.hasNext();) {
        String xmlstring = "MACI/Managers/" + (String) iterator.next();
        DAO xmlDao = xmlDAL.get_DAO_Servant(xmlstring);
        DAO rdbDao = rdbDAL.get_DAO_Servant(xmlstring);
        examineLoggingConfig(xmlDao, rdbDao);
        assertEquals(xmlDao.get_string("Startup"), rdbDao.get_string("Startup"));
        assertEquals(xmlDao.get_string("ServiceComponents"), rdbDao.get_string("ServiceComponents"));
        String sx = null;
        boolean xbool = true;
        try {
            sx = xmlDao.get_string("ServiceDaemons");
        } catch (CDBFieldDoesNotExistEx e) {
            xbool = false;
        }
        String sr = null;
        try {
            sr = rdbDao.get_string("ServiceDaemons");
        } catch (CDBFieldDoesNotExistEx e) {
            if (xbool)
                fail("Service Daemons: XML CDB has value: " + sx + " but TMCDB can't find the field.");
            continue; // Neither CDB can find it; move to next property
        }
        if (!xbool)
            fail("Service Daemons: TMCDB has value: " + sr + " but XML CDB can't find the field.");
        assertEquals(sx, sr); // TODO: Redo this once Matej's implementation is complete
    }
}

From source file:nl.uva.expose.classification.MakeTextFile.java

public String getMemParty(Integer memIndexId) throws IOException {
    String aff = "";
    HashSet<String> affiliations = this.miInfo.getDocAllTerm(memIndexId, "AFF");
    ///*from   www.  java 2s. c o  m*/
    if (affiliations.contains("nl.p.lidbontes"))
        return "nl.p.lidbontes";
    if (affiliations.contains("nl.p.groepkortenoevenhernandez"))
        return "nl.p.groepkortenoevenhernandez";
    if (affiliations.contains("nl.p.lidbrinkman"))
        return "nl.p.lidbrinkman";
    if (affiliations.contains("nl.p.lidverdonk"))
        return "nl.p.lidverdonk";
    //
    for (String s : affiliations) {
        aff = s;
        //            break;
    }
    if (affiliations.size() > 1) {
        System.err.println("More than one affiliation: " + affiliations.toString() + " --> " + aff);
    }
    return aff.trim();
}

From source file:web.DirldapshowadduserController.java

/**
 * This method is called by the spring framework. The configuration
 * for this controller to be invoked is based on the pagetype and
 * is set in the urlMapping property in the spring config file.
 *
 * @param request the <code>HttpServletRequest</code>
 * @param response the <code>HttpServletResponse</code>
 * @throws ServletException/*from   w ww . ja va 2 s .  c o m*/
 * @throws IOException
 * @return ModelAndView this instance is returned to spring
 */
public synchronized ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    // ***************************************************************************
    // This will initialize common data in the abstract class and the return result is of no value.
    // The abstract class initializes protected variables, login, logininfo.
    // Which can be accessed in all controllers if they want to.
    // ***************************************************************************

    try {
        ModelAndView m = super.handleRequest(request, response);
    } catch (Exception e) {
        return handleError("error in handleRequest", e);
    }

    if (!WebUtil.isLicenseProfessional(login)) {
        return handleError("Cannot manage directory feature in deluxe version.");
    }

    outOfSession(request, response);
    String directoryId = request.getParameter(DbConstants.DIRECTORY_ID);
    if (RegexStrUtil.isNull(login) || RegexStrUtil.isNull(directoryId)) {
        return handleUserpageError("Login/directoryId is null in DirldapshowadduserController.");
    }

    if (!RegexStrUtil.isNull(directoryId)) {
        if (directoryId.length() > GlobalConst.directoryidSize) {
            return handleError(
                    "directoryId.length() > WebConstants.directoryIdSize DirldapshowadduserController ");
        }
        directoryId = RegexStrUtil.goodNameStr(directoryId);
    }

    String loginId = null;
    if (loginInfo == null) {
        return handleUserpageError("LoginInfo is null in DirldapshowadduserController.");
    } else {
        loginId = loginInfo.getValue(DbConstants.LOGIN_ID);
    }

    String pageSizeStr = request.getParameter(DbConstants.PAGE_SIZE);
    String pageNumStr = request.getParameter(DbConstants.PAGE_NUM);

    int pageSize = GlobalConst.defaultPageSize;
    int pageNum = GlobalConst.defaultPageNum;

    if (!RegexStrUtil.isNull(pageSizeStr)) {
        pageSize = new Integer(pageSizeStr).intValue();
    } else {
        pageSizeStr = new Integer(pageSize).toString();
    }

    if (!RegexStrUtil.isNull(pageNumStr)) {
        pageNum = new Integer(pageNumStr).intValue();
    } else {
        pageNumStr = new Integer(pageNum).toString();
    }

    String startStr = GlobalConst.startStr;
    String endStr = GlobalConst.endStr;
    String alphabets = request.getParameter(DbConstants.ALPHABET);
    String[] arrStr = null;
    if (!RegexStrUtil.isNull(alphabets)) {
        arrStr = alphabets.split("-");
    } else {
        alphabets = startStr + "-" + endStr;
    }

    char startChar = GlobalConst.startChar;
    char endChar = GlobalConst.endChar;

    if (arrStr != null && arrStr.length > 1) {
        logger.info("arrStr = " + arrStr);
        startChar = ((String) arrStr[0]).charAt(0);
        startStr = arrStr[0];
        endChar = ((String) arrStr[1]).charAt(0);
        endStr = arrStr[1];
    }

    logger.info("startChar = " + startChar + " endChar = " + endChar);

    /**
     *  add users for a directory
     *  list users for a directory
     */
    DirectoryUserDao dirUserDao = (DirectoryUserDao) daoMapper.getDao(DbConstants.DIR_USER);
    DirectoryDao dirDao = (DirectoryDao) daoMapper.getDao(DbConstants.DIRECTORY);
    if ((dirDao == null) || (dirUserDao == null)) {
        return handleError("DirectoryDao/dirUserDao is null in DirldapshowadduserController  " + login);
    }

    DirectoryAuthorDao authorDao = (DirectoryAuthorDao) daoMapper.getDao(DbConstants.DIRECTORY_AUTHOR);
    if (authorDao == null) {
        return handleError("authorDao is null in DirldapshowadduserController  " + login);
    }

    List userDirList = null;
    Directory directory = null;
    List userLoginList = null;
    List authorsLoginList = null;
    try {
        userDirList = dirUserDao.listUsers(directoryId, DbConstants.READ_FROM_SLAVE);
        userLoginList = dirUserDao.getLoginsOfUsers(userDirList);
        directory = dirDao.viewDirectory(directoryId, loginId, login, DbConstants.READ_FROM_SLAVE,
                DbConstants.BLOB_READ_FROM_SLAVE, DbConstants.WEBSITE_READ_FROM_SLAVE);
        HashSet authorSet = authorDao.listAuthorsOfDirectory(directoryId, loginId, login,
                DbConstants.READ_FROM_SLAVE);
        logger.info("authorSet = " + authorSet.toString());
        authorsLoginList = authorDao.getLoginsOfAuthors(authorSet);
    } catch (BaseDaoException e) {
        return handleError(
                "Exception occured in listUsers/getLoginsOfUsers()/viewDirectory()/listAuthorsOfDirectory()/getLoginsOfAuthors() for login "
                        + login + " directoryId =" + directoryId,
                e);
    }

    if (userDirList == null) {
        return handleError("userDirList is null DirldapshowadduserController, for directoryid " + directoryId
                + " for login admin = " + login);
    }

    /**
    * get all ldap users based on certain attributes
         * get all ldap group users based on the user grouptype for 
         * this directory
         * Includes name, email, group 
    */
    List allLdapUsersName, allLdapUsersGroup, allLdapUsersMail, allLdapUsersUid;
    List groupUsersGroup, groupUsersMail, groupUsersUid;

    allLdapUsersName = allLdapUsersGroup = allLdapUsersMail = allLdapUsersUid = null;
    groupUsersGroup = groupUsersMail = groupUsersUid = null;

    List totalLdapUsers = null;
    String maxPageNumStr = null;
    String maxPageSizeStr = null;
    boolean enableUserGroup = false;
    boolean enableShareGroup = false;

    if (WebUtil.isLdapActive()) {
        try {
            enableUserGroup = dirDao.isUserGroupEnabled(login, loginId, directoryId);
            if (!enableUserGroup) {
                enableShareGroup = dirDao.isShareGroupEnabled(login, loginId, directoryId);
            }
            LdapApi ldapConnection = new LdapApi();
            if (ldapConnection == null) {
                return handleError("ldapConnection is null, ShowldapusersfordirController");
            } else {
                /**
                *  Returns a list of userlogins, list of emails(login), 
                   *  Get the group of author, get the list of users who
                *  who belong to this group
                */
                String[] attrs = { LdapConstants.ldapAttrMail, LdapConstants.ldapGroup,
                        LdapConstants.ldapAttrUid };
                List groupUsers = null;
                String group = null;
                int userMailIndex = 0;
                int userGroupIndex = 1;
                int userUidIndex = 2;

                if (enableUserGroup || enableShareGroup) {
                    group = dirDao.getDirectoryGroup(login, loginId, directoryId);
                    logger.info("group = " + group);
                    if (!RegexStrUtil.isNull(group)) {
                        groupUsers = ldapConnection.getLdapUsers(LdapUtil.getUserSearchDn(group), attrs,
                                startChar, endChar, pageSize, pageNum);
                    }
                    if (groupUsers == null) {
                        return handleError(
                                "ldap groupUsers is null, group= " + group + " directoryid = " + directoryId);
                    } else {
                        if (groupUsers.size() >= userMailIndex) {
                            groupUsersMail = (List) groupUsers.get(userMailIndex);
                            if (groupUsersMail != null) {
                                logger.info("groupUsersMail = " + groupUsersMail.toString());
                            }
                        }
                        if (groupUsers.size() >= userGroupIndex) {
                            groupUsersGroup = (List) groupUsers.get(userGroupIndex);
                            if (groupUsersGroup != null) {
                                logger.info("groupUsersGroup = " + groupUsersGroup.toString());
                            }
                        }
                        if (groupUsers.size() >= userUidIndex) {
                            groupUsersUid = (List) groupUsers.get(userUidIndex);
                            if (groupUsersUid != null) {
                                logger.info("groupUsersUid = " + groupUsersUid.toString());
                            }
                        }
                        logger.info("group = " + group);
                        logger.info("groupUsers = " + groupUsers.toString());
                    }
                }

                /*
                * When the scope is !enableUserGroup
                */
                List allLdapUsers = null;

                if (!enableUserGroup) {
                    allLdapUsers = ldapConnection.getLdapUsers(LdapConstants.ldapAdminRoleDn, attrs, startChar,
                            endChar, pageSize, pageNum);
                    totalLdapUsers = ldapConnection.getLdapUsers(LdapConstants.ldapAdminRoleDn, attrs,
                            startChar, endChar);

                    if (allLdapUsers == null) {
                        return handleError("allLdapUsers  is null, directoryid = " + directoryId);
                    } else {
                        logger.info("allLdapUsers = " + allLdapUsers.toString());
                    }

                    if (totalLdapUsers != null) {
                        logger.info("totalLdapUsers.size() " + totalLdapUsers.size());
                        if (totalLdapUsers.size() > userMailIndex) {
                            List totalLdapUsersMail = (List) totalLdapUsers.get(userMailIndex);
                            if (totalLdapUsersMail != null) {
                                int maxPageNum = WebUtil.getMaxPageNumber(totalLdapUsersMail.size(), pageSize);
                                int maxPageSize = WebUtil.getMaxPageSize(totalLdapUsersMail.size(), pageSize);
                                logger.info("maxPageSize = " + maxPageSize);
                                logger.info("maxPageNum = " + maxPageNum);
                                maxPageSizeStr = new Integer(maxPageSize).toString();
                                maxPageNumStr = new Integer(maxPageNum).toString();
                                logger.info("maxPageSizeStr = " + maxPageSizeStr);
                                logger.info("maxPageNumStr = " + maxPageNumStr);
                            }
                        }
                    }
                }

                /** 
                * List the users only when we want 
                * to display enableShareGroup or show the list of users
                */
                if (allLdapUsers != null) {
                    if (allLdapUsers.size() > userMailIndex) {
                        allLdapUsersMail = (List) allLdapUsers.get(userMailIndex);
                    }
                    if (allLdapUsers.size() > userGroupIndex) {
                        allLdapUsersGroup = (List) allLdapUsers.get(userGroupIndex);
                    }
                    if (allLdapUsers.size() > userUidIndex) {
                        allLdapUsersUid = (List) allLdapUsers.get(userUidIndex);
                    }
                }

                if (!enableShareGroup && !enableUserGroup) {

                    logger.info("enableShareGroup = " + !enableShareGroup);
                    logger.info("enableUserGroup = " + !enableUserGroup);

                    if (allLdapUsersMail == null || allLdapUsersUid == null || allLdapUsersGroup == null) {
                        logger.info(
                                "allLdapUserseMail/allLdapUsersUid/allLdapUsersGroup is null, indicates that all users of ldap belong to the group "
                                        + login);
                        return handleError("allLdapUsersMail/allLdapUsersUid/allLdapUsersGroup is null");
                    } else {
                        if (allLdapUsersMail != null) {
                            logger.info("allLdapUsersMail = " + allLdapUsersMail.toString());
                        }
                        if (allLdapUsersGroup != null) {
                            logger.info("allLdapUsersGroup = " + allLdapUsersGroup.toString());
                        }
                        if (allLdapUsersUid != null) {
                            logger.info("allLdapUsersUid = " + allLdapUsersUid.toString());
                        }
                    }
                }
            }
        } catch (Exception e) {
            return handleError("ldap Exception getUsers()", e);
        }
    }

    CobrandDao cobrandDao = (CobrandDao) getDaoMapper().getDao(DbConstants.COBRAND);
    if (cobrandDao == null) {
        return handleUserpageError("CobrandDao is null, DirldapshowadduserController");
    }
    Userpage cobrand = cobrandDao.getUserCobrand(loginInfo.getValue(DbConstants.LOGIN_ID));

    String viewName = DbConstants.SHOW_DB_DIR_ADD_USERS;
    Map myModel = new HashMap();
    myModel.put(DbConstants.LOGIN_INFO, loginInfo);
    myModel.put(DbConstants.LOGIN_LIST, userLoginList);
    String users_view = request.getParameter(DbConstants.USERS_VIEW);
    myModel.put(DbConstants.USERS_VIEW, users_view);
    // just the logins of the authors
    myModel.put(DbConstants.AUTHORS_LIST, authorsLoginList);
    myModel.put(DbConstants.MEMBERS, userDirList);
    myModel.put(DbConstants.PAGE_NUM, pageNumStr);
    myModel.put(DbConstants.DIRECTORY, directory);
    myModel.put(DbConstants.START, startStr);
    myModel.put(DbConstants.END, endStr);
    myModel.put(DbConstants.USER_PAGE, userpage);
    myModel.put(DbConstants.MAX_PAGE_NUM, maxPageNumStr);
    myModel.put(DbConstants.MAX_PAGE_SIZE, maxPageSizeStr);
    myModel.put(DbConstants.PAGE_SIZE, pageSizeStr);
    myModel.put(DbConstants.ALPHABET, alphabets);
    myModel.put(DbConstants.COBRAND, cobrand);
    myModel.put(DbConstants.DIR_EXISTS, rbDirectoryExists);

    if (WebUtil.isLdapActive()) {
        if (enableUserGroup) {
            myModel.put(DbConstants.ALL_LDAP_USERS_MAIL, groupUsersMail);
            myModel.put(DbConstants.ALL_LDAP_USERS_GROUP, groupUsersGroup);
            myModel.put(DbConstants.ALL_LDAP_USERS_UID, groupUsersUid);
        } else {
            myModel.put(DbConstants.ALL_LDAP_USERS_MAIL, allLdapUsersMail);
            myModel.put(DbConstants.ALL_LDAP_USERS_GROUP, allLdapUsersGroup);
            myModel.put(DbConstants.ALL_LDAP_USERS_UID, allLdapUsersUid);
        }
        if (enableUserGroup) {
            myModel.put(DbConstants.ENABLE_USER_GROUP, "1");
        } else {
            myModel.put(DbConstants.ENABLE_USER_GROUP, "0");
        }
        /*
              if (enableShareGroup) {
                 myModel.put(DbConstants.ENABLE_SHARE_GROUP, "1");
              } else {
                 myModel.put(DbConstants.ENABLE_SHARE_GROUP, "0");
              }
        */
        myModel.put(DbConstants.TOTAL_LDAP_USERS, totalLdapUsers);
    }

    if (DiaryAdmin.isDiaryAdmin(login)) {
        myModel.put(DbConstants.BUSINESS_EXISTS, "1");
    } else {
        myModel.put(DbConstants.BUSINESS_EXISTS, isBizExists(login));
    }
    return new ModelAndView(viewName, "model", myModel);
}

From source file:web.DirldaprmuserController.java

/**
 * This method is called by the spring framework. The configuration
 * for this controller to be invoked is based on the pagetype and
 * is set in the urlMapping property in the spring config file.
 *
 * @param request the <code>HttpServletRequest</code>
 * @param response the <code>HttpServletResponse</code>
 * @throws ServletException//from  w  w  w.j  a  v a  2s .com
 * @throws IOException
 * @return ModelAndView this instance is returned to spring
 */
public synchronized ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    try {
        ModelAndView m = super.handleRequest(request, response);
    } catch (Exception e) {
        return handleError("error in handleRequest", e);
    }

    if (!WebUtil.isLicenseProfessional(login)) {
        return handleError("Cannot manage directory feature in deluxe version.");
    }

    outOfSession(request, response);
    if (RegexStrUtil.isNull(login) || RegexStrUtil.isNull(member) || (loginInfo == null)) {
        return handleUserpageError("Login/member/loginInfo is null in DirldaprmuserController.");
    }

    String directoryId = request.getParameter(DbConstants.DIRECTORY_ID);
    if (!RegexStrUtil.isNull(directoryId)) {
        if (directoryId.length() > GlobalConst.directoryidSize) {
            return handleError("directoryId.length() > WebConstants.directoryidSize DirldaprmuserController ");
        }
        directoryId = RegexStrUtil.goodNameStr(directoryId);
    }

    /**
     *  list the directories that this user belongs to
     *  list the directories that this member is blocked from
     */
    DirectoryDao dirDao = (DirectoryDao) daoMapper.getDao(DbConstants.DIRECTORY);

    DirectoryUserDao dirUserDao = (DirectoryUserDao) daoMapper.getDao(DbConstants.DIR_USER);
    if (dirUserDao == null) {
        return handleError("DirectoryUserDao is null in DirldaprmuserController, login= " + login);
    }

    try {
        dirUserDao.removeUser(directoryId, member, loginInfo.getValue(DbConstants.LOGIN_ID), login);
    } catch (BaseDaoException e) {
        return handleError("Exception occured in listUsers() for login " + login, e);
    }

    String loginId = null;
    if (loginInfo == null) {
        return handleUserpageError("LoginInfo is null in DirldaprmuserController.");
    } else {
        loginId = loginInfo.getValue(DbConstants.LOGIN_ID);
    }

    String pageSizeStr = request.getParameter(DbConstants.PAGE_SIZE);
    String pageNumStr = request.getParameter(DbConstants.PAGE_NUM);

    int pageSize = GlobalConst.defaultPageSize;
    int pageNum = GlobalConst.defaultPageNum;

    if (!RegexStrUtil.isNull(pageSizeStr)) {
        pageSize = new Integer(pageSizeStr).intValue();
    } else {
        pageSizeStr = new Integer(pageSize).toString();
    }

    if (!RegexStrUtil.isNull(pageNumStr)) {
        pageNum = new Integer(pageNumStr).intValue();
    } else {
        pageNumStr = new Integer(pageNum).toString();
    }

    String startStr = GlobalConst.startStr;
    String endStr = GlobalConst.endStr;
    String alphabets = request.getParameter(DbConstants.ALPHABET);
    String[] arrStr = null;
    if (!RegexStrUtil.isNull(alphabets)) {
        arrStr = alphabets.split("-");
    } else {
        alphabets = startStr + "-" + endStr;
    }

    char startChar = GlobalConst.startChar;
    char endChar = GlobalConst.endChar;

    if (arrStr != null && arrStr.length > 1) {
        logger.info("arrStr = " + arrStr);
        startChar = ((String) arrStr[0]).charAt(0);
        startStr = arrStr[0];
        endChar = ((String) arrStr[1]).charAt(0);
        endStr = arrStr[1];
    }

    logger.info("startChar = " + startChar + " endChar = " + endChar);

    /**
     *  add users for a directory
     *  list users for a directory
     */
    DirectoryAuthorDao authorDao = (DirectoryAuthorDao) daoMapper.getDao(DbConstants.DIRECTORY_AUTHOR);
    if (authorDao == null) {
        return handleError("authorDao is null in DirldaprmuserController  " + login);
    }

    List userDirList = null;
    List userLoginList = null;
    List authorsLoginList = null;
    Directory directory = null;

    try {
        userDirList = dirUserDao.listUsers(directoryId, DbConstants.READ_FROM_SLAVE);
        userLoginList = dirUserDao.getLoginsOfUsers(userDirList);
        directory = dirDao.viewDirectory(directoryId, loginId, login, DbConstants.READ_FROM_SLAVE,
                DbConstants.BLOB_READ_FROM_SLAVE, DbConstants.WEBSITE_READ_FROM_SLAVE);
        HashSet authorSet = authorDao.listAuthorsOfDirectory(directoryId, loginId, login,
                DbConstants.READ_FROM_SLAVE);
        logger.info("authorSet = " + authorSet.toString());
        authorsLoginList = authorDao.getLoginsOfAuthors(authorSet);
    } catch (BaseDaoException e) {
        return handleError(
                "Exception occured in listUsers/getLoginsOfUsers()/viewDirectory()/listAuthorsOfDirectory()/getLoginsOfAuthors() for login "
                        + login + " directoryId =" + directoryId,
                e);
    }

    if (userDirList == null) {
        return handleError("userDirList is null DirldaprmuserController, for directoryId " + directoryId
                + " for login admin = " + login);
    }

    /**
    * get all ldap users based on certain attributes
         * get all ldap group users based on the user grouptype for 
         * this directory
         * Includes name, email, group 
    */
    List allLdapUsersName, allLdapUsersGroup, allLdapUsersMail, allLdapUsersUid;
    List groupUsersGroup, groupUsersMail, groupUsersUid;

    allLdapUsersName = allLdapUsersGroup = allLdapUsersMail = allLdapUsersUid = null;
    groupUsersGroup = groupUsersMail = groupUsersUid = null;

    List totalLdapUsers = null;
    String maxPageNumStr = null;
    String maxPageSizeStr = null;
    boolean enableUserGroup = false;
    boolean enableShareGroup = false;

    if (WebUtil.isLdapActive()) {
        try {
            enableUserGroup = dirDao.isUserGroupEnabled(login, loginId, directoryId);
            if (!enableUserGroup) {
                enableShareGroup = dirDao.isShareGroupEnabled(login, loginId, directoryId);
            }
            LdapApi ldapConnection = new LdapApi();
            if (ldapConnection == null) {
                return handleError("ldapConnection is null, ShowldapusersfordirController");
            } else {
                /**
                *  Returns a list of userlogins, list of emails(login), 
                   *  Get the group of author, get the list of users who
                *  who belong to this group
                */
                String[] attrs = { LdapConstants.ldapAttrMail, LdapConstants.ldapGroup,
                        LdapConstants.ldapAttrUid };
                List groupUsers = null;
                String group = null;
                int userMailIndex = 0;
                int userGroupIndex = 1;
                int userUidIndex = 2;

                if (enableUserGroup || enableShareGroup) {
                    group = dirDao.getDirectoryGroup(login, loginId, directoryId);
                    logger.info("group = " + group);
                    if (!RegexStrUtil.isNull(group)) {
                        groupUsers = ldapConnection.getLdapUsers(LdapUtil.getUserSearchDn(group), attrs,
                                startChar, endChar, pageSize, pageNum);
                    }
                    if (groupUsers == null) {
                        return handleError(
                                "ldap groupUsers is null, group= " + group + " directoryId = " + directoryId);
                    } else {
                        if (groupUsers.size() >= userMailIndex) {
                            groupUsersMail = (List) groupUsers.get(userMailIndex);
                            if (groupUsersMail != null) {
                                logger.info("groupUsersMail = " + groupUsersMail.toString());
                            }
                        }
                        if (groupUsers.size() >= userGroupIndex) {
                            groupUsersGroup = (List) groupUsers.get(userGroupIndex);
                            if (groupUsersGroup != null) {
                                logger.info("groupUsersGroup = " + groupUsersGroup.toString());
                            }
                        }
                        if (groupUsers.size() >= userUidIndex) {
                            groupUsersUid = (List) groupUsers.get(userUidIndex);
                            if (groupUsersUid != null) {
                                logger.info("groupUsersUid = " + groupUsersUid.toString());
                            }
                        }
                        logger.info("group = " + group);
                        logger.info("groupUsers = " + groupUsers.toString());
                    }
                }

                /*
                * When the scope is !enableUserGroup
                */
                List allLdapUsers = null;

                if (!enableUserGroup) {
                    allLdapUsers = ldapConnection.getLdapUsers(LdapConstants.ldapAdminRoleDn, attrs, startChar,
                            endChar, pageSize, pageNum);
                    totalLdapUsers = ldapConnection.getLdapUsers(LdapConstants.ldapAdminRoleDn, attrs,
                            startChar, endChar);

                    if (allLdapUsers == null) {
                        return handleError("allLdapUsers  is null, directoryId = " + directoryId);
                    } else {
                        logger.info("allLdapUsers = " + allLdapUsers.toString());
                    }

                    if (totalLdapUsers != null) {
                        logger.info("totalLdapUsers.size() " + totalLdapUsers.size());
                        if (totalLdapUsers.size() > userMailIndex) {
                            List totalLdapUsersMail = (List) totalLdapUsers.get(userMailIndex);
                            if (totalLdapUsersMail != null) {
                                int maxPageNum = WebUtil.getMaxPageNumber(totalLdapUsersMail.size(), pageSize);
                                int maxPageSize = WebUtil.getMaxPageSize(totalLdapUsersMail.size(), pageSize);
                                logger.info("maxPageSize = " + maxPageSize);
                                logger.info("maxPageNum = " + maxPageNum);

                                maxPageSizeStr = new Integer(maxPageSize).toString();
                                maxPageNumStr = new Integer(maxPageNum).toString();

                                logger.info("maxPageSizeStr = " + maxPageSizeStr);
                                logger.info("maxPageNumStr = " + maxPageNumStr);
                            }
                        }
                    }
                }

                /** 
                * List the users only when we want 
                * to display enableShareGroup or show the list of users
                */
                if (allLdapUsers != null) {
                    if (allLdapUsers.size() > userMailIndex) {
                        allLdapUsersMail = (List) allLdapUsers.get(userMailIndex);
                    }
                    if (allLdapUsers.size() > userGroupIndex) {
                        allLdapUsersGroup = (List) allLdapUsers.get(userGroupIndex);
                    }
                    if (allLdapUsers.size() > userUidIndex) {
                        allLdapUsersUid = (List) allLdapUsers.get(userUidIndex);
                    }
                }

                if (!enableShareGroup && !enableUserGroup) {

                    logger.info("enableShareGroup = " + !enableShareGroup);
                    logger.info("enableUserGroup = " + !enableUserGroup);

                    if (allLdapUsersMail == null || allLdapUsersGroup == null) {
                        logger.info(
                                "allLdapUserseMail is null, indicates that all users of ldap belong to the group "
                                        + login);
                        return handleError("allLdapUsersMail/allLdapUsersGroup is null");
                    } else {
                        if (allLdapUsersMail != null) {
                            logger.info("allLdapUsersMail = " + allLdapUsersMail.toString());
                        }
                        if (allLdapUsersGroup != null) {
                            logger.info("allLdapUsersGroup = " + allLdapUsersGroup.toString());
                        }
                    }
                }
            } // ldapConnection != null
        } catch (Exception e) {
            return handleError("ldap Exception getUsers()", e);
        }
    }

    CobrandDao cobrandDao = (CobrandDao) getDaoMapper().getDao(DbConstants.COBRAND);
    if (cobrandDao == null) {
        return handleUserpageError("CobrandDao is null, DirldaprmuserController");
    }
    Userpage cobrand = cobrandDao.getUserCobrand(loginInfo.getValue(DbConstants.LOGIN_ID));

    String viewName = DbConstants.SHOW_DB_DIR_ADD_USERS;
    Map myModel = new HashMap();
    myModel.put(DbConstants.LOGIN_INFO, loginInfo);
    myModel.put(DbConstants.LOGIN_LIST, userLoginList);
    String users_view = request.getParameter(DbConstants.USERS_VIEW);
    myModel.put(DbConstants.USERS_VIEW, users_view);
    // just the logins of the authors
    myModel.put(DbConstants.AUTHORS_LIST, authorsLoginList);
    myModel.put(DbConstants.MEMBERS, userDirList);
    myModel.put(DbConstants.PAGE_NUM, pageNumStr);
    myModel.put(DbConstants.DIRECTORY, directory);
    myModel.put(DbConstants.START, startStr);
    myModel.put(DbConstants.END, endStr);
    myModel.put(DbConstants.USER_PAGE, userpage);
    myModel.put(DbConstants.MAX_PAGE_NUM, maxPageNumStr);
    myModel.put(DbConstants.MAX_PAGE_SIZE, maxPageSizeStr);
    myModel.put(DbConstants.PAGE_SIZE, pageSizeStr);
    myModel.put(DbConstants.ALPHABET, alphabets);
    myModel.put(DbConstants.COBRAND, cobrand);
    myModel.put(DbConstants.DIR_EXISTS, rbDirectoryExists);

    if (WebUtil.isLdapActive()) {
        if (enableUserGroup) {
            myModel.put(DbConstants.ALL_LDAP_USERS_MAIL, groupUsersMail);
            myModel.put(DbConstants.ALL_LDAP_USERS_GROUP, groupUsersGroup);
            myModel.put(DbConstants.ALL_LDAP_USERS_UID, groupUsersUid);
        } else {
            myModel.put(DbConstants.ALL_LDAP_USERS_MAIL, allLdapUsersMail);
            myModel.put(DbConstants.ALL_LDAP_USERS_GROUP, allLdapUsersGroup);
            myModel.put(DbConstants.ALL_LDAP_USERS_UID, allLdapUsersUid);
        }
        if (enableUserGroup) {
            myModel.put(DbConstants.ENABLE_USER_GROUP, "1");
        } else {
            myModel.put(DbConstants.ENABLE_USER_GROUP, "0");
        }
        /*
              if (enableShareGroup) {
                 myModel.put(DbConstants.ENABLE_SHARE_GROUP, "1");
              } else {
                 myModel.put(DbConstants.ENABLE_SHARE_GROUP, "0");
              }
        */
        myModel.put(DbConstants.TOTAL_LDAP_USERS, totalLdapUsers);
    }

    if (DiaryAdmin.isDiaryAdmin(login)) {
        myModel.put(DbConstants.BUSINESS_EXISTS, "1");
    } else {
        myModel.put(DbConstants.BUSINESS_EXISTS, isBizExists(login));
    }
    return new ModelAndView(viewName, "model", myModel);
}

From source file:org.archive.crawler.selftest.SelfTestBase.java

protected Set<String> filesInArcs() throws IOException {
    List<ArchiveRecordHeader> headers = headersInArcs();
    HashSet<String> result = new HashSet<String>();
    for (ArchiveRecordHeader arh : headers) {
        // ignore 'filedesc:' record
        if (arh.getUrl().startsWith("filedesc:")) {
            continue;
        }/*from   w  w  w. j  a v a 2  s. c  o m*/
        UURI uuri = UURIFactory.getInstance(arh.getUrl());
        String path = uuri.getPath();
        if (path.startsWith("/")) {
            path = path.substring(1);
        }
        if (arh.getUrl().startsWith("http:")) {
            result.add(path);
        }
    }
    LOGGER.finest(result.toString());
    return result;
}

From source file:pltag.parser.Lexicon.java

public void getFamily(String string) {
    HashMap<String, Integer> similars = new HashMap<String, Integer>();
    int most = 0;
    HashSet<String> mostSimilar = new HashSet<String>();
    for (String tree : (Collection<String>) lexEntriesTree.getCollection(string)) {
        if (!this.noOfTrees.containsKey(tree) || noOfTrees.get(tree) < 5) {
            continue;
        }// w w w. ja  v a 2  s  .  co  m
        String t = tree.substring(tree.indexOf("\t") + 1);
        for (String assoc : trees.getCollection(t)) {
            if (assoc.contains(" unk") || assoc.contains(string)) {
                continue;
            }
            if (similars.containsKey(assoc)) {
                int newNum = similars.get(assoc) + 1;
                similars.put(assoc, newNum);
                if (newNum > most) {
                    most = newNum;
                    mostSimilar.clear();
                    mostSimilar.add(assoc);
                }
                if (newNum == most) {
                    mostSimilar.add(assoc);
                }
            } else {
                similars.put(assoc, 1);
            }
        }
    }
    HashSet<String> simtrees = new HashSet<String>();
    for (String mostSimWords : mostSimilar) {
        simtrees.addAll((Collection<String>) lexEntriesTree.getCollection(mostSimWords));

    }
    System.out.println(mostSimilar + "\t");
    System.out.print(simtrees.toString() + "\n");
}

From source file:web.ShowldapauthorsfordirController.java

/**
 * This method is called by the spring framework. The configuration
 * for this controller to be invoked is based on the pagetype and
 * is set in the urlMapping property in the spring config file.
 *
 * @param request the <code>HttpServletRequest</code>
 * @param response the <code>HttpServletResponse</code>
 * @throws ServletException//from   w  w w  . j a va 2  s .  co  m
 * @throws IOException
 * @return ModelAndView this instance is returned to spring
 */
public synchronized ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    // ***************************************************************************
    // This is the only line of code you need to get all session info initialized!
    // Always be the first line before anything else is done. Add to each controller's
    // handlRequest method. Also remember to extend SessionObject.
    // ***************************************************************************

    try {
        ModelAndView m = super.handleRequest(request, response);
    } catch (Exception e) {
        return handleError("error in handleRequest");
    }

    logger.info("ShowldapauthorsfordirController entered");

    if (RegexStrUtil.isNull(login)) {
        return handleUserpageError("Login is null, ShowldapauthorsfordirController");
    }

    String pageNumStr = request.getParameter(DbConstants.PAGE_NUM);
    String pageSizeStr = request.getParameter(DbConstants.PAGE_SIZE);

    int pageSize = GlobalConst.defaultPageSize;
    int pageNum = GlobalConst.defaultPageNum;

    if (!RegexStrUtil.isNull(pageSizeStr)) {
        pageSize = new Integer(pageSizeStr).intValue();
    } else {
        pageSizeStr = new Integer(pageSize).toString();
    }

    logger.info("pageSizeStr = " + pageSizeStr);

    if (!RegexStrUtil.isNull(pageNumStr)) {
        pageNum = new Integer(pageNumStr).intValue();
    } else {
        pageNumStr = new Integer(pageNum).toString();
    }

    logger.info("pageNumStr = " + pageNumStr);

    String startStr = GlobalConst.startStr;
    String endStr = GlobalConst.endStr;
    String alphabets = request.getParameter(DbConstants.ALPHABET);
    String[] arrStr = null;
    if (!RegexStrUtil.isNull(alphabets)) {
        arrStr = alphabets.split("-");
    } else {
        alphabets = startStr + "-" + endStr;
    }

    char startChar = GlobalConst.startChar;
    char endChar = GlobalConst.endChar;

    if (arrStr != null && arrStr.length > 1) {
        logger.info("arrStr = " + arrStr);
        startChar = ((String) arrStr[0]).charAt(0);
        startStr = arrStr[0];
        endChar = ((String) arrStr[1]).charAt(0);
        endStr = arrStr[1];
    }

    logger.info("startChar = " + startChar + " endChar = " + endChar);
    String directoryId = request.getParameter(DbConstants.DIRECTORY_ID);
    if (RegexStrUtil.isNull(directoryId)) {
        return handleError("directoryId is null, ShowldapauthorsfordirController");
    }

    if (getDaoMapper() == null) {
        return handleError("DaoMapper is null, in ShowldapauthorsfordirController." + login);
    }

    DirectoryAuthorDao authorDao = (DirectoryAuthorDao) getDaoMapper().getDao(DbConstants.DIRECTORY_AUTHOR);
    if (authorDao == null) {
        return handleError("DirectoryAuthorDao is null, in ShowldapauthorsfordirController." + login);
    }

    DirectoryDao dirDao = (DirectoryDao) getDaoMapper().getDao(DbConstants.DIRECTORY);
    if (dirDao == null) {
        return handleError("dirDao is null, in ShowldapauthorsfordirController." + login);
    }

    List users = null;
    HashSet authorSet = null;
    Directory directory = null;
    String loginId = null;
    List authorLoginList = null;
    try {
        if (loginInfo != null) {
            loginId = loginInfo.getValue(DbConstants.LOGIN_ID);
            directory = dirDao.viewDirectory(directoryId, loginId, login, DbConstants.READ_FROM_SLAVE,
                    DbConstants.BLOB_READ_FROM_SLAVE, DbConstants.WEBSITE_READ_FROM_SLAVE);
            authorSet = authorDao.listAuthorsOfDirectory(directoryId, loginId, login,
                    DbConstants.READ_FROM_SLAVE);
            logger.info("authorSet = " + authorSet.toString());
            authorLoginList = authorDao.getLoginsOfAuthors(authorSet);
        }
    } catch (BaseDaoException e) {
        return handleError(
                "Exception occurred in viewDirectory()/listAuthorsOfDirectory(), ShowldapauthorsfordirController, for login "
                        + login,
                e);
    }

    /** 
     * cobrand
     */
    Userpage cobrand = null;
    CobrandDao cobrandDao = (CobrandDao) getDaoMapper().getDao(DbConstants.COBRAND);
    if (cobrandDao == null) {
        return handleError("CobrandDao is null, ShowldapauthorsfordirController");
    }
    try {
        cobrand = cobrandDao.getUserCobrand(loginId);
    } catch (BaseDaoException e) {
        return handleError("cobrand is null, ShowldapauthorsfordirController.", e);
    }

    /**
    * get all ldap users based on certain attributes
         * get all ldap group users based on the user grouptype for 
         * this directory
         * Includes name, email, group 
    */
    List allLdapUsersName, allLdapUsersGroup, allLdapUsersMail, allLdapUsersUid;
    List groupUsersGroup, groupUsersMail, groupUsersUid;

    allLdapUsersName = allLdapUsersGroup = allLdapUsersMail = null;
    groupUsersGroup = groupUsersMail = null;
    groupUsersUid = allLdapUsersUid = null;

    List totalLdapUsers = null;
    String maxPageNumStr = null;
    String maxPageSizeStr = null;
    String ldapGroup = null;
    boolean enableUserGroup = false;
    boolean enableShareGroup = false;

    if (WebUtil.isLdapActive()) {
        int userMailIndex = 0;
        int userGroupIndex = 1;
        int userUidIndex = 2;
        try {
            enableUserGroup = dirDao.isUserGroupEnabled(login, loginId, directoryId);
            if (!enableUserGroup) {
                enableShareGroup = dirDao.isShareGroupEnabled(login, loginId, directoryId);
            }
            LdapApi ldapConnection = new LdapApi();
            if (ldapConnection == null) {
                return handleError("ldapConnection is null, ShowldapauthorsfordirController");
            } else {
                /**
                *  Returns a list of userlogins, list of emails(login), 
                   *  Get the group of author, get the list of users who
                *  who belong to this group
                */
                String[] attrs = { LdapConstants.ldapAttrMail, LdapConstants.ldapGroup,
                        LdapConstants.ldapAttrUid };
                List groupUsers = null;
                String groupArea = null;

                logger.info("enableUserGroup = " + enableUserGroup);
                logger.info("enableShareGroup = " + enableShareGroup);

                if (enableUserGroup || enableShareGroup) {
                    groupArea = dirDao.getDirectoryGroupAndAreaInfo(login, loginId, directoryId);
                    logger.info("groupArea = " + groupArea);
                    ldapGroup = dirDao.getDirectoryGroup(login);
                    if (!RegexStrUtil.isNull(groupArea)) {
                        String searchDn = LdapUtil.getUserSearchDn(groupArea);
                        logger.info("searchDn = " + searchDn);
                        groupUsers = ldapConnection.getLdapUsers(searchDn, attrs, startChar, endChar, pageSize,
                                pageNum);
                        if (groupUsers == null) {
                            return handleError("ldap groupUsers is null, groupArea= " + groupArea
                                    + " directoryid = " + directoryId);
                        } else {
                            logger.info("groupUsers = " + groupUsers.toString());
                            if (groupUsers.size() >= userMailIndex) {
                                groupUsersMail = (List) groupUsers.get(userMailIndex);
                                if (groupUsersMail != null) {
                                    logger.info("groupUsersMail = " + groupUsersMail.toString());
                                }
                            }
                            if (groupUsers.size() >= userGroupIndex) {
                                groupUsersGroup = (List) groupUsers.get(userGroupIndex);
                                if (groupUsersGroup != null) {
                                    logger.info("groupUsersGroup = " + groupUsersGroup.toString());
                                }
                            }
                            if (groupUsers.size() >= userUidIndex) {
                                groupUsersUid = (List) groupUsers.get(userUidIndex);
                                if (groupUsersUid != null) {
                                    logger.info("groupUsersUid = " + groupUsersUid.toString());
                                }
                            }
                        }
                    }
                }

                /*
                * When the scope is !enableUserGroup
                */
                List allLdapUsers = null;
                if (!enableUserGroup) {
                    logger.info("!enableUserGroup ");
                    allLdapUsers = ldapConnection.getLdapUsers(LdapConstants.ldapAdminRoleDn, attrs, startChar,
                            endChar, pageSize, pageNum);
                    totalLdapUsers = ldapConnection.getLdapUsers(LdapConstants.ldapAdminRoleDn, attrs,
                            startChar, endChar);
                    if (allLdapUsers == null) {
                        return handleError("allLdapUsers  is null, directoryid = " + directoryId);
                    } else {
                        logger.info("allLdapUsers = " + allLdapUsers.toString());
                    }

                    List totalLdapUsersMail = null;
                    List totalLdapUsersGroup = null;
                    List totalLdapUsersUid = null;

                    if (totalLdapUsers != null) {
                        if (totalLdapUsers.size() > userMailIndex) {
                            totalLdapUsersMail = (List) totalLdapUsers.get(userMailIndex);
                        }
                        if (totalLdapUsers.size() > userGroupIndex) {
                            totalLdapUsersGroup = (List) totalLdapUsers.get(userGroupIndex);
                        }
                        if (totalLdapUsers.size() > userUidIndex) {
                            totalLdapUsersUid = (List) totalLdapUsers.get(userUidIndex);
                        }
                        logger.info("totalLdapUsers.size() " + totalLdapUsers.size());
                        logger.info("totalLdapUsers= " + totalLdapUsers.toString());

                        if (totalLdapUsersMail != null) {
                            int maxPageNum = WebUtil.getMaxPageNumber(totalLdapUsersMail.size(), pageSize);
                            int maxPageSize = WebUtil.getMaxPageSize(totalLdapUsersMail.size(), pageSize);
                            logger.info("maxPageSize = " + maxPageSize);
                            logger.info("maxPageNum = " + maxPageNum);
                            maxPageSizeStr = new Integer(maxPageSize).toString();
                            maxPageNumStr = new Integer(maxPageNum).toString();
                            logger.info("maxPageSizeStr = " + maxPageSizeStr);
                            logger.info("maxPageNumStr = " + maxPageNumStr);
                        }
                    }
                }

                /** 
                * List the users only when we want 
                * to display enableShareGroup or show the list of users
                */
                /* 
                         if (enableShareGroup && groupUsers != null) {
                            allLdapUsersMail = LdapUtil.removeElements((List)allLdapUsers.get(userMailIndex), (List)groupUsers.get(userMailIndex));
                            allLdapUsersGroup = LdapUtil.removeElements((List)allLdapUsers.get(userGroupIndex), (List)groupUsers.get(userGroupIndex));
                         } else { 
                         }
                */

                if (allLdapUsers != null) {
                    if (allLdapUsers.size() > userMailIndex) {
                        allLdapUsersMail = (List) allLdapUsers.get(userMailIndex);
                    }
                    if (allLdapUsers.size() > userGroupIndex) {
                        allLdapUsersGroup = (List) allLdapUsers.get(userGroupIndex);
                    }
                    if (allLdapUsers.size() > userUidIndex) {
                        allLdapUsersUid = (List) allLdapUsers.get(userUidIndex);
                    }
                }

                if (!enableShareGroup && !enableUserGroup) {
                    logger.info("enableShareGroup = " + !enableShareGroup);
                    logger.info("enableUserGroup = " + !enableUserGroup);

                    if (allLdapUsersMail == null || allLdapUsersUid == null || allLdapUsersGroup == null) {
                        logger.info(
                                "allLdapUserseMail/allLdapUsersUid/allldapUsersGroup is null, indicates that all users of ldap belong to the group "
                                        + login);
                        return handleError("allLdapUsersMail/allLdapUsersUid/allLdapUsersGroup is null");
                    } else {
                        if (allLdapUsersMail != null) {
                            logger.info("allLdapUsersMail = " + allLdapUsersMail.toString());
                        }
                        if (allLdapUsersGroup != null) {
                            logger.info("allLdapUsersGroup = " + allLdapUsersGroup.toString());
                        }
                        if (allLdapUsersUid != null) {
                            logger.info("allLdapUsersUid = " + allLdapUsersUid.toString());
                        }
                    }
                }
            }
        } catch (Exception e) {
            return handleError("ldap Exception getUsers()" + e.getMessage(), e);
        }
    }

    String viewName = DbConstants.SHOW_DB_AUTHORS;
    Map myModel = new HashMap();
    myModel.put(DbConstants.LOGIN_INFO, loginInfo);
    myModel.put(DbConstants.PAGE_NUM, pageNumStr);
    myModel.put(DbConstants.DIRECTORY, directory);
    myModel.put(DbConstants.MEMBERS, authorSet);
    myModel.put(DbConstants.COBRAND, cobrand);
    myModel.put(DbConstants.DIR_EXISTS, rbDirectoryExists);
    myModel.put(DbConstants.START, startStr);
    myModel.put(DbConstants.END, endStr);
    myModel.put(DbConstants.USER_PAGE, userpage);
    myModel.put(DbConstants.BUSINESS_EXISTS, isBizExists(login));
    myModel.put(DbConstants.MAX_PAGE_NUM, maxPageNumStr);
    myModel.put(DbConstants.MAX_PAGE_SIZE, maxPageSizeStr);
    myModel.put(DbConstants.PAGE_SIZE, pageSizeStr);
    myModel.put(DbConstants.ALPHABET, alphabets);
    //  myModel.put(DbConstants.USERS, users);
    //  myModel.put(DbConstants.USERS_ALPHABET, alphabetUsers);

    if (WebUtil.isLdapActive()) {
        if (enableUserGroup) {
            myModel.put(DbConstants.LDAP_GROUP, ldapGroup);
            myModel.put(DbConstants.ALL_LDAP_USERS_MAIL, groupUsersMail);
            myModel.put(DbConstants.ALL_LDAP_USERS_GROUP, groupUsersGroup);
            myModel.put(DbConstants.ALL_LDAP_USERS_UID, groupUsersUid);
        } else {
            myModel.put(DbConstants.ALL_LDAP_USERS_MAIL, allLdapUsersMail);
            myModel.put(DbConstants.ALL_LDAP_USERS_GROUP, allLdapUsersGroup);
            myModel.put(DbConstants.ALL_LDAP_USERS_UID, allLdapUsersUid);
        }
        if (enableUserGroup) {
            myModel.put(DbConstants.ENABLE_USER_GROUP, "1");
        } else {
            myModel.put(DbConstants.ENABLE_USER_GROUP, "0");
        }
        /*
              if (enableShareGroup) {
                 myModel.put(DbConstants.ENABLE_SHARE_GROUP, "1");
              } else {
                 myModel.put(DbConstants.ENABLE_SHARE_GROUP, "0");
              }
        */
        myModel.put(DbConstants.TOTAL_LDAP_USERS, totalLdapUsers);
    }
    myModel.put(DbConstants.LOGIN_LIST, authorLoginList);
    return new ModelAndView(viewName, "model", myModel);
}