Dave Ward f6c9247876 Merged V4.1-BUG-FIX to HEAD
44796: Fix for ALF-16413 - Share asks for Basic-Auth while not needed trying to access RSS feeds (thus breaking SSO).
    - Share Feed Controller which correctly deals with SSO config for the "alfresco-feed" endpoint
   Configure the "alfresco-feed" endpoint to use SSO in the same way the "alfresco" endpoint is configured for it. Share will then detect this when serving feeds and ensure the SSO auth is used ahead of Basic HTTP auth.
   44820: Merged V3.4-BUG-FIX (3.4.12) to V4.1-BUG-FIX (4.1.3)
      - A few extra 4.x changes were required
      44818: ALF-17256 (3.4.12) Update Copyright notice to 2013 
   44831: ALF-17224 (All wiki pages are enumerated/built to display a single wiki page)
   44841: ALF-17206	CIFS loses metadata when metadata edited from Windows 7 Explorer
   44844: Incremented version revision to 4.1.4
   44848: Fix for     ALF-17178 SolrLuceneAnalyser.findAnalyser generating InavlidQNameExceptions wher they are easily protected.
   44849: Fix for     ALF-17162 Queries for content properties with a long search string causes huge amount of memory usage
   44851: ALF-17224: Improvements for the wiki dashlet
   44866: Merged PATCHES/V4.1.1 to V4.1-BUG-FIX
      44663: ALF-17281 / MNT-231: Unable to cancel editing on certain docs in 4.1.1.10
      - It's now impossible for WebDAV or anything else execpt CheckOutCheckInService to unlock a checked out node
      - It's also now possible to un check out / check in broken unlocked nodes, such as those on ts.alfresco.com!
      - Unit tests by Viachaslau Tikhanovich
      44664: ALF-17281 / MNT-231: Unable to cancel editing on certain docs in 4.1.1.10
      - File missed in previous checkin
   44867: ALF-17285: Merged PATCHES/V4.0.1 to V4.1-BUG-FIX
      44766: MNT-241: Severe performance issues with WebDAV / filesystem / IMAP rename operations
      - FileFolderServiceImpl.rename calls moveNode to do its renaming work
      - Unfortunately AbstractNodeDAOImpl.moveNode() was not optimized for the rename case and attempted to cascade-recompute ACLs on a simple folder rename
      - On a large hierarchy this could result in hanging transactions and delays of several minutes whilst all the node ACLs were repointed and all the node caches were invalidate
      44787: MNT-241: Fixed merge issue.
      44823: MNT-241: Severe performance issues with WebDAV / filesystem / IMAP rename operations
      - The last optimization revealed a caching problem
      - The childByName cache was retaining stale values because node renaming wasn't incrementing the node version key
      - We were previously relying on the unnecessary ACL re-evaluation on a move to 'bump' the version key and invalidate the childByName cache as a side effect
      - Now we explicitly invalidate childByNameCache when necessary and also update parent association rows individually rather than in bulk, hopefully avoiding unnecessary database lock contention
      44830: MNT-241: Subtlety: On rename we only update and invalidate those associations for which name uniqueness checking is enforced. Such associations have a positive CRC
   44868: Merged PATCHES/V4.1.3 to V4.1-BUG-FIX (RECORD ONLY)
      44845: Incremented version revision to 4.1.3
      44847: Merged PATCHES/V4.1.1 to PATCHES/V4.1.3
      44863: ALF-17285: Merged PATCHES/V4.0.1 to PATCHES/V4.1.3
      44864: ALF-15935: Merge V4.1-BUG-FIX to V4.1.3
        44029 : MNT-180 - Clone for Hotfix: Word document on Windows via CIFS becomes locked (Read Only) when network drops temporarily
      44865: Merged V4.1-BUG-FIX to PATCHES/V4.1.3
   44872: Merged PATCHES/V4.1.3 to V4.1-BUG-FIX
      44871: Fixed merge issue
   44875: Merged V4.1-BUG-FIX (4.1.2) to V3.4-BUG-FIX (3.4.12) RECORD ONLY
      44815: Merged V4.1-BUG-FIX to V3.4-BUG-FIX
         44776: ALF-17164: Fix failing build in case build is not run in continuous mode - move generation of version.properties out of continuous mode
      44874: ALF-17283: Merged V4.1-BUG-FIX (4.1.2) to V3.4-BUG-FIX (3.4.12)
         41411: Fix possible FTP data session leak if client mixes PORT and PASV commands. ALF-15126
   44876: Merged DEV to V4.1-BUG-FIX
      44838: ALF-14468: Unable to authorize to Facebook
      Add 'www' to 'alfresco.com' urls.
   44878: ALF-17208 - category.ftl does not allow to find multiple tags in Share advanced Search
   44879: Fix for ALF-17150 - Edit Online action missing in Share for some mime types
   44880: Fix to merge fail (rev 44866/44872)
   44881: Fix for ALF-17186 - JBOSS specific: Google Docs v2 are not working
   44904: Fix build
   - Merry Christmas!
   44906: Merged V3.4-BUG-FIX to V4.1-BUG-FIX
      44882: Fix for ALF-13805 - Authenticating Share RSS feed using cookies rather than basic auth
      44884: Incremented version revision to 3.4.13
      44903: Merged V3.4 to V3.4-BUG-FIX
         44885: Fix unit test to cope with ALF-14421 version label behaviour (major unless specified).
      44905: Merged V3.4 to V3.4-BUG-FIX (RECORD ONLY)
         44883: Merged V3.4-BUG-FIX to V3.4 (3.4.12)


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@44910 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
2012-12-21 10:34:39 +00:00

557 lines
23 KiB
Java

/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.repo.lock;
import static org.junit.Assert.assertNotNull;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
import org.alfresco.service.cmr.lock.LockService;
import org.alfresco.service.cmr.lock.LockStatus;
import org.alfresco.service.cmr.lock.LockType;
import org.alfresco.service.cmr.lock.NodeLockedException;
import org.alfresco.service.cmr.lock.UnableToAquireLockException;
import org.alfresco.service.cmr.lock.UnableToReleaseLockException;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.security.MutableAuthenticationService;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.BaseSpringTest;
import org.alfresco.util.TestWithUserUtils;
/**
* Simple lock service test
*
* @author Roy Wetherall
*/
public class LockServiceImplTest extends BaseSpringTest
{
/**
* Services used in tests
*/
private NodeService nodeService;
private LockService lockService;
private MutableAuthenticationService authenticationService;
private CheckOutCheckInService cociService;
/**
* Data used in tests
*/
private NodeRef parentNode;
private NodeRef childNode1;
private NodeRef childNode2;
private NodeRef noAspectNode;
private NodeRef checkedOutNode;
private static final String GOOD_USER_NAME = "goodUser";
private static final String BAD_USER_NAME = "badUser";
private static final String PWD = "password";
NodeRef rootNodeRef;
private StoreRef storeRef;
/**
* Called during the transaction setup
*/
protected void onSetUpInTransaction() throws Exception
{
this.nodeService = (NodeService)applicationContext.getBean("dbNodeService");
this.lockService = (LockService)applicationContext.getBean("lockService");
this.authenticationService = (MutableAuthenticationService)applicationContext.getBean("authenticationService");
this.cociService = (CheckOutCheckInService) applicationContext.getBean("checkOutCheckInService");
// Set the authentication
AuthenticationComponent authComponent = (AuthenticationComponent)this.applicationContext.getBean("authenticationComponent");
authComponent.setSystemUserAsCurrentUser();
// Create the node properties
HashMap<QName, Serializable> nodeProperties = new HashMap<QName, Serializable>();
nodeProperties.put(QName.createQName("{test}property1"), "value1");
// Create a workspace that contains the 'live' nodes
storeRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
// Get a reference to the root node
rootNodeRef = this.nodeService.getRootNode(storeRef);
// Create node
this.parentNode = this.nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName("{}ParentNode"),
ContentModel.TYPE_CONTAINER,
nodeProperties).getChildRef();
this.nodeService.addAspect(this.parentNode, ContentModel.ASPECT_LOCKABLE, new HashMap<QName, Serializable>());
HashMap<QName, Serializable> audProps = new HashMap<QName, Serializable>();
audProps.put(ContentModel.PROP_CREATOR, "Monkey");
this.nodeService.addAspect(this.parentNode, ContentModel.ASPECT_AUDITABLE, audProps);
assertNotNull(this.parentNode);
// Add some children to the node
this.childNode1 = this.nodeService.createNode(
this.parentNode,
ContentModel.ASSOC_CHILDREN,
QName.createQName("{}ChildNode1"),
ContentModel.TYPE_CONTAINER,
nodeProperties).getChildRef();
this.nodeService.addAspect(this.childNode1, ContentModel.ASPECT_LOCKABLE, new HashMap<QName, Serializable>());
assertNotNull(this.childNode1);
this.childNode2 = this.nodeService.createNode(
this.parentNode,
ContentModel.ASSOC_CHILDREN,
QName.createQName("{}ChildNode2"),
ContentModel.TYPE_CONTAINER,
nodeProperties).getChildRef();
this.nodeService.addAspect(this.childNode2, ContentModel.ASPECT_LOCKABLE, new HashMap<QName, Serializable>());
assertNotNull(this.childNode2);
// Create a node with no lockAspect
this.noAspectNode = this.nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName("{}noAspectNode"),
ContentModel.TYPE_CONTAINER,
nodeProperties).getChildRef();
assertNotNull(this.noAspectNode);
// Create node with checkedOut
this.checkedOutNode = this.nodeService.createNode(
rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName("{}checkedOutNode"),
ContentModel.TYPE_CONTAINER,
nodeProperties).getChildRef();
assertNotNull(this.checkedOutNode);
// Check out test file
NodeRef fileWorkingCopyNodeRef = cociService.checkout(checkedOutNode);
assertNotNull(fileWorkingCopyNodeRef);
assertTrue(nodeService.hasAspect(checkedOutNode, ContentModel.ASPECT_CHECKED_OUT));
assertTrue(nodeService.hasAspect(checkedOutNode, ContentModel.ASPECT_LOCKABLE));
// Create the users
TestWithUserUtils.createUser(GOOD_USER_NAME, PWD, rootNodeRef, this.nodeService, this.authenticationService);
TestWithUserUtils.createUser(BAD_USER_NAME, PWD, rootNodeRef, this.nodeService, this.authenticationService);
// Stash the user node ref's for later use
TestWithUserUtils.authenticateUser(BAD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
}
/**
* Test lock
*/
public void testLock()
{
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
// Check that the node is not currently locked
assertEquals(
LockStatus.NO_LOCK,
this.lockService.getLockStatus(this.parentNode));
// Test valid lock
this.lockService.lock(this.parentNode, LockType.WRITE_LOCK);
assertEquals(
LockStatus.LOCK_OWNER,
this.lockService.getLockStatus(this.parentNode));
TestWithUserUtils.authenticateUser(BAD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
assertEquals(
LockStatus.LOCKED,
this.lockService.getLockStatus(this.parentNode));
// Test lock when already locked
try
{
this.lockService.lock(this.parentNode, LockType.WRITE_LOCK);
fail("The user should not be able to lock the node since it is already locked by another user.");
}
catch (UnableToAquireLockException exception)
{
System.out.println(exception.getMessage());
}
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
// Test already locked by this user
try
{
this.lockService.lock(this.parentNode, LockType.WRITE_LOCK);
}
catch (Exception exception)
{
fail("No error should be thrown when a node is re-locked by the current lock owner.");
}
// Test with no apect node
this.lockService.lock(this.noAspectNode, LockType.WRITE_LOCK);
}
/**
* Test lock with lockChildren == true
*/
// TODO
public void testLockChildren()
{
}
/**
* Test lock with collection
*/
// TODO
public void testLockMany()
{
}
/**
* Test unlock node
*/
public void testUnlock()
{
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
// Lock the parent node
testLock();
TestWithUserUtils.authenticateUser(BAD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
// Try and unlock a locked node
try
{
this.lockService.unlock(this.parentNode);
// This will pass in the open workd
//fail("A user cannot unlock a node that is currently lock by another user.");
}
catch (UnableToReleaseLockException exception)
{
System.out.println(exception.getMessage());
}
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
// Unlock the node
this.lockService.unlock(this.parentNode);
assertEquals(
LockStatus.NO_LOCK,
this.lockService.getLockStatus(this.parentNode));
TestWithUserUtils.authenticateUser(BAD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
assertEquals(
LockStatus.NO_LOCK,
this.lockService.getLockStatus(this.parentNode));
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
// Try and unlock node with no lock
try
{
this.lockService.unlock(this.parentNode);
}
catch (Exception exception)
{
fail("Unlocking an unlocked node should not result in an exception being raised.");
}
// Test with no apect node
this.lockService.unlock(this.noAspectNode);
}
// TODO
public void testUnlockChildren()
{
}
// TODO
public void testUnlockMany()
{
}
/**
* Test getLockStatus
*/
public void testGetLockStatus()
{
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
// Check an unlocked node
LockStatus lockStatus1 = this.lockService.getLockStatus(this.parentNode);
assertEquals(LockStatus.NO_LOCK, lockStatus1);
this.lockService.lock(this.parentNode, LockType.WRITE_LOCK);
TestWithUserUtils.authenticateUser(BAD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
// Check for locked status
LockStatus lockStatus2 = this.lockService.getLockStatus(this.parentNode);
assertEquals(LockStatus.LOCKED, lockStatus2);
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
// Check for lock owner status
LockStatus lockStatus3 = this.lockService.getLockStatus(this.parentNode);
assertEquals(LockStatus.LOCK_OWNER, lockStatus3);
// Test with no apect node
this.lockService.getLockStatus(this.noAspectNode);
// Test method overload
LockStatus lockStatus4 = this.lockService.getLockStatus(this.parentNode);
assertEquals(LockStatus.LOCK_OWNER, lockStatus4);
}
public void testGetLocks()
{
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
List<NodeRef> locked1 = this.lockService.getLocks(this.storeRef);
assertNotNull(locked1);
assertEquals(0, locked1.size());
this.lockService.lock(this.parentNode, LockType.WRITE_LOCK);
this.lockService.lock(this.childNode1, LockType.WRITE_LOCK);
this.lockService.lock(this.childNode2, LockType.READ_ONLY_LOCK);
List<NodeRef> locked2 = this.lockService.getLocks(this.storeRef);
assertNotNull(locked2);
assertEquals(3, locked2.size());
List<NodeRef> locked3 = this.lockService.getLocks(this.storeRef, LockType.WRITE_LOCK);
assertNotNull(locked3);
assertEquals(2, locked3.size());
List<NodeRef> locked4 = this.lockService.getLocks(this.storeRef, LockType.READ_ONLY_LOCK);
assertNotNull(locked4);
assertEquals(1, locked4.size());
TestWithUserUtils.authenticateUser(BAD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
List<NodeRef> locked5 = this.lockService.getLocks(this.storeRef);
assertNotNull(locked5);
assertEquals(0, locked5.size());
}
/**
* Test getLockType
*/
public void testGetLockType()
{
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
// Get the lock type (should be null since the object is not locked)
LockType lockType1 = this.lockService.getLockType(this.parentNode);
assertNull(lockType1);
// Lock the object for writing
this.lockService.lock(this.parentNode, LockType.WRITE_LOCK);
LockType lockType2 = this.lockService.getLockType(this.parentNode);
assertNotNull(lockType2);
assertEquals(LockType.WRITE_LOCK, lockType2);
// Unlock the node
this.lockService.unlock(this.parentNode);
LockType lockType3 = this.lockService.getLockType(this.parentNode);
assertNull(lockType3);
// Lock the object for read only
this.lockService.lock(this.parentNode, LockType.READ_ONLY_LOCK);
LockType lockType4 = this.lockService.getLockType(this.parentNode);
assertNotNull(lockType4);
assertEquals(LockType.READ_ONLY_LOCK, lockType4);
// Lock the object for node lock
this.lockService.lock(this.parentNode, LockType.NODE_LOCK);
LockType lockType5 = this.lockService.getLockType(this.parentNode);
assertNotNull(lockType5);
assertEquals(LockType.NODE_LOCK, lockType5);
// Unlock the node
this.lockService.unlock(this.parentNode);
LockType lockType6 = this.lockService.getLockType(this.parentNode);
assertNull(lockType6);
// Test with no apect node
LockType lockType7 = this.lockService.getLockType(this.noAspectNode);
assertTrue("lock type is not null", lockType7 == null);
}
public void testTimeToExpire()
{
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
this.lockService.lock(this.parentNode, LockType.WRITE_LOCK, 1);
assertEquals(LockStatus.LOCK_OWNER, this.lockService.getLockStatus(this.parentNode));
TestWithUserUtils.authenticateUser(BAD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
assertEquals(LockStatus.LOCKED, this.lockService.getLockStatus(this.parentNode));
// Wait for 2 second before re-testing the status
try {Thread.sleep(2*1000);} catch (Exception exception){};
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
assertEquals(LockStatus.LOCK_EXPIRED, this.lockService.getLockStatus(this.parentNode));
TestWithUserUtils.authenticateUser(BAD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
assertEquals(LockStatus.LOCK_EXPIRED, this.lockService.getLockStatus(this.parentNode));
// Re-lock and then update the time to expire before lock expires
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
this.lockService.lock(this.parentNode, LockType.WRITE_LOCK, 0);
try
{
TestWithUserUtils.authenticateUser(BAD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
this.lockService.lock(this.parentNode, LockType.WRITE_LOCK, 1);
fail("Can not update lock info if not lock owner");
}
catch (UnableToAquireLockException exception)
{
// Expected
}
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
this.lockService.lock(this.parentNode, LockType.WRITE_LOCK, 1);
assertEquals(LockStatus.LOCK_OWNER, this.lockService.getLockStatus(this.parentNode));
TestWithUserUtils.authenticateUser(BAD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
assertEquals(LockStatus.LOCKED, this.lockService.getLockStatus(this.parentNode));
// Wait for 2 second before re-testing the status
try {Thread.sleep(2*1000);} catch (Exception exception){};
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
assertEquals(LockStatus.LOCK_EXPIRED, this.lockService.getLockStatus(this.parentNode));
TestWithUserUtils.authenticateUser(BAD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
assertEquals(LockStatus.LOCK_EXPIRED, this.lockService.getLockStatus(this.parentNode));
}
/**
* Unit test to validate the behaviour of creating children of locked nodes.
* No lock - can create children
* READ_ONLY_LOCK - can't create children
* WRITE_LOCK - owner can create children
* non owner can't create children
* NODE_LOCK non owner can create children
* owner can create children
*/
public void testCreateChildrenOfLockedNodes() throws Exception
{
/**
* Check we can create a child of an unlocked node.
*/
assertEquals(
LockStatus.NO_LOCK,
this.lockService.getLockStatus(this.parentNode));
ChildAssociationRef child = nodeService.createNode(parentNode, ContentModel.ASSOC_CONTAINS, QName.createQName("ChildA"), ContentModel.TYPE_FOLDER);
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
this.lockService.lock(this.parentNode, LockType.WRITE_LOCK);
// Owner can create children
child = nodeService.createNode(parentNode, ContentModel.ASSOC_CONTAINS, QName.createQName("ChildB"), ContentModel.TYPE_FOLDER);
TestWithUserUtils.authenticateUser(BAD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
try
{
// Non owner can't create children with a write lock in place
child = nodeService.createNode(parentNode, ContentModel.ASSOC_CONTAINS, QName.createQName("ChildB"), ContentModel.TYPE_FOLDER);
fail("could create a child with a read only lock");
}
catch (NodeLockedException e)
{
logger.debug("exception while trying to create a child of a read only lock", e);
}
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
this.lockService.lock(this.parentNode, LockType.NODE_LOCK);
// owner can create children with a node lock
child = nodeService.createNode(parentNode, ContentModel.ASSOC_CONTAINS, QName.createQName("ChildD"), ContentModel.TYPE_FOLDER);
TestWithUserUtils.authenticateUser(BAD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
// Non owner can create children with a node lock
child = nodeService.createNode(parentNode, ContentModel.ASSOC_CONTAINS, QName.createQName("ChildC"), ContentModel.TYPE_FOLDER);
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
this.lockService.lock(this.parentNode, LockType.READ_ONLY_LOCK);
// owner should not be able to create children with a READ_ONLY_LOCK
try
{
child = nodeService.createNode(parentNode, ContentModel.ASSOC_CONTAINS, QName.createQName("ChildD"), ContentModel.TYPE_FOLDER);
fail("could create a child with a read only lock");
}
catch (NodeLockedException e)
{
logger.debug("exception while trying to create a child of a read only lock", e);
}
TestWithUserUtils.authenticateUser(BAD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
// Non owner should not be able to create children with READ_ONLY_LOCK
try
{
child = nodeService.createNode(parentNode, ContentModel.ASSOC_CONTAINS, QName.createQName("ChildE"), ContentModel.TYPE_FOLDER);
fail("could create a child with a read only lock");
}
catch (NodeLockedException e)
{
logger.debug("exception while trying to create a child of a read only lock", e);
}
}
/**
* Test that it is impossible to unlock a checked out node
*/
public void testUnlockCheckedOut() throws Exception
{
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
try
{
this.lockService.unlock(checkedOutNode);
fail("could unlock a checked out node");
}
catch (UnableToReleaseLockException e)
{
logger.debug("exception while trying to unlock a checked out node", e);
}
}
}