Example usage for javax.naming NamingException getMessage

List of usage examples for javax.naming NamingException getMessage

Introduction

In this page you can find the example usage for javax.naming NamingException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:net.testdriven.psiprobe.controllers.sql.ExecuteSqlController.java

protected ModelAndView handleContext(String contextName, Context context, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    String resourceName = ServletRequestUtils.getStringParameter(request, "resource");
    String sql = ServletRequestUtils.getStringParameter(request, "sql", null);

    if (sql == null || sql.equals("") || sql.trim().equals("")) {
        request.setAttribute("errorMessage",
                getMessageSourceAccessor().getMessage("probe.src.dataSourceTest.sql.required"));

        return new ModelAndView(getViewName());
    }// w ww  .j a v a 2s . co  m

    int maxRows = ServletRequestUtils.getIntParameter(request, "maxRows", 0);
    int rowsPerPage = ServletRequestUtils.getIntParameter(request, "rowsPerPage", 0);
    int historySize = ServletRequestUtils.getIntParameter(request, "historySize", 0);

    // store current option values and query history in a session attribute

    HttpSession sess = request.getSession();
    DataSourceTestInfo sessData = (DataSourceTestInfo) sess.getAttribute(DataSourceTestInfo.DS_TEST_SESS_ATTR);

    synchronized (sess) {
        if (sessData == null) {
            sessData = new DataSourceTestInfo();
            sess.setAttribute(DataSourceTestInfo.DS_TEST_SESS_ATTR, sessData);
        }

        sessData.setMaxRows(maxRows);
        sessData.setRowsPerPage(rowsPerPage);
        sessData.setHistorySize(historySize);
        sessData.addQueryToHistory(sql);
    }

    DataSource dataSource = null;

    try {
        dataSource = getContainerWrapper().getResourceResolver().lookupDataSource(context, resourceName);
    } catch (NamingException e) {
        request.setAttribute("errorMessage", getMessageSourceAccessor()
                .getMessage("probe.src.dataSourceTest.resource.lookup.failure", new Object[] { resourceName }));
    }

    if (dataSource == null) {
        request.setAttribute("errorMessage", getMessageSourceAccessor()
                .getMessage("probe.src.dataSourceTest.resource.lookup.failure", new Object[] { resourceName }));
    } else {
        List<Map<String, String>> results = null;
        int rowsAffected;

        try {
            // TODO: use Spring's jdbc template?

            try (Connection conn = dataSource.getConnection()) {
                conn.setAutoCommit(true);

                try (PreparedStatement stmt = conn.prepareStatement(sql)) {
                    boolean hasResultSet = stmt.execute();

                    if (!hasResultSet) {
                        rowsAffected = stmt.getUpdateCount();
                    } else {
                        results = new ArrayList<>();

                        try (ResultSet rs = stmt.getResultSet()) {
                            ResultSetMetaData metaData = rs.getMetaData();

                            while (rs.next() && (maxRows < 0 || results.size() < maxRows)) {
                                Map<String, String> record = new LinkedHashMap<>();

                                for (int i = 1; i <= metaData.getColumnCount(); i++) {
                                    String value = rs.getString(i);

                                    if (rs.wasNull()) {
                                        value = getMessageSourceAccessor()
                                                .getMessage("probe.src.dataSourceTest.sql.null");
                                    } else {
                                        value = HtmlUtils.htmlEscape(value);
                                    }

                                    // a work around for IE browsers bug of not displaying
                                    // a border around an empty table column

                                    if (value.equals("")) {
                                        value = "&nbsp;";
                                    }

                                    // Pad the keys of columns with existing labels so they are distinct
                                    String key = metaData.getColumnLabel(i);
                                    while (record.containsKey(key)) {
                                        key += " ";
                                    }
                                    record.put(HtmlUtils.htmlEscape(key), value);
                                }

                                results.add(record);
                            }
                        }

                        rowsAffected = results.size();
                    }
                }
            }

            // store the query results in the session attribute in order
            // to support a result set pagination feature without re-executing the query

            synchronized (sess) {
                sessData.setResults(results);
            }

            ModelAndView mv = new ModelAndView(getViewName(), "results", results);
            mv.addObject("rowsAffected", String.valueOf(rowsAffected));
            mv.addObject("rowsPerPage", String.valueOf(rowsPerPage));

            return mv;
        } catch (SQLException e) {
            String message = getMessageSourceAccessor().getMessage("probe.src.dataSourceTest.sql.failure",
                    new Object[] { e.getMessage() });
            logger.error(message, e);
            request.setAttribute("errorMessage", message);
        }
    }

    return new ModelAndView(getViewName());
}

From source file:psiprobe.controllers.sql.ExecuteSqlController.java

@Override
protected ModelAndView handleContext(String contextName, Context context, HttpServletRequest request,
        HttpServletResponse response) throws Exception {

    String resourceName = ServletRequestUtils.getStringParameter(request, "resource");
    String sql = ServletRequestUtils.getStringParameter(request, "sql", null);

    if (sql == null || sql.equals("") || sql.trim().equals("")) {
        request.setAttribute("errorMessage",
                getMessageSourceAccessor().getMessage("probe.src.dataSourceTest.sql.required"));

        return new ModelAndView(getViewName());
    }/*from   w  w  w .  ja  v  a2s .co  m*/

    int maxRows = ServletRequestUtils.getIntParameter(request, "maxRows", 0);
    int rowsPerPage = ServletRequestUtils.getIntParameter(request, "rowsPerPage", 0);
    int historySize = ServletRequestUtils.getIntParameter(request, "historySize", 0);

    // store current option values and query history in a session attribute

    HttpSession sess = request.getSession(false);
    DataSourceTestInfo sessData = (DataSourceTestInfo) sess.getAttribute(DataSourceTestInfo.DS_TEST_SESS_ATTR);

    synchronized (sess) {
        if (sessData == null) {
            sessData = new DataSourceTestInfo();
            sess.setAttribute(DataSourceTestInfo.DS_TEST_SESS_ATTR, sessData);
        }

        sessData.setMaxRows(maxRows);
        sessData.setRowsPerPage(rowsPerPage);
        sessData.setHistorySize(historySize);
        sessData.addQueryToHistory(sql);
    }

    DataSource dataSource = null;

    try {
        dataSource = getContainerWrapper().getResourceResolver().lookupDataSource(context, resourceName,
                getContainerWrapper());
    } catch (NamingException e) {
        request.setAttribute("errorMessage", getMessageSourceAccessor()
                .getMessage("probe.src.dataSourceTest.resource.lookup.failure", new Object[] { resourceName }));
        logger.trace("", e);
    }

    if (dataSource == null) {
        request.setAttribute("errorMessage", getMessageSourceAccessor()
                .getMessage("probe.src.dataSourceTest.resource.lookup.failure", new Object[] { resourceName }));
    } else {
        List<Map<String, String>> results = null;
        int rowsAffected = 0;

        try {
            // TODO: use Spring's jdbc template?
            try (Connection conn = dataSource.getConnection()) {
                conn.setAutoCommit(true);

                try (PreparedStatement stmt = conn.prepareStatement(sql)) {
                    boolean hasResultSet = stmt.execute();

                    if (!hasResultSet) {
                        rowsAffected = stmt.getUpdateCount();
                    } else {
                        results = new ArrayList<>();

                        try (ResultSet rs = stmt.getResultSet()) {
                            ResultSetMetaData metaData = rs.getMetaData();

                            while (rs.next() && (maxRows < 0 || results.size() < maxRows)) {
                                Map<String, String> record = new LinkedHashMap<>();

                                for (int i = 1; i <= metaData.getColumnCount(); i++) {
                                    String value = rs.getString(i);

                                    if (rs.wasNull()) {
                                        value = getMessageSourceAccessor()
                                                .getMessage("probe.src.dataSourceTest.sql.null");
                                    } else {
                                        value = HtmlUtils.htmlEscape(value);
                                    }

                                    // a work around for IE browsers bug of not displaying
                                    // a border around an empty table column

                                    if (value.isEmpty()) {
                                        value = "&nbsp;";
                                    }

                                    // Pad the keys of columns with existing labels so they are distinct
                                    String key = metaData.getColumnLabel(i);
                                    while (record.containsKey(key)) {
                                        key += " ";
                                    }
                                    record.put(HtmlUtils.htmlEscape(key), value);
                                }

                                results.add(record);
                            }
                        }

                        rowsAffected = results.size();
                    }
                }
            }

            // store the query results in the session attribute in order
            // to support a result set pagination feature without re-executing the query

            synchronized (sess) {
                sessData.setResults(results);
            }

            ModelAndView mv = new ModelAndView(getViewName(), "results", results);
            mv.addObject("rowsAffected", String.valueOf(rowsAffected));
            mv.addObject("rowsPerPage", String.valueOf(rowsPerPage));

            return mv;
        } catch (SQLException e) {
            String message = getMessageSourceAccessor().getMessage("probe.src.dataSourceTest.sql.failure",
                    new Object[] { e.getMessage() });
            logger.error(message, e);
            request.setAttribute("errorMessage", message);
        }
    }

    return new ModelAndView(getViewName());
}

From source file:org.apache.catalina.loader.WebappClassLoader.java

/**
 * Have one or more classes or resources been modified so that a reload
 * is appropriate?/*  w ww .jav a2  s . co m*/
 */
public boolean modified() {

    if (log.isDebugEnabled())
        log.debug("modified()");

    // Checking for modified loaded resources
    int length = paths.length;

    // A rare race condition can occur in the updates of the two arrays
    // It's totally ok if the latest class added is not checked (it will
    // be checked the next time
    int length2 = lastModifiedDates.length;
    if (length > length2)
        length = length2;

    for (int i = 0; i < length; i++) {
        try {
            long lastModified = ((ResourceAttributes) resources.getAttributes(paths[i])).getLastModified();
            if (lastModified != lastModifiedDates[i]) {
                if (log.isDebugEnabled())
                    log.debug("  Resource '" + paths[i] + "' was modified; Date is now: "
                            + new java.util.Date(lastModified) + " Was: "
                            + new java.util.Date(lastModifiedDates[i]));
                return (true);
            }
        } catch (NamingException e) {
            log.error("    Resource '" + paths[i] + "' is missing");
            return (true);
        }
    }

    length = jarNames.length;

    // Check if JARs have been added or removed
    if (getJarPath() != null) {

        try {
            NamingEnumeration enum_ = resources.listBindings(getJarPath());
            int i = 0;
            while (enum_.hasMoreElements() && (i < length)) {
                NameClassPair ncPair = (NameClassPair) enum_.nextElement();
                String name = ncPair.getName();
                // Ignore non JARs present in the lib folder
                if (!name.endsWith(".jar"))
                    continue;
                if (!name.equals(jarNames[i])) {
                    // Missing JAR
                    log.info("    Additional JARs have been added : '" + name + "'");
                    return (true);
                }
                i++;
            }
            if (enum_.hasMoreElements()) {
                while (enum_.hasMoreElements()) {
                    NameClassPair ncPair = (NameClassPair) enum_.nextElement();
                    String name = ncPair.getName();
                    // Additional non-JAR files are allowed
                    if (name.endsWith(".jar")) {
                        // There was more JARs
                        log.info("    Additional JARs have been added");
                        return (true);
                    }
                }
            } else if (i < jarNames.length) {
                // There was less JARs
                log.info("    Additional JARs have been added");
                return (true);
            }
        } catch (NamingException e) {
            if (log.isDebugEnabled())
                log.debug("    Failed tracking modifications of '" + getJarPath() + "'");
        } catch (ClassCastException e) {
            log.error("    Failed tracking modifications of '" + getJarPath() + "' : " + e.getMessage());
        }

    }

    // No classes have been modified
    return (false);

}

From source file:com.googlecode.psiprobe.controllers.sql.ExecuteSqlController.java

protected ModelAndView handleContext(String contextName, Context context, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    String resourceName = ServletRequestUtils.getStringParameter(request, "resource");
    String sql = ServletRequestUtils.getStringParameter(request, "sql", null);

    if (sql == null || sql.equals("") || sql.trim().equals("")) {
        request.setAttribute("errorMessage",
                getMessageSourceAccessor().getMessage("probe.src.dataSourceTest.sql.required"));

        return new ModelAndView(getViewName());
    }/*from   ww  w .  j a  v a2s  . c o m*/

    int maxRows = ServletRequestUtils.getIntParameter(request, "maxRows", 0);
    int rowsPerPage = ServletRequestUtils.getIntParameter(request, "rowsPerPage", 0);
    int historySize = ServletRequestUtils.getIntParameter(request, "historySize", 0);

    // store current option values and query history in a session attribute

    HttpSession sess = request.getSession();
    DataSourceTestInfo sessData = (DataSourceTestInfo) sess.getAttribute(DataSourceTestInfo.DS_TEST_SESS_ATTR);

    synchronized (sess) {
        if (sessData == null) {
            sessData = new DataSourceTestInfo();
            sess.setAttribute(DataSourceTestInfo.DS_TEST_SESS_ATTR, sessData);
        }

        sessData.setMaxRows(maxRows);
        sessData.setRowsPerPage(rowsPerPage);
        sessData.setHistorySize(historySize);
        sessData.addQueryToHistory(sql);
    }

    DataSource dataSource = null;

    try {
        dataSource = getContainerWrapper().getResourceResolver().lookupDataSource(context, resourceName,
                getContainerWrapper());
    } catch (NamingException e) {
        request.setAttribute("errorMessage", getMessageSourceAccessor()
                .getMessage("probe.src.dataSourceTest.resource.lookup.failure", new Object[] { resourceName }));
    }

    if (dataSource == null) {
        request.setAttribute("errorMessage", getMessageSourceAccessor()
                .getMessage("probe.src.dataSourceTest.resource.lookup.failure", new Object[] { resourceName }));
    } else {
        List results = null;
        int rowsAffected = 0;

        try {
            // TODO: use Spring's jdbc template?
            Connection conn = dataSource.getConnection();

            try {
                conn.setAutoCommit(true);
                PreparedStatement stmt = conn.prepareStatement(sql);

                try {
                    boolean hasResultSet = stmt.execute();

                    if (!hasResultSet) {
                        rowsAffected = stmt.getUpdateCount();
                    } else {
                        results = new ArrayList();
                        ResultSet rs = stmt.getResultSet();

                        try {
                            ResultSetMetaData metaData = rs.getMetaData();

                            while (rs.next() && (maxRows < 0 || results.size() < maxRows)) {
                                Map record = new LinkedHashMap();

                                for (int i = 1; i <= metaData.getColumnCount(); i++) {
                                    String value = rs.getString(i);

                                    if (rs.wasNull()) {
                                        value = getMessageSourceAccessor()
                                                .getMessage("probe.src.dataSourceTest.sql.null");
                                    } else {
                                        value = HtmlUtils.htmlEscape(value);
                                    }

                                    // a work around for IE browsers bug of not displaying
                                    // a border around an empty table column

                                    if (value.equals("")) {
                                        value = "&nbsp;";
                                    }

                                    // Pad the keys of columns with existing labels so they are distinct
                                    String key = metaData.getColumnLabel(i);
                                    while (record.containsKey(key)) {
                                        key += " ";
                                    }
                                    record.put(HtmlUtils.htmlEscape(key), value);
                                }

                                results.add(record);
                            }
                        } finally {
                            rs.close();
                        }

                        rowsAffected = results.size();
                    }
                } finally {
                    stmt.close();
                }
            } finally {
                conn.close();
            }

            // store the query results in the session attribute in order
            // to support a result set pagination feature without re-executing the query

            synchronized (sess) {
                sessData.setResults(results);
            }

            ModelAndView mv = new ModelAndView(getViewName(), "results", results);
            mv.addObject("rowsAffected", String.valueOf(rowsAffected));
            mv.addObject("rowsPerPage", String.valueOf(rowsPerPage));

            return mv;
        } catch (SQLException e) {
            String message = getMessageSourceAccessor().getMessage("probe.src.dataSourceTest.sql.failure",
                    new Object[] { e.getMessage() });
            logger.error(message, e);
            request.setAttribute("errorMessage", message);
        }
    }

    return new ModelAndView(getViewName());
}

From source file:org.wso2.carbon.user.core.ldap.ReadOnlyLDAPUserStoreManager.java

/**
 * @param userName//from   w w w  .j  av  a2 s .  co m
 * @param searchBase
 * @param searchFilter
 * @return
 * @throws UserStoreException
 */
protected String getNameInSpaceForUserName(String userName, String searchBase, String searchFilter)
        throws UserStoreException {
    boolean debug = log.isDebugEnabled();

    String userDN = null;

    DirContext dirContext = this.connectionSource.getContext();
    NamingEnumeration<SearchResult> answer = null;
    try {
        SearchControls searchCtls = new SearchControls();
        searchCtls.setSearchScope(SearchControls.SUBTREE_SCOPE);

        if (log.isDebugEnabled()) {
            try {
                log.debug("Searching for user with SearchFilter: " + searchFilter + " in SearchBase: "
                        + dirContext.getNameInNamespace());
            } catch (NamingException e) {
                log.debug("Error while getting DN of search base", e);
            }
        }
        SearchResult userObj = null;
        String[] searchBases = searchBase.split("#");
        for (String base : searchBases) {
            answer = dirContext.search(escapeDNForSearch(base), searchFilter, searchCtls);
            if (answer.hasMore()) {
                userObj = (SearchResult) answer.next();
                if (userObj != null) {
                    //no need to decode since , if decoded the whole string, can't be encoded again
                    //eg CN=Hello\,Ok=test\,test, OU=Industry
                    userDN = userObj.getNameInNamespace();
                    break;
                }
            }
        }
        if (userDN != null) {
            LdapName ldn = new LdapName(userDN);
            userCache.put(userName, ldn);
        }
        if (debug) {
            log.debug("Name in space for " + userName + " is " + userDN);
        }
    } catch (Exception e) {
        log.debug(e.getMessage(), e);
    } finally {
        JNDIUtil.closeNamingEnumeration(answer);
        JNDIUtil.closeContext(dirContext);
    }
    return userDN;
}

From source file:com.concursive.connect.web.webdav.servlets.WebdavServlet.java

/**
 * PROPFIND Method.//from  w w w.  j  a v a2  s  . co  m
 *
 * @param context Description of the Parameter
 * @throws javax.servlet.ServletException Description of the Exception
 * @throws java.io.IOException            Description of the Exception
 */
protected void doPropfind(ActionContext context) throws ServletException, IOException {

    String path = getRelativePath(context.getRequest());
    //fix for windows clients
    if (path.equals("/files")) {
        path = "";
    }

    if (path.endsWith("/")) {
        path = path.substring(0, path.length() - 1);
    }

    if ((path.toUpperCase().startsWith("/WEB-INF")) || (path.toUpperCase().startsWith("/META-INF"))) {
        context.getResponse().sendError(WebdavStatus.SC_FORBIDDEN);
        return;
    }

    // Properties which are to be displayed.
    Vector properties = null;
    // Propfind depth
    int depth = INFINITY;
    // Propfind type
    int type = FIND_ALL_PROP;

    String depthStr = context.getRequest().getHeader("Depth");
    if (depthStr == null) {
        depth = INFINITY;
    } else {
        if (depthStr.equals("0")) {
            depth = 0;
        } else if (depthStr.equals("1")) {
            depth = 1;
        } else if (depthStr.equals("infinity")) {
            depth = INFINITY;
        }
    }

    /*
     *  Read the request xml and determine all the properties
     */

    /*
    Node propNode = null;
    DocumentBuilder documentBuilder = getDocumentBuilder();
    try {
      Document document = documentBuilder.parse
          (new InputSource(context.getRequest().getInputStream()));
      // Get the root element of the document
      Element rootElement = document.getDocumentElement();
      NodeList childList = rootElement.getChildNodes();
      for (int i = 0; i < childList.getLength(); i++) {
        Node currentNode = childList.item(i);
        switch (currentNode.getNodeType()) {
          case Node.TEXT_NODE:
    break;
          case Node.ELEMENT_NODE:
    if (currentNode.getNodeName().endsWith("prop")) {
      type = FIND_BY_PROPERTY;
      propNode = currentNode;
    }
    if (currentNode.getNodeName().endsWith("propname")) {
      type = FIND_PROPERTY_NAMES;
    }
    if (currentNode.getNodeName().endsWith("allprop")) {
      type = FIND_ALL_PROP;
    }
    break;
        }
      }
    } catch (Exception e) {
      // Most likely there was no content : we use the defaults.
      // TODO : Enhance that !
      e.printStackTrace(System.out);
    }
            
    if (type == FIND_BY_PROPERTY) {
      properties = new Vector();
      NodeList childList = propNode.getChildNodes();
      for (int i = 0; i < childList.getLength(); i++) {
        Node currentNode = childList.item(i);
        switch (currentNode.getNodeType()) {
          case Node.TEXT_NODE:
    break;
          case Node.ELEMENT_NODE:
    String nodeName = currentNode.getNodeName();
    String propertyName = null;
    if (nodeName.indexOf(':') != -1) {
      propertyName = nodeName.substring
          (nodeName.indexOf(':') + 1);
    } else {
      propertyName = nodeName;
    }
    // href is a live property which is handled differently
    properties.addElement(propertyName);
    break;
        }
      }
    }
    */
    // Properties have been determined
    // Retrieve the resources

    Connection db = null;
    boolean exists = true;
    boolean status = true;
    Object object = null;
    ModuleContext resources = null;
    StringBuffer xmlsb = new StringBuffer();
    try {
        db = this.getConnection(context);
        resources = getCFSResources(db, context);
        if (resources == null) {
            context.getResponse().sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            return;
        }
        object = resources.lookup(db, path);
    } catch (NamingException e) {
        //e.printStackTrace(System.out);
        exists = false;
        int slash = path.lastIndexOf('/');
        if (slash != -1) {
            String parentPath = path.substring(0, slash);
            Vector currentLockNullResources = (Vector) lockNullResources.get(parentPath);
            if (currentLockNullResources != null) {
                Enumeration lockNullResourcesList = currentLockNullResources.elements();
                while (lockNullResourcesList.hasMoreElements()) {
                    String lockNullPath = (String) lockNullResourcesList.nextElement();
                    if (lockNullPath.equals(path)) {
                        context.getResponse().setStatus(WebdavStatus.SC_MULTI_STATUS);
                        context.getResponse().setContentType("text/xml; charset=UTF-8");
                        // Create multistatus object
                        XMLWriter generatedXML = new XMLWriter(context.getResponse().getWriter());
                        generatedXML.writeXMLHeader();
                        generatedXML.writeElement(null, "multistatus" + generateNamespaceDeclarations(),
                                XMLWriter.OPENING);
                        parseLockNullProperties(context.getRequest(), generatedXML, lockNullPath, type,
                                properties);
                        generatedXML.writeElement(null, "multistatus", XMLWriter.CLOSING);
                        generatedXML.sendData();
                        //e.printStackTrace(System.out);
                        return;
                    }
                }
            }
        }
    } catch (SQLException e) {
        e.printStackTrace(System.out);
        context.getResponse().sendError(SQLERROR, e.getMessage());
        status = false;
    } finally {
        this.freeConnection(db, context);
    }

    if (!status) {
        return;
    }

    if (!exists) {
        context.getResponse().sendError(HttpServletResponse.SC_NOT_FOUND, path);
        return;
    }

    context.getResponse().setStatus(WebdavStatus.SC_MULTI_STATUS);
    context.getResponse().setContentType("text/xml; charset=UTF-8");
    // Create multistatus object
    ////System.out.println("Creating Multistatus Object");

    XMLWriter generatedXML = new XMLWriter(context.getResponse().getWriter());
    generatedXML.writeXMLHeader();
    generatedXML.writeElement(null, "multistatus" + generateNamespaceDeclarations(), XMLWriter.OPENING);

    //System.out.println("Depth: " + depth);
    if (depth == 0) {
        parseProperties(context, resources, generatedXML, path, type, properties);
    } else {
        // The stack always contains the object of the current level
        Stack stack = new Stack();
        stack.push(path);
        // Stack of the objects one level below
        Stack stackBelow = new Stack();

        while ((!stack.isEmpty()) && (depth >= 0)) {
            String currentPath = (String) stack.pop();
            if (!currentPath.equals(path)) {
                parseProperties(context, resources, generatedXML, currentPath, type, properties);
            }
            try {
                db = this.getConnection(context);
                object = resources.lookup(db, currentPath);
            } catch (NamingException e) {
                continue;
            } catch (SQLException e) {
                //e.printStackTrace(System.out);
                context.getResponse().sendError(SQLERROR, e.getMessage());
                status = false;
            } finally {
                this.freeConnection(db, context);
            }

            if (!status) {
                return;
            }

            if ((object instanceof ModuleContext) && depth > 0) {
                // Get a list of all the resources at the current path and store them
                // in the stack
                try {
                    NamingEnumeration enum1 = resources.list(currentPath);
                    int count = 0;
                    while (enum1.hasMoreElements()) {
                        NameClassPair ncPair = (NameClassPair) enum1.nextElement();
                        String newPath = currentPath;
                        if (!(newPath.endsWith("/"))) {
                            newPath += "/";
                        }
                        newPath += ncPair.getName();
                        stackBelow.push(newPath);
                        count++;
                    }
                    if (currentPath.equals(path) && count == 0) {
                        // This directory does not have any files or folders.
                        parseProperties(context, resources, generatedXML, properties);
                    }
                } catch (NamingException e) {
                    //e.printStackTrace(System.out);
                    context.getResponse().sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, path);
                    return;
                }

                // Displaying the lock-null resources present in that collection
                String lockPath = currentPath;
                if (lockPath.endsWith("/")) {
                    lockPath = lockPath.substring(0, lockPath.length() - 1);
                }
                Vector currentLockNullResources = (Vector) lockNullResources.get(lockPath);
                if (currentLockNullResources != null) {
                    Enumeration lockNullResourcesList = currentLockNullResources.elements();
                    while (lockNullResourcesList.hasMoreElements()) {
                        String lockNullPath = (String) lockNullResourcesList.nextElement();
                        System.out.println("Lock null path: " + lockNullPath);
                        parseLockNullProperties(context.getRequest(), generatedXML, lockNullPath, type,
                                properties);
                    }
                }
            }
            if (stack.isEmpty()) {
                depth--;
                stack = stackBelow;
                stackBelow = new Stack();
            }
            xmlsb.append(generatedXML.toString());
            //System.out.println("xml : " + generatedXML.toString());
            generatedXML.sendData();
        }
    }

    generatedXML.writeElement(null, "multistatus", XMLWriter.CLOSING);
    xmlsb.append(generatedXML.toString());
    generatedXML.sendData();
    //System.out.println("xml: " + xmlsb.toString());
}