smbdav
Class SmbDAVUtilities

java.lang.Object
  extended bysmbdav.SmbDAVUtilities

public class SmbDAVUtilities
extends java.lang.Object

This class contains static utility methods for the Davenport servlet and its associated classes.

Author:
Eric Glass

Field Summary
static int CHILDREN_DEPTH
          Depth constant indicating that the operation applies to the targeted resource and its immediate children.
static int INFINITE_DEPTH
          Depth constant indicating that the operation applies to the targeted resource and all of its progeny.
static long INFINITE_TIMEOUT
          Timeout constant indicating an infinite lock timeout.
static long MAXIMUM_TIMEOUT
          Timeout constant representing the maximum lock timeout value.
static int RESOURCE_ONLY_DEPTH
          Depth constant indicating that the operation applies only to the targeted resource itself.
static long UNSPECIFIED_TIMEOUT
          Timeout constant indicating an unspecified lock timeout.
 
Method Summary
static java.lang.String formatCreationDate(long creation)
          Formats a timestamp (representing milliseconds since the epoch) as used in the WebDAV creationdate property.
static java.lang.String formatGetLastModified(long lastModified)
          Formats a timestamp (representing milliseconds since the epoch) as used in the WebDAV getlastmodified property.
static java.lang.String formatTimeout(long timeout)
          Utility method to format a lock timeout value for use in the "Timeout" header.
static java.lang.String generateUuid()
          Generates a UUID, as described in ISO-11578.
static java.lang.String getETag(jcifs.smb.SmbFile file)
          Returns the entity tag for the specified resource.
static java.lang.String getResource(java.lang.Class context, java.lang.String resource, java.lang.Object[] parameters, java.util.Locale locale)
          Returns the specified resource string value.
static void lockDiscovery(jcifs.smb.SmbFile file, LockManager lockManager, org.w3c.dom.Element destination)
          Utility method to output the "lockdiscovery" XML for the active locks on the specified SMB resource, as managed by the specified lock manager.
static int parseDepth(java.lang.String depth)
          Utility method to parse the "Depth" header.
static long parseTimeout(java.lang.String timeout)
          Utility method to parse the "Timeout" header.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RESOURCE_ONLY_DEPTH

public static final int RESOURCE_ONLY_DEPTH
Depth constant indicating that the operation applies only to the targeted resource itself.

See Also:
Constant Field Values

CHILDREN_DEPTH

public static final int CHILDREN_DEPTH
Depth constant indicating that the operation applies to the targeted resource and its immediate children.

See Also:
Constant Field Values

INFINITE_DEPTH

public static final int INFINITE_DEPTH
Depth constant indicating that the operation applies to the targeted resource and all of its progeny.

See Also:
Constant Field Values

UNSPECIFIED_TIMEOUT

public static final long UNSPECIFIED_TIMEOUT
Timeout constant indicating an unspecified lock timeout.

See Also:
Constant Field Values

INFINITE_TIMEOUT

public static final long INFINITE_TIMEOUT
Timeout constant indicating an infinite lock timeout.

See Also:
Constant Field Values

MAXIMUM_TIMEOUT

public static final long MAXIMUM_TIMEOUT
Timeout constant representing the maximum lock timeout value.

See Also:
Constant Field Values
Method Detail

getResource

public static java.lang.String getResource(java.lang.Class context,
                                           java.lang.String resource,
                                           java.lang.Object[] parameters,
                                           java.util.Locale locale)
Returns the specified resource string value.

Parameters:
context - A class representing the context for the resource string.
resource - The resource name.
parameters - Substitution parameters for the message.
locale - The desired locale.
Returns:
A String containing the resource value.

formatCreationDate

public static java.lang.String formatCreationDate(long creation)
Formats a timestamp (representing milliseconds since the epoch) as used in the WebDAV creationdate property.

Parameters:
creation - The creation timestamp, represented as the number of milliseconds since midnight, January 1, 1970 UTC.
Returns:
A String containing the formatted result.

formatGetLastModified

public static java.lang.String formatGetLastModified(long lastModified)
Formats a timestamp (representing milliseconds since the epoch) as used in the WebDAV getlastmodified property.

Parameters:
lastModified - The last modification timestamp, represented as the number of milliseconds since midnight, January 1, 1970 UTC.
Returns:
A String containing the formatted result.

getETag

public static java.lang.String getETag(jcifs.smb.SmbFile file)
Returns the entity tag for the specified resource. The returned string uniquely identifies the current incarnation of the given resource.

Parameters:
file - The resource whose entity tag is to be retrieved.
Returns:
A String containing the entity tag for the resource.

parseDepth

public static int parseDepth(java.lang.String depth)
Utility method to parse the "Depth" header.

Parameters:
depth - The value of the WebDAV "Depth" header.
Returns:
An int containing the depth code. One of RESOURCE_ONLY_DEPTH, CHILDREN_DEPTH, or INFINITE_DEPTH.

formatTimeout

public static java.lang.String formatTimeout(long timeout)
Utility method to format a lock timeout value for use in the "Timeout" header.

Parameters:
timeout - The timeout value in milliseconds.
Returns:
A String containing the formatted timeout value. If the provided timeout is UNSPECIFIED_TIMEOUT, this method returns null. If the value is INFINITE_TIMEOUT, this returns the string "Infinite". For all other values, this method returns a string of the form "Second-nnnn", where nnnn is the timeout value converted to seconds. If the value is greater than MAXIMUM_TIMEOUT, MAXIMUM_TIMEOUT will be used instead.

parseTimeout

public static long parseTimeout(java.lang.String timeout)
Utility method to parse the "Timeout" header. This implementation recognizes the "Infinite" keyword, as well as the "Second-xxxxx" format.

Parameters:
timeout - The value of the WebDAV "Timeout" header.
Returns:
A long containing the timeout value in milliseconds. UNSPECIFIED_TIMEOUT indicates no timeout value was specified or recognized. INFINITE_TIMEOUT indicates an infinite timeout was requested.

lockDiscovery

public static void lockDiscovery(jcifs.smb.SmbFile file,
                                 LockManager lockManager,
                                 org.w3c.dom.Element destination)
                          throws java.io.IOException
Utility method to output the "lockdiscovery" XML for the active locks on the specified SMB resource, as managed by the specified lock manager.

Parameters:
file - The SMB resource whose active locks are to be enumerated.
lockManager - The lock manager to examine.
destination - The element under which the active locks will be enumerated. This would typically be a "lockdiscovery" element.
Throws:
java.io.IOException

generateUuid

public static java.lang.String generateUuid()
Generates a UUID, as described in ISO-11578.

Returns:
A String containing a globally unique UUID.


Copyright © 2004 Eric Glass