ALF-20169 "cmis:secondary type properties are not visible " : fix + build tests (though I'm going to do a bit more testing), removal of unused imports, slight refactoring of some tests

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@56189 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Steven Glover
2013-10-01 09:48:22 +00:00
parent 1521b6b76f
commit 4034089d18
4 changed files with 556 additions and 512 deletions

View File

@@ -13,7 +13,7 @@
<bean id="OpenCMISPropertyAccessorMapping1.1" class="org.alfresco.opencmis.mapping.RuntimePropertyAccessorMapping" init-method="init"> <bean id="OpenCMISPropertyAccessorMapping1.1" class="org.alfresco.opencmis.mapping.RuntimePropertyAccessorMapping" init-method="init">
<property name="serviceRegistry" ref="ServiceRegistry" /> <property name="serviceRegistry" ref="ServiceRegistry" />
<property name="cmisConnector" ref="CMISConnector1.1" /> <property name="cmisConnector" ref="CMISConnector" />
<property name="cmisMapping" ref="OpenCMISMapping1.1" /> <property name="cmisMapping" ref="OpenCMISMapping1.1" />
<property name="cmisDictionaryService" ref="OpenCMISDictionaryService1.1" /> <property name="cmisDictionaryService" ref="OpenCMISDictionaryService1.1" />
</bean> </bean>
@@ -74,15 +74,6 @@
<property name="authorityService" ref="AuthorityService" /> <property name="authorityService" ref="AuthorityService" />
</bean> </bean>
<bean id="CMISServiceFactory1.1" class="org.alfresco.opencmis.AlfrescoCmisServiceFactory" init-method="init">
<property name="cmisConnector" ref="CMISConnector1.1" />
<property name="cmisTransactions" ref="CMISService_Transactions" />
<property name="cmisExceptions" ref="CMISService_Exceptions" />
<property name="cmisControl" ref="CMISService_Control" />
<property name="cmisStreams" ref="CMISService_Streams" />
<property name="authorityService" ref="AuthorityService" />
</bean>
<bean id="CMISService_Transactions" class="org.alfresco.repo.transaction.RetryingTransactionInterceptor"> <bean id="CMISService_Transactions" class="org.alfresco.repo.transaction.RetryingTransactionInterceptor">
<property name="transactionService" ref="TransactionService" /> <property name="transactionService" ref="TransactionService" />
<property name="transactionManager" ref="transactionManager" /> <property name="transactionManager" ref="transactionManager" />
@@ -126,7 +117,6 @@
</bean> </bean>
<bean id="CMISConnector" class="org.alfresco.opencmis.CMISConnector" init-method="setup"> <bean id="CMISConnector" class="org.alfresco.opencmis.CMISConnector" init-method="setup">
<property name="cmisVersion" value="CMIS_1_0" />
<property name="store" value="${opencmis.connector.default.store}" /> <property name="store" value="${opencmis.connector.default.store}" />
<property name="rootPath" value="${opencmis.connector.default.rootPath}" /> <property name="rootPath" value="${opencmis.connector.default.rootPath}" />
<property name="typesDefaultMaxItems" value="${opencmis.connector.default.typesDefaultMaxItems}" /> <property name="typesDefaultMaxItems" value="${opencmis.connector.default.typesDefaultMaxItems}" />
@@ -153,64 +143,8 @@
<property name="OpenCMISDictionaryService" ref="OpenCMISDictionaryService" /> <property name="OpenCMISDictionaryService" ref="OpenCMISDictionaryService" />
<property name="OpenCMISQueryService" ref="OpenCMISQueryService" /> <property name="OpenCMISQueryService" ref="OpenCMISQueryService" />
<property name="OpenCMISDictionaryService11" ref="OpenCMISDictionaryService1.1" />
<property name="activityPoster" ref="cmisActivityPoster" /> <property name="OpenCMISQueryService11" ref="OpenCMISQueryService1.1" />
<property name="hiddenAspect" ref="hiddenAspect" />
<property name="siteService" ref="SiteService" />
<property name="actionService" ref="ActionService" />
<property name="objectFilter" ref="objectFilter" />
<property name="descriptorService" ref="DescriptorService" />
<property name="nodeService" ref="NodeService" />
<property name="thumbnailService" ref="ThumbnailService" />
<property name="serviceRegistry" ref="ServiceRegistry" />
<property name="fileFolderService" ref="FileFolderService" />
<property name="versionService" ref="VersionService" />
<property name="checkOutCheckInService" ref="CheckoutCheckinService" />
<property name="lockService" ref="LockService" />
<property name="contentService" ref="ContentService" />
<property name="renditionService" ref="RenditionService" />
<property name="tenantAdminService" ref="tenantAdminService" />
<property name="singletonCache" ref="immutableSingletonCache" />
<property name="transactionService" ref="transactionService"/>
<property name="authenticationService" ref="authenticationService" />
<property name="permissionService" ref="PermissionService" />
<property name="permissionModelDao" ref="permissionsModelDAO" />
<property name="mimetypeService" ref="MimetypeService" />
<property name="auditService" ref="auditService" />
<property name="namespaceService" ref="namespaceService" />
<property name="searchService" ref="SearchService" />
<property name="dictionaryService" ref="DictionaryService" />
<property name="behaviourFilter" ref="policyBehaviourFilter" />
</bean>
<bean id="CMISConnector1.1" class="org.alfresco.opencmis.CMISConnector">
<property name="cmisVersion" value="CMIS_1_1" />
<property name="store" value="${opencmis.connector.default.store}" />
<property name="rootPath" value="${opencmis.connector.default.rootPath}" />
<property name="typesDefaultMaxItems" value="${opencmis.connector.default.typesDefaultMaxItems}" />
<property name="typesDefaultDepth" value="${opencmis.connector.default.typesDefaultDepth}" />
<property name="objectsDefaultMaxItems" value="${opencmis.connector.default.objectsDefaultMaxItems}" />
<property name="objectsDefaultDepth" value="${opencmis.connector.default.objectsDefaultDepth}" />
<property name="renditionKindMapping">
<map>
<entry key="cmis:thumbnail">
<list>
<value>doclib</value>
</list>
</entry>
<entry key="alf:webpreview">
<list>
<value>webpreview</value>
<value>imgpreview</value>
</list>
</entry>
</map>
</property>
<property name="openHttpSession" value="${opencmis.connector.default.openHttpSession}" />
<property name="OpenCMISDictionaryService" ref="OpenCMISDictionaryService1.1" />
<property name="OpenCMISQueryService" ref="OpenCMISQueryService1.1" />
<property name="activityPoster" ref="cmisActivityPoster" /> <property name="activityPoster" ref="cmisActivityPoster" />
<property name="hiddenAspect" ref="hiddenAspect" /> <property name="hiddenAspect" ref="hiddenAspect" />

View File

@@ -48,13 +48,11 @@ import org.alfresco.query.PagingRequest;
import org.alfresco.query.PagingResults; import org.alfresco.query.PagingResults;
import org.alfresco.repo.content.encoding.ContentCharsetFinder; import org.alfresco.repo.content.encoding.ContentCharsetFinder;
import org.alfresco.repo.node.getchildren.GetChildrenCannedQuery; import org.alfresco.repo.node.getchildren.GetChildrenCannedQuery;
import org.alfresco.repo.search.QueryParameterDefImpl;
import org.alfresco.repo.security.authentication.AuthenticationUtil; import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.Authorization; import org.alfresco.repo.security.authentication.Authorization;
import org.alfresco.repo.transaction.RetryingTransactionHelper; import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback; import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.version.VersionModel; import org.alfresco.repo.version.VersionModel;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.model.FileInfo; import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.model.FileNotFoundException; import org.alfresco.service.cmr.model.FileNotFoundException;
import org.alfresco.service.cmr.repository.AssociationRef; import org.alfresco.service.cmr.repository.AssociationRef;
@@ -63,7 +61,6 @@ import org.alfresco.service.cmr.repository.ContentIOException;
import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.InvalidNodeRefException; import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.search.QueryParameterDefinition;
import org.alfresco.service.cmr.search.ResultSet; import org.alfresco.service.cmr.search.ResultSet;
import org.alfresco.service.cmr.search.SearchParameters; import org.alfresco.service.cmr.search.SearchParameters;
import org.alfresco.service.cmr.search.SearchService; import org.alfresco.service.cmr.search.SearchService;

View File

@@ -298,7 +298,9 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
private PermissionService permissionService; private PermissionService permissionService;
private ModelDAO permissionModelDao; private ModelDAO permissionModelDao;
private CMISDictionaryService cmisDictionaryService; private CMISDictionaryService cmisDictionaryService;
private CMISDictionaryService cmisDictionaryService11;
private CMISQueryService cmisQueryService; private CMISQueryService cmisQueryService;
private CMISQueryService cmisQueryService11;
private MimetypeService mimetypeService; private MimetypeService mimetypeService;
private AuditService auditService; private AuditService auditService;
private NamespaceService namespaceService; private NamespaceService namespaceService;
@@ -309,8 +311,6 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
private ThumbnailService thumbnailService; private ThumbnailService thumbnailService;
private ServiceRegistry serviceRegistry; private ServiceRegistry serviceRegistry;
private CmisVersion cmisVersion;
private ActivityPoster activityPoster; private ActivityPoster activityPoster;
private BehaviourFilter behaviourFilter; private BehaviourFilter behaviourFilter;
@@ -350,11 +350,6 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
this.objectFilter = objectFilter; this.objectFilter = objectFilter;
} }
public void setCmisVersion(CmisVersion cmisVersion)
{
this.cmisVersion = cmisVersion;
}
/** /**
* Sets the root store. * Sets the root store.
* *
@@ -640,10 +635,23 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
this.cmisDictionaryService = cmisDictionaryService; this.cmisDictionaryService = cmisDictionaryService;
} }
public void setOpenCMISDictionaryService11(CMISDictionaryService cmisDictionaryService)
{
this.cmisDictionaryService11 = cmisDictionaryService;
}
public CMISDictionaryService getOpenCMISDictionaryService() public CMISDictionaryService getOpenCMISDictionaryService()
{
CmisVersion cmisVersion = getRequestCmisVersion();
if(cmisVersion.equals(CmisVersion.CMIS_1_0))
{ {
return cmisDictionaryService; return cmisDictionaryService;
} }
else
{
return cmisDictionaryService11;
}
}
/** /**
* Sets the OpenCMIS query service. * Sets the OpenCMIS query service.
@@ -653,6 +661,24 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
this.cmisQueryService = cmisQueryService; this.cmisQueryService = cmisQueryService;
} }
public void setOpenCMISQueryService11(CMISQueryService cmisQueryService)
{
this.cmisQueryService11 = cmisQueryService;
}
public CMISQueryService getOpenCMISQueryService()
{
CmisVersion cmisVersion = getRequestCmisVersion();
if(cmisVersion.equals(CmisVersion.CMIS_1_0))
{
return cmisQueryService;
}
else
{
return cmisQueryService11;
}
}
/** /**
* Sets the MIME type service. * Sets the MIME type service.
*/ */
@@ -1196,6 +1222,13 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
versionService.createVersion(nodeRef, versionProperties); versionService.createVersion(nodeRef, versionProperties);
} }
public CmisVersion getRequestCmisVersion()
{
CallContext callContext = AlfrescoCmisServiceCall.get();
CmisVersion cmisVersion = callContext.getCmisVersion();
return cmisVersion;
}
private boolean isPublicApi() private boolean isPublicApi()
{ {
boolean isPublicApi = false; boolean isPublicApi = false;
@@ -1263,7 +1296,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
private TypeDefinitionWrapper getType(QName typeQName) private TypeDefinitionWrapper getType(QName typeQName)
{ {
return cmisDictionaryService.findNodeType(typeQName); return getOpenCMISDictionaryService().findNodeType(typeQName);
} }
/** /**
@@ -1273,7 +1306,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
public TypeDefinitionWrapper getType(AssociationRef assocRef) public TypeDefinitionWrapper getType(AssociationRef assocRef)
{ {
QName typeQName = assocRef.getTypeQName(); QName typeQName = assocRef.getTypeQName();
return cmisDictionaryService.findAssocType(typeQName); return getOpenCMISDictionaryService().findAssocType(typeQName);
} }
/** /**
@@ -1282,7 +1315,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
*/ */
public TypeDefinitionWrapper getType(String cmisTypeId) public TypeDefinitionWrapper getType(String cmisTypeId)
{ {
return cmisDictionaryService.findType(cmisTypeId); return getOpenCMISDictionaryService().findType(cmisTypeId);
} }
/** /**
@@ -1483,6 +1516,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
}); });
} }
CmisVersion cmisVersion = getRequestCmisVersion();
if(cmisVersion.equals(CmisVersion.CMIS_1_0)) if(cmisVersion.equals(CmisVersion.CMIS_1_0))
{ {
// add aspects (cmis 1.0) // add aspects (cmis 1.0)
@@ -1708,6 +1742,46 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
} }
} }
private void addAspectProperties(CMISNodeInfo info, String filter, PropertiesImpl result)
{
if(getRequestCmisVersion().equals(CmisVersion.CMIS_1_1))
{
Set<String> propertyIds = new HashSet<String>();
Set<String> filterSet = splitFilter(filter);
Set<QName> aspects = nodeService.getAspects(info.getNodeRef());
for (QName aspect : aspects)
{
TypeDefinitionWrapper aspectType = getOpenCMISDictionaryService().findNodeType(aspect);
if (aspectType == null)
{
continue;
}
for (PropertyDefinitionWrapper propDef : aspectType.getProperties())
{
if (propertyIds.contains(propDef.getPropertyId()))
{
// skip properties that have already been added
continue;
}
if ((filterSet != null) && (!filterSet.contains(propDef.getPropertyDefinition().getQueryName())))
{
// skip properties that are not in the filter
continue;
}
Serializable value = propDef.getPropertyAccessor().getValue(info);
result.addProperty(getProperty(propDef.getPropertyDefinition().getPropertyType(), propDef, value));
// mark property as 'added'
propertyIds.add(propDef.getPropertyId());
}
}
}
}
public Properties getNodeProperties(CMISNodeInfo info, String filter) public Properties getNodeProperties(CMISNodeInfo info, String filter)
{ {
PropertiesImpl result = new PropertiesImpl(); PropertiesImpl result = new PropertiesImpl();
@@ -1730,6 +1804,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
result.addProperty(getProperty(propDef.getPropertyDefinition().getPropertyType(), propDef, value)); result.addProperty(getProperty(propDef.getPropertyDefinition().getPropertyType(), propDef, value));
} }
addAspectProperties(info, filter, result);
return result; return result;
} }
@@ -1768,6 +1844,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
result.addProperty(getProperty(propDef.getPropertyDefinition().getPropertyType(), propDef, value)); result.addProperty(getProperty(propDef.getPropertyDefinition().getPropertyType(), propDef, value));
} }
addAspectProperties(info, filter, result);
return result; return result;
} }
@@ -1809,7 +1887,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
Set<QName> aspects = nodeService.getAspects(info.getNodeRef()); Set<QName> aspects = nodeService.getAspects(info.getNodeRef());
for (QName aspect : aspects) for (QName aspect : aspects)
{ {
TypeDefinitionWrapper aspectType = cmisDictionaryService.findNodeType(aspect); TypeDefinitionWrapper aspectType = getOpenCMISDictionaryService().findNodeType(aspect);
if (aspectType == null) if (aspectType == null)
{ {
continue; continue;
@@ -2133,7 +2211,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
// filter relationships that not map the CMIS domain model // filter relationships that not map the CMIS domain model
for (AssociationRef assocRef : assocs) for (AssociationRef assocRef : assocs)
{ {
TypeDefinitionWrapper assocTypeDef = cmisDictionaryService.findAssocType(assocRef.getTypeQName()); TypeDefinitionWrapper assocTypeDef = getOpenCMISDictionaryService().findAssocType(assocRef.getTypeQName());
if (assocTypeDef == null || getType(assocRef.getSourceRef()) == null if (assocTypeDef == null || getType(assocRef.getSourceRef()) == null
|| getType(assocRef.getTargetRef()) == null) || getType(assocRef.getTargetRef()) == null)
{ {
@@ -2201,7 +2279,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
// filter relationships that not map the CMIS domain model // filter relationships that not map the CMIS domain model
for (AssociationRef assocRef : assocs) for (AssociationRef assocRef : assocs)
{ {
TypeDefinitionWrapper assocTypeDef = cmisDictionaryService.findAssocType(assocRef.getTypeQName()); TypeDefinitionWrapper assocTypeDef = getOpenCMISDictionaryService().findAssocType(assocRef.getTypeQName());
if (assocTypeDef == null || getType(assocRef.getSourceRef()) == null if (assocTypeDef == null || getType(assocRef.getSourceRef()) == null
|| getType(assocRef.getTargetRef()) == null) || getType(assocRef.getTargetRef()) == null)
{ {
@@ -2678,6 +2756,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
// prepare query // prepare query
CMISQueryOptions options = new CMISQueryOptions(statement, getRootStoreRef()); CMISQueryOptions options = new CMISQueryOptions(statement, getRootStoreRef());
CmisVersion cmisVersion = getRequestCmisVersion();
options.setCmisVersion(cmisVersion); options.setCmisVersion(cmisVersion);
options.setQueryMode(CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS); options.setQueryMode(CMISQueryMode.CMS_WITH_ALFRESCO_EXTENSIONS);
@@ -2697,7 +2776,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|| (!RENDITION_NONE.equals(renditionFilter)); || (!RENDITION_NONE.equals(renditionFilter));
// query // query
CMISResultSet rs = cmisQueryService.query(options); CMISResultSet rs = getOpenCMISQueryService().query(options);
try try
{ {
CMISResultSetColumn[] columns = rs.getMetaData().getColumns(); CMISResultSetColumn[] columns = rs.getMetaData().getColumns();
@@ -2800,9 +2879,13 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
PropertyData<?> property = incomingPropsMap.get(propertyId); PropertyData<?> property = incomingPropsMap.get(propertyId);
PropertyDefinitionWrapper propDef = type.getPropertyById(property.getId()); PropertyDefinitionWrapper propDef = type.getPropertyById(property.getId());
if (propDef == null) if (propDef == null)
{
propDef = getOpenCMISDictionaryService().findProperty(propertyId);
if (propDef == null)
{ {
throw new CmisInvalidArgumentException("Property " + property.getId() + " is unknown!"); throw new CmisInvalidArgumentException("Property " + property.getId() + " is unknown!");
} }
}
Updatability updatability = propDef.getPropertyDefinition().getUpdatability(); Updatability updatability = propDef.getPropertyDefinition().getUpdatability();
if ((updatability == Updatability.READONLY) if ((updatability == Updatability.READONLY)
@@ -2877,7 +2960,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
{ {
String secondaryType = (String)o; String secondaryType = (String)o;
TypeDefinitionWrapper wrapper = cmisDictionaryService.findType(secondaryType); TypeDefinitionWrapper wrapper = getOpenCMISDictionaryService().findType(secondaryType);
if(wrapper != null) if(wrapper != null)
{ {
QName aspectQName = wrapper.getAlfrescoName(); QName aspectQName = wrapper.getAlfrescoName();
@@ -2906,7 +2989,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
while(it.hasNext()) while(it.hasNext())
{ {
QName aspectQName = it.next(); QName aspectQName = it.next();
TypeDefinitionWrapper w = cmisDictionaryService.findNodeType(aspectQName); TypeDefinitionWrapper w = getOpenCMISDictionaryService().findNodeType(aspectQName);
if(w == null || secondaryTypeAspects.contains(aspectQName)) if(w == null || secondaryTypeAspects.contains(aspectQName))
{ {
// the type is not exposed or is in the secondary types to set, so remove it from the to remove set // the type is not exposed or is in the secondary types to set, so remove it from the to remove set
@@ -2919,7 +3002,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
{ {
nodeService.removeAspect(nodeRef, aspectQName); nodeService.removeAspect(nodeRef, aspectQName);
// aspect is being removed so remove all of its properties from the propsToAdd map // aspect is being removed so remove all of its properties from the propsToAdd map
TypeDefinitionWrapper w = cmisDictionaryService.findNodeType(aspectQName); TypeDefinitionWrapper w = getOpenCMISDictionaryService().findNodeType(aspectQName);
for(PropertyDefinitionWrapper wr : w.getProperties()) for(PropertyDefinitionWrapper wr : w.getProperties())
{ {
String propertyId = wr.getPropertyId(); String propertyId = wr.getPropertyId();
@@ -2935,7 +3018,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
// get aspect properties // get aspect properties
AspectDefinition aspectDef = dictionaryService.getAspect(aspectQName); AspectDefinition aspectDef = dictionaryService.getAspect(aspectQName);
Map<QName, org.alfresco.service.cmr.dictionary.PropertyDefinition> aspectPropDefs = aspectDef.getProperties(); Map<QName, org.alfresco.service.cmr.dictionary.PropertyDefinition> aspectPropDefs = aspectDef.getProperties();
TypeDefinitionWrapper w = cmisDictionaryService.findNodeType(aspectQName); TypeDefinitionWrapper w = getOpenCMISDictionaryService().findNodeType(aspectQName);
// for each aspect property... // for each aspect property...
for(QName propQName : aspectPropDefs.keySet()) for(QName propQName : aspectPropDefs.keySet())
{ {
@@ -3099,7 +3182,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
} }
// overflow check // overflow check
PropertyDefinitionWrapper propDef = cmisDictionaryService.findProperty(propertyId); PropertyDefinitionWrapper propDef = getOpenCMISDictionaryService().findProperty(propertyId);
if(propDef == null) if(propDef == null)
{ {
throw new CmisInvalidArgumentException("Property " + propertyId + " is unknown!"); throw new CmisInvalidArgumentException("Property " + propertyId + " is unknown!");

View File

@@ -89,9 +89,7 @@ public class CMISTest
private VersionService versionService; private VersionService versionService;
private LockService lockService; private LockService lockService;
private AlfrescoCmisServiceFactory factory10; private AlfrescoCmisServiceFactory factory;
private AlfrescoCmisServiceFactory factory11;
private SimpleCallContext context;
private ActionService actionService; private ActionService actionService;
private RuleService ruleService; private RuleService ruleService;
@@ -155,11 +153,13 @@ public class CMISTest
private static class SimpleCallContext implements CallContext private static class SimpleCallContext implements CallContext
{ {
private final Map<String, Object> contextMap = new HashMap<String, Object>(); private final Map<String, Object> contextMap = new HashMap<String, Object>();
private CmisVersion cmisVersion;
public SimpleCallContext(String user, String password) public SimpleCallContext(String user, String password, CmisVersion cmisVersion)
{ {
contextMap.put(USERNAME, user); contextMap.put(USERNAME, user);
contextMap.put(PASSWORD, password); contextMap.put(PASSWORD, password);
this.cmisVersion = cmisVersion;
} }
public String getBinding() public String getBinding()
@@ -238,7 +238,7 @@ public class CMISTest
@Override @Override
public CmisVersion getCmisVersion() public CmisVersion getCmisVersion()
{ {
return CmisVersion.CMIS_1_1; return cmisVersion;
} }
} }
@@ -253,10 +253,8 @@ public class CMISTest
this.versionService = (VersionService) ctx.getBean("versionService"); this.versionService = (VersionService) ctx.getBean("versionService");
this.lockService = (LockService) ctx.getBean("lockService"); this.lockService = (LockService) ctx.getBean("lockService");
this.repositoryHelper = (Repository)ctx.getBean("repositoryHelper"); this.repositoryHelper = (Repository)ctx.getBean("repositoryHelper");
this.factory10 = (AlfrescoCmisServiceFactory)ctx.getBean("CMISServiceFactory"); this.factory = (AlfrescoCmisServiceFactory)ctx.getBean("CMISServiceFactory");
this.factory11 = (AlfrescoCmisServiceFactory)ctx.getBean("CMISServiceFactory1.1");
this.cmisConnector = (CMISConnector) ctx.getBean("CMISConnector"); this.cmisConnector = (CMISConnector) ctx.getBean("CMISConnector");
this.context = new SimpleCallContext("admin", "admin");
} }
private FileInfo createContent(final String folderName, final String docName, final boolean isRule) private FileInfo createContent(final String folderName, final String docName, final boolean isRule)
@@ -333,30 +331,17 @@ public class CMISTest
private <T extends Object> T withCmisService(CmisServiceCallback<T> callback) private <T extends Object> T withCmisService(CmisServiceCallback<T> callback)
{ {
CmisService cmisService = null; return withCmisService(callback, CmisVersion.CMIS_1_0);
try
{
cmisService = factory10.getService(context);
T ret = callback.execute(cmisService);
return ret;
}
finally
{
if(cmisService != null)
{
cmisService.close();
}
}
} }
private <T extends Object> T withCmisService11(CmisServiceCallback<T> callback) private <T extends Object> T withCmisService(CmisServiceCallback<T> callback, CmisVersion cmisVersion)
{ {
CmisService cmisService = null; CmisService cmisService = null;
try try
{ {
cmisService = factory11.getService(context); CallContext context = new SimpleCallContext("admin", "admin", cmisVersion);
cmisService = factory.getService(context);
T ret = callback.execute(cmisService); T ret = callback.execute(cmisService);
return ret; return ret;
} }
@@ -535,6 +520,48 @@ public class CMISTest
} }
} }
private static class TestContext
{
private String repositoryId = null;
private ObjectData objectData = null;
private Holder<String> objectId = null;
public TestContext()
{
super();
}
public String getRepositoryId()
{
return repositoryId;
}
public void setRepositoryId(String repositoryId)
{
this.repositoryId = repositoryId;
}
public ObjectData getObjectData()
{
return objectData;
}
public void setObjectData(ObjectData objectData)
{
this.objectData = objectData;
}
public Holder<String> getObjectId()
{
return objectId;
}
public void setObjectId(Holder<String> objectId)
{
this.objectId = objectId;
}
}
/** /**
* Test for ALF-16310. * Test for ALF-16310.
* *
@@ -545,9 +572,7 @@ public class CMISTest
@Test @Test
public void testCancelCheckout() public void testCancelCheckout()
{ {
String repositoryId = null; final TestContext testContext = new TestContext();
ObjectData objectData = null;
Holder<String> objectId = null;
final String folderName = "testfolder." + GUID.generate(); final String folderName = "testfolder." + GUID.generate();
final String docName = "testdoc.txt." + GUID.generate(); final String docName = "testdoc.txt." + GUID.generate();
@@ -573,90 +598,95 @@ public class CMISTest
} }
}); });
CmisService service = factory10.getService(context); final ObjectData objectData = withCmisService(new CmisServiceCallback<ObjectData>()
try
{ {
List<RepositoryInfo> repositories = service.getRepositoryInfos(null); @Override
public ObjectData execute(CmisService cmisService)
{
List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null);
assertTrue(repositories.size() > 0); assertTrue(repositories.size() > 0);
RepositoryInfo repo = repositories.get(0); RepositoryInfo repo = repositories.get(0);
repositoryId = repo.getId(); String repositoryId = repo.getId();
objectData = service.getObjectByPath(repositoryId, "/" + folderName + "/" + docName, null, true, testContext.setRepositoryId(repositoryId);
ObjectData objectData = cmisService.getObjectByPath(repositoryId, "/" + folderName + "/" + docName, null, true,
IncludeRelationships.NONE, null, false, true, null); IncludeRelationships.NONE, null, false, true, null);
testContext.setObjectData(objectData);
// checkout // checkout
objectId = new Holder<String>(objectData.getId()); Holder<String> objectId = new Holder<String>(objectData.getId());
service.checkOut(repositoryId, objectId, null, new Holder<Boolean>(true)); testContext.setObjectId(objectId);
} cmisService.checkOut(repositoryId, objectId, null, new Holder<Boolean>(true));
finally
{ return objectData;
service.close();
} }
});
// AtomPub cancel checkout // AtomPub cancel checkout
withCmisService(new CmisServiceCallback<Void>()
{
@Override
public Void execute(CmisService cmisService)
{
try try
{ {
service = factory10.getService(context);
// check allowable actions // check allowable actions
ObjectData originalDoc = service.getObject(repositoryId, objectData.getId(), null, true, IncludeRelationships.NONE, null, false, true, null); ObjectData originalDoc = cmisService.getObject(testContext.getRepositoryId(), objectData.getId(), null, true, IncludeRelationships.NONE, null, false, true, null);
AllowableActions allowableActions = originalDoc.getAllowableActions(); AllowableActions allowableActions = originalDoc.getAllowableActions();
assertNotNull(allowableActions); assertNotNull(allowableActions);
assertFalse(allowableActions.getAllowableActions().contains(Action.CAN_DELETE_OBJECT)); assertFalse(allowableActions.getAllowableActions().contains(Action.CAN_DELETE_OBJECT));
// try to cancel the checkout // try to cancel the checkout
service.deleteObjectOrCancelCheckOut(repositoryId, objectData.getId(), Boolean.TRUE, null); cmisService.deleteObjectOrCancelCheckOut(testContext.getRepositoryId(), objectData.getId(), Boolean.TRUE, null);
fail(); fail();
} }
catch(CmisConstraintException e) catch(CmisConstraintException e)
{ {
// expected // expected
} }
finally
{ return null;
service.close();
} }
});
try withCmisService(new CmisServiceCallback<Void>()
{
@Override
public Void execute(CmisService cmisService)
{ {
service = factory10.getService(context);
// cancel checkout on pwc // cancel checkout on pwc
service.deleteObjectOrCancelCheckOut(repositoryId, objectId.getValue(), Boolean.TRUE, null); cmisService.deleteObjectOrCancelCheckOut(testContext.getRepositoryId(), testContext.getObjectId().getValue(), Boolean.TRUE, null);
} return null;
finally
{
service.close();
} }
});
try withCmisService(new CmisServiceCallback<Void>()
{
@Override
public Void execute(CmisService cmisService)
{ {
service = factory10.getService(context);
// get original document // get original document
ObjectData originalDoc = service.getObject(repositoryId, objectData.getId(), null, true, IncludeRelationships.NONE, null, false, true, null); ObjectData originalDoc = cmisService.getObject(testContext.getRepositoryId(), objectData.getId(), null, true, IncludeRelationships.NONE, null, false, true, null);
Map<String, PropertyData<?>> properties = originalDoc.getProperties().getProperties(); Map<String, PropertyData<?>> properties = originalDoc.getProperties().getProperties();
PropertyData<Boolean> isVersionSeriesCheckedOutProp = (PropertyData<Boolean>)properties.get(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT); PropertyData<Boolean> isVersionSeriesCheckedOutProp = (PropertyData<Boolean>)properties.get(PropertyIds.IS_VERSION_SERIES_CHECKED_OUT);
assertNotNull(isVersionSeriesCheckedOutProp); assertNotNull(isVersionSeriesCheckedOutProp);
Boolean isVersionSeriesCheckedOut = isVersionSeriesCheckedOutProp.getFirstValue(); Boolean isVersionSeriesCheckedOut = isVersionSeriesCheckedOutProp.getFirstValue();
assertNotNull(isVersionSeriesCheckedOut); assertNotNull(isVersionSeriesCheckedOut);
assertEquals(Boolean.FALSE, isVersionSeriesCheckedOut); assertEquals(Boolean.FALSE, isVersionSeriesCheckedOut);
}
finally
{
service.close();
}
try return null;
{ }
service = factory10.getService(context); });
withCmisService(new CmisServiceCallback<Void>()
{
@Override
public Void execute(CmisService cmisService)
{
// delete original document // delete original document
service.deleteObject(repositoryId, objectData.getId(), true, null); cmisService.deleteObject(testContext.getRepositoryId(), objectData.getId(), true, null);
} return null;
finally
{
service.close();
} }
});
List<FileInfo> children = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<List<FileInfo>>() List<FileInfo> children = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<List<FileInfo>>()
{ {
@@ -681,14 +711,10 @@ public class CMISTest
@Test @Test
public void testDeleteFolder() public void testDeleteFolder()
{ {
String repositoryId = null;
ObjectData objectData = null;
Holder<String> objectId = null;
AuthenticationUtil.pushAuthentication(); AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
Map<FileInfo, Boolean> testFolderMap = new HashMap<FileInfo, Boolean>(4); final Map<FileInfo, Boolean> testFolderMap = new HashMap<FileInfo, Boolean>(4);
try try
{ {
@@ -714,24 +740,25 @@ public class CMISTest
FileInfo folderEmptyWithRule = createContent(folderNameEmptyRule, null, true); FileInfo folderEmptyWithRule = createContent(folderNameEmptyRule, null, true);
testFolderMap.put(folderEmptyWithRule, Boolean.TRUE); testFolderMap.put(folderEmptyWithRule, Boolean.TRUE);
CmisService service = factory10.getService(context); withCmisService(new CmisServiceCallback<Void>()
try
{ {
List<RepositoryInfo> repositories = service.getRepositoryInfos(null); @Override
public Void execute(CmisService cmisService)
{
List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null);
RepositoryInfo repo = repositories.get(0); RepositoryInfo repo = repositories.get(0);
repositoryId = repo.getId(); String repositoryId = repo.getId();
for (Map.Entry<FileInfo, Boolean> entry : testFolderMap.entrySet()) for (Map.Entry<FileInfo, Boolean> entry : testFolderMap.entrySet())
{ {
objectData = service.getObjectByPath(repositoryId, "/" + entry.getKey().getName(), null, true, IncludeRelationships.NONE, null, false, true, null); ObjectData objectData = cmisService.getObjectByPath(repositoryId, "/" + entry.getKey().getName(), null, true, IncludeRelationships.NONE, null, false, true, null);
objectId = new Holder<String>(objectData.getId()); Holder<String> objectId = new Holder<String>(objectData.getId());
try try
{ {
// delete folder // delete folder
service.deleteObjectOrCancelCheckOut(repositoryId, objectId.getValue(), Boolean.TRUE, null); cmisService.deleteObjectOrCancelCheckOut(repositoryId, objectId.getValue(), Boolean.TRUE, null);
} }
catch (CmisConstraintException ex) catch (CmisConstraintException ex)
{ {
@@ -741,12 +768,10 @@ public class CMISTest
assertTrue(entry.getValue()); assertTrue(entry.getValue());
} }
}
finally
{
service.close();
}
return null;
}
});
} }
finally finally
{ {
@@ -769,9 +794,6 @@ public class CMISTest
@Test @Test
public void testGetAllVersionsOnReadOnlyLockedNode() public void testGetAllVersionsOnReadOnlyLockedNode()
{ {
String repositoryId;
ObjectData objectData;
final String folderName = "testfolder." + GUID.generate(); final String folderName = "testfolder." + GUID.generate();
final String docName = "testdoc.txt." + GUID.generate(); final String docName = "testdoc.txt." + GUID.generate();
@@ -800,30 +822,32 @@ public class CMISTest
} }
}); });
CmisService service = factory10.getService(context); withCmisService(new CmisServiceCallback<Void>()
try
{ {
List<RepositoryInfo> repositories = service.getRepositoryInfos(null); @Override
public Void execute(CmisService cmisService)
{
List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null);
assertTrue(repositories.size() > 0); assertTrue(repositories.size() > 0);
RepositoryInfo repo = repositories.get(0); RepositoryInfo repo = repositories.get(0);
repositoryId = repo.getId(); String repositoryId = repo.getId();
objectData = service.getObjectByPath(repositoryId, "/" + folderName + "/" + docName, null, true, ObjectData objectData = cmisService.getObjectByPath(repositoryId, "/" + folderName + "/" + docName, null, true,
IncludeRelationships.NONE, null, false, true, null); IncludeRelationships.NONE, null, false, true, null);
try try
{ {
service.getAllVersions(repositoryId, objectData.getId(), fileInfo.getNodeRef().getId(), null, true, null); cmisService.getAllVersions(repositoryId, objectData.getId(), fileInfo.getNodeRef().getId(), null, true, null);
} }
catch (Throwable e) catch (Throwable e)
{ {
e.printStackTrace(); e.printStackTrace();
fail(); fail();
} }
return null;
} }
finally });
{
service.close();
}
} }
finally finally
{ {
@@ -837,7 +861,6 @@ public class CMISTest
@Test @Test
public void testOrderByCreationAndModificationDate() public void testOrderByCreationAndModificationDate()
{ {
String repositoryId = null;
final List<FileInfo> nodes = new ArrayList<FileInfo>(10); final List<FileInfo> nodes = new ArrayList<FileInfo>(10);
final List<FileInfo> expectedChildrenByCreationDate = new ArrayList<FileInfo>(10); final List<FileInfo> expectedChildrenByCreationDate = new ArrayList<FileInfo>(10);
final List<FileInfo> expectedChildrenByModificationDate = new ArrayList<FileInfo>(10); final List<FileInfo> expectedChildrenByModificationDate = new ArrayList<FileInfo>(10);
@@ -898,14 +921,16 @@ public class CMISTest
AuthenticationUtil.popAuthentication(); AuthenticationUtil.popAuthentication();
} }
CmisService cmisService = factory10.getService(context); withCmisService(new CmisServiceCallback<Void>()
try {
@Override
public Void execute(CmisService cmisService)
{ {
// get repository id // get repository id
List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null); List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null);
assertTrue(repositories.size() > 0); assertTrue(repositories.size() > 0);
RepositoryInfo repo = repositories.get(0); RepositoryInfo repo = repositories.get(0);
repositoryId = repo.getId(); String repositoryId = repo.getId();
String folderId = nodes.get(0).getNodeRef().getId(); String folderId = nodes.get(0).getNodeRef().getId();
String orderBy = PropertyIds.CREATION_DATE + " DESC"; String orderBy = PropertyIds.CREATION_DATE + " DESC";
@@ -943,30 +968,33 @@ public class CMISTest
assertEquals(expectedChild.getNodeRef().toString(), actualObjectId); assertEquals(expectedChild.getNodeRef().toString(), actualObjectId);
assertEquals(expectedChild.getModifiedDate().getTime(), actualModificationDate.getTimeInMillis()); assertEquals(expectedChild.getModifiedDate().getTime(), actualModificationDate.getTimeInMillis());
} }
return null;
} }
finally });
{
cmisService.close();
}
} }
@SuppressWarnings("rawtypes") @SuppressWarnings({ "rawtypes", "unchecked" })
@Test @Test
public void testSecondaryTypes() public void testSecondaryTypes()
{ {
CmisService cmisService = factory11.getService(context); final String aspectName = "P:cm:indexControl";
try
{
// get repository id // get repository id
final String repositoryId = withCmisService(new CmisServiceCallback<String>()
{
@Override
public String execute(CmisService cmisService)
{
List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null); List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null);
assertTrue(repositories.size() > 0); assertTrue(repositories.size() > 0);
RepositoryInfo repo = repositories.get(0); RepositoryInfo repo = repositories.get(0);
final String repositoryId = repo.getId(); final String repositoryId = repo.getId();
final String aspectName = "P:cm:indexControl"; return repositoryId;
}
}, CmisVersion.CMIS_1_1);
System.out.println("START"); final String objectId = withCmisService(new CmisServiceCallback<String>()
final String objectId = withCmisService11(new CmisServiceCallback<String>()
{ {
@Override @Override
public String execute(CmisService cmisService) public String execute(CmisService cmisService)
@@ -981,11 +1009,11 @@ public class CMISTest
String objectId = cmisService.create(repositoryId, properties, repositoryHelper.getCompanyHome().getId(), contentStream, VersioningState.MAJOR, null, null); String objectId = cmisService.create(repositoryId, properties, repositoryHelper.getCompanyHome().getId(), contentStream, VersioningState.MAJOR, null, null);
return objectId; return objectId;
} }
}); }, CmisVersion.CMIS_1_1);
final Holder<String> objectIdHolder = new Holder<String>(objectId); final Holder<String> objectIdHolder = new Holder<String>(objectId);
withCmisService11(new CmisServiceCallback<Void>() withCmisService(new CmisServiceCallback<Void>()
{ {
@Override @Override
public Void execute(CmisService cmisService) public Void execute(CmisService cmisService)
@@ -996,9 +1024,9 @@ public class CMISTest
cmisService.updateProperties(repositoryId, objectIdHolder, null, properties, null); cmisService.updateProperties(repositoryId, objectIdHolder, null, properties, null);
return null; return null;
} }
}); }, CmisVersion.CMIS_1_1);
final Properties currentProperties = withCmisService11(new CmisServiceCallback<Properties>() final Properties currentProperties = withCmisService(new CmisServiceCallback<Properties>()
{ {
@Override @Override
public Properties execute(CmisService cmisService) public Properties execute(CmisService cmisService)
@@ -1006,18 +1034,15 @@ public class CMISTest
Properties properties = cmisService.getProperties(repositoryId, objectIdHolder.getValue(), null, null); Properties properties = cmisService.getProperties(repositoryId, objectIdHolder.getValue(), null, null);
return properties; return properties;
} }
}); }, CmisVersion.CMIS_1_1);
System.out.println("objectId = " + objectIdHolder.getValue());
List secondaryTypeIds = currentProperties.getProperties().get(PropertyIds.SECONDARY_OBJECT_TYPE_IDS).getValues(); List secondaryTypeIds = currentProperties.getProperties().get(PropertyIds.SECONDARY_OBJECT_TYPE_IDS).getValues();
System.out.println("secondaryTypeIds = " + secondaryTypeIds);
secondaryTypeIds.remove(aspectName); secondaryTypeIds.remove(aspectName);
System.out.println("secondaryTypeIds = " + secondaryTypeIds);
final PropertiesImpl newProperties = new PropertiesImpl(); final PropertiesImpl newProperties = new PropertiesImpl();
newProperties.addProperty(new PropertyStringImpl(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondaryTypeIds)); newProperties.addProperty(new PropertyStringImpl(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondaryTypeIds));
withCmisService11(new CmisServiceCallback<Void>() withCmisService(new CmisServiceCallback<Void>()
{ {
@Override @Override
public Void execute(CmisService cmisService) public Void execute(CmisService cmisService)
@@ -1025,9 +1050,9 @@ public class CMISTest
cmisService.updateProperties(repositoryId, objectIdHolder, null, newProperties, null); cmisService.updateProperties(repositoryId, objectIdHolder, null, newProperties, null);
return null; return null;
} }
}); }, CmisVersion.CMIS_1_1);
Properties currentProperties1 = withCmisService11(new CmisServiceCallback<Properties>() Properties currentProperties1 = withCmisService(new CmisServiceCallback<Properties>()
{ {
@Override @Override
public Properties execute(CmisService cmisService) public Properties execute(CmisService cmisService)
@@ -1035,14 +1060,9 @@ public class CMISTest
Properties properties = cmisService.getProperties(repositoryId, objectIdHolder.getValue(), null, null); Properties properties = cmisService.getProperties(repositoryId, objectIdHolder.getValue(), null, null);
return properties; return properties;
} }
}); }, CmisVersion.CMIS_1_1);
secondaryTypeIds = currentProperties1.getProperties().get(PropertyIds.SECONDARY_OBJECT_TYPE_IDS).getValues(); secondaryTypeIds = currentProperties1.getProperties().get(PropertyIds.SECONDARY_OBJECT_TYPE_IDS).getValues();
System.out.println("secondaryTypeIds = " + secondaryTypeIds);
}
finally
{
cmisService.close();
}
} }
/** /**
@@ -1054,11 +1074,9 @@ public class CMISTest
AuthenticationUtil.pushAuthentication(); AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
CmisService cmisService = factory10.getService(context);
try try
{ {
FileInfo fileInfo = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<FileInfo>() final FileInfo fileInfo = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<FileInfo>()
{ {
@Override @Override
public FileInfo execute() throws Throwable public FileInfo execute() throws Throwable
@@ -1082,6 +1100,11 @@ public class CMISTest
}); });
// get repository id // get repository id
withCmisService(new CmisServiceCallback<Void>()
{
@Override
public Void execute(CmisService cmisService)
{
List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null); List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null);
assertTrue(repositories.size() > 0); assertTrue(repositories.size() > 0);
RepositoryInfo repo = repositories.get(0); RepositoryInfo repo = repositories.get(0);
@@ -1164,6 +1187,10 @@ public class CMISTest
{ {
assertTrue(e instanceof CmisConstraintException); assertTrue(e instanceof CmisConstraintException);
} }
return null;
}
}, CmisVersion.CMIS_1_0);
} }
catch(Exception e) catch(Exception e)
{ {
@@ -1171,8 +1198,6 @@ public class CMISTest
} }
finally finally
{ {
cmisService.close();
AuthenticationUtil.popAuthentication(); AuthenticationUtil.popAuthentication();
} }
} }
@@ -1196,11 +1221,9 @@ public class CMISTest
AuthenticationUtil.pushAuthentication(); AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
CmisService cmisService = factory10.getService(context);
try try
{ {
FileInfo fileInfo = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<FileInfo>() final FileInfo fileInfo = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<FileInfo>()
{ {
@Override @Override
public FileInfo execute() throws Throwable public FileInfo execute() throws Throwable
@@ -1225,6 +1248,11 @@ public class CMISTest
} }
}); });
withCmisService(new CmisServiceCallback<Void>()
{
@Override
public Void execute(CmisService cmisService)
{
// get repository id // get repository id
List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null); List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null);
assertTrue(repositories.size() > 0); assertTrue(repositories.size() > 0);
@@ -1259,6 +1287,10 @@ public class CMISTest
// should throw a CMISConstraintException // should throw a CMISConstraintException
cmisService.updateProperties(repositoryId, objectId, null, properties, null); cmisService.updateProperties(repositoryId, objectId, null, properties, null);
fail(); fail();
return null;
}
}, CmisVersion.CMIS_1_0);
} }
catch(CmisConstraintException e) catch(CmisConstraintException e)
{ {
@@ -1267,8 +1299,6 @@ public class CMISTest
} }
finally finally
{ {
cmisService.close();
AuthenticationUtil.popAuthentication(); AuthenticationUtil.popAuthentication();
} }
} }