Post Lock Request

To acquire a lock the client must send a POST request to the resource's lock collection URI. The posted file must contain a valid Atom entry element like this:

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:metadata="http://xmlns.escenic.com/2010/atom-metadata">
  <summary type="text">Lock created by: User1 from WS</summary>
  <metadata:fragment>TITLE</metadata:fragment>
</entry>

The metadata:fragment element is only required when requesting a fragment lock. Omit it to request a resource lock.

The request must contain a Content-Type header the value application/atom+xml;type=entry. A valid request might look like this:

curl --include -u user:password -X POST -H "Content-Type: application/atom+xml;type=entry" \
     http://host-ip-address/webservice/escenic/lock/article/4 \
     --upload-file atom-entry-file

where atom-entry-file is the path of a file containing an Atom entry like the one shown above.

If the lock request succeeds, then the web service returns a 201 Created response in which Location contains the resource's private lock URI:

HTTP/1.1 201 Created
Server: Apache-Coyote/1.1
Location: http://host-ip-address/webservice/escenic/lock/article/4/private/9
Content-Length: 0
Date: Sat, 04 Dec 2010 02:35:38 GMT

If the lock request fails because the requested resource is already locked someone else has already locked the resource then the web service returns a 409 CONFLICT response.

Once the client has acquired the private lock URI, it can proceed with the update as described in Put Updated Resource. If, however, the client needs information about the lock for some reason, it can retrieve the lock resource by sending a GET request to the private lock URI:

curl --include -u user:password http://host-ip-address/webservice/escenic/lock/article/4/private/9

The web service then returns an entry containing information about the lock:

<?xml version="1.0"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:age="http://purl.org/atompub/age/1.0" xmlns:metadata="http://xmlns.escenic.com/2010/atom-metadata">
  <id>http://host-ip-address/webservice/escenic/lock/article/4/public/39</id>
  <title type="text">Lock of the fragment TITLE</title>
  <link href="http://host-ip-address/webservice/escenic/lock/article/4/public/39" rel="self"/>
  <metadata:fragment>TITLE</metadata:fragment>
  <author>
    <uri>http://host-ip-address/webservice/escenic/person/1</uri>
    <name>pub1 Administrator</name>
  </author>
  <updated>2010-12-04T02:35:39.000Z</updated>
  <age:expires>2010-12-05T02:35:39.000Z</age:expires>
  <summary type="text"/>
  <content type="text">The fragment 'TITLE' of the resource is locked by pub1 Administrator</content>
</entry>

Note that the content of this resource is identical to the content of the public lock resource (the self link, for example, contains the URI of the public lock rather than the private lock).