public class LockMethod extends XMLResponseMethodBase implements DepthSupport
Per the specification, a lock indicates that someone is updating the resource, (hence the lock is a "write lock"), although the specification notes that the the syntax is extensible, and permits the eventual creation of locking for other access types.
The most basic form of lock is an exclusive lock. This is a lock where the access right in question is only granted to a single client. The need for this arbitration results from a desire to avoid having to merge results. However, there are times when the goal of a lock is not to exclude others from exercising an access right but rather to provide a mechanism for principals to indicate that they intend to exercise their access rights. Shared locks are provided for this case. A shared lock allows multiple clients to receive a lock. Hence any user with appropriate access can get the lock.
With shared locks there are two trust sets that affect a resource. The first trust set is created by access permissions. Principals who are trusted, for example, may have permission to write to the resource. Among those who have access permission to write to the resource, the set of principals who have taken out a shared lock also must trust each other, creating a (typically) smaller trust set within the access permission write set.
The following table indicates what happens if a new lock request is sent to a resource that is already locked:
Lock Request | ||
---|---|---|
Current Lock | Exclusive Lock | Shared Lock |
None | Success | Sucess |
Shared | Failure | Sucess |
Exclusive | Failure | Failure |
XMLResponseMethodBase.OptionsResponse, XMLResponseMethodBase.Response, XMLResponseMethodBase.ResponseWithinMultistatus, XMLResponseMethodBase.SingleResponse
Modifier and Type | Field and Description |
---|---|
static short |
SCOPE_EXCLUSIVE |
static short |
SCOPE_SHARED |
static int |
TIMEOUT_INFINITY |
static short |
TYPE_WRITE |
builder, decodeResponseHrefs, responseURLs
effectiveVersion, statusLine
DEPTH_0, DEPTH_1, DEPTH_INFINITY
Constructor and Description |
---|
LockMethod()
Method constructor.
|
LockMethod(java.lang.String path)
Method constructor.
|
LockMethod(java.lang.String path,
java.lang.String refreshOpaqueToken,
int timeout)
Method constructor.
|
LockMethod(java.lang.String path,
java.lang.String owner,
int timeout,
boolean isTransaction)
Creates a lock method that can start a transaction when server supports
them in a
MS like style.
|
LockMethod(java.lang.String path,
java.lang.String refreshOpaqueToken,
long timeout)
Deprecated.
The timeout value MUST NOT be greater than 2^32-1.
|
LockMethod(java.lang.String path,
java.lang.String owner,
short scope,
int timeout)
Method constructor.
|
LockMethod(java.lang.String path,
java.lang.String owner,
short scope,
long timeout)
Deprecated.
The timeout value MUST NOT be greater than 2^32-1.
|
Modifier and Type | Method and Description |
---|---|
void |
addRequestHeaders(org.apache.commons.httpclient.HttpState state,
org.apache.commons.httpclient.HttpConnection conn)
Generate additional headers needed by the request.
|
protected java.lang.String |
generateRequestBody()
DAV requests that contain a body must override this function to
generate that body.
|
int |
getDepth()
Depth getter.
|
java.lang.String |
getLockToken() |
java.lang.String |
getName() |
java.lang.String |
getOwner()
Return the owner of the lock as reported by the server.
|
short |
getScope() |
int |
getTimeout()
get the timeout value.
|
boolean |
isRefresh() |
boolean |
isTypeTransaction() |
void |
parseResponse(java.io.InputStream input,
org.apache.commons.httpclient.HttpState state,
org.apache.commons.httpclient.HttpConnection conn)
Parse response.
|
void |
recycle()
Reset the State of the class to its initial state, so that it can be
used again.
|
void |
setDepth(int depth)
Depth setter.
|
void |
setOwner(java.lang.String owner)
Sets the owner of the lock.
|
void |
setRequestHeader(java.lang.String headerName,
java.lang.String headerValue)
Set a header value, redirecting the special cases of Depth and Time headers
to
setDepth(int) and setTimeout(int) as appropriate. |
void |
setScope(short scope) |
void |
setTimeout(int timeout)
Set the timeout value.
|
void |
setTimeout(long timeout)
Deprecated.
The timeout value MUST NOT be greater than 2^32-1.
|
void |
setTypeTransaction(boolean typeTransaction) |
convertElementToProperty, getDebug, getRequestContentLength, getResponseDocument, getResponseHashtable, getResponses, getResponseURLs, parseXMLResponse, readResponseBody, setDebug, setDecodeResponseHrefs, setDocument, setResponseHashtable, writeRequestBody
isRequestContentAlreadySet, readContinueCode, setRequestBody, setRequestBody, setRequestBody, setRequestBody, setRequestBody
abort, addCookieRequestHeader, addHostRequestHeader, addProxyConnectionHeader, addRequestHeader, addRequestHeader, addResponseFooter, addUserAgentRequestHeader, checkNotUsed, checkUsed, execute, generateRequestLine, getAuthenticationRealm, getContentCharSet, getDoAuthentication, getEffectiveVersion, getFollowRedirects, getHostAuthState, getHostConfiguration, getMethodRetryHandler, getParams, getPath, getProxyAuthenticationRealm, getProxyAuthState, getQueryString, getRecoverableExceptionCount, getRequestCharSet, getRequestHeader, getRequestHeaderGroup, getRequestHeaders, getRequestHeaders, getResponseBody, getResponseBody, getResponseBodyAsStream, getResponseBodyAsString, getResponseBodyAsString, getResponseCharSet, getResponseContentLength, getResponseFooter, getResponseFooters, getResponseHeader, getResponseHeaderGroup, getResponseHeaders, getResponseHeaders, getResponseStream, getResponseTrailerHeaderGroup, getStatusCode, getStatusLine, getStatusText, getURI, hasBeenUsed, isAborted, isConnectionCloseForced, isHttp11, isRequestSent, isStrictMode, processCookieHeaders, processResponseBody, processResponseHeaders, processStatusLine, readResponse, readResponseHeaders, readStatusLine, releaseConnection, removeRequestHeader, removeRequestHeader, responseBodyConsumed, setConnectionCloseForced, setDoAuthentication, setFollowRedirects, setHostConfiguration, setHttp11, setMethodRetryHandler, setParams, setPath, setQueryString, setQueryString, setRequestHeader, setResponseStream, setStrictMode, setURI, shouldCloseConnection, validate, writeRequest, writeRequestHeaders, writeRequestLine
public static final short SCOPE_EXCLUSIVE
public static final short SCOPE_SHARED
public static final short TYPE_WRITE
public static final int TIMEOUT_INFINITY
public LockMethod(java.lang.String path, java.lang.String owner, int timeout, boolean isTransaction)
Transaction
header with the lock token as value. You will have to enclose it in '<' and '>' just
like ordinary lock tokens.
UnlockMethod
.path
- any path inside Slide's scopeowner
- of this transactiontimeout
- timeout of this transactionisTransaction
- true
when this method is used to starte a transactionpublic LockMethod()
public LockMethod(java.lang.String path)
public LockMethod(java.lang.String path, java.lang.String refreshOpaqueToken, int timeout)
public LockMethod(java.lang.String path, java.lang.String owner, short scope, int timeout)
public LockMethod(java.lang.String path, java.lang.String refreshOpaqueToken, long timeout)
public LockMethod(java.lang.String path, java.lang.String owner, short scope, long timeout)
public void setRequestHeader(java.lang.String headerName, java.lang.String headerValue)
setDepth(int)
and setTimeout(int)
as appropriate.setRequestHeader
in interface org.apache.commons.httpclient.HttpMethod
setRequestHeader
in class org.apache.commons.httpclient.HttpMethodBase
headerName
- Header nameheaderValue
- Header valuepublic boolean isTypeTransaction()
public void setTypeTransaction(boolean typeTransaction)
public void setDepth(int depth)
setDepth
in interface DepthSupport
depth
- New depth valuepublic int getDepth()
getDepth
in interface DepthSupport
public java.lang.String getLockToken()
public boolean isRefresh()
public short getScope()
public void setOwner(java.lang.String owner)
setOwner("Jezebel Lipshitz")
will
produce an owner
element in the request document like this:
<D:owner>Jezebel Lipshitz</D:owner>
Examples in the Webdav specification suggest that one can use e-mail addresses, home page URLs, or other information; this implementation doesn't handle any of that.
public java.lang.String getOwner()
public void setScope(short scope)
public int getTimeout()
public void setTimeout(int timeout)
public void setTimeout(long timeout)
public java.lang.String getName()
getName
in interface org.apache.commons.httpclient.HttpMethod
getName
in class org.apache.commons.httpclient.HttpMethodBase
public void recycle()
XMLResponseMethodBase
recycle
in interface org.apache.commons.httpclient.HttpMethod
recycle
in class XMLResponseMethodBase
public void addRequestHeaders(org.apache.commons.httpclient.HttpState state, org.apache.commons.httpclient.HttpConnection conn) throws java.io.IOException, org.apache.commons.httpclient.HttpException
addRequestHeaders
in class org.apache.commons.httpclient.HttpMethodBase
state
- State tokenconn
- The connection being used for the request.java.io.IOException
org.apache.commons.httpclient.HttpException
protected java.lang.String generateRequestBody()
The default behavior simply returns an empty body.
generateRequestBody
in class XMLResponseMethodBase
public void parseResponse(java.io.InputStream input, org.apache.commons.httpclient.HttpState state, org.apache.commons.httpclient.HttpConnection conn) throws java.io.IOException, org.apache.commons.httpclient.HttpException
parseResponse
in class XMLResponseMethodBase
input
- Input streamjava.io.IOException
org.apache.commons.httpclient.HttpException