From 05cf5fb4d2935f920d84d60f3403b8c0962aedaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BC?= Date: Mon, 7 Nov 2011 19:43:18 +0000 Subject: [PATCH] - reverted behaviour of CMIS createDocument() with VersioningState == CHECKEDOUT - added support for sticky sessions to CMIS server git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31819 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/opencmis-context.xml | 3 ++ .../opencmis/AlfrescoCmisService.java | 9 +++++ .../org/alfresco/opencmis/CMISConnector.java | 33 ++++++++++++++----- 3 files changed, 36 insertions(+), 9 deletions(-) diff --git a/config/alfresco/opencmis-context.xml b/config/alfresco/opencmis-context.xml index 397cf3fe3b..b4c85792cf 100644 --- a/config/alfresco/opencmis-context.xml +++ b/config/alfresco/opencmis-context.xml @@ -59,6 +59,9 @@ + + + diff --git a/source/java/org/alfresco/opencmis/AlfrescoCmisService.java b/source/java/org/alfresco/opencmis/AlfrescoCmisService.java index 7457f1cbd6..a4d948ba5f 100644 --- a/source/java/org/alfresco/opencmis/AlfrescoCmisService.java +++ b/source/java/org/alfresco/opencmis/AlfrescoCmisService.java @@ -35,6 +35,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.servlet.http.HttpServletRequest; import javax.transaction.Status; import javax.transaction.UserTransaction; @@ -170,6 +171,14 @@ public class AlfrescoCmisService extends AbstractCmisService { this.context = context; + if (connector.openHttpSession()) + { + // create a session -> set a cookie + // if the CMIS client supports cookies that might help in clustered + // environments + ((HttpServletRequest) context.get(CallContext.HTTP_SERVLET_REQUEST)).getSession(); + } + AuthenticationUtil.pushAuthentication(); try diff --git a/source/java/org/alfresco/opencmis/CMISConnector.java b/source/java/org/alfresco/opencmis/CMISConnector.java index 529887743b..d240b0c045 100644 --- a/source/java/org/alfresco/opencmis/CMISConnector.java +++ b/source/java/org/alfresco/opencmis/CMISConnector.java @@ -251,6 +251,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen private Map rootNodeRefs = new ConcurrentHashMap(1); private Map renditionMapping = new ConcurrentHashMap(1); private String proxyUser; + private boolean openHttpSession = false; // OpenCMIS objects private BigInteger typesDefaultMaxItems = TYPES_DEFAULT_MAX_ITEMS; @@ -335,6 +336,16 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen this.kindToRenditionNames = renditionKinds; } + public void setOpenHttpSession(boolean openHttpSession) + { + this.openHttpSession = openHttpSession; + } + + public boolean openHttpSession() + { + return openHttpSession; + } + /** * Sets the descriptor service. */ @@ -812,8 +823,17 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen */ public void applyVersioningState(NodeRef nodeRef, VersioningState versioningState) { - if ((versioningState == VersioningState.MAJOR) || (versioningState == VersioningState.MINOR) - || (versioningState == VersioningState.CHECKEDOUT)) + if (versioningState == VersioningState.CHECKEDOUT) + { + if (!nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE)) + { + Map props = new HashMap(); + props.put(ContentModel.PROP_INITIAL_VERSION, false); + props.put(ContentModel.PROP_AUTO_VERSION, false); + nodeService.addAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE, props); + } + getCheckOutCheckInService().checkout(nodeRef); + } else if ((versioningState == VersioningState.MAJOR) || (versioningState == VersioningState.MINOR)) { if (!nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE)) { @@ -824,17 +844,12 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen } Map versionProperties = new HashMap(5); - versionProperties.put(VersionModel.PROP_VERSION_TYPE, versioningState == VersioningState.MAJOR - || versioningState == VersioningState.CHECKEDOUT ? VersionType.MAJOR : VersionType.MINOR); + versionProperties.put(VersionModel.PROP_VERSION_TYPE, + versioningState == VersioningState.MAJOR ? VersionType.MAJOR : VersionType.MINOR); versionProperties.put(VersionModel.PROP_DESCRIPTION, "Initial Version"); versionService.createVersion(nodeRef, versionProperties); } - - if (versioningState == VersioningState.CHECKEDOUT) - { - getCheckOutCheckInService().checkout(nodeRef); - } } /**