From 6c45b22b37a7a3e34d5160d3c0dfe6f1848553cc Mon Sep 17 00:00:00 2001 From: Alan Davis Date: Wed, 12 Feb 2014 08:16:47 +0000 Subject: [PATCH] Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud) 59887: Merged V4.2-BUG-FIX (4.2.2) to HEAD-BUG-FIX (Cloud/4.3) 59643: Merged DEV to V4.2-BUG-FIX (4.2.2) 59235: MNT-10223 : CMIS: Created document has incorrect value on Properties tab Fixed the isLatestMajorVersion() implementation to return false if the version of the doc is minor. 59236: MNT-10223 : CMIS: Created document has incorrect value on Properties tab Added a test for the issue. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@62205 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../alfresco/opencmis/CMISNodeInfoImpl.java | 6 +- .../org/alfresco/opencmis/CMISTest.java | 70 +++++++++++++++++++ 2 files changed, 74 insertions(+), 2 deletions(-) diff --git a/source/java/org/alfresco/opencmis/CMISNodeInfoImpl.java b/source/java/org/alfresco/opencmis/CMISNodeInfoImpl.java index 269c45d491..6b7835e2fb 100644 --- a/source/java/org/alfresco/opencmis/CMISNodeInfoImpl.java +++ b/source/java/org/alfresco/opencmis/CMISNodeInfoImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2010 Alfresco Software Limited. + * Copyright (C) 2005-2013 Alfresco Software Limited. * * This file is part of Alfresco * @@ -592,7 +592,9 @@ public class CMISNodeInfoImpl implements CMISNodeInfo isLatestMajorVersion = Boolean.FALSE; if (!isPWC()) { - if(isCurrentNode()) + // MNT-10223. It should not be a version and not a minor version + Version version = getVersion(); + if (isCurrentNode() && version != null && version.getVersionType() == VersionType.MAJOR) { isLatestMajorVersion = Boolean.TRUE; } diff --git a/source/test-java/org/alfresco/opencmis/CMISTest.java b/source/test-java/org/alfresco/opencmis/CMISTest.java index 317d849b5d..0967e6f130 100644 --- a/source/test-java/org/alfresco/opencmis/CMISTest.java +++ b/source/test-java/org/alfresco/opencmis/CMISTest.java @@ -1,3 +1,22 @@ +/* + * Copyright (C) 2005-2013 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ + package org.alfresco.opencmis; import static org.junit.Assert.assertEquals; @@ -17,6 +36,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import org.alfresco.cmis.CMISDictionaryModel; import org.alfresco.model.ContentModel; import org.alfresco.repo.action.evaluator.ComparePropertyValueEvaluator; import org.alfresco.repo.action.executer.AddFeaturesActionExecuter; @@ -1317,4 +1337,54 @@ public class CMISTest assertEquals(2, ol.getNumItems()); assertEquals("3", changeLogToken.getValue()); } + + /** + * MNT-10223 + * Check the IsLatestMajorVersion for a doc with minor version. + */ + @Test + public void testIsLatestMajorVersion() + { + final TestContext testContext = new TestContext(); + + // create simple text plain content + final PropertiesImpl properties = new PropertiesImpl(); + String objectTypeId = "cmis:document"; + properties.addProperty(new PropertyIdImpl(PropertyIds.OBJECT_TYPE_ID, objectTypeId)); + String fileName = "textFile" + GUID.generate(); + properties.addProperty(new PropertyStringImpl(PropertyIds.NAME, fileName)); + final ContentStreamImpl contentStream = new ContentStreamImpl(fileName, MimetypeMap.MIMETYPE_TEXT_PLAIN, "Simple text plain document"); + + withCmisService(new CmisServiceCallback() { + @Override + public String execute(CmisService cmisService) { + List repositories = cmisService.getRepositoryInfos(null); + assertTrue(repositories.size() > 0); + RepositoryInfo repo = repositories.get(0); + String repositoryId = repo.getId(); + String objectId = cmisService.create(repositoryId, properties, repositoryHelper.getCompanyHome().getId(), contentStream, VersioningState.MINOR, null, null); + + ObjectData cmidDoc = cmisService.getObject(repositoryId, objectId, null, true, IncludeRelationships.NONE, null, false, false, null); + List> properties = cmidDoc.getProperties().getPropertyList(); + boolean found = false; + PropertyData propIsLatestMajorVersion = null; + for (PropertyData property : properties) + { + if (property.getId().equals(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION)) + { + found = true; + propIsLatestMajorVersion = property; + break; + } + } + //properties..contains(CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION); + assertTrue("The CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION property was not found", found); + if (found) + { + assertFalse("The CMISDictionaryModel.PROP_IS_LATEST_MAJOR_VERSION should be false as minor version was created", (Boolean) propIsLatestMajorVersion.getValues().get(0)); + } + return objectId; + } + }); + } }