Example usage for org.apache.commons.vfs FileSystemException toString

List of usage examples for org.apache.commons.vfs FileSystemException toString

Introduction

In this page you can find the example usage for org.apache.commons.vfs FileSystemException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:egovframework.rte.fdl.filehandling.EgovFileUtil.java

/**
 * <p>/*from w w w  . j a v  a 2s.  c o m*/
 *  ? ? ?  .
 * </p>
 * @param cmd
 *        <code>String</code>
 * @return  
 * @throws FileSystemException
 */
public static int rm(final String cmd) throws FileSystemException {
    int result = -1;

    try {
        final FileObject file = manager.resolveFile(basefile, cmd);

        result = file.delete(Selectors.SELECT_SELF_AND_CHILDREN);

        log.debug("result is " + result);

    } catch (FileSystemException e) {
        log.error(e.toString());
        throw new FileSystemException(e);
    }

    return result;
}

From source file:egovframework.rte.fdl.filehandling.EgovFileUtil.java

/**
 * <p>// ww w .j a  v a 2 s  .  c  o  m
 *  ? ?? ?  .
 * </p>
 * @param source
 *        <code>String</code>
 * @param target
 *        <code>String</code>
 * @throws Exception
 */
public static void cp(String source, String target) throws Exception {

    try {
        final FileObject src = manager.resolveFile(basefile, source);
        FileObject dest = manager.resolveFile(basefile, target);

        if (dest.exists() && dest.getType() == FileType.FOLDER) {
            dest = dest.resolveFile(src.getName().getBaseName());
        }

        dest.copyFrom(src, Selectors.SELECT_ALL);
    } catch (FileSystemException fse) {
        log.error(fse.toString());
        ;
        throw new FileSystemException(fse);
    }
}

From source file:egovframework.rte.fdl.filehandling.EgovFileUtil.java

/**
 * <p>//w  ww . jav  a 2 s . c  om
 *  ? ?? ?  ??.
 * </p>
 * @param source
 *        <code>String</code>
 * @param target
 *        <code>String</code>
 * @throws Exception
 */
public static void mv(String source, String target) throws Exception {

    try {
        final FileObject src = manager.resolveFile(basefile, source);
        FileObject dest = manager.resolveFile(basefile, target);

        if (dest.exists() && dest.getType() == FileType.FOLDER) {
            dest = dest.resolveFile(src.getName().getBaseName());
        }

        src.moveTo(dest);
    } catch (FileSystemException fse) {
        log.error(fse.toString());
        ;
        throw new FileSystemException(fse);
    }
}

From source file:com.newatlanta.appengine.nio.file.GaePath.java

public GaePath(FileSystem fileSystem, String path) {
    this.fileSystem = fileSystem;
    this.path = path;
    try {/*from   w ww  . jav  a2  s . co m*/
        fileObject = GaeVFS.resolveFile(path);
    } catch (FileSystemException e) {
        throw new InvalidPathException(path, e.toString());
    }
}

From source file:com.newatlanta.appengine.nio.file.GaePath.java

@Override
public Path resolve(String other) {
    try {// w w w . j a v a  2  s.  c  o  m
        return new GaePath(fileSystem, fileObject.resolveFile(other));
    } catch (FileSystemException e) {
        throw new InvalidPathException(other, e.toString());
    }
}

From source file:com.newatlanta.appengine.nio.file.GaePath.java

@Override
public Path relativize(Path other) {
    if (!(other instanceof GaePath)) {
        throw new ProviderMismatchException();
    }/*www .  j a v a 2s.com*/
    if (this.equals(other)) {
        return null;
    }
    try {
        return new GaePath(fileSystem,
                fileObject.getName().getRelativeName(((GaePath) other).fileObject.getName()));
    } catch (FileSystemException e) {
        throw new InvalidPathException(other.toString(), e.toString());
    }
}

From source file:com.newatlanta.appengine.nio.file.GaePath.java

@Override
public GaePath getParent() {
    try {//from   www.  j a v  a  2  s. co  m
        FileObject parentObject = fileObject.getParent();
        if (parentObject == null) {
            return null;
        }
        return new GaePath(fileSystem, parentObject);
    } catch (FileSystemException e) {
        throw new InvalidPathException(fileObject.getName().getParent().getPath(), e.toString());
    }
}

From source file:org.pentaho.di.trans.steps.getxmldata.GetXMLData.java

private boolean openNextFile() {
    try {// w  w w .  jav a2 s.  c  om
        if (data.filenr >= data.files.nrOfFiles()) {
            // finished processing!

            if (log.isDetailed()) {
                logDetailed(BaseMessages.getString(PKG, "GetXMLData.Log.FinishedProcessing"));
            }
            return false;
        }
        // get file
        data.file = data.files.getFile(data.filenr);
        data.filename = KettleVFS.getFilename(data.file);
        // Add additional fields?
        if (meta.getShortFileNameField() != null && meta.getShortFileNameField().length() > 0) {
            data.shortFilename = data.file.getName().getBaseName();
        }
        if (meta.getPathField() != null && meta.getPathField().length() > 0) {
            data.path = KettleVFS.getFilename(data.file.getParent());
        }
        if (meta.isHiddenField() != null && meta.isHiddenField().length() > 0) {
            data.hidden = data.file.isHidden();
        }
        if (meta.getExtensionField() != null && meta.getExtensionField().length() > 0) {
            data.extension = data.file.getName().getExtension();
        }
        if (meta.getLastModificationDateField() != null && meta.getLastModificationDateField().length() > 0) {
            data.lastModificationDateTime = new Date(data.file.getContent().getLastModifiedTime());
        }
        if (meta.getUriField() != null && meta.getUriField().length() > 0) {
            data.uriName = data.file.getName().getURI();
        }
        if (meta.getRootUriField() != null && meta.getRootUriField().length() > 0) {
            data.rootUriName = data.file.getName().getRootURI();
        }
        // Check if file is empty
        long fileSize;
        try {
            fileSize = data.file.getContent().getSize();
        } catch (FileSystemException e) {
            fileSize = -1;
        }

        if (meta.getSizeField() != null && meta.getSizeField().length() > 0) {
            data.size = fileSize;
        }
        // Move file pointer ahead!
        data.filenr++;

        if (meta.isIgnoreEmptyFile() && fileSize == 0) {
            // log only basic as a warning (was before logError)
            logBasic(BaseMessages.getString(PKG, "GetXMLData.Error.FileSizeZero", "" + data.file.getName()));
            openNextFile();

        } else {
            if (log.isDetailed()) {
                logDetailed(BaseMessages.getString(PKG, "GetXMLData.Log.OpeningFile", data.file.toString()));
            }

            // Open the XML document
            if (!setDocument(null, data.file, false, false)) {
                if (data.stopPruning) {
                    return false; // ignore error when stopped while pruning
                }
                throw new KettleException(BaseMessages.getString(PKG, "GetXMLData.Log.UnableCreateDocument"));
            }

            // Apply XPath and set node list
            if (data.prunePath == null) { // this was already done in processStreaming()
                if (!applyXPath()) {
                    throw new KettleException(BaseMessages.getString(PKG, "GetXMLData.Log.UnableApplyXPath"));
                }
            }

            addFileToResultFilesname(data.file);

            if (log.isDetailed()) {
                logDetailed(BaseMessages.getString(PKG, "GetXMLData.Log.FileOpened", data.file.toString()));
                logDetailed(BaseMessages.getString(PKG, "GetXMLData.Log.LoopFileOccurences", "" + data.nodesize,
                        data.file.getName().getBaseName()));
            }
        }
    } catch (Exception e) {
        logError(BaseMessages.getString(PKG, "GetXMLData.Log.UnableToOpenFile", "" + data.filenr,
                data.file.toString(), e.toString()));
        stopAll();
        setErrors(1);
        return false;
    }
    return true;
}