Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)

98073: Merged 5.0.N (5.0.2) to HEAD-BUG-FIX (5.1/Cloud)
      97984: Merged V4.2-BUG-FIX (4.2.5) to 5.0.N (5.0.2)
         97763: Merged DEV to V4.2-BUG-FIX
          96388: MNT-13183 : Folder accessed through WebDAV is empty when a document is locked through CIFS access
           Detect "AlfrescoLockKeeperImpl" and then create new LockInfo object. 
          97572: MNT-13183 : Folder accessed through WebDAV is empty when a document is locked through CIFS access
           Added marker for webdav lock. Added new junit test.
          97725: MNT-13183 : Folder accessed through WebDAV is empty when a document is locked through CIFS access
           Corrected some code. 


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@98102 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2015-02-26 07:46:57 +00:00
parent f7b7a8c2bd
commit 7802d4d1dc
3 changed files with 48 additions and 10 deletions

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2010 Alfresco Software Limited. * Copyright (C) 2005-2015 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -40,6 +40,8 @@ public class LockInfoImpl implements Serializable, LockInfo
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public static final String ADDINFO_WEBDAV_MARKER = "WebDAV_LockInfo";
// Exclusive lock token // Exclusive lock token
private String exclusiveLockToken = null; private String exclusiveLockToken = null;
@@ -264,20 +266,29 @@ public class LockInfoImpl implements Serializable, LockInfo
{ {
throw new RuntimeException("Unable to generate JSON for " + toString(), e); throw new RuntimeException("Unable to generate JSON for " + toString(), e);
} }
return json; return ADDINFO_WEBDAV_MARKER + ":" + json;
} }
public static LockInfo fromJSON(String json) public static LockInfo fromJSON(String json)
{ {
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
if (json != null && json.startsWith(ADDINFO_WEBDAV_MARKER))
{
try try
{ {
json = json.substring(ADDINFO_WEBDAV_MARKER.length() + 1);
LockInfo lockInfo = objectMapper.readValue(json, LockInfoImpl.class); LockInfo lockInfo = objectMapper.readValue(json, LockInfoImpl.class);
return lockInfo; return lockInfo;
} }
catch (Throwable e) catch (Throwable e)
{ {
throw new RuntimeException("Unable to parse JSON from [" + json + "]", e); throw new IllegalArgumentException("Unable to parse JSON from [" + json + "]", e);
}
}
else
{
throw new IllegalArgumentException("Was not detected WEBDAV_LOCK marker.");
} }
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2012 Alfresco Software Limited. * Copyright (C) 2005-2015 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -343,14 +343,16 @@ public class WebDAVLockServiceImpl implements WebDAVLockService
if (lockState != null) if (lockState != null)
{ {
String additionalInfo = lockState.getAdditionalInfo(); String additionalInfo = lockState.getAdditionalInfo();
if (additionalInfo != null)
try
{ {
lockInfo = LockInfoImpl.fromJSON(additionalInfo); lockInfo = LockInfoImpl.fromJSON(additionalInfo);
} }
else catch (IllegalArgumentException e)
{ {
lockInfo = new LockInfoImpl(); lockInfo = new LockInfoImpl();
} }
lockInfo.setExpires(lockState.getExpires()); lockInfo.setExpires(lockState.getExpires());
lockInfo.setOwner(lockState.getOwner()); lockInfo.setOwner(lockState.getOwner());
} }

View File

@@ -2,6 +2,8 @@ package org.alfresco.repo.webdav;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any; import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean; import static org.mockito.Matchers.anyBoolean;
@@ -203,4 +205,27 @@ public class WebDAVLockServiceImplTest
lockInfo = davLockService.getLockInfo(nodeRef3); lockInfo = davLockService.getLockInfo(nodeRef3);
assertEquals(null, lockInfo); assertEquals(null, lockInfo);
} }
@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));
}
} }