Search in sources :

Example 1 with LockState

use of org.alfresco.repo.lock.mem.LockState in project alfresco-remote-api by Alfresco.

the class WebDAVLockServiceImplTest method mnt13183LockInfo.

@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));
}
Also used : LockState(org.alfresco.repo.lock.mem.LockState) Test(org.junit.Test)

Example 2 with LockState

use of org.alfresco.repo.lock.mem.LockState in project alfresco-remote-api by Alfresco.

the class WebDAVLockServiceImpl method getLockInfo.

/**
 * Gets the lock status for the node reference relative to the current user.
 *
 * @see LockService#getLockStatus(org.alfresco.service.cmr.repository.NodeRef, String)
 *
 * @param nodeRef    the node reference
 * @return           the lock status
 */
@Override
public LockInfo getLockInfo(NodeRef nodeRef) {
    LockInfo lockInfo = null;
    LockState lockState = lockService.getLockState(nodeRef);
    if (lockState != null) {
        String additionalInfo = lockState.getAdditionalInfo();
        try {
            lockInfo = LockInfoImpl.fromJSON(additionalInfo);
        } catch (IllegalArgumentException e) {
            lockInfo = new LockInfoImpl();
        }
        lockInfo.setExpires(lockState.getExpires());
        lockInfo.setOwner(lockState.getOwner());
    }
    return lockInfo;
}
Also used : LockState(org.alfresco.repo.lock.mem.LockState)

Example 3 with LockState

use of org.alfresco.repo.lock.mem.LockState in project alfresco-repository by Alfresco.

the class LockServiceImpl method getLockStatus.

/**
 * Gets the lock status for a node and a user name
 *
 * @param nodeRef   the node reference
 * @param userName  the user name
 * @return          the lock status
 */
@Extend(traitAPI = LockServiceTrait.class, extensionAPI = LockServiceExtension.class)
public LockStatus getLockStatus(NodeRef nodeRef, String userName) {
    Pair<LockState, LockStatus> stateAndStatus = getLockStateAndStatus(nodeRef, userName);
    LockStatus lockStatus = stateAndStatus.getSecond();
    return lockStatus;
}
Also used : LockStatus(org.alfresco.service.cmr.lock.LockStatus) LockState(org.alfresco.repo.lock.mem.LockState) Extend(org.alfresco.traitextender.Extend)

Example 4 with LockState

use of org.alfresco.repo.lock.mem.LockState in project alfresco-repository by Alfresco.

the class LockServiceImpl method getLockStateAndStatus.

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);
}
Also used : LockStatus(org.alfresco.service.cmr.lock.LockStatus) LockState(org.alfresco.repo.lock.mem.LockState) Date(java.util.Date) Pair(org.alfresco.util.Pair)

Example 5 with LockState

use of org.alfresco.repo.lock.mem.LockState in project alfresco-repository by Alfresco.

the class LockServiceImpl method getAdditionalInfo.

@Override
@Extend(traitAPI = LockServiceTrait.class, extensionAPI = LockServiceExtension.class)
public String getAdditionalInfo(NodeRef nodeRef) {
    LockState lockState = getLockState(nodeRef);
    String additionalInfo = lockState.getAdditionalInfo();
    return additionalInfo;
}
Also used : LockState(org.alfresco.repo.lock.mem.LockState) Extend(org.alfresco.traitextender.Extend)

Aggregations

LockState (org.alfresco.repo.lock.mem.LockState)14 LockStatus (org.alfresco.service.cmr.lock.LockStatus)5 Extend (org.alfresco.traitextender.Extend)5 UnableToAquireLockException (org.alfresco.service.cmr.lock.UnableToAquireLockException)4 UnableToReleaseLockException (org.alfresco.service.cmr.lock.UnableToReleaseLockException)4 Date (java.util.Date)3 NotSupportedException (javax.transaction.NotSupportedException)3 SystemException (javax.transaction.SystemException)3 AccessDeniedException (org.alfresco.repo.security.permissions.AccessDeniedException)3 NodeLockedException (org.alfresco.service.cmr.lock.NodeLockedException)3 Lifetime (org.alfresco.repo.lock.mem.Lifetime)2 LockStore (org.alfresco.repo.lock.mem.LockStore)2 Serializable (java.io.Serializable)1 LockType (org.alfresco.service.cmr.lock.LockType)1 ChildAssociationRef (org.alfresco.service.cmr.repository.ChildAssociationRef)1 NodeService (org.alfresco.service.cmr.repository.NodeService)1 QName (org.alfresco.service.namespace.QName)1 Pair (org.alfresco.util.Pair)1 Test (org.junit.Test)1