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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to