- 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
This commit is contained in:
Florian Mü
2011-11-07 19:43:18 +00:00
parent cd92e7c08e
commit 05cf5fb4d2
3 changed files with 36 additions and 9 deletions

View File

@@ -60,6 +60,9 @@
</map> </map>
</property> </property>
<!-- Uncomment the following line to support sticky sessions. Make sure the CMIS client supports cookies. -->
<!-- <property name="openHttpSession" value="true" /> -->
<property name="OpenCMISDictionaryService" ref="OpenCMISDictionaryService" /> <property name="OpenCMISDictionaryService" ref="OpenCMISDictionaryService" />
<property name="OpenCMISQueryService" ref="OpenCMISQueryService" /> <property name="OpenCMISQueryService" ref="OpenCMISQueryService" />

View File

@@ -35,6 +35,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.transaction.Status; import javax.transaction.Status;
import javax.transaction.UserTransaction; import javax.transaction.UserTransaction;
@@ -170,6 +171,14 @@ public class AlfrescoCmisService extends AbstractCmisService
{ {
this.context = context; 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(); AuthenticationUtil.pushAuthentication();
try try

View File

@@ -251,6 +251,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
private Map<String, NodeRef> rootNodeRefs = new ConcurrentHashMap<String, NodeRef>(1); private Map<String, NodeRef> rootNodeRefs = new ConcurrentHashMap<String, NodeRef>(1);
private Map<String, CMISRenditionMapping> renditionMapping = new ConcurrentHashMap<String, CMISRenditionMapping>(1); private Map<String, CMISRenditionMapping> renditionMapping = new ConcurrentHashMap<String, CMISRenditionMapping>(1);
private String proxyUser; private String proxyUser;
private boolean openHttpSession = false;
// OpenCMIS objects // OpenCMIS objects
private BigInteger typesDefaultMaxItems = TYPES_DEFAULT_MAX_ITEMS; private BigInteger typesDefaultMaxItems = TYPES_DEFAULT_MAX_ITEMS;
@@ -335,6 +336,16 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
this.kindToRenditionNames = renditionKinds; this.kindToRenditionNames = renditionKinds;
} }
public void setOpenHttpSession(boolean openHttpSession)
{
this.openHttpSession = openHttpSession;
}
public boolean openHttpSession()
{
return openHttpSession;
}
/** /**
* Sets the descriptor service. * Sets the descriptor service.
*/ */
@@ -812,8 +823,17 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
*/ */
public void applyVersioningState(NodeRef nodeRef, VersioningState versioningState) public void applyVersioningState(NodeRef nodeRef, VersioningState versioningState)
{ {
if ((versioningState == VersioningState.MAJOR) || (versioningState == VersioningState.MINOR) if (versioningState == VersioningState.CHECKEDOUT)
|| (versioningState == VersioningState.CHECKEDOUT)) {
if (!nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE))
{
Map<QName, Serializable> props = new HashMap<QName, Serializable>();
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)) if (!nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE))
{ {
@@ -824,17 +844,12 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
} }
Map<String, Serializable> versionProperties = new HashMap<String, Serializable>(5); Map<String, Serializable> versionProperties = new HashMap<String, Serializable>(5);
versionProperties.put(VersionModel.PROP_VERSION_TYPE, versioningState == VersioningState.MAJOR versionProperties.put(VersionModel.PROP_VERSION_TYPE,
|| versioningState == VersioningState.CHECKEDOUT ? VersionType.MAJOR : VersionType.MINOR); versioningState == VersioningState.MAJOR ? VersionType.MAJOR : VersionType.MINOR);
versionProperties.put(VersionModel.PROP_DESCRIPTION, "Initial Version"); versionProperties.put(VersionModel.PROP_DESCRIPTION, "Initial Version");
versionService.createVersion(nodeRef, versionProperties); versionService.createVersion(nodeRef, versionProperties);
} }
if (versioningState == VersioningState.CHECKEDOUT)
{
getCheckOutCheckInService().checkout(nodeRef);
}
} }
/** /**