Jackrabbit 网站上有一个文档(JCR_Webdav_Protocol.doc - Apache Jackrabbit)描述了 WebDAV 方法调用和 Jackrabbit JCR API 调用之间的映射:
http://jackrabbit.apache.org/JCR_Webdav_Protocol.doc
虽然本文档最后一次更新是 2006 年 3 月 29 日,但我发现迈出第一步非常有帮助。
我使用 Word 和 Wireshark 针对我的 Jackrabbit 默认存储库跟踪了与 Microsoft Office 2010 的会话。以下 shell 脚本在 *nix 上使用 curl 和 libreoffice 执行相同的操作。
如您所见,删除、上传、版本控制文档 WebDAV 调用是在 Word 中的操作之前执行的。
浏览目录会在您的 Internet Explorer 实例中打开 URL。
Microsoft Word 检索文档属性 (PROPFIND),然后打开 (GET) 并锁定文档。它还出于未知原因请求 %EE%B3%B0 上的属性(UTF-8 (hex) 0xEE 0xB3 0xB0 (eeb3b0) 或 UTF-16 "\uECF0" aka "" from the Private Use Range of Unicode Character Set) .
在 Microsoft Word 中保存文档后,它将上传 (PUT) 并更新文档节点的属性 (PROPPATCH) 以包括 Win32CreationTime、Win32LastModifiedTime 和 Win32LastAccessTime 戳。
在 Word 中关闭文档将使用 UNLOCK 释放获取的锁。
再次手动执行 CHECKIN 文档以完成版本生命周期。
版本树报告也可以从 WebDAV 获得。
#!/bin/sh
# Delete document
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X DELETE -v http://localhost:7001/repository/default/test.docx
# Upload document
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X PUT -v http://localhost:7001/repository/default/test.docx --data-binary "@test.docx"
# Version-Control document
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X VERSION-CONTROL -v http://localhost:7001/repository/default/test.docx
# Checkout document
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X CHECKOUT -v http://localhost:7001/repository/default/test.docx
# Browse directory
curl -A "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko" -X GET -v http://localhost:7001/repository/default/
# Open document in Word
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X PROPFIND -v http://localhost:7001/repository/default/test.docx | xmllint --format -
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X GET -v http://localhost:7001/repository/default/test.docx -O
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X PROPFIND -v http://localhost:7001/repository/default/test.docx%EE%B3%B0
cat > LOCK_document.xml <<EOF
<?xml version="1.0" encoding="utf-8" ?>
<D:lockinfo xmlns:D="DAV:">
<D:lockscope>
<D:exclusive/>
</D:lockscope>
<D:locktype>
<D:write/>
</D:locktype>
<D:owner>
<D:href>WINDOWSDOMAIN\USER</D:href>
</D:owner>
</D:lockinfo>
EOF
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X LOCK -v http://localhost:7001/repository/default/test.docx --data "@LOCK_document.xml" | xmllint --format - | tee LOCK_document.txt
export LOCK_token=$(grep opaquelocktoken LOCK_document.txt | sed 's/^.*opaquelocktoken:/<opaquelocktoken:/' | sed 's/<\/D:href>.*$/>/')
curl -A "Microsoft Office Existence Discovery" -X HEAD -v http://localhost:7001/repository/default/test.docx
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X OPTIONS -v http://localhost:7001/ -H "translate: f"
# Edit document in Word
libreoffice test.docx
# Save document in Word
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X HEAD -v http://localhost:7001/repository/default/test.docx
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X PUT -v http://localhost:7001/repository/default/test.docx -H "If: (${LOCK_token})" --data-binary "@test.docx"
cat > PROPPATCH_document.xml <<EOF
<?xml version="1.0" encoding="utf-8" ?>
<D:propertyupdate xmlns:D="DAV:" xmlns:Z="urn:schemas-microsoft-com:">
<D:set>
<D:prop>
<Z:Win32CreationTime>Mon, 09 Mar 2015 15:24:36 GMT</Z:Win32CreationTime>
<Z:Win32LastAccessTime>Mon, 16 Mar 2015 13:22:40 GMT</Z:Win32LastAccessTime>
<Z:Win32LastModifiedTime>Mon, 16 Mar 2015 13:22:40 GMT</Z:Win32LastModifiedTime>
</D:prop>
</D:set>
</D:propertyupdate>
EOF
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X PROPPATCH -v http://localhost:7001/repository/default/test.docx -H "If: (${LOCK_token})" --data "@PROPPATCH_document.xml" | xmllint --format -
# Close document in Word
curl -A "Microsoft Office Existence Discovery" -X HEAD -v http://localhost:7001/repository/default/test.docx
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X UNLOCK -v http://localhost:7001/repository/default/test.docx -H "Lock-Token: ${LOCK_token}"
# Checkin document
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X CHECKIN -v http://localhost:7001/repository/default/test.docx
# Version tree report on document
cat > REPORT_version-tree.xml <<EOF
<?xml version="1.0" encoding="utf-8" ?>
<D:version-tree xmlns:D="DAV:">
<D:prop>
<D:version-name/>
</D:prop>
</D:version-tree>
EOF
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X REPORT -v http://localhost:7001/repository/default/test.docx --data "@REPORT_version-tree.xml" | xmllint --format -
我只是对 Jackrabbit 的自动版本功能有问题,显然还没有实现。
https://issues.apache.org/jira/browse/JCR-1348
#<!--
# see http://www.webdav.org/specs/rfc3253.html#PROPERTY_auto-version
# <D:auto-version>checkout-checkin</D:auto-version>
# <D:auto-version>checkout-unlocked-checkin</D:auto-version>
# <D:auto-version>checkout</D:auto-version>
# <D:auto-version>locked-checkout</D:auto-version>
#-->
cat > PROPPATCH_auto-version.xml <<EOF
<?xml version="1.0" encoding="utf-8" ?>
<D:propertyupdate xmlns:D="DAV:">
<D:set>
<D:prop>
<D:auto-version>checkout-checkin</D:auto-version>
</D:prop>
</D:set>
</D:propertyupdate>
EOF
curl -A Microsoft-WebDAV-MiniRedir/6.1.7601 -X PROPPATCH -v http://localhost:7001/repository/default/test.docx -H "If: (${LOCK_token})" --data "@PROPPATCH_auto-version.xml" | xmllint --format -