Commons VFS
  1. Commons VFS
  2. VFS-263

WebdavFileObject does not implement doSetAttribute()

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0
    • Fix Version/s: 2.0
    • Labels:
      None
    • Environment:

      all

      Description

      Usually, WebDAV servers allow to read from and write to properties (attributes in VFS speech) of a WebDAV resource.

      Though WebdavFileObject in current TRUNK allows to read those properties, it doesn't allow to write them. WebdavFileObject should implement doSetAttribute() to fully support WebDAV properties.

        Activity

        Hide
        Ingo Maas added a comment -

        Closed.

        Show
        Ingo Maas added a comment - Closed.
        Hide
        Ralph Goers added a comment -

        Patch applied. Please verify and close.

        Show
        Ralph Goers added a comment - Patch applied. Please verify and close.
        Hide
        Ingo Maas added a comment -

        The way I've solved it for me:
        ////
        protected void doSetAttribute(String attrName, Object value) throws Exception {
        try
        {
        URLFileName fileName = (URLFileName) getName();
        String urlStr = urlString( fileName);
        DavPropertySet properties = new DavPropertySet();
        DavPropertyNameSet propertyNameSet = new DavPropertyNameSet();
        DavProperty property = new DefaultDavProperty( attrName, value, Namespace.EMPTY_NAMESPACE);

        if (value != null)

        { properties.add( property); }

        else

        { propertyNameSet.add( property.getName() ); // remove porperty }

        PropPatchMethod method = new PropPatchMethod( urlStr, properties, propertyNameSet);
        setupMethod( method);
        execute( method);
        if (!method.succeeded() )

        { throw new FileSystemException("Property '" + attrName + "' could not be set."); }

        }
        catch (FileSystemException fse)

        { throw fse; }

        catch (Exception e)

        { throw new FileSystemException("vfs.provider.webdav/propfind.error", getName(), e); }

        }

        Show
        Ingo Maas added a comment - The way I've solved it for me: //// protected void doSetAttribute(String attrName, Object value) throws Exception { try { URLFileName fileName = (URLFileName) getName(); String urlStr = urlString( fileName); DavPropertySet properties = new DavPropertySet(); DavPropertyNameSet propertyNameSet = new DavPropertyNameSet(); DavProperty property = new DefaultDavProperty( attrName, value, Namespace.EMPTY_NAMESPACE); if (value != null) { properties.add( property); } else { propertyNameSet.add( property.getName() ); // remove porperty } PropPatchMethod method = new PropPatchMethod( urlStr, properties, propertyNameSet); setupMethod( method); execute( method); if (!method.succeeded() ) { throw new FileSystemException("Property '" + attrName + "' could not be set."); } } catch (FileSystemException fse) { throw fse; } catch (Exception e) { throw new FileSystemException("vfs.provider.webdav/propfind.error", getName(), e); } }

          People

          • Assignee:
            Unassigned
            Reporter:
            Ingo Maas
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 5m
              5m
              Remaining:
              Remaining Estimate - 5m
              5m
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development