Merged BRANCHES/V4.2 to HEAD:

55206: Branch created for 4.2.x releases.
   55209: Merged HEAD to BRANCHES/V4.2:
        55208: Added Sharepoint config to unit test classpath to fix VtiRequestDispatcherTest.
   55222: Merged HEAD-BUG-FIX to V4.2
        55220: Merged V4.1-BUG-FIX (4.1.7) to HEAD-BUG-FIX (4.2)
           55218: Fix for ALF-19894 Site is not displayed after restoring from Trashcan
             This bug was reported on 4.2, but the bug is also present on 4.1.
             I have added a testcase to reproduce the bug along with a fix.
             The problem was in SiteServiceImpl.delete where the code was writing an empty property value into the {}memberships property
             and therefore there was no record of which users had been members of the deleted site.
   55245: Fixed javadoc while checking that ALF-19055 was fixed.  ActivityService no longer uses 'format
   55246: CLOUD-2050 -Content changes are not synced from Cloud to On-Premise (errors in the logs)
   55249: Hazelcast: Added ability to create cache with 'read-backup-data' via property *.readBackupData
   55250: Hazelcast cache builder now accepts 'async-backup-count' value and any error in setting a value logs the full exception
   55251: Asynchronous cache: Better logging of in- and after-transaction processes
   55252: Asynchronous cache: Better logging of in- and after-transaction processes
   55266: Workflow REST API fix for variable retrieval
   55276: Merged HEAD to BRANCHES/V4.2:
        55274: Disabling Sharepoint unit tests until we can make them run properly in the build.
   55278: ALF-19889 - String for Brazilian Portuguese
   55279: Merged DEV to 4.2
        ALF-17464 : Replication jobs aren't displayed until sorting by some characteristic
           - Changing not exact equals (!==) to not euqals (!=)
   55280: Fix for ALF-19865 - Forgot password link redirects to Login page. Also cleaned up the mess that is the 'Sign in to Alfresco in the cloud' dialog.
   55281: Probable fix for ALF-19225 Intermittent test failures in SubscriptionServiceActivitiesTest
   55282: ALF-19865 - Cloud Sync profile area now looks like the rest of profile area.
   55285: Merged BRANCHES/DEV/BELARUS/HEAD-2013_08_27 to BRANCHES/V4.2:
        55068: ALF-19915 : MT and WebDAV: Content is lost when uploading non-empty document
   55286: Merged BRANCHES/DEV/BELARUS/HEAD-2013_08_29 to BRANCHES/V4.2:
        55207: ALF-19915 : MT and WebDAV: Content is lost when uploading non-empty document
        55210: ALF-19915 : MT and WebDAV: Content is lost when uploading non-empty document
   55297: As part of prep work for fixing ALF-20023 Recent Sites and Favorite Sites in copy/move pickers empty,
   55299: ALF-19556: IE10 specific fix for file upload browse (impressive how IE finds more and more innovative ways to spoil things for itself)
   55300: Fixed date issue when creating a new process instance
   55308: Resync to HEAD@55302


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@55309 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Brian Remmington
2013-09-15 15:00:13 +00:00
parent 4fcdc669d9
commit 7f8effa1f4
7 changed files with 246 additions and 15 deletions

View File

@@ -1086,4 +1086,14 @@ public class WebDAVHelper
{ {
return LockUtils.isLockedAndReadOnly(nodeRef, m_serviceRegistry.getLockService()); return LockUtils.isLockedAndReadOnly(nodeRef, m_serviceRegistry.getLockService());
} }
/**
* Indicates if the node is locked and the current user is not lock owner<p>
*
* @param nodeRef the node reference
*/
public boolean isLockedAndNotLockOwner(final NodeRef nodeRef)
{
return LockUtils.isLockedAndNotLockOwner(nodeRef, m_serviceRegistry.getLockService());
}
} }

View File

@@ -1010,7 +1010,7 @@ public abstract class WebDAVMethod
NodeRef nodeRef = fileInfo.getNodeRef(); NodeRef nodeRef = fileInfo.getNodeRef();
// Regardless of WebDAV locks, if we can't write to this node, then it's locked! // Regardless of WebDAV locks, if we can't write to this node, then it's locked!
if (getDAVHelper().isLockedAndReadOnly(nodeRef)) if (getDAVHelper().isLockedAndNotLockOwner(nodeRef))
{ {
throw new WebDAVServerException(WebDAV.WEBDAV_SC_LOCKED); throw new WebDAVServerException(WebDAV.WEBDAV_SC_LOCKED);
} }

View File

@@ -480,7 +480,7 @@ public class ProcessesImpl extends WorkflowRestImpl implements Processes
if (startFormData != null) if (startFormData != null)
{ {
String formKey = startFormData.getFormKey(); String formKey = startFormData.getFormKey();
definitionTypeMap.put(processInfo.getProcessDefinitionId(), workflowFactory.getTaskFullTypeDefinition(formKey, true)); definitionTypeMap.put(processInfo.getProcessDefinitionId(), getWorkflowFactory().getTaskFullTypeDefinition(formKey, true));
} }
} }
@@ -676,12 +676,22 @@ public class ProcessesImpl extends WorkflowRestImpl implements Processes
} }
} }
} }
else if (taskProperties.containsKey(propNameMap.get(variableName)))
{
PropertyDefinition propDef = taskProperties.get(propNameMap.get(variableName));
DataTypeDefinition propDataType = propDef.getDataType();
if ("java.util.Date".equalsIgnoreCase(propDataType.getJavaClassName()))
{
// fix for different ISO 8601 Date format classes in Alfresco (org.alfresco.util and Spring Surf)
variableValue = ISO8601DateFormat.parse((String) variableValue);
}
}
if (variableValue instanceof Serializable) if (variableValue instanceof Serializable)
{ {
startParams.put(propNameMap.get(variableName), (Serializable) variableValue); startParams.put(propNameMap.get(variableName), (Serializable) variableValue);
} }
} }
} }
} }
} }
@@ -888,7 +898,7 @@ public class ProcessesImpl extends WorkflowRestImpl implements Processes
formKey = startFormData.getFormKey(); formKey = startFormData.getFormKey();
} }
TypeDefinition startTaskTypeDefinition = workflowFactory.getTaskFullTypeDefinition(formKey, true); TypeDefinition startTaskTypeDefinition = getWorkflowFactory().getTaskFullTypeDefinition(formKey, true);
// Convert raw variables to Variable objects // Convert raw variables to Variable objects
List<Variable> resultingVariables = restVariableHelper.getVariables(variables, startTaskTypeDefinition); List<Variable> resultingVariables = restVariableHelper.getVariables(variables, startTaskTypeDefinition);

View File

@@ -59,7 +59,7 @@ public class RestVariableHelper
private NamespaceService namespaceService; private NamespaceService namespaceService;
private WorkflowQNameConverter qnameConverter; private WorkflowQNameConverter qNameConverter;
public static final Set<String> INTERNAL_PROPERTIES = new HashSet<String>(Arrays.asList(ActivitiConstants.VAR_TENANT_DOMAIN)); public static final Set<String> INTERNAL_PROPERTIES = new HashSet<String>(Arrays.asList(ActivitiConstants.VAR_TENANT_DOMAIN));
@@ -71,7 +71,15 @@ public class RestVariableHelper
public void setNamespaceService(NamespaceService namespaceService) public void setNamespaceService(NamespaceService namespaceService)
{ {
this.namespaceService = namespaceService; this.namespaceService = namespaceService;
this.qnameConverter = new WorkflowQNameConverter(namespaceService); }
protected WorkflowQNameConverter getQNameConverter()
{
if (qNameConverter == null)
{
qNameConverter = new WorkflowQNameConverter(namespaceService);
}
return qNameConverter;
} }
/** /**
@@ -84,13 +92,13 @@ public class RestVariableHelper
TypeDefinition startFormTypeDefinition, TypeDefinition taskTypeDefinition) TypeDefinition startFormTypeDefinition, TypeDefinition taskTypeDefinition)
{ {
List<TaskVariable> result = new ArrayList<TaskVariable>(); List<TaskVariable> result = new ArrayList<TaskVariable>();
if (localVariables != null) if (localVariables != null && localVariables.size() > 0)
{ {
TypeDefinitionContext context = new TypeDefinitionContext(taskTypeDefinition); TypeDefinitionContext context = new TypeDefinitionContext(taskTypeDefinition);
addTaskVariables(result, localVariables, context, VariableScope.LOCAL); addTaskVariables(result, localVariables, context, VariableScope.LOCAL);
} }
if (globalVariables != null) if (globalVariables != null && globalVariables.size() > 0)
{ {
TypeDefinitionContext context = new TypeDefinitionContext(startFormTypeDefinition); TypeDefinitionContext context = new TypeDefinitionContext(startFormTypeDefinition);
addTaskVariables(result, globalVariables, context, VariableScope.GLOBAL); addTaskVariables(result, globalVariables, context, VariableScope.GLOBAL);
@@ -381,12 +389,12 @@ public class RestVariableHelper
for (Entry<QName, PropertyDefinition> entry : typeDefinition.getProperties().entrySet()) for (Entry<QName, PropertyDefinition> entry : typeDefinition.getProperties().entrySet())
{ {
propertyDefinitions.put(qnameConverter.mapQNameToName(entry.getKey()), entry.getValue()); propertyDefinitions.put(getQNameConverter().mapQNameToName(entry.getKey()), entry.getValue());
} }
for (Entry<QName, AssociationDefinition> entry : typeDefinition.getAssociations().entrySet()) for (Entry<QName, AssociationDefinition> entry : typeDefinition.getAssociations().entrySet())
{ {
associationDefinitions.put(qnameConverter.mapQNameToName(entry.getKey()), entry.getValue()); associationDefinitions.put(getQNameConverter().mapQNameToName(entry.getKey()), entry.getValue());
} }
} }

View File

@@ -487,7 +487,7 @@ public class TasksImpl extends WorkflowRestImpl implements Tasks
if (startFormData != null) if (startFormData != null)
{ {
String formKey = startFormData.getFormKey(); String formKey = startFormData.getFormKey();
definitionTypeMap.put(task.getProcessDefinitionId(), workflowFactory.getTaskFullTypeDefinition(formKey, true)); definitionTypeMap.put(task.getProcessDefinitionId(), getWorkflowFactory().getTaskFullTypeDefinition(formKey, true));
} }
} }
@@ -878,7 +878,7 @@ public class TasksImpl extends WorkflowRestImpl implements Tasks
StartFormData startFormData = activitiProcessEngine.getFormService().getStartFormData(taskInstance.getProcessDefinitionId()); StartFormData startFormData = activitiProcessEngine.getFormService().getStartFormData(taskInstance.getProcessDefinitionId());
if (startFormData != null) if (startFormData != null)
{ {
startFormTypeDefinition = workflowFactory.getTaskFullTypeDefinition(startFormData.getFormKey(), true); startFormTypeDefinition = getWorkflowFactory().getTaskFullTypeDefinition(startFormData.getFormKey(), true);
} }
else else
{ {

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2005-2012 Alfresco Software Limited. * Copyright (C) 2005-2013 Alfresco Software Limited.
* *
* This file is part of Alfresco * This file is part of Alfresco
* *
@@ -19,14 +19,32 @@
package org.alfresco.repo.webdav; package org.alfresco.repo.webdav;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.tenant.TenantAdminService;
import org.alfresco.repo.tenant.TenantService;
import org.alfresco.repo.tenant.TenantUtil;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.ApplicationContextHelper;
import org.alfresco.util.GUID;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner; import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.context.ApplicationContext;
import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse; import org.springframework.mock.web.MockHttpServletResponse;
import java.util.List;
/** /**
* Tests for the WebDAVMethod class. * Tests for the WebDAVMethod class.
* *
@@ -39,7 +57,152 @@ public class WebDAVMethodTest
private MockHttpServletRequest req; private MockHttpServletRequest req;
private MockHttpServletResponse resp; private MockHttpServletResponse resp;
private @Mock WebDAVHelper davHelper; private @Mock WebDAVHelper davHelper;
private NodeService nodeService;
private SearchService searchService;
private NamespaceService namespaceService;
private TenantService tenantService;
private TransactionService transactionService;
private WebDAVHelper webDAVHelper;
private TenantAdminService tenantAdminService;
private @Mock LockMethod lockMethod;
private @Mock PutMethod putMethod;
public static final String TEST_RUN = System.currentTimeMillis()+"";
public static final String TEST_TENANT_DOMAIN = TEST_RUN+".my.test";
public static final String DEFAULT_ADMIN_PW = "admin";
protected void setUpApplicationContext()
{
ApplicationContext appContext = ApplicationContextHelper.getApplicationContext(new String[]
{
"classpath:alfresco/application-context.xml", "classpath:alfresco/web-scripts-application-context.xml",
"classpath:alfresco/remote-api-context.xml"
});
this.nodeService = (NodeService) appContext.getBean("NodeService");
this.searchService = (SearchService) appContext.getBean("SearchService");
this.namespaceService = (NamespaceService) appContext.getBean("NamespaceService");
this.tenantService = (TenantService) appContext.getBean("tenantService");
this.transactionService = (TransactionService) appContext.getBean("transactionService");
this.webDAVHelper = (WebDAVHelper) appContext.getBean("webDAVHelper");
this.tenantAdminService = (TenantAdminService) appContext.getBean("tenantAdminService");
// Authenticate as system to create initial test data set
AuthenticationComponent authenticationComponent = (AuthenticationComponent) appContext.getBean("authenticationComponent");
authenticationComponent.setSystemUserAsCurrentUser();
}
private void checkLockedNodeTestWork() throws WebDAVServerException
{
req = new MockHttpServletRequest();
resp = new MockHttpServletResponse();
String rootPath = "/app:company_home";
String storeName = "workspace://SpacesStore";
StoreRef storeRef = new StoreRef(storeName);
NodeRef storeRootNodeRef = nodeService.getRootNode(storeRef);
List<NodeRef> nodeRefs = searchService.selectNodes(storeRootNodeRef, rootPath, null, namespaceService, false);
NodeRef defaultRootNode = nodeRefs.get(0);
lockMethod = new LockMethod();
NodeRef rootNodeRef = tenantService.getRootNode(nodeService, searchService, namespaceService, rootPath, defaultRootNode);
String strPath = "/" + "testLockedNode" + GUID.generate();
lockMethod.createExclusive = true;
lockMethod.setDetails(req, resp, webDAVHelper, rootNodeRef);
lockMethod.m_strPath = strPath;
// Lock the node (will create a new one).
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Object>()
{
@Override
public Object execute() throws Throwable {
lockMethod.executeImpl();
return null;
}
});
// Prepare for PUT
req.addHeader(WebDAV.HEADER_IF, "(<" + lockMethod.lockToken + ">)");
putMethod = new PutMethod();
putMethod.setDetails(req, resp, webDAVHelper, rootNodeRef);
putMethod.parseRequestHeaders();
putMethod.m_strPath = strPath;
String content = "test content stream";
req.setContent(content.getBytes());
// Issue a put request
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Object>()
{
@Override
public Object execute() throws Throwable
{
putMethod.executeImpl();
return null;
}
});
}
/**
* Call the org.alfresco.repo.webdav.WebDAVMethod#checkNode(org.alfresco.service.cmr.model.FileInfo, boolean, boolean)
* for a write locked node for tenant and non-tenant.
* See ALF-19915.
*/
@Test
public void checkLockedNodeTest() throws Exception
{
setUpApplicationContext();
// Create a tenant domain
TenantUtil.runAsSystemTenant(new TenantUtil.TenantRunAsWork<Object>() {
public Object doWork() throws Exception {
if (!tenantAdminService.existsTenant(TEST_TENANT_DOMAIN))
{
tenantAdminService.createTenant(TEST_TENANT_DOMAIN, (DEFAULT_ADMIN_PW + " " + TEST_TENANT_DOMAIN).toCharArray(), null);
}
return null;
}
}, TenantService.DEFAULT_DOMAIN);
// run as admin
try
{
TenantUtil.runAsUserTenant(new TenantUtil.TenantRunAsWork<Object>()
{
@Override
public Object doWork() throws Exception
{
checkLockedNodeTestWork();
return null;
}
}, AuthenticationUtil.getAdminUserName(), TenantService.DEFAULT_DOMAIN);
}
catch (Exception e)
{
fail("Failed to lock and put content as admin with error: " + e.getCause());
}
// run as tenant admin
try
{
TenantUtil.runAsUserTenant(new TenantUtil.TenantRunAsWork<Object>()
{
@Override
public Object doWork() throws Exception
{
checkLockedNodeTestWork();
return null;
}
}, AuthenticationUtil.getAdminUserName(), TEST_TENANT_DOMAIN);
}
catch (Exception e)
{
fail("Failed to lock and put content as tenant admin with error: " + e.getCause());
}
}
@Test @Test
public void canGetStatusForAccessDeniedException() public void canGetStatusForAccessDeniedException()
{ {

View File

@@ -162,7 +162,7 @@ public class ProcessWorkflowApiTest extends EnterpriseWorkflowTestApi
JSONObject createProcessObject = new JSONObject(); JSONObject createProcessObject = new JSONObject();
createProcessObject.put("processDefinitionKey", "activitiAdhoc"); createProcessObject.put("processDefinitionKey", "activitiAdhoc");
final JSONObject variablesObject = new JSONObject(); final JSONObject variablesObject = new JSONObject();
variablesObject.put("bpm_dueDate", ISO8601DateFormat.format(new Date())); variablesObject.put("bpm_dueDate", "2013-09-30T00:00:00.000+0300");
variablesObject.put("bpm_priority", 1); variablesObject.put("bpm_priority", 1);
variablesObject.put("bpm_description", "test description"); variablesObject.put("bpm_description", "test description");
TenantUtil.runAsUserTenant(new TenantRunAsWork<Void>() TenantUtil.runAsUserTenant(new TenantRunAsWork<Void>()
@@ -744,6 +744,15 @@ public class ProcessWorkflowApiTest extends EnterpriseWorkflowTestApi
assertEquals(1, processList.getList().size()); assertEquals(1, processList.getList().size());
// include process variables as well // include process variables as well
paramMap = new HashMap<String, String>();
paramMap.put("where", "(includeVariables=true)");
paramMap.put("maxItems", "1");
paramMap.put("skipCount", "0");
processList = processesClient.getProcesses(paramMap);
assertNotNull(processList);
assertEquals(1, processList.getList().size());
paramMap = new HashMap<String, String>(); paramMap = new HashMap<String, String>();
paramMap.put("where", "(processDefinitionKey = 'activitiAdhoc' AND includeVariables = true)"); paramMap.put("where", "(processDefinitionKey = 'activitiAdhoc' AND includeVariables = true)");
paramMap.put("maxItems", "1"); paramMap.put("maxItems", "1");
@@ -828,6 +837,37 @@ public class ProcessWorkflowApiTest extends EnterpriseWorkflowTestApi
} }
} }
@Test
public void testGetProcessInstancesWithDifferentProcessDefs() throws Exception
{
final RequestContext requestContext = initApiClientWithTestUser();
final ProcessInfo process1 = startAdhocProcess(requestContext, null);
final ProcessInfo process2 = startParallelReviewProcess(requestContext);
final ProcessInfo process3 = startReviewPooledProcess(requestContext);
try
{
ProcessesClient processesClient = publicApiClient.processesClient();
Map<String, String> paramMap = new HashMap<String, String>();
ListResponse<ProcessInfo> processList = processesClient.getProcesses(paramMap);
assertNotNull(processList);
assertEquals(3, processList.getList().size());
// include process variables as well
paramMap = new HashMap<String, String>();
paramMap.put("where", "(includeVariables=true)");
processList = processesClient.getProcesses(paramMap);
assertNotNull(processList);
assertEquals(3, processList.getList().size());
}
finally
{
cleanupProcessInstance(process1.getId(), process2.getId(), process3.getId());
}
}
@Test @Test
public void testGetProcessInstancesWithPaging() throws Exception public void testGetProcessInstancesWithPaging() throws Exception
{ {