Package org.apache.commons.vfs2

Examples of org.apache.commons.vfs2.FileSystemException


    public long getSize() throws FileSystemException
    {
        // Do some checking
        if (!fileObject.getType().hasContent())
        {
            throw new FileSystemException("vfs.provider/get-size-not-file.error", fileObject);
        }
        /*
        if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS)
        {
            throw new FileSystemException("vfs.provider/get-size-write.error", file);
        }
        */

        try
        {
            // Get the size
            return fileObject.doGetContentSize();
        }
        catch (final Exception exc)
        {
            throw new FileSystemException("vfs.provider/get-size.error", new Object[]{fileObject}, exc);
        }
    }
View Full Code Here


            throw new FileSystemException("vfs.provider/get-last-modified-writing.error", file);
        }
        */
        if (!fileObject.getType().hasAttributes())
        {
            throw new FileSystemException("vfs.provider/get-last-modified-no-exist.error", fileObject);
        }
        try
        {
            return fileObject.doGetLastModifiedTime();
        }
        catch (final Exception e)
        {
            throw new FileSystemException("vfs.provider/get-last-modified.error", fileObject, e);
        }
    }
View Full Code Here

            throw new FileSystemException("vfs.provider/set-last-modified-writing.error", file);
        }
        */
        if (!fileObject.getType().hasAttributes())
        {
            throw new FileSystemException("vfs.provider/set-last-modified-no-exist.error", fileObject);
        }
        try
        {
            if (!fileObject.doSetLastModifiedTime(modTime))
            {
                throw new FileSystemException("vfs.provider/set-last-modified.error", fileObject);
            }
        }
        catch (final Exception e)
        {
            throw new FileSystemException("vfs.provider/set-last-modified.error", fileObject, e);
        }
    }
View Full Code Here

     */
    public boolean hasAttribute(final String attrName) throws FileSystemException
    {
        if (!fileObject.getType().hasAttributes())
        {
            throw new FileSystemException("vfs.provider/exists-attributes-no-exist.error", fileObject);
        }
        getAttributes();
        return attrs.containsKey(attrName);
    }
View Full Code Here

     */
    public Map<String, Object> getAttributes() throws FileSystemException
    {
        if (!fileObject.getType().hasAttributes())
        {
            throw new FileSystemException("vfs.provider/get-attributes-no-exist.error", fileObject);
        }
        if (resetAttributes || roAttrs == null)
        {
            try
            {
                synchronized (this)
                {
                    attrs = fileObject.doGetAttributes();
                    roAttrs = Collections.unmodifiableMap(attrs);
                    resetAttributes = false;
                }
            }
            catch (final Exception e)
            {
                throw new FileSystemException("vfs.provider/get-attributes.error", fileObject, e);
            }
        }
        return roAttrs;
    }
View Full Code Here

    public void setAttribute(final String attrName, final Object value)
        throws FileSystemException
    {
        if (!fileObject.getType().hasAttributes())
        {
            throw new FileSystemException("vfs.provider/set-attribute-no-exist.error", new Object[]{attrName, fileObject});
        }
        try
        {
            fileObject.doSetAttribute(attrName, value);
        }
        catch (final Exception e)
        {
            throw new FileSystemException("vfs.provider/set-attribute.error", new Object[]{attrName, fileObject}, e);
        }

        if (attrs != null)
        {
            attrs.put(attrName, value);
View Full Code Here

     */
    public void removeAttribute(final String attrName) throws FileSystemException
    {
        if (!fileObject.getType().hasAttributes())
        {
            throw new FileSystemException("vfs.provider/remove-attribute-no-exist.error", fileObject);
        }

        try
        {
            fileObject.doRemoveAttribute(attrName);
        }
        catch (final Exception e)
        {
            throw new FileSystemException("vfs.provider/remove-attribute.error", new Object[]{attrName, fileObject}, e);
        }

        if (attrs != null)
        {
            attrs.remove(attrName);
View Full Code Here

     */
    public Certificate[] getCertificates() throws FileSystemException
    {
        if (!fileObject.exists())
        {
            throw new FileSystemException("vfs.provider/get-certificates-no-exist.error", fileObject);
        }
        /*
        if (getThreadData().getState() == STATE_WRITING || getThreadData().getState() == STATE_RANDOM_ACCESS)
        {
            throw new FileSystemException("vfs.provider/get-certificates-writing.error", file);
        }
        */

        try
        {
            final Certificate[] certs = fileObject.doGetCertificates();
            if (certs != null)
            {
                return certs;
            }
            else
            {
                return new Certificate[0];
            }
        }
        catch (final Exception e)
        {
            throw new FileSystemException("vfs.provider/get-certificates.error", fileObject, e);
        }
    }
View Full Code Here

        /*
        if (getThreadData().getState() != STATE_NONE)
        */
        if (this.getThreadData().getOutstr() != null)
        {
            throw new FileSystemException("vfs.provider/write-in-use.error", fileObject);
        }

        // Get the raw output stream
        final OutputStream outstr = fileObject.getOutputStream(bAppend);

View Full Code Here

                {
                    ra.close();
                }
                catch (IOException e)
                {
                    throw new FileSystemException(e);
                }
            }

            // Close the output stream
            if (this.getThreadData().getOutstr() != null)
View Full Code Here

TOP

Related Classes of org.apache.commons.vfs2.FileSystemException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.