1

I am trying to put some custom property in a directory WebDAV, but it is only working with files.

I am using Sardine library with Jackrabbit, example:

public static void main(String[] args) throws IOException {
    Sardine sardine = SardineFactory.begin();
    String someUrl = "http://localhost:8080/repository/default/temp/";
    int depthInfiniteRecursion = -1;

    // 1. Set custom properties on a resource:
    List<DavResource> resourcesBefore = sardine.list(someUrl, depthInfiniteRecursion);

    for (DavResource resource : resourcesBefore) {
        Map<QName, String> addProps = new LinkedHashMap<>();         
        QName author = new QName("http://luankevinferreira.github.io", "author", "playground");
        addProps.put(author, "Luan K. Ferreira");
        sardine.patch(resource.getHref().toURL().toString(), addProps);
    }

    // 2. Retrieve custom properties on a resource:
    List<DavResource> resources = sardine.list(someUrl, depthInfiniteRecursion);

    for (DavResource resource : resources) {
        Map<String, String> customProps = resource.getCustomProps();
        // Use custom properties...
        System.out.println("Resource: " + resource);
        System.out.println("Properties: " + customProps);
    }
}

The result of the execution with one directory and one file is:

Resource: /repository/default/temp/
Properties: {createdBy=admin, created=2018-08-21T18:37:10.446Z, iscollection=1}
Resource: /repository/default/temp/test.txt
Properties: {author=Luan K. Ferreira, iscollection=0}

Is there anyway to put the property in the directory?

Luan Kevin Ferreira
  • 1,184
  • 2
  • 16
  • 40

0 Answers0