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

Java LockStatus类代码示例

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

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



LockStatus类属于org.alfresco.service.cmr.lock包,在下文中一共展示了LockStatus类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: hasAuthority

import org.alfresco.service.cmr.lock.LockStatus; //导入依赖的package包/类
public boolean hasAuthority(final NodeRef nodeRef, final String userName)
{
    return AuthenticationUtil.runAs(new RunAsWork<Boolean>(){

        public Boolean doWork() throws Exception
        {
            if (lockService.getLockStatus(nodeRef, userName) == LockStatus.LOCK_OWNER)
            {
                return true;
            }
            NodeRef original = checkOutCheckInService.getCheckedOut(nodeRef);
            if (original != null)
            {
                return (lockService.getLockStatus(original, userName) == LockStatus.LOCK_OWNER);
            }
            else
            {
                return false;
            }
        }}, AuthenticationUtil.getSystemUserName());
    
    
    
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:LockOwnerDynamicAuthority.java


示例2: onContentUpdate

import org.alfresco.service.cmr.lock.LockStatus; //导入依赖的package包/类
@Override
public void onContentUpdate(final NodeRef nodeRef, boolean newContent)
{
    AuthenticationUtil.runAsSystem(new RunAsWork<Object>()
    {
        @Override
        public Object doWork()
        {
            if (nodeService.exists(nodeRef) && lockService.getLockStatus(nodeRef) != LockStatus.LOCKED)
            {
                deleteFailedThumbnailChildren(nodeRef);
            }
            return null;
        }
    });
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:17,代码来源:FailedThumbnailSourceAspect.java


示例3: isWorkingCopyOrLocked

import org.alfresco.service.cmr.lock.LockStatus; //导入依赖的package包/类
private boolean isWorkingCopyOrLocked(NodeRef nodeRef)
{
    boolean isWorkingCopy = false;
    boolean isLocked = false;

    if (nodeRef != null)
    {
        Set<QName> aspects = nodeService.getAspects(nodeRef);

        isWorkingCopy = aspects.contains(ContentModel.ASPECT_WORKING_COPY);
        if (!isWorkingCopy)
        {
            if (aspects.contains(ContentModel.ASPECT_LOCKABLE))
            {
                LockStatus lockStatus = lockService.getLockStatus(nodeRef);
                if (lockStatus == LockStatus.LOCKED || lockStatus == LockStatus.LOCK_OWNER)
                {
                    isLocked = true;
                }
            }
        }
    }
    return (isWorkingCopy || isLocked);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:CommentServiceImpl.java


示例4: lockStatus

import org.alfresco.service.cmr.lock.LockStatus; //导入依赖的package包/类
/**
 * Given the lock owner and expiry date of a lock calculates the lock status with respect
 * to the user name supplied, e.g. the current user.
 * 
 * @param userName    User name to evaluate the lock against.
 * @param lockOwner   Owner of the lock.
 * @param expiryDate  Expiry date of the lock.
 * @return LockStatus
 * @deprecated eventually move into LockService
 */
public static LockStatus lockStatus(String userName, String lockOwner, Date expiryDate)
{
    LockStatus result = LockStatus.NO_LOCK;
    
    if (lockOwner != null)
    {
        if (expiryDate != null && expiryDate.before(new Date()) == true)
        {
            // Indicate that the lock has expired
            result = LockStatus.LOCK_EXPIRED;
        }
        else
        {
            if (lockOwner.equals(userName) == true)
            {
                result = LockStatus.LOCK_OWNER;
            }
            else
            {
                result = LockStatus.LOCKED;
            }
        }
    }
    return result;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:36,代码来源:LockUtils.java


示例5: getLockState

import org.alfresco.service.cmr.lock.LockStatus; //导入依赖的package包/类
@Extend(traitAPI=LockableAspectInterceptorTrait.class,extensionAPI=LockableAspectInterceptorExtension.class)
private LockState getLockState(NodeRef nodeRef)
{
    LockState lockState = lockStore.get(nodeRef);
    // Disregard in-memory lock if expired
    if (lockState != null)
    {
        String lockOwner = lockState.getOwner();
        Date expiryDate = lockState.getExpires();
        LockStatus status = LockUtils.lockStatus(lockOwner, lockOwner, expiryDate);
        if (status.equals(LockStatus.LOCK_EXPIRED))
        {
            lockState = null;
        }
    }
    return lockState;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:18,代码来源:LockableAspectInterceptor.java


示例6: isLockedAndReadOnly

import org.alfresco.service.cmr.lock.LockStatus; //导入依赖的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: isNodeLocked

import org.alfresco.service.cmr.lock.LockStatus; //导入依赖的package包/类
/**
 * Return whether a Node is currently locked
 * 
 * @param node             The Node wrapper to test against
 * @param lockService      The LockService to use
 * 
 * @return whether a Node is currently locked
 */
public static Boolean isNodeLocked(Node node, LockService lockService)
{
   Boolean locked = Boolean.FALSE;
   
   if (node.hasAspect(ContentModel.ASPECT_LOCKABLE))
   {
      LockStatus lockStatus = lockService.getLockStatus(node.getNodeRef());
      if (lockStatus == LockStatus.LOCKED || lockStatus == LockStatus.LOCK_OWNER)
      {
         locked = Boolean.TRUE;
      }
   }
   
   return locked;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:24,代码来源:Repository.java


示例8: nodeLocked

import org.alfresco.service.cmr.lock.LockStatus; //导入依赖的package包/类
/**
 * given that the node is locked
 * when the type set behaviour is executed
 * then a new version is not created
 */
@SuppressWarnings("unchecked")
@Test
public void nodeLocked()
{
    // auto version on
    extendedVersionableAspect.setAutoVersionOnTypeChange(true);
    
    // node does exists
    when(mockedNodeService.exists(nodeRef))
        .thenReturn(true);
    
    // node is locked
    when(mockedLockService.getLockStatus(nodeRef))
        .thenReturn(LockStatus.LOCKED);
    
    // execute behaviour
    extendedVersionableAspect.onSetNodeType(nodeRef, oldType, newType);
    
    // verify other
    verify(mockedNodeService).exists(nodeRef);
    
    // assert the version was not created
    verify(mockedVersionService, never()).createVersion(eq(nodeRef), any(Map.class));
}
 
开发者ID:Alfresco,项目名称:records-management-old,代码行数:30,代码来源:ExtendedVersionableAspectUnitTest.java


示例9: isLockedByGoogleDocs

import org.alfresco.service.cmr.lock.LockStatus; //导入依赖的package包/类
/**
 * Is the node locked by Googledocs? If the document is marked locked in the model, but not locked in the repository, the locked
 * property is set to false
 * 
 * @param nodeRef
 * @return
 */
public boolean isLockedByGoogleDocs(NodeRef nodeRef)
{

    boolean locked = false;

    if ((Boolean)nodeService.getProperty(nodeRef, GoogleDocsModel.PROP_LOCKED))
    {
        LockStatus lockStatus = lockservice.getLockStatus(nodeRef);
        if (lockStatus.equals(LockStatus.NO_LOCK))
        {
            // fix broken lock
            nodeService.setProperty(nodeRef, GoogleDocsModel.PROP_LOCKED, false);
        }
        else
        {
            locked = true;
        }
    }

    log.debug("Node " + nodeRef + " locked by Google Docs");

    return locked;
}
 
开发者ID:Pluies,项目名称:Alfresco-Google-docs-plugin,代码行数:31,代码来源:GoogleDocsServiceImpl.java


示例10: isGoogleDocsLockOwner

import org.alfresco.service.cmr.lock.LockStatus; //导入依赖的package包/类
/**
 * @param nodeRef
 * @return Will return false is the document is not locked
 */
public boolean isGoogleDocsLockOwner(NodeRef nodeRef)
{
    boolean isOwner = false;

    if (isLockedByGoogleDocs(nodeRef))
    {
        LockStatus lockStatus = lockservice.getLockStatus(nodeRef);
        if (lockStatus.equals(LockStatus.LOCK_OWNER))
        {
            isOwner = true;
        }
    }

    return isOwner;
}
 
开发者ID:Pluies,项目名称:Alfresco-Google-docs-plugin,代码行数:20,代码来源:GoogleDocsServiceImpl.java


示例11: checkout

import org.alfresco.service.cmr.lock.LockStatus; //导入依赖的package包/类
@Override
@Extend(traitAPI=CheckOutCheckInServiceTrait.class,extensionAPI=CheckOutCheckInServiceExtension.class)
public NodeRef checkout(
        final NodeRef nodeRef, 
        final NodeRef destinationParentNodeRef,
        final QName destinationAssocTypeQName, 
        QName destinationAssocQName) 
{
    if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_CHECKED_OUT))
    {
        throw new CheckOutCheckInServiceException(MSG_ALREADY_CHECKEDOUT);
    }

    // Make sure we are not checking out a working copy node
    if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY))
    {
        throw new CheckOutCheckInServiceException(MSG_ERR_ALREADY_WORKING_COPY);
    }
    
    // It is not enough to check LockUtils.isLockedOrReadOnly in case when the same user does offline and online edit (for instance in two open browsers). In this case we get
    // set ContentModel.ASPECT_LOCKABLE and LockType.WRITE_LOCK. So, here we have to check following
    LockStatus lockStatus = lockService.getLockStatus(nodeRef);
    if (lockStatus != LockStatus.NO_LOCK && lockStatus != LockStatus.LOCK_EXPIRED)
    {
        throw new NodeLockedException(nodeRef);
    }
    
    behaviourFilter.disableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE);
    behaviourFilter.disableBehaviour(destinationParentNodeRef, ContentModel.ASPECT_AUDITABLE);
    try
    {
        return doCheckout(nodeRef, destinationParentNodeRef, destinationAssocTypeQName, destinationAssocQName);
    }
    finally
    {
        behaviourFilter.enableBehaviour(nodeRef, ContentModel.ASPECT_AUDITABLE);
        behaviourFilter.enableBehaviour(destinationParentNodeRef, ContentModel.ASPECT_AUDITABLE);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:40,代码来源:CheckOutCheckInServiceImpl.java


示例12: getLockStatus

import org.alfresco.service.cmr.lock.LockStatus; //导入依赖的package包/类
/**
 * @see org.alfresco.service.cmr.lock.LockService#getLockStatus(NodeRef)
 */
@Extend(traitAPI=LockServiceTrait.class,extensionAPI=LockServiceExtension.class)
public LockStatus getLockStatus(NodeRef nodeRef)
{
    nodeRef = tenantService.getName(nodeRef);
    
    return getLockStatus(nodeRef, getUserName());
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:11,代码来源:LockServiceImpl.java


示例13: getLockStateAndStatus

import org.alfresco.service.cmr.lock.LockStatus; //导入依赖的package包/类
private Pair<LockState, LockStatus> getLockStateAndStatus(NodeRef nodeRef, String userName)
{
    final LockState lockState = getLockState(nodeRef);
    
    String lockOwner = lockState.getOwner();
    Date expiryDate = lockState.getExpires();
    LockStatus status = LockUtils.lockStatus(userName, lockOwner, expiryDate);
    return new Pair<LockState, LockStatus>(lockState, status);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:10,代码来源:LockServiceImpl.java


示例14: isLocked

import org.alfresco.service.cmr.lock.LockStatus; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Extend(traitAPI=LockServiceTrait.class,extensionAPI=LockServiceExtension.class)
public boolean isLocked(NodeRef nodeRef)
{
    LockStatus lockStatus = getLockStatus(nodeRef);
    switch (lockStatus)
    {
        case LOCKED:
        case LOCK_OWNER:
            return true;
        default:
            return false;
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:17,代码来源:LockServiceImpl.java


示例15: testUnSet

import org.alfresco.service.cmr.lock.LockStatus; //导入依赖的package包/类
/**
 * 
 */
public void testUnSet()
{
    permissionService.setPermission(rootNodeRef, "andy", PermissionService.ALL_PERMISSIONS, true);
    authenticationService.authenticate("andy", "andy".toCharArray());
    assertEquals(LockStatus.NO_LOCK, lockService.getLockStatus(rootNodeRef));
    authenticationService.clearCurrentSecurityContext();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:11,代码来源:LockOwnerDynamicAuthorityTest.java


示例16: testAutoVersionIncrementOnPropertiesUpdateByLockOwnerAlf14584

import org.alfresco.service.cmr.lock.LockStatus; //导入依赖的package包/类
public void testAutoVersionIncrementOnPropertiesUpdateByLockOwnerAlf14584() throws Exception
{
    final String name = generateDocumentName(DOCUMENT_NAME, "0.2");

    transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>()
    {
        @Override
        public Void execute() throws Throwable
        {
            Map<QName, Serializable> properties = getAndAssertProperties(document, "0.1");

            Serializable autoVersionProps = properties.get(ContentModel.PROP_AUTO_VERSION_PROPS);
            assertNotNull(("Autoversion property is NULL! NodeRef = '" + document.toString() + "'"), autoVersionProps);
            assertTrue(("Autoversion must be TRUE! NodeRef = '" + document.toString() + "'"), (Boolean) autoVersionProps);

            lockService.lock(document, LockType.WRITE_LOCK);

            LockStatus lockStatus = lockService.getLockStatus(document);
            assertTrue(
                    ("Node with NodeRef = '" + document.toString() + "' should be locked for " + AuthenticationUtil.getFullyAuthenticatedUser() + " user! The user is lock owner"),
                    lockService.isLocked(document));
            assertEquals(LockStatus.LOCK_OWNER, lockService.getLockStatus(document));

            nodeService.setProperty(document, ContentModel.PROP_NAME, name);

            return null;
        }
    });

    assertDocumentVersionAndName("0.2", name);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:32,代码来源:VersionableAspectTest.java


示例17: testLockRevertedOnRollback

import org.alfresco.service.cmr.lock.LockStatus; //导入依赖的package包/类
public void testLockRevertedOnRollback() throws NotSupportedException, SystemException
{
    // Preconditions of test
    assertEquals(LockStatus.NO_LOCK, lockService.getLockStatus(noAspectNode));
    assertFalse(lockService.isLocked(noAspectNode));
    assertEquals(LockStatus.NO_LOCK, lockService.getLockStatus(rootNodeRef));
    assertFalse(lockService.isLocked(rootNodeRef));
    
    // Lock noAspectNode
    lockService.lock(noAspectNode, LockType.WRITE_LOCK, 0, Lifetime.EPHEMERAL);
    
    // Lock rootNodeRef
    lockService.lock(rootNodeRef, LockType.NODE_LOCK, 0, Lifetime.EPHEMERAL);
    
    // Sometime later, a refresh occurs (so this should not be reverted to unlocked, but to this state)
    lockService.lock(rootNodeRef, LockType.NODE_LOCK, 3600, Lifetime.EPHEMERAL);
    
    // Rollback
    endTransaction();
    
    // This lock should not be present.
    assertEquals(LockStatus.NO_LOCK, lockService.getLockStatus(noAspectNode));
    assertFalse(lockService.isLocked(noAspectNode));
    
    // This lock should still be present.
    assertEquals(LockStatus.LOCK_OWNER, lockService.getLockStatus(rootNodeRef));
    assertTrue(lockService.isLocked(rootNodeRef));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:29,代码来源:LockServiceImplTest.java


示例18: testIsLockedAndReadOnly_ForLockOwnerWithNullLockType

import org.alfresco.service.cmr.lock.LockStatus; //导入依赖的package包/类
@Test
public void testIsLockedAndReadOnly_ForLockOwnerWithNullLockType()
{
    when(lockService.getLockStatus(nodeRef)).thenReturn(LockStatus.LOCK_OWNER);
    when(lockService.getLockType(nodeRef)).thenReturn(null);
    when(lockService.isLockedAndReadOnly(nodeRef)).thenReturn(true);
    
    boolean returnedVal = LockUtils.isLockedAndReadOnly(nodeRef, lockService);
    assertEquals(true, returnedVal);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:11,代码来源:LockUtilsTest.java


示例19: testIsLockedAndReadOnly_ForLockOwnerWithWriteLockType

import org.alfresco.service.cmr.lock.LockStatus; //导入依赖的package包/类
@Test
public void testIsLockedAndReadOnly_ForLockOwnerWithWriteLockType()
{
    when(lockService.getLockStatus(nodeRef)).thenReturn(LockStatus.LOCK_OWNER);
    when(lockService.getLockType(nodeRef)).thenReturn(LockType.WRITE_LOCK);
    when(lockService.isLockedAndReadOnly(nodeRef)).thenReturn(false);
    
    boolean returnedVal = LockUtils.isLockedAndReadOnly(nodeRef, lockService);
    assertEquals(false, returnedVal);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:11,代码来源:LockUtilsTest.java


示例20: testIsLockedAndReadOnly_ForLockOwnerWithNodeLockType

import org.alfresco.service.cmr.lock.LockStatus; //导入依赖的package包/类
@Test
public void testIsLockedAndReadOnly_ForLockOwnerWithNodeLockType()
{
    when(lockService.getLockStatus(nodeRef)).thenReturn(LockStatus.LOCK_OWNER);
    when(lockService.getLockType(nodeRef)).thenReturn(LockType.NODE_LOCK);
    when(lockService.isLockedAndReadOnly(nodeRef)).thenReturn(true);
    
    boolean returnedVal = LockUtils.isLockedAndReadOnly(nodeRef, lockService);
    assertEquals(true, returnedVal);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:11,代码来源:LockUtilsTest.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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