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));
}
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;
}
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;
}
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);
}
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;
}
Aggregations