Hi all,
I want to lock a particular document present in the marklogic
database, so that other users can't do any update/ modification to that
document untill the lock is released.
To achieve this task marklogic provides inbuilt functions
xdmp:lock-acquire() - Acquire a lock on a document or directory .
xdmp:lock-release() - Unlock a document or directory.
I used xdmp:lock-acquire() to lock a document by an user, but still that
particular document is modifiable(update/insert data to that document) by
other user.
Locking of document: (Current user name is : admin)
<result>
{
try{
<current-user>
{
xdmp:get-current-user( )
}
</current-user>,
xdmp:lock-acquire("harmonyUsers.xml",
"shared",
"infinity",
<href>http://example.com/~user</href>,
())
}catch ($e) {
"Error during acquiring lock on the document", $e
},
"Document locked"
}
</result>
Inserting a record to the same document (locked) by another user :
(Current user name is : santhosh)
xquery version "1.0-ml";
(: __________________________________________________________
:: (Q1.1)
:: Trying to insert a child node to the locked document.
::
:: __________________________________________________________
:)
<role-screen>
{
let $u := doc("harmonyUsers.xml")//use...@locked="false"]
return
if($u) then (
xdmp:node-insert-child($u,<user>
<userName>sonabh123</userName>
<userId>sonabh123</userId>
<password>sonabh123</password>
<role>123456</role>
</user>),
xdmp:get-current-user( )
)
else ()
}
</role-screen>
This insert operation is done successfully even though the document is
locked by other user(admin) .
This is the document which i loaded to marklogic server.
Can any body please suggest some solution or idea to this problem.
Thanks in advance.
Regards,
Santhosh Rajasekaran
Tata Consultancy Services
Mailto: [email protected]
Website: http://www.tcs.com
____________________________________________
Experience certainty. IT Services
Business Solutions
Outsourcing
____________________________________________
=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
users.xml
Description: Binary data
_______________________________________________ General mailing list [email protected] http://xqzone.com/mailman/listinfo/general
