02-27-2009 06:01 AM
private void unlockWith(final NodeRef pNodeRef, String pUsername) {
System.out.println( "pUsername:" + pUsername );
String lCurrentUsername = AuthenticationUtil.getCurrentUserName();
System.out.println( "lCurrentUsername:" + lCurrentUsername );
AuthenticationUtil.RunAsWork<Object> lWork = new AuthenticationUtil.RunAsWork<Object>() {
public Object doWork() throws Exception {
lockService.unlock( pNodeRef );
return null;
}
};
AuthenticationUtil.runAs( lWork, pUsername );
//maybe usefull
AuthenticationUtil.runAs( lWork, "admin" );
AuthenticationUtil.setCurrentUser( lCurrentUsername );
System.out.println( "AuthenticationUtil.getCurrentUserName():"
+ AuthenticationUtil.getCurrentUserName() );
}
var query = "TYPE:\"msc:courrier\"";
var nodes = search.luceneSearch(query);
var i;
var j =0;
for (i = 0; i < nodes.length; i++)
{
if (nodes[i].isLocked || nodes[i].isLockedOwner) {
j++;
}
}
if (logger.isLoggingEnabled())
logger.log("noeud lockes="+j);
02-27-2009 07:48 AM
LockStatus lLockStatus = lockService.getLockStatus( lNodeRef );
if (lLockStatus.equals( LockStatus.LOCK_OWNER ))
{
unlockWith( lNodeRef, AuthenticationUtil.getCurrentUserName() );
}
if (lLockStatus.equals( LockStatus.LOCKED ))
{
String lUsername = (String) nodeService.getProperty( lNodeRef,
ContentModel.PROP_LOCK_OWNER );
unlockWith( lNodeRef, lUsername );
}
private void unlockWith(final NodeRef pNodeRef, String pUsername) {
String lCurrentUsername = AuthenticationUtil.getCurrentUserName();
AuthenticationUtil.RunAsWork<Object> lWork = new AuthenticationUtil.RunAsWork<Object>() {
public Object doWork() throws Exception {
lockService.unlock( pNodeRef );
return null;
}
};
AuthenticationUtil.runAs( lWork, pUsername );
AuthenticationUtil.setCurrentUser( lCurrentUsername );
}
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.