包含在查找更多文档专项支持资源 | 以 PDF 格式下载本书 (2845 KB)
Chapter 10 Web Publishing With WebDAVSun Java System Web Server 7.0 supports WebDAV or Web-based Distributed Authoring and Versioning, a standard in Web-based collaboration. WebDAV is an extension to the HTTP/1.1 protocol that allows clients to perform remote web content authoring operations. A complete WebDAV transaction involves a WebDAV-enabled server, such as Sun Java System Web Server 7.0 that can service requests for WebDAV resources, as well as a WebDAV-enabled client such as Adobe® GoLive® or Macromedia® DreamWeaver® that supports WebDAV-enabled Web publishing requests. On the server-side, you need to enable and configure Sun Java System Web Server 7.0 to be able to service WebDAV requests. You might want to configure WebDAV for several reasons: for example, to tune server performance, to eliminate security risks, or to provide for conflict-free remote authoring. To suit your configuration requirements, you can change the minimum amount of time the server holds a lock on a WebDAV resource, the depth of the PROPFIND request on a collection, and the maximum size of the XML content allowed in the body of a request, and so on. Default WebDAV attributes can be configured at the virtual server level for all collections under a virtual server. The values configured here correspond to the DAV element in the server.xml file. WebDAV attributes can also be configured at a collection level and override any virtual server level attributes configured for the collection. The attribute values configured at the collection level correspond to the DAVCOLLECTION element in the server.xml file. About WebDAVWebDAV is an extension of the HTTP/1.1 protocol, and adds new HTTP methods and headers that provide authoring support for Web resources of any type, not only HTML and XML but also, text, graphics, spreadsheets, and all other formats. Some of the tasks you can accomplish using WebDAV are:
WebDAV support in Sun Java System Web Server 7.0 provides the following features:
Common WebDAV TerminologyThis section outlines the common terms you will encounter as you work with WebDAV. URI. A URI (Uniform Resource Identifier) is a file identifier that provides an additional layer of security by using an abbreviated URL. The first part of the URL is substituted with a URL mapping that hides the file’s full physical pathname from the user. Source URI. The term, source URI, refers to the URI at which a resource’s source can be accessed. To understand the concept of source URI, consider the following example: A JSP page, foo.jsp, is located at the URI /docs/date.jsp. This page contains HTML markup and Java code which, when executed, prints today’s date on the client’s browser. When the server receives a GET request for foo.jsp from a client, before serving the page it executes the Java code. What the client receives is not foo.jsp as it resides on the server but instead a dynamically generated page that displays the current date. If you were to create a source URI, say /publish/docs, and map it to the /docs directory containing foo.jsp, then a request for /publish/docs/foo.jsp will be a request for the source code of the /docs/foo.jsp JSP page. In this case, the server will serve the page without executing the Java code. The client will receive the unprocessed page exactly as stored on disk. A request for the source URI is thus a request for the source of the resource. Collection. A WebDAV collection is a resource or a set of resources that are enabled for WebDAV operations. A collection contains a set of URIs, termed member URIs, which identify member resources that are WebDAV-enabled. Member URI. A URI which is a member of the set of URIs inside a collection. Internal Member URI. A Member URI that is immediately relative to the URI of the collection. For example, if the resource with the URL http://info.sun.com/resources/info is WebDAV-enabled and if the resource with the URL http://info.sun.com/resources/ is also WebDAV-enabled, then the resource with the URL http://info.sun.com/resources/ is a collection and contains http://info.sun.com/resources/info as an internal member. Property. A name/value pair that contains descriptive information about a resource. Properties are used for efficient discovery and management of resources. For example, a ’creationdate’ property might allow for the indexing of all resources by the date on which the resources were created, and an ’author’ property, for indexing by author name. Live Property. A property that is enforced by the server. For example, the live getcontentlength property has as its value, the length of the entity returned by a GET request, which is automatically calculated by the server. Live properties include the following:
Dead Property. A property that is not enforced by the server. The server only records the value of a dead property; the client is responsible for maintaining its consistency. Sun Java System Web Server supports the following live properties:
Note – Sun Java System Web Server supports the live property executable that allows clients to change the file permissions associated with a resource. An example of a PROPPATCH request for the executable live property: PROPPATCH /test/index.html HTTP/1.1 Host: sun Content-type: text/xml Content-length: XXXX <?xml version="1.0"?> <A:propertyupdate xmlns:A="DAV:" xmlns:B="http://apache.org/dav/props/"> <A:set> <A:prop> <B:executable>T</B:executable> </A:prop> </A:set> </A:propertyupdate> Locking. The ability to lock a resource provides a mechanism to guarantee that one user will not modify a resource while it is being edited by another. Locking prevents overwrite conflicts and resolves the "lost updates" problem. Sun Java System Web Server supports two types of locking: shared and exclusive. New HTTP Headers. WebDAV works by extending the HTTP/1.1 protocol. It defines new HTTP headers by which clients can communicate requests for WebDAV resources. These headers are:
New HTTP Methods. WebDAV introduces several new HTTP methods that instruct WebDAV-enabled servers how to handle requests. These methods are used in addition to existing HTTP methods such as GET, PUT, and DELETE to carry out WebDAV transactions. The new HTTP methods are briefly described below:
Enable WebDAV at Instance LevelYou can use the Administration Server to enable WebDAV for the entire server. When you do so, the following directive is added to the magnus.conf file that loads the WebDAV plugin: Init fn="load-modules" shlib="/s1ws6.1/lib/libdavplugin.so" funcs="init-dav,ntrans-dav,pcheck-dav,service-dav" shlib_flags="(global|now)" Init fn="init-dav" LateInit=yes The init-dav Init function initializes and registers the WebDAV subsystem. For enabling WebDAV execute the following command in CLI.
See CLI Reference, enable-webdav(1). Managing WebDAV CollectionsEnabling WebDAV CollectionFor enabling WebDAV collection, execute the following command:
See CLI Reference, enable-dav-collection(1). Disabling WebDAV CollectionFor disabling WebDAV collection, execute the following command:
See CLI Reference, disable-dav-collection(1). Adding a WebDAV CollectionFor adding a WebDAV Collection, execute the following command:
See CLI Reference, create-dav-collection(1). Listing WebDAV CollectionsFor listing all WebDAV collections, execute the following command:
See CLI Reference, list-dav-collections(1). Removing WebDAV CollectionFor removing WebDAV collection, execute the following command:
See CLI Reference, delete-dav-collection(1). Configuring WebDAV PropertiesSetting WebDAV PropertiesFor setting WebDAV properties at the server level, execute the following command:
See CLI Reference, set-webdav-prop(1). Viewing WebDAV PropertiesFor viewing WebDAV properties at the server level, execute the following command:
See CLI Reference, get-webdav-prop(1). Setting WebDAV Collection PropertiesFor setting WebDAV collection properties, execute the following command:
See CLI Reference, set-dav-collection-prop(1). Viewing WebDAV Collection PropertiesFor viewing WebDAV collection properties, execute the following command:
See CLI Reference, get-dav-collection-prop(1). Modifying WebDAV ParametersSome common WebDAV properties are listed in the following table: Table 10–1 WebDAV Parameters
Disabling WebDAV at Server LevelFor disabling WebDAV at server level, execute the following command:
See CLI Reference, disable-webdav(1). Managing WebDAV Authentication DatabasesFrom the administration console, click WebDAV tab from the selected configuration to edit WebDAV authentication database settings. The following table provides a short description of each field in the page: Table 10–2 WebDAV Authentication Database Properties
Using Source URI and Translate:f Header on a WebDAV-Enabled ServerWebDAV methods operate on the source of a resource or a collection. HTTP methods such as GET and PUT are overloaded by the WebDAV protocol and therefore, a request with these methods can either be a request to the source of the resource or a request to the content (output) of the resource. Microsoft and many other WebDAV vendors have addressed this problem by sending a Translate:f header with the request to inform the server that the request is for the source. In order to be interoperable with the popular WebDAV client Microsoft WebFolders, Sun Java System Web Server 7.0 recognizes the Translate:f header as a request to the source of the resource. To accommodate clients that do not send the Translate:f header, Sun Java System Web Server defines a source URI. For a WebDAV-enabled collection, the request to the URI retrieves the content (output) of the resource and a request to the source URI retrieves the source of the resource. A request to the URI with a Translate:f header is treated as a request to the source URI. Note that by default all access to the source of a resource is denied by the dav-src ACL with the following declaration in the server instance-specific ACL file: deny (all) user = "anyone"; An user can enable access to the source to a user by adding access rights to the source URI. Locking and Unlocking ResourcesSun Java System Web Server allows the server administrator to lock a resource so as to serialize access to that resource. Using a lock, a user accessing a particular resource is reassured that another user will not modify the same resource. In this way, the "lost updates" problem is resolved as multiple users share resources on the server. The lock database maintained by the server keeps track of the lock tokens issued and in use by clients. Sun Java System Web Server supports the opaquelocktoken URI scheme, which is designed to be unique across all resources for all time. This uses the Universal Unique Identifier (UUID) mechanism, as described in ISO-1157.08. Sun Java System Web Server recognizes two types of locking mechanisms:
Exclusive LocksAn exclusive lock is a lock that grants access to a resource to only a single user. Another user can access the same resource only after the exclusive lock on the resource is removed. Exclusive locking sometimes proves to be too rigid and expensive a mechanism for locking resources. For example, in the event of a program crash or the lock owner forgetting to unlock the resource, a lock timeout or the administrator’s intervention will be required to remove the exclusive lock. Shared LocksA shared lock allows multiple users to receive a lock to a resource. Hence any user with appropriate access can get the lock. When using shared locks, lock owners may use any other communication channel to coordinate their work. The intent of a shared lock is to let collaborators know who else may be working on a resource. Minimum Lock TimeoutYou can control locking by configuring the value of the minlocktimeout attribute of the DAV or DAVCOLLECTION objects in the server.xml file. The minlocktimeout attribute specifies the minimum lifetime of a lock in seconds. This value indicates the amount of time that an element will be locked before the lock is automatically removed. This is an optional attribute. If the value is set to -1, the lock will never expire. Setting the value to 0 allows all the resources in the collection to be locked with the Timeout header specified in the request. If no Timeout header is specified, then the resource is locked with infinite timeout. If a request has a Timeout header set to the value Infinite, then also, the resource is locked with infinite timeout. If the request for a WebDAV resource has a Timeout header value that is equal to or greater than the minlocktimeout value specified in server.xml, then the resource is locked for the period of time specified in the request. However, if the request has a Timeout header value that is lower than the minlocktimeout value specified in server.xml, then the resource is locked with the minlocktimeout value specified in server.xml. The following table illustrates how Sun Java System Web Server handles locking requests: Table 10–3 How Sun Java System Web Server handles locking requests
Note – Using CLI For setting lock expiry through CLI, execute the following command:
See CLI Reference, expire-lock(1). In the above example opaque-token specifies the ID of the lock that you want to set to expire. For displaying existing locks through CLI, execute the following command:
See CLI Reference, list-locks(1). |
|||||||||||||||||||||||||||||||||||||||||||||||||||