是否可以使用Sardine将自定义属性放在目录中?

时间:2018-08-22 16:44:10

标签: webdav jackrabbit sardine

我试图将一些自定义属性放在目录WebDAV中,但是它仅适用于文件。

我正在使用带有Jackrabbit的Sardine库,例如:

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);
    }
}

一个目录和一个文件的执行结果为:

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}

是否有将属性放置在目录中?

0 个答案:

没有答案