commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alartin <alar...@gmail.com>
Subject VFS FileContent can not set attribute
Date Fri, 18 May 2007 00:54:57 GMT

Hi all,
  Maybe I found a bug of VFS1.0 : I can not set attributes to a file even
the file type is supported to set attribute:
Here are my code:
----------------------------------------------------
FileObject fileObj = VFS.getManager().resolveFile("D:\\tmp\\a.txt");
        FileContent co = fileObj.getContent();
        FileType ft = fileObj.getType();
        System.out.println(ft.getName()+" "+ft.hasAttributes());
        if(ft.hasAttributes()) {
             co.setAttribute("a1","value1");
        }
----------------------------------------------------
and Exception:
---------------------------------------------------
file true
Exception in thread "main" org.apache.commons.vfs.FileSystemException: Could
not set attribute "a1" of "file:///D:/tmp/a.txt".
        at
org.apache.commons.vfs.provider.DefaultFileContent.setAttribute(DefaultFileContent.java:264)
        at temp.FileTest.main(FileTest.java:34)
Caused by: org.apache.commons.vfs.FileSystemException: This file type does
not support setting attributes.
        at
org.apache.commons.vfs.provider.AbstractFileObject.doSetAttribute(AbstractFileObject.java:301)
        at
org.apache.commons.vfs.provider.DefaultFileContent.setAttribute(DefaultFileContent.java:260)
        ... 1 more
Java Result: 1
----------------------------------------------------
I found that the DefaultFileContent use an private AbstractFileObject and
the setAttribute method of it always:
Here are the code of that method:
--------------------------------------------------
protected void doSetAttribute(final String atttrName, final Object value)
        throws Exception
    {
        throw new
FileSystemException("vfs.provider/set-attribute-not-supported.error");
    }
--------------------------------------------------
Is it a bug??
-- 
View this message in context: http://www.nabble.com/VFS-FileContent-can-not-set-attribute-tf3775171.html#a10674869
Sent from the Commons - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message