mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)
70226: Merged V4.2-BUG-FIX (4.2.3) to HEAD-BUG-FIX (4.3/Cloud) 70137: Reverse Merge V4.2-BUG-FIX (4.2.3) << Commit appears to have resulted in lots of build errors. Not obvious why. >> 70056: Merged DEV to V4.2-BUG-FIX (4.2.3) 69689 : MNT-10946 : Admin is no longer able to unlock files - Check if node is locked for non-admin users. Fix related test 69751 : MNT-10946 : Admin is no longer able to unlock files - Changed warn message git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@70491 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -66,8 +66,6 @@ import org.alfresco.service.cmr.repository.StoreRef;
|
|||||||
import org.alfresco.service.cmr.search.ResultSet;
|
import org.alfresco.service.cmr.search.ResultSet;
|
||||||
import org.alfresco.service.cmr.search.SearchService;
|
import org.alfresco.service.cmr.search.SearchService;
|
||||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||||
import org.alfresco.service.cmr.security.AuthorityService;
|
|
||||||
import org.alfresco.service.cmr.security.PermissionService;
|
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
import org.alfresco.util.PropertyCheck;
|
import org.alfresco.util.PropertyCheck;
|
||||||
@@ -96,7 +94,6 @@ public class LockServiceImpl implements LockService,
|
|||||||
private TenantService tenantService;
|
private TenantService tenantService;
|
||||||
private AuthenticationService authenticationService;
|
private AuthenticationService authenticationService;
|
||||||
private SearchService searchService;
|
private SearchService searchService;
|
||||||
private AuthorityService authorityService;
|
|
||||||
private BehaviourFilter behaviourFilter;
|
private BehaviourFilter behaviourFilter;
|
||||||
private LockStore lockStore;
|
private LockStore lockStore;
|
||||||
private PolicyComponent policyComponent;
|
private PolicyComponent policyComponent;
|
||||||
@@ -142,10 +139,6 @@ public class LockServiceImpl implements LockService,
|
|||||||
this.searchService = searchService;
|
this.searchService = searchService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAuthorityService(AuthorityService authorityService) {
|
|
||||||
this.authorityService = authorityService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialise methods called by Spring framework
|
* Initialise methods called by Spring framework
|
||||||
*/
|
*/
|
||||||
@@ -480,8 +473,6 @@ public class LockServiceImpl implements LockService,
|
|||||||
|
|
||||||
if (lockState.isLockInfo())
|
if (lockState.isLockInfo())
|
||||||
{
|
{
|
||||||
// check if the node is the user able to unlock the node
|
|
||||||
checkForLockIfNotAdmin(nodeRef);
|
|
||||||
// MNT-231: forbidden to unlock a checked out node
|
// MNT-231: forbidden to unlock a checked out node
|
||||||
if (!allowCheckedOut && nodeService.hasAspect(nodeRef, ContentModel.ASPECT_CHECKED_OUT))
|
if (!allowCheckedOut && nodeService.hasAspect(nodeRef, ContentModel.ASPECT_CHECKED_OUT))
|
||||||
{
|
{
|
||||||
@@ -512,8 +503,8 @@ public class LockServiceImpl implements LockService,
|
|||||||
}
|
}
|
||||||
else if (lifetime == Lifetime.EPHEMERAL)
|
else if (lifetime == Lifetime.EPHEMERAL)
|
||||||
{
|
{
|
||||||
// force unlock the ephemeral lock.
|
// Remove the ephemeral lock.
|
||||||
lockStore.forceUnlock(nodeRef);
|
lockStore.set(nodeRef, LockState.createUnlocked(nodeRef));
|
||||||
nodeIndexer.indexUpdateNode(nodeRef);
|
nodeIndexer.indexUpdateNode(nodeRef);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -666,16 +657,6 @@ public class LockServiceImpl implements LockService,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkForLockIfNotAdmin(NodeRef nodeRef)
|
|
||||||
{
|
|
||||||
Set<String> userAuthorities = authorityService.getAuthoritiesForUser(AuthenticationUtil.getRunAsUser());
|
|
||||||
// ignore checkForLock for admins
|
|
||||||
if (!userAuthorities.contains(PermissionService.ADMINISTRATOR_AUTHORITY))
|
|
||||||
{
|
|
||||||
checkForLock(nodeRef);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures that the parent is not locked.
|
* Ensures that the parent is not locked.
|
||||||
*
|
*
|
||||||
|
@@ -68,19 +68,8 @@ public abstract class AbstractLockStore<T extends ConcurrentMap<NodeRef, LockSta
|
|||||||
return lockState;
|
return lockState;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void forceUnlock(NodeRef nodeRef)
|
|
||||||
{
|
|
||||||
set(nodeRef, LockState.createUnlocked(nodeRef), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void set(NodeRef nodeRef, LockState lockState)
|
public void set(NodeRef nodeRef, LockState lockState)
|
||||||
{
|
|
||||||
set(nodeRef, lockState, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void set(NodeRef nodeRef, LockState lockState, boolean ignoreOwnerCheck)
|
|
||||||
{
|
{
|
||||||
Map<NodeRef, LockState> txMap = getTxMap();
|
Map<NodeRef, LockState> txMap = getTxMap();
|
||||||
LockState previousLockState = null;
|
LockState previousLockState = null;
|
||||||
@@ -113,7 +102,7 @@ public abstract class AbstractLockStore<T extends ConcurrentMap<NodeRef, LockSta
|
|||||||
String userName = AuthenticationUtil.getFullyAuthenticatedUser();
|
String userName = AuthenticationUtil.getFullyAuthenticatedUser();
|
||||||
String owner = previousLockState.getOwner();
|
String owner = previousLockState.getOwner();
|
||||||
Date expires = previousLockState.getExpires();
|
Date expires = previousLockState.getExpires();
|
||||||
if (!ignoreOwnerCheck && LockUtils.lockStatus(userName, owner, expires) == LockStatus.LOCKED)
|
if (LockUtils.lockStatus(userName, owner, expires) == LockStatus.LOCKED)
|
||||||
{
|
{
|
||||||
throw new UnableToAquireLockException(nodeRef);
|
throw new UnableToAquireLockException(nodeRef);
|
||||||
}
|
}
|
||||||
|
@@ -35,13 +35,6 @@ public interface LockStore
|
|||||||
void set(NodeRef nodeRef, LockState lockState);
|
void set(NodeRef nodeRef, LockState lockState);
|
||||||
public Set<NodeRef> getNodes();
|
public Set<NodeRef> getNodes();
|
||||||
|
|
||||||
/**
|
|
||||||
* WARNING: only use in lockService - unlocks node ignoring lockOwner
|
|
||||||
*
|
|
||||||
* @param nodeRef
|
|
||||||
*/
|
|
||||||
void forceUnlock(NodeRef nodeRef);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WARNING: only use in test code - unsafe method for production use.
|
* WARNING: only use in test code - unsafe method for production use.
|
||||||
*
|
*
|
||||||
|
@@ -33,7 +33,6 @@ import org.alfresco.repo.lock.mem.LockStore;
|
|||||||
import org.alfresco.repo.search.IndexerAndSearcher;
|
import org.alfresco.repo.search.IndexerAndSearcher;
|
||||||
import org.alfresco.repo.search.SearcherComponent;
|
import org.alfresco.repo.search.SearcherComponent;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
|
||||||
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
|
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
|
||||||
import org.alfresco.service.cmr.lock.LockService;
|
import org.alfresco.service.cmr.lock.LockService;
|
||||||
import org.alfresco.service.cmr.lock.LockStatus;
|
import org.alfresco.service.cmr.lock.LockStatus;
|
||||||
@@ -905,40 +904,4 @@ public class LockServiceImplTest extends BaseSpringTest
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUnlockEphemeralNodeWithAdminUser()
|
|
||||||
{
|
|
||||||
for (Lifetime lt : new Lifetime[]{Lifetime.EPHEMERAL, Lifetime.PERSISTENT})
|
|
||||||
{
|
|
||||||
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
|
|
||||||
|
|
||||||
/* create node */
|
|
||||||
final NodeRef testNode =
|
|
||||||
this.nodeService.createNode(parentNode, ContentModel.ASSOC_CONTAINS, QName.createQName("{}testNode"), ContentModel.TYPE_CONTAINER).getChildRef();
|
|
||||||
|
|
||||||
// lock it as GOOD user
|
|
||||||
this.lockService.lock(testNode, LockType.WRITE_LOCK, 2 * 86400, lt, null);
|
|
||||||
|
|
||||||
TestWithUserUtils.authenticateUser(BAD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// try to unlock as bad user
|
|
||||||
this.lockService.unlock(testNode);
|
|
||||||
fail("BAD user shouldn't be able to unlock " + lt + " lock");
|
|
||||||
}
|
|
||||||
catch(NodeLockedException e)
|
|
||||||
{
|
|
||||||
// it's expected
|
|
||||||
}
|
|
||||||
|
|
||||||
TestWithUserUtils.authenticateUser(AuthenticationUtil.getAdminUserName(), "admin", rootNodeRef, this.authenticationService);
|
|
||||||
|
|
||||||
// try to unlock as ADMIN user
|
|
||||||
this.lockService.unlock(testNode);
|
|
||||||
|
|
||||||
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
|
|
||||||
|
|
||||||
this.nodeService.deleteNode(testNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user