• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java LockType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.alfresco.service.cmr.lock.LockType的典型用法代码示例。如果您正苦于以下问题:Java LockType类的具体用法?Java LockType怎么用?Java LockType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LockType类属于org.alfresco.service.cmr.lock包,在下文中一共展示了LockType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:LockServiceImpl.java


示例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);
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:LockServiceImpl.java


示例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);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:18,代码来源:LockServiceImpl.java


示例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;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:22,代码来源:LockServiceImpl.java


示例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
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:23,代码来源:LockServiceImpl.java


示例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;
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:LockServiceImpl.java


示例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
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:23,代码来源:LockBehaviourImplTest.java


示例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));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:LockServiceImplTest.java


示例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);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:AbstractLockStoreTestBase.java


示例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));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:AbstractLockStoreTestBase.java


示例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));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:AbstractLockStoreTestBase.java


示例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));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:LockableAspectInterceptorTest.java


示例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));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:LockableAspectInterceptorTest.java


示例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));   
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:23,代码来源:WebDAVLockServiceImplTest.java


示例16: testEphemeralLockIndexing

import org.alfresco.service.cmr.lock.LockType; //导入依赖的package包/类
@Test
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));
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:26,代码来源:LockServiceImplTest.java


示例17: testGetPropertyEphemeralLock

import org.alfresco.service.cmr.lock.LockType; //导入依赖的package包/类
@Test
public void testGetPropertyEphemeralLock()
{
  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();
  
  assertEquals(null, nodeService.getProperty(nodeRef, ContentModel.PROP_LOCK_OWNER));
  assertEquals(null, nodeService.getProperty(nodeRef, ContentModel.PROP_LOCK_TYPE));
  assertEquals(null, nodeService.getProperty(nodeRef, ContentModel.PROP_EXPIRY_DATE));
  assertEquals(null, nodeService.getProperty(nodeRef, ContentModel.PROP_LOCK_LIFETIME));
  Date now = new Date();
  // Set a lock on the node
  lockStore.set(nodeRef,
              LockState.createLock(nodeRef, LockType.WRITE_LOCK, lockOwner, now, Lifetime.EPHEMERAL, null));
  
  // cm:lockable properties should be spoofed
  assertEquals(lockOwner, nodeService.getProperty(nodeRef, ContentModel.PROP_LOCK_OWNER));
  assertEquals(LockType.WRITE_LOCK.toString(), nodeService.getProperty(nodeRef, ContentModel.PROP_LOCK_TYPE));
  assertEquals(now, nodeService.getProperty(nodeRef, ContentModel.PROP_EXPIRY_DATE));
  assertEquals(Lifetime.EPHEMERAL.toString(), nodeService.getProperty(nodeRef, ContentModel.PROP_LOCK_LIFETIME));
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:26,代码来源:LockableAspectInterceptorTest.java


示例18: addLock

import org.alfresco.service.cmr.lock.LockType; //导入依赖的package包/类
@Override
public void addLock(NodeRef nodeRef) 
{
	if(lockEnabled)
	{
		if(logger.isDebugEnabled())
		{
			logger.debug("lock nodeRef:" + nodeRef);
		}
	    getLockService().lock(nodeRef, LockType.WRITE_LOCK, getTimeToExpire(), Lifetime.EPHEMERAL, LOCK_KEEPER_KEY);
	    lockKeeperTransactionalCache.put(nodeRef, new KeeperInfo(AuthenticationUtil.getFullyAuthenticatedUser()));
	}
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:14,代码来源:LockKeeperImpl.java


示例19: lock

import org.alfresco.service.cmr.lock.LockType; //导入依赖的package包/类
@Override
public void lock(NodeRef nodeRef, LockType lockType, int timeToExpire) throws UnableToAquireLockException
{
    getTrait().lock(smartStore.materializeIfPossible(nodeRef),
                    lockType,
                    timeToExpire);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:8,代码来源:VirtualLockServiceExtension.java


示例20: LockState

import org.alfresco.service.cmr.lock.LockType; //导入依赖的package包/类
/**
 * Constructor.
 * 
 * @param nodeRef NodeRef
 * @param lockType LockType
 * @param owner String
 * @param expires Date
 * @param lifetime Lifetime
 * @param additionalInfo String
 */
private LockState(NodeRef nodeRef, LockType lockType, String owner, Date expires,
            Lifetime lifetime, String additionalInfo)
{
    this.nodeRef = nodeRef;
    this.lockType = lockType;
    this.owner = owner;
    this.expires = (expires == null ? null : new Date(expires.getTime()));
    this.lifetime = lifetime;
    this.additionalInfo = additionalInfo;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:LockState.java



注:本文中的org.alfresco.service.cmr.lock.LockType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java StreamFlags类代码示例发布时间:2022-05-22
下一篇:
Java CacheFactoryBean类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap