From 3214f17fe23e9afd81afee138f962634f00b878f Mon Sep 17 00:00:00 2001 From: Alan Davis Date: Fri, 14 Mar 2014 17:42:24 +0000 Subject: [PATCH] Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud) 64097: Merged V4.2-BUG-FIX (4.2.2) to HEAD-BUG-FIX (4.3.0.BF) 63991: Merged DEV to V4.2-BUG-FIX (4.2.2) 63740: ALF-20389: CMIS webservice gives cast problem - Now, only ContentStreamImpl extensions will be checked for mimetype. Also, unit test was added. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@64354 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../AlfrescoCmisStreamInterceptor.java | 2 +- .../org/alfresco/opencmis/CMISTest.java | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/source/java/org/alfresco/opencmis/AlfrescoCmisStreamInterceptor.java b/source/java/org/alfresco/opencmis/AlfrescoCmisStreamInterceptor.java index 35953e6d56..8f755c5f9e 100644 --- a/source/java/org/alfresco/opencmis/AlfrescoCmisStreamInterceptor.java +++ b/source/java/org/alfresco/opencmis/AlfrescoCmisStreamInterceptor.java @@ -54,7 +54,7 @@ public class AlfrescoCmisStreamInterceptor implements MethodInterceptor Object[] arguments = mi.getArguments(); for (int i = 0; i < parameterTypes.length; i++) { - if (parameterTypes[i].isAssignableFrom(ContentStreamImpl.class)) + if (arguments[i] instanceof ContentStreamImpl) { ContentStreamImpl contentStream = (ContentStreamImpl) arguments[i]; if (contentStream != null) diff --git a/source/test-java/org/alfresco/opencmis/CMISTest.java b/source/test-java/org/alfresco/opencmis/CMISTest.java index f8b1f7af13..4a017e6ed2 100644 --- a/source/test-java/org/alfresco/opencmis/CMISTest.java +++ b/source/test-java/org/alfresco/opencmis/CMISTest.java @@ -78,9 +78,11 @@ import org.apache.chemistry.opencmis.commons.enums.CmisVersion; import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships; import org.apache.chemistry.opencmis.commons.enums.VersioningState; import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException; +import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException; import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException; import org.apache.chemistry.opencmis.commons.impl.dataobjects.CmisExtensionElementImpl; import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl; +import org.apache.chemistry.opencmis.commons.impl.dataobjects.ExtensionDataImpl; import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertiesImpl; import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIdImpl; import org.apache.chemistry.opencmis.commons.impl.dataobjects.PropertyIntegerDefinitionImpl; @@ -639,6 +641,37 @@ public class CMISTest } } + /** + * ALF-20389 Test Alfresco cmis stream interceptor that checks content stream for mimetype. Only ContentStreamImpl extensions should take palace. + */ + @Test + public void testGetRepositoryInfos() + { + boolean cmisEx = false; + List infoDataList = null; + try + { + infoDataList = withCmisService(new CmisServiceCallback>() + { + @Override + public List execute(CmisService cmisService) + { + ExtensionDataImpl result = new ExtensionDataImpl(); + List extensions = new ArrayList(); + result.setExtensions(extensions); + + return cmisService.getRepositoryInfos(result); + } + }); + } + catch (CmisRuntimeException e) + { + cmisEx = true; + } + + assertNotNull(cmisEx ? "CmisRuntimeException was thrown. Please, take a look on ALF-20389" : "No CMIS repository information was retrieved", infoDataList); + } + private static class TestContext { private String repositoryId = null;