From c657b2825aafdbc41fd990726631f6099e896880 Mon Sep 17 00:00:00 2001 From: Alan Davis Date: Thu, 9 Jul 2015 22:09:30 +0000 Subject: [PATCH] Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud) 108038: Merged 5.0.N (5.0.3) to HEAD-BUG-FIX (5.1/Cloud) 107601: Merged V4.2-BUG-FIX (4.2.5) to 5.0.N (5.0.3) 107332: Merged DEV to V4.2-BUG-FIX (4.2.5) 105981 : MNT-12226 : Alfresco fails to version metadata after uploading new content version even when autoVersionOnUpdateProps=true - Added config for upload.post.js webscript. So now users may configure versioning for Share APP separatelly. 106157 : MNT-12226 : Alfresco fails to version metadata after uploading new content version even when autoVersionOnUpdateProps=true - Updated previous solution so that if no config provided for upload.post.js webscript then default model versioning strategy used., 107537: MNT-12226 : Alfresco fails to version metadata after uploading new content version even when autoVersionOnUpdateProps=true - Fixed build failure. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@108069 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../repository/upload/upload.post.config.xml | 5 ++++ .../alfresco/repository/upload/upload.post.js | 26 ++++++++++++++++--- .../org/alfresco/rest/api/tests/TestCMIS.java | 12 +++++++++ 3 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 config/alfresco/templates/webscripts/org/alfresco/repository/upload/upload.post.config.xml diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/upload/upload.post.config.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/upload/upload.post.config.xml new file mode 100644 index 0000000000..f6b9a7a5d4 --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/upload/upload.post.config.xml @@ -0,0 +1,5 @@ + + + true + false + \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/upload/upload.post.js b/config/alfresco/templates/webscripts/org/alfresco/repository/upload/upload.post.js index 2a9ecc5883..a60e21613c 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/upload/upload.post.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/upload/upload.post.js @@ -55,6 +55,10 @@ function main() utils.setLocale(args["lang"]); } + var uploadConfig = new XML(config.script), + autoVersion = uploadConfig.autoVersion.toString() == "" ? null : uploadConfig.autoVersion.toString() == "true", + autoVersionProps = uploadConfig.autoVersionProps.toString() == "" ? null : uploadConfig.autoVersionProps.toString() == "true"; + // Parse file attributes for each (field in formdata.fields) { @@ -229,8 +233,15 @@ function main() if (!workingcopy) { - // Ensure the file is versionable (autoVersion = true, autoVersionProps = false) - updateNode.ensureVersioningEnabled(true, false); + // Ensure the file is versionable (autoVersion and autoVersionProps read from config) + if (autoVersion != null && autoVersionProps != null) + { + updateNode.ensureVersioningEnabled(autoVersion, autoVersionProps); + } + else + { + updateNode.ensureVersioningEnabled(); + } // It's not a working copy, do a check out to get the actual working copy updateNode = updateNode.checkoutForUpload(); @@ -362,8 +373,15 @@ function main() newFile.save(); // TODO (THOR-175) - review - // Ensure the file is versionable (autoVersion = true, autoVersionProps = false) - newFile.ensureVersioningEnabled(true, false); + // Ensure the file is versionable (autoVersion and autoVersionProps read from config) + if (autoVersion != null && autoVersionProps != null) + { + newFile.ensureVersioningEnabled(autoVersion, autoVersionProps); + } + else + { + newFile.ensureVersioningEnabled(); + } // NOTE: Removal of first request for thumbnails to improve upload performance // Thumbnails are still requested by Share on first render of the doclist image. diff --git a/source/test-java/org/alfresco/rest/api/tests/TestCMIS.java b/source/test-java/org/alfresco/rest/api/tests/TestCMIS.java index 9f0e002c6f..65858abd46 100644 --- a/source/test-java/org/alfresco/rest/api/tests/TestCMIS.java +++ b/source/test-java/org/alfresco/rest/api/tests/TestCMIS.java @@ -61,6 +61,7 @@ import org.alfresco.repo.tenant.TenantService; import org.alfresco.repo.tenant.TenantUtil; import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; +import org.alfresco.repo.version.VersionableAspect; import org.alfresco.rest.api.tests.RepoService.SiteInformation; import org.alfresco.rest.api.tests.RepoService.TestNetwork; import org.alfresco.rest.api.tests.RepoService.TestPerson; @@ -122,6 +123,7 @@ import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictExcept import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.io.IOUtils; +import org.junit.After; import org.junit.Before; import org.junit.Test; import org.springframework.context.ApplicationContext; @@ -155,6 +157,7 @@ public class TestCMIS extends EnterpriseTestApi private CMISStrictDictionaryService cmisDictionary; private QNameFilter cmisTypeExclusions; private NodeService nodeService; + private VersionableAspect versionableAspect; @Before public void before() throws Exception @@ -166,6 +169,15 @@ public class TestCMIS extends EnterpriseTestApi this.cmisDictionary = (CMISStrictDictionaryService)ctx.getBean("OpenCMISDictionaryService"); this.cmisTypeExclusions = (QNameFilter)ctx.getBean("cmisTypeExclusions"); this.nodeService = (NodeService) ctx.getBean("NodeService"); + + this.versionableAspect = (VersionableAspect) ctx.getBean("versionableAspect"); + this.versionableAspect.setEnableAutoVersionOnUpdateProps(true); + } + + @After + public void after() + { + this.versionableAspect.setEnableAutoVersionOnUpdateProps(false); } private void checkSecondaryTypes(Document doc, Set expectedSecondaryTypes, Set expectedMissingSecondaryTypes)