Example usage for org.apache.commons.vfs2.util Messages getString

List of usage examples for org.apache.commons.vfs2.util Messages getString

Introduction

In this page you can find the example usage for org.apache.commons.vfs2.util Messages getString.

Prototype

public static String getString(final String code, final Object... params) 

Source Link

Document

Formats a message.

Usage

From source file:fr.cls.atoll.motu.library.misc.vfs.provider.gsiftp.GsiFtpFileObject.java

/**
 * Fetches the children of this file, if not already cached.
 * /*from   ww w  . j a  v a2 s .  c  o m*/
 * @throws IOException Signals that an I/O exception has occurred.
 */
private void doGetChildren() throws IOException {
    if (children != null) {
        return;
    }

    final GridFTPClient client = ftpFs.getClient();
    try {
        // String key =
        // GsiFtpFileSystemConfigBuilder.getInstance().getEntryParser(getFileSystem().getFileSystemOptions());

        /** required to perform multiple requests **/
        client.setLocalPassive();
        client.setActive();

        final Vector tmpChildren = client.list(getName().getPath());

        if (tmpChildren == null || tmpChildren.size() == 0) {
            children = EMPTY_FTP_FILE_MAP;
        } else {
            children = new TreeMap();

            // Remove '.' and '..' elements
            for (int i = 0; i < tmpChildren.size(); i++) {
                // final FTPFile child = tmpChildren[i];
                final FileInfo child = (FileInfo) tmpChildren.get(i);

                if (child == null) {
                    if (log.isDebugEnabled()) {
                        log.debug(Messages.getString("vfs.provider.ftp/invalid-directory-entry.debug",
                                new Object[] { new Integer(i), relPath }));
                    }
                    continue;
                }
                if (!".".equals(child.getName()) && !"..".equals(child.getName())) {
                    children.put(child.getName(), child);
                }
            }
        }
    } catch (ServerException se) {
        se.printStackTrace();
        // System.err.println("GsiFtpFileObject " + se);
        throw new IOException(se.getMessage());
    } catch (ClientException ce) {
        throw new IOException(ce.getMessage());
    } finally {
        ftpFs.putClient(client);
    }
}