本文整理汇总了Java中org.alfresco.service.cmr.lock.LockType类的典型用法代码示例。如果您正苦于以下问题:Java LockType类的具体用法?Java LockType怎么用?Java LockType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LockType类属于org.alfresco.service.cmr.lock包,在下文中一共展示了LockType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invokeBeforeLock
import org.alfresco.service.cmr.lock.LockType; //导入依赖的package包/类
/**
* Invoke the before log policy
*
* @param nodeRef the node to be locked
* @param lockType the lock type
*/
private void invokeBeforeLock(
NodeRef nodeRef,
LockType lockType)
{
if (!nodeService.exists(nodeRef))
{
return;
}
List<QName> classes = getInvokeClasses(nodeRef);
for (QName invokeClass : classes)
{
Collection<BeforeLock> policies = beforeLock.getList(invokeClass);
for (BeforeLock policy : policies)
{
policy.beforeLock(nodeRef, lockType);
}
}
}
示例2: lock
import org.alfresco.service.cmr.lock.LockType; //导入依赖的package包/类
/**
* @see org.alfresco.service.cmr.lock.LockService#lock(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.cmr.lock.LockType, int, Lifetime, boolean)
*/
@Override
@Extend(traitAPI=LockServiceTrait.class,extensionAPI=LockServiceExtension.class)
public void lock(NodeRef nodeRef, LockType lockType, int timeToExpire, Lifetime lifetime, boolean lockChildren)
{
lock(nodeRef, lockType, timeToExpire, lifetime);
if (lockChildren)
{
Collection<ChildAssociationRef> childAssocRefs = this.nodeService.getChildAssocs(nodeRef);
for (ChildAssociationRef childAssocRef : childAssocRefs)
{
lock(childAssocRef.getChildRef(), lockType, timeToExpire, lifetime, lockChildren);
}
}
}
示例3: persistLockProps
import org.alfresco.service.cmr.lock.LockType; //导入依赖的package包/类
private void persistLockProps(NodeRef nodeRef, LockType lockType, Lifetime lifetime, String userName, Date expiryDate, String additionalInfo)
{
addToIgnoreSet(nodeRef);
try
{
// Set the current user as the lock owner
this.nodeService.setProperty(nodeRef, ContentModel.PROP_LOCK_OWNER, userName);
this.nodeService.setProperty(nodeRef, ContentModel.PROP_LOCK_TYPE, lockType.toString());
this.nodeService.setProperty(nodeRef, ContentModel.PROP_LOCK_LIFETIME, lifetime.toString());
this.nodeService.setProperty(nodeRef, ContentModel.PROP_EXPIRY_DATE, expiryDate);
this.nodeService.setProperty(nodeRef, ContentModel.PROP_LOCK_ADDITIONAL_INFO, additionalInfo);
}
finally
{
removeFromIgnoreSet(nodeRef);
}
}
示例4: getLockType
import org.alfresco.service.cmr.lock.LockType; //导入依赖的package包/类
/**
* @see LockService#getLockType(NodeRef)
*/
@Extend(traitAPI=LockServiceTrait.class,extensionAPI=LockServiceExtension.class)
public LockType getLockType(NodeRef nodeRef)
{
LockType result = null;
// Don't disable the lockable aspect interceptor - allow it to fetch the lock type
// from the correct place (persistent storage or lockStore).
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_LOCKABLE) == true)
{
String lockTypeString = (String) this.nodeService.getProperty(nodeRef, ContentModel.PROP_LOCK_TYPE);
if (lockTypeString != null)
{
result = LockType.valueOf(lockTypeString);
}
}
return result;
}
示例5: onCreateChildAssociation
import org.alfresco.service.cmr.lock.LockType; //导入依赖的package包/类
/**
* Ensures that the parent is not locked.
*
* @see #checkForLock(NodeRef)
*/
public void onCreateChildAssociation(ChildAssociationRef childAssocRef, boolean isNewNode)
{
LockType lockType = getLockType(childAssocRef.getParentRef());
if(lockType != null)
{
switch (lockType)
{
case WRITE_LOCK:
case READ_ONLY_LOCK:
checkForLock(childAssocRef.getParentRef());
break;
case NODE_LOCK:
// don't check for lock
}
}
}
示例6: isLockedAndReadOnly
import org.alfresco.service.cmr.lock.LockType; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Extend(traitAPI=LockServiceTrait.class,extensionAPI=LockServiceExtension.class)
public boolean isLockedAndReadOnly(NodeRef nodeRef)
{
LockStatus lockStatus = getLockStatus(nodeRef);
switch (lockStatus)
{
case NO_LOCK:
case LOCK_EXPIRED:
return false;
case LOCK_OWNER:
return getLockType(nodeRef) != LockType.WRITE_LOCK;
default:
return true;
}
}
示例7: testHasLockableAspect
import org.alfresco.service.cmr.lock.LockType; //导入依赖的package包/类
@Test
public void testHasLockableAspect() throws Exception
{
assertFalse("Node should not be reported as lockable",
nodeService.hasAspect(originalContentNodeRef,
ContentModel.ASPECT_LOCKABLE));
lockService.lock(originalContentNodeRef,
LockType.WRITE_LOCK,
10,
Lifetime.EPHEMERAL,
null);
assertTrue("Node should be reported as lockable",
nodeService.hasAspect(originalContentNodeRef,
ContentModel.ASPECT_LOCKABLE));
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:18,代码来源:VirtualLockableAspectInterceptorExtensionTest.java
示例8: testVersionServiceLockBehaviour02
import org.alfresco.service.cmr.lock.LockType; //导入依赖的package包/类
/**
* Test version service lock checking
*/
public void testVersionServiceLockBehaviour02()
{
// Add the version aspect to the node
this.nodeService.addAspect(this.nodeRef, ContentModel.ASPECT_VERSIONABLE, null);
// Lock the node as the bad user with a write lock
this.lockService.lock(this.nodeRef, LockType.WRITE_LOCK);
try
{
TestWithUserUtils.authenticateUser(BAD_USER_NAME, PWD, rootNodeRef, this.authenticationService);
this.versionService.createVersion(this.nodeRef, new HashMap<String, Serializable>());
fail("Should have failed since this node has been locked by another user with a write lock.");
}
catch (AccessDeniedException exception)
{
// Exception occurs when the properties are updated for a node
}
}
示例9: testEphemeralLockIndexing
import org.alfresco.service.cmr.lock.LockType; //导入依赖的package包/类
@Test
@Category(RedundantTests.class)
public void testEphemeralLockIndexing()
{
TestWithUserUtils.authenticateUser(GOOD_USER_NAME, PWD, rootNodeRef, authenticationService);
IndexerAndSearcher indexerAndSearcher = (IndexerAndSearcher)
applicationContext.getBean("indexerAndSearcherFactory");
SearcherComponent searcher = new SearcherComponent();
searcher.setIndexerAndSearcherFactory(indexerAndSearcher);
// Create a lock (owned by the current user)
lockService.lock(noAspectNode, LockType.WRITE_LOCK, 86400, Lifetime.EPHEMERAL);
// Query for the user's locks
final String query = String.format("[email protected]\\:lockOwner:\"%s\" [email protected]\\:lockType:\"WRITE_LOCK\"", GOOD_USER_NAME);
ResultSet rs = searcher.query(storeRef, "lucene", query);
assertTrue(rs.getNodeRefs().contains(noAspectNode));
// Unlock the node
lockService.unlock(noAspectNode);
// Perform a new search, the index should reflect that it is not locked.
rs = searcher.query(storeRef, "lucene", query);
assertFalse(rs.getNodeRefs().contains(noAspectNode));
}
示例10: testSetAndGet
import org.alfresco.service.cmr.lock.LockType; //导入依赖的package包/类
@Test
public void testSetAndGet()
{
NodeRef ephemeralNodeRef = new NodeRef("workspace://SpacesStore/12345");
LockState ephemeralLock = LockState.createLock(
ephemeralNodeRef, LockType.NODE_LOCK, "owner", null, Lifetime.EPHEMERAL, null);
NodeRef persistentNodeRef = new NodeRef("workspace://SpacesStore/5838743");
LockState persistentLock = LockState.createLock(
persistentNodeRef, LockType.NODE_LOCK, "owner", null, Lifetime.PERSISTENT, null);
lockStore.set(ephemeralNodeRef, ephemeralLock);
lockStore.set(persistentNodeRef, persistentLock);
LockState newLockState = lockStore.get(ephemeralNodeRef);
assertEquals(ephemeralLock, newLockState);
newLockState = lockStore.get(persistentNodeRef);
assertEquals(persistentLock, newLockState);
}
示例11: testContains
import org.alfresco.service.cmr.lock.LockType; //导入依赖的package包/类
@Test
public void testContains()
{
NodeRef nodeRef1 = new NodeRef("workspace://SpacesStore/12345");
LockState lock1 = LockState.createLock(nodeRef1, LockType.NODE_LOCK, "owner", null, Lifetime.EPHEMERAL, null);
NodeRef nodeRef2 = new NodeRef("workspace://SpacesStore/5838743");
LockState lock2 = LockState.createLock(nodeRef2, LockType.NODE_LOCK, "owner", null, Lifetime.PERSISTENT, null);
NodeRef nodeRef3 = new NodeRef("workspace://SpacesStore/65752323");
lockStore.set(nodeRef1, lock1);
lockStore.set(nodeRef2, lock2);
assertNotNull(lockStore.get(nodeRef1));
assertNotNull(lockStore.get(nodeRef2));
assertNull(lockStore.get(nodeRef3));
}
示例12: testClear
import org.alfresco.service.cmr.lock.LockType; //导入依赖的package包/类
@Test
public void testClear()
{
NodeRef nodeRef1 = new NodeRef("workspace://SpacesStore/12345");
LockState lock1 = LockState.createLock(nodeRef1, LockType.NODE_LOCK, "owner", null, Lifetime.EPHEMERAL, null);
NodeRef nodeRef2 = new NodeRef("workspace://SpacesStore/5838743");
LockState lock2 = LockState.createLock(nodeRef2, LockType.NODE_LOCK, "owner", null, Lifetime.PERSISTENT, null);
lockStore.set(nodeRef1, lock1);
lockStore.set(nodeRef2, lock2);
assertNotNull(lockStore.get(nodeRef1));
assertNotNull(lockStore.get(nodeRef2));
lockStore.clear();
assertNull(lockStore.get(nodeRef1));
assertNull(lockStore.get(nodeRef2));
}
示例13: testHasAspectEphemeralLock
import org.alfresco.service.cmr.lock.LockType; //导入依赖的package包/类
@Test
public void testHasAspectEphemeralLock()
{
QName nodeName = QName.createQName("http://www.alfresco.org/test/" + getClass().getSimpleName(), "testNode");
NodeRef nodeRef = nodeService.createNode(
rootNode,
ContentModel.ASSOC_CHILDREN,
nodeName,
ContentModel.TYPE_BASE).getChildRef();
assertFalse("Node should not be reported as lockable",
nodeService.hasAspect(nodeRef, ContentModel.ASPECT_LOCKABLE));
lockStore.set(nodeRef, LockState.createLock(nodeRef, LockType.WRITE_LOCK, lockOwner, null, Lifetime.EPHEMERAL, null));
assertTrue("Node should be reported as lockable",
nodeService.hasAspect(nodeRef, ContentModel.ASPECT_LOCKABLE));
}
示例14: testHasAspectPersistentLock
import org.alfresco.service.cmr.lock.LockType; //导入依赖的package包/类
@Test
public void testHasAspectPersistentLock()
{
QName nodeName = QName.createQName("http://www.alfresco.org/test/" + getClass().getSimpleName(), "testNode");
NodeRef nodeRef = nodeService.createNode(
rootNode,
ContentModel.ASSOC_CHILDREN,
nodeName,
ContentModel.TYPE_BASE).getChildRef();
assertFalse("Node should not be reported as lockable",
nodeService.hasAspect(nodeRef, ContentModel.ASPECT_LOCKABLE));
lockStore.set(nodeRef,
LockState.createLock(nodeRef, LockType.WRITE_LOCK, lockOwner, null, Lifetime.PERSISTENT, null));
// Persistent lock should not result in the aspects being augmented
assertFalse("Node should not be reported as lockable",
nodeService.hasAspect(nodeRef, ContentModel.ASPECT_LOCKABLE));
nodeService.addAspect(nodeRef, ContentModel.ASPECT_LOCKABLE, new HashMap<QName, Serializable>(0));
// The existence of the real aspect should be reported.
assertTrue("Node should be reported as lockable",
nodeService.hasAspect(nodeRef, ContentModel.ASPECT_LOCKABLE));
}
示例15: mnt13183LockInfo
import org.alfresco.service.cmr.lock.LockType; //导入依赖的package包/类
@Test
public void mnt13183LockInfo()
{
// CIFS lock node to 1 hour
lockService.lock(nodeRef1, LockType.WRITE_LOCK, 3600, Lifetime.EPHEMERAL, "lock_info_that_is_not_from_webdav");
// WebDAV get lock info
LockInfo lockInfoNodeRef1 = davLockService.getLockInfo(nodeRef1);
assertNull("exclusiveLockToken is null", lockInfoNodeRef1.getExclusiveLockToken());
String user = AuthenticationUtil.getFullyAuthenticatedUser();
// WebDav lock, check marker
davLockService.lock(nodeRef2, user, 3600);
LockState lockState2 = lockService.getLockState(nodeRef2);
assertNotNull("lockState is not null", lockState2);
String additionalInfo2 = lockState2.getAdditionalInfo();
assertNotNull("additionalInfo is not null", additionalInfo2);
assertTrue("Check WEBDAV_LOCK marker", additionalInfo2.startsWith(LockInfoImpl.ADDINFO_WEBDAV_MARKER));
}