9.5 Editing a File

Word normally saves files automatically while a user edits. However, when you use a Web Folder, auto-saves happen in a local temporary file cache. New content isn't sent to the server until the user chooses to save the file.

While the file is opened in Word, Web Folders automatically keeps the lock alive by refreshing it just as it is supposed to expire (see Figure 9-5).

Figure 9-5. Summary of editing and saving file.

graphics/09fig05.gif

Web Folders issues a PUT operation every time the user chooses to save the file. Some WebDAV clients, like Xythos WebFile Client, do not save as frequently as Web Folders does. Instead, the Xythos client conserves bandwidth by caching changes on disk for a time and uploading changes to the server asynchronously. This allows the client to respond very quickly to a user save request, and the user can go on editing the document, even if the upload is slow. However, once in a while the user might attempt to view a document with some other tool and could be confused to see a document that doesn't yet contain the user's latest changes.

9.5.1 Automatic Lock Refresh

Roughly every two minutes as Alice is working on the file, Web Folders automatically refreshes the lock. Web Folders chooses 119 seconds as the refresh lifetime of the lock, possibly because that's the value the server chose when the lock was created. If the client or the server chooses a different lifetime for the lock, the refresh requests would occur at a different rate (see Listing 9-17).

Listing 9-17 LOCK request to refresh a lock.
 LOCK /users/alice/work/ergo-accessories.doc HTTP/1.1 If: (<locktoken:vserver1-LockTokendocstore1:9100>) Timeout: Second-119 [typical headers omitted] graphics/enter.gif 

The LOCK request no longer needs a body, because it's just used to refresh the lock identified using the request URI and the lock token (see Listing 9-18).

Listing 9-18 Response to LOCK request to refresh a lock.
 HTTP/1.0 200 OK Content-Type: text/xml; charset=UTF-8 Date: Sun, 18 Nov 2001 22:32:53 GMT Content-Length: 385 Server: Tomcat Web Server/3.3 Final ( JSP 1.1; Servlet 2.2 ) graphics/enter.gif <?xml version="1.0" encoding="utf-8" ?> <D:prop xmlns:D="DAV:"> <D:lockdiscovery>    <D:activelock>       <D:locktype><D:write/></D:locktype>       <D:lockscope><D:exclusive/></D:lockscope>       <D:depth>0</D:depth>       <D:owner>alice</D:owner>       <D:timeout>Second-119</D:timeout>       <D:locktoken><D:href> graphics/ap03inl01.gif          locktoken:vserver1-LockTokendocstore1:9100</D:href>       </D:locktoken>    </D:activelock> </D:lockdiscovery> </D:prop> 

The server responds successfully. This time, the status code is 200 OK, not 201 Created, because no new resource was created as a result of this LOCK request.

The server includes the complete lock information every time the lock is refreshed. The lock type, depth, owner, and timeout are identical. None of this information can be changed in a lock refresh action except timeout. The lock token must also be included again.

9.5.2 User Action to Save File

When the user chooses to save, Word does nothing if the file hasn't been changed since the last save. If the document has changed, Word pops up a dialog that says "Transferring http://www.example.com/hr/alice/work/ergo-accessories.doc." The entire new body of the file is sent to the server synchronously the user must wait until the entire request is sent and the response received before being allowed to continue editing. There is no way in HTTP or WebDAV to upload partial files (Section 5.4.1).

The file is saved with a PUT request, identical to the one used to save the content initially, except of course with new body content and content length value. Web Folders even continues to erroneously omit the Content-Type header.

Every time Word saves the file, the Web Folders code also performs a new HEAD request to confirm the document status. Again, it's not certain exactly why Web Folders does this; it could be to confirm the server's file size, date last modified, or URL.

These two requests and responses are not shown in full because they do not differ substantially from the PUT and HEAD examples in Listings 9-13 through 9-16.



WebDAV. Next Generation Collaborative Web Authoring
WebDAV. Next Generation Collaborative Web Authoring
ISBN: 130652083
EAN: N/A
Year: 2003
Pages: 146

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net