ALF-9933 RSOLR 042: Add query support for new CMIS object ids

- added test suite for opencmis query
- fixed object ids with appropriate unit test for folders, unversioned and versioned docs.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30050 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Andrew Hind
2011-08-25 10:35:05 +00:00
parent c72a19b637
commit 0ba194c1d9
6 changed files with 6049 additions and 21 deletions

View File

@@ -43,7 +43,7 @@ import org.alfresco.model.ContentModel;
import org.alfresco.opencmis.dictionary.CMISNodeInfo; import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.opencmis.dictionary.CMISObjectVariant; import org.alfresco.opencmis.dictionary.CMISObjectVariant;
import org.alfresco.opencmis.dictionary.FolderTypeDefintionWrapper; import org.alfresco.opencmis.dictionary.FolderTypeDefintionWrapper;
import org.alfresco.opencmis.dictionary.PropertyDefintionWrapper; import org.alfresco.opencmis.dictionary.PropertyDefinitionWrapper;
import org.alfresco.opencmis.dictionary.TypeDefinitionWrapper; import org.alfresco.opencmis.dictionary.TypeDefinitionWrapper;
import org.alfresco.query.PagingRequest; import org.alfresco.query.PagingRequest;
import org.alfresco.query.PagingResults; import org.alfresco.query.PagingResults;
@@ -627,7 +627,7 @@ public class AlfrescoCmisService extends AbstractCmisService
if (sort.length > 0) if (sort.length > 0)
{ {
PropertyDefintionWrapper propDef = connector.getOpenCMISDictionaryService() PropertyDefinitionWrapper propDef = connector.getOpenCMISDictionaryService()
.findPropertyByQueryName(sort[0]); .findPropertyByQueryName(sort[0]);
if (propDef != null) if (propDef != null)
{ {
@@ -973,7 +973,7 @@ public class AlfrescoCmisService extends AbstractCmisService
continue; continue;
} }
PropertyDefintionWrapper propDef = connector.getOpenCMISDictionaryService().findPropertyByQueryName( PropertyDefinitionWrapper propDef = connector.getOpenCMISDictionaryService().findPropertyByQueryName(
sort[0]); sort[0]);
if (propDef != null) if (propDef != null)
{ {
@@ -1967,7 +1967,7 @@ public class AlfrescoCmisService extends AbstractCmisService
return Collections.emptyList(); return Collections.emptyList();
} else } else
{ {
return connector.getRendtions(info.getNodeRef(), renditionFilter, maxItems, skipCount); return connector.getRenditions(info.getNodeRef(), renditionFilter, maxItems, skipCount);
} }
} }

View File

@@ -0,0 +1,188 @@
/*
* Copyright (C) 2005-2010 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 <http://www.gnu.org/licenses/>.
*/
package org.alfresco.opencmis;
import java.util.Date;
import javax.transaction.Status;
import javax.transaction.UserTransaction;
import junit.framework.TestCase;
import org.alfresco.cmis.CMISAccessControlService;
import org.alfresco.cmis.CMISRenditionService;
import org.alfresco.cmis.CMISServices;
import org.alfresco.opencmis.dictionary.CMISDictionaryService;
import org.alfresco.opencmis.mapping.CMISMapping;
import org.alfresco.opencmis.search.CMISQueryService;
import org.alfresco.repo.dictionary.DictionaryDAO;
import org.alfresco.repo.dictionary.NamespaceDAOImpl;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
import org.alfresco.repo.security.permissions.impl.ModelDAO;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.cmr.search.SearchService;
import org.alfresco.service.cmr.security.MutableAuthenticationService;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.cmr.thumbnail.ThumbnailService;
import org.alfresco.service.cmr.version.VersionService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.ApplicationContextHelper;
import org.springframework.context.ApplicationContext;
/**
* Base CMIS test
* Basic TX control and authentication
*
* @author andyh
*
*/
public abstract class BaseCMISTest extends TestCase
{
private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
protected CMISMapping cmisMapping;
protected CMISConnector cmisConnector;
protected CMISDictionaryService cmisDictionaryService;
protected DictionaryService dictionaryService;
protected TransactionService transactionService;
protected AuthenticationComponent authenticationComponent;
protected UserTransaction testTX;
protected NodeService nodeService;
protected NodeRef rootNodeRef;
protected FileFolderService fileFolderService;
protected ServiceRegistry serviceRegistry;
protected NamespaceService namespaceService;
protected CMISQueryService cmisQueryService;
private MutableAuthenticationService authenticationService;
private MutableAuthenticationDao authenticationDAO;
protected SearchService searchService;
protected ContentService contentService;
protected PermissionService permissionService;
protected ThumbnailService thumbnailService;
protected ModelDAO permissionModelDao;
protected DictionaryDAO dictionaryDAO;
protected NamespaceDAOImpl namespaceDao;
protected VersionService versionService;
public void setUp() throws Exception
{
serviceRegistry = (ServiceRegistry) ctx.getBean("ServiceRegistry");
cmisDictionaryService = (CMISDictionaryService) ctx.getBean("OpenCMISDictionaryService");
cmisMapping = (CMISMapping) ctx.getBean("OpenCMISMapping");
cmisQueryService = (CMISQueryService) ctx.getBean("OpenCMISQueryService");
cmisConnector = (CMISConnector) ctx.getBean("CMISConnector");
dictionaryService = (DictionaryService) ctx.getBean("dictionaryService");
nodeService = (NodeService) ctx.getBean("nodeService");
fileFolderService = (FileFolderService) ctx.getBean("fileFolderService");
namespaceService = (NamespaceService) ctx.getBean("namespaceService");
transactionService = (TransactionService) ctx.getBean("transactionComponent");
authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
searchService = (SearchService) ctx.getBean("searchService");
contentService = (ContentService) ctx.getBean("contentService");
permissionService = (PermissionService) ctx.getBean("permissionService");
versionService = (VersionService) ctx.getBean("versionService");
authenticationService = (MutableAuthenticationService) ctx.getBean("authenticationService");
authenticationDAO = (MutableAuthenticationDao) ctx.getBean("authenticationDao");
thumbnailService = (ThumbnailService) ctx.getBean("thumbnailService");
permissionModelDao = (ModelDAO) ctx.getBean("permissionsModelDAO");
dictionaryDAO = (DictionaryDAO) ctx.getBean("dictionaryDAO");
namespaceDao = (NamespaceDAOImpl) ctx.getBean("namespaceDAO");
testTX = transactionService.getUserTransaction();
testTX.begin();
this.authenticationComponent.setSystemUserAsCurrentUser();
String storeName = "CMISTest-" + getStoreName() + "-" + (new Date().getTime());
StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, storeName);
rootNodeRef = nodeService.getRootNode(storeRef);
if(authenticationDAO.userExists("cmis"))
{
authenticationService.deleteAuthentication("cmis");
}
authenticationService.createAuthentication("cmis", "cmis".toCharArray());
}
private String getStoreName()
{
String testName = getName();
testName = testName.replace("_", "-");
testName = testName.replace("%", "-");
return testName;
}
protected void runAs(String userName)
{
authenticationService.authenticate(userName, userName.toCharArray());
assertNotNull(authenticationService.getCurrentUserName());
}
@Override
protected void tearDown() throws Exception
{
if (testTX.getStatus() == Status.STATUS_ACTIVE)
{
testTX.rollback();
}
AuthenticationUtil.clearCurrentSecurityContext();
super.tearDown();
}
}

View File

@@ -49,7 +49,7 @@ import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.opencmis.dictionary.CMISObjectVariant; import org.alfresco.opencmis.dictionary.CMISObjectVariant;
import org.alfresco.opencmis.dictionary.CMISPropertyAccessor; import org.alfresco.opencmis.dictionary.CMISPropertyAccessor;
import org.alfresco.opencmis.dictionary.DocumentTypeDefinitionWrapper; import org.alfresco.opencmis.dictionary.DocumentTypeDefinitionWrapper;
import org.alfresco.opencmis.dictionary.PropertyDefintionWrapper; import org.alfresco.opencmis.dictionary.PropertyDefinitionWrapper;
import org.alfresco.opencmis.dictionary.TypeDefinitionWrapper; import org.alfresco.opencmis.dictionary.TypeDefinitionWrapper;
import org.alfresco.opencmis.mapping.DirectProperty; import org.alfresco.opencmis.mapping.DirectProperty;
import org.alfresco.opencmis.search.CMISQueryOptions; import org.alfresco.opencmis.search.CMISQueryOptions;
@@ -846,7 +846,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
public void checkChildObjectType(CMISNodeInfo folderInfo, String childType) public void checkChildObjectType(CMISNodeInfo folderInfo, String childType)
{ {
TypeDefinitionWrapper targetType = folderInfo.getType(); TypeDefinitionWrapper targetType = folderInfo.getType();
PropertyDefintionWrapper allowableChildObjectTypeProperty = targetType PropertyDefinitionWrapper allowableChildObjectTypeProperty = targetType
.getPropertyById(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS); .getPropertyById(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS);
List<String> childTypes = (List<String>) allowableChildObjectTypeProperty.getPropertyAccessor().getValue( List<String> childTypes = (List<String>) allowableChildObjectTypeProperty.getPropertyAccessor().getValue(
folderInfo); folderInfo);
@@ -940,7 +940,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
// set renditions // set renditions
if (!RENDITION_NONE.equals(renditionFilter)) if (!RENDITION_NONE.equals(renditionFilter))
{ {
List<RenditionData> renditions = getRendtions(info.getNodeRef(), renditionFilter, null, null); List<RenditionData> renditions = getRenditions(info.getNodeRef(), renditionFilter, null, null);
if ((renditions != null) && (!renditions.isEmpty())) if ((renditions != null) && (!renditions.isEmpty()))
{ {
result.setRenditions(renditions); result.setRenditions(renditions);
@@ -1106,7 +1106,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
Set<String> filterSet = splitFilter(filter); Set<String> filterSet = splitFilter(filter);
for (PropertyDefintionWrapper propDef : info.getType().getProperties()) for (PropertyDefinitionWrapper propDef : info.getType().getProperties())
{ {
if (!propDef.getPropertyId().equals(PropertyIds.OBJECT_ID)) if (!propDef.getPropertyId().equals(PropertyIds.OBJECT_ID))
{ {
@@ -1133,7 +1133,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
Map<QName, Serializable> nodeProps = node.getProperties(); Map<QName, Serializable> nodeProps = node.getProperties();
for (PropertyDefintionWrapper propDef : type.getProperties()) for (PropertyDefinitionWrapper propDef : type.getProperties())
{ {
if (!propDef.getPropertyId().equals(PropertyIds.OBJECT_ID)) if (!propDef.getPropertyId().equals(PropertyIds.OBJECT_ID))
{ {
@@ -1168,7 +1168,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
Set<String> filterSet = splitFilter(filter); Set<String> filterSet = splitFilter(filter);
for (PropertyDefintionWrapper propDef : info.getType().getProperties()) for (PropertyDefinitionWrapper propDef : info.getType().getProperties())
{ {
if ((filterSet != null) && (!filterSet.contains(propDef.getPropertyDefinition().getQueryName()))) if ((filterSet != null) && (!filterSet.contains(propDef.getPropertyDefinition().getQueryName())))
{ {
@@ -1206,7 +1206,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
.getTypeId())); .getTypeId()));
List<CmisExtensionElement> propertyExtensionList = new ArrayList<CmisExtensionElement>(); List<CmisExtensionElement> propertyExtensionList = new ArrayList<CmisExtensionElement>();
for (PropertyDefintionWrapper propDef : aspectType.getProperties()) for (PropertyDefinitionWrapper propDef : aspectType.getProperties())
{ {
if (propertyIds.contains(propDef.getPropertyId())) if (propertyIds.contains(propDef.getPropertyId()))
{ {
@@ -1315,7 +1315,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private AbstractPropertyData<?> getProperty(PropertyType propType, PropertyDefintionWrapper propDef, private AbstractPropertyData<?> getProperty(PropertyType propType, PropertyDefinitionWrapper propDef,
Serializable value) Serializable value)
{ {
AbstractPropertyData<?> result = null; AbstractPropertyData<?> result = null;
@@ -1590,7 +1590,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
return result; return result;
} }
public List<RenditionData> getRendtions(NodeRef nodeRef, String renditionFilter, BigInteger maxItems, public List<RenditionData> getRenditions(NodeRef nodeRef, String renditionFilter, BigInteger maxItems,
BigInteger skipCount) BigInteger skipCount)
{ {
String tenantDomain = tenantAdminService.getCurrentUserDomain(); String tenantDomain = tenantAdminService.getCurrentUserDomain();
@@ -1994,7 +1994,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
// set renditions // set renditions
if (!RENDITION_NONE.equals(renditionFilter)) if (!RENDITION_NONE.equals(renditionFilter))
{ {
List<RenditionData> renditions = getRendtions(nodeRef, renditionFilter, null, null); List<RenditionData> renditions = getRenditions(nodeRef, renditionFilter, null, null);
if ((renditions != null) && (!renditions.isEmpty())) if ((renditions != null) && (!renditions.isEmpty()))
{ {
hit.setRenditions(renditions); hit.setRenditions(renditions);
@@ -2200,7 +2200,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
throw new CmisInvalidArgumentException("Cannot process not null property!"); throw new CmisInvalidArgumentException("Cannot process not null property!");
} }
PropertyDefintionWrapper propDef = type.getPropertyById(property.getId()); PropertyDefinitionWrapper propDef = type.getPropertyById(property.getId());
if (propDef == null) if (propDef == null)
{ {
throw new CmisInvalidArgumentException("Property " + property.getId() + " is unknown!"); throw new CmisInvalidArgumentException("Property " + property.getId() + " is unknown!");

View File

@@ -18,7 +18,7 @@
*/ */
package org.alfresco.opencmis.search; package org.alfresco.opencmis.search;
import org.alfresco.opencmis.dictionary.PropertyDefintionWrapper; import org.alfresco.opencmis.dictionary.PropertyDefinitionWrapper;
import org.alfresco.service.cmr.search.ResultSetColumn; import org.alfresco.service.cmr.search.ResultSetColumn;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.apache.chemistry.opencmis.commons.enums.PropertyType; import org.apache.chemistry.opencmis.commons.enums.PropertyType;
@@ -32,7 +32,7 @@ public class CMISResultSetColumn implements ResultSetColumn
private String name; private String name;
private PropertyDefintionWrapper propertyDefinition; private PropertyDefinitionWrapper propertyDefinition;
private PropertyType dataType; private PropertyType dataType;
@@ -40,7 +40,7 @@ public class CMISResultSetColumn implements ResultSetColumn
private QName alfrescoDataTypeQName; private QName alfrescoDataTypeQName;
CMISResultSetColumn(String name, PropertyDefintionWrapper propertyDefinition, PropertyType dataType, CMISResultSetColumn(String name, PropertyDefinitionWrapper propertyDefinition, PropertyType dataType,
QName alfrescoPropertyQName, QName alfrescoDataTypeQName) QName alfrescoPropertyQName, QName alfrescoDataTypeQName)
{ {
this.name = name; this.name = name;
@@ -55,7 +55,7 @@ public class CMISResultSetColumn implements ResultSetColumn
return name; return name;
} }
public PropertyDefintionWrapper getCMISPropertyDefinition() public PropertyDefinitionWrapper getCMISPropertyDefinition()
{ {
return propertyDefinition; return propertyDefinition;
} }

View File

@@ -22,7 +22,7 @@ import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import org.alfresco.opencmis.dictionary.CMISDictionaryService; import org.alfresco.opencmis.dictionary.CMISDictionaryService;
import org.alfresco.opencmis.dictionary.PropertyDefintionWrapper; import org.alfresco.opencmis.dictionary.PropertyDefinitionWrapper;
import org.alfresco.opencmis.dictionary.TypeDefinitionWrapper; import org.alfresco.opencmis.dictionary.TypeDefinitionWrapper;
import org.alfresco.repo.search.impl.querymodel.Column; import org.alfresco.repo.search.impl.querymodel.Column;
import org.alfresco.repo.search.impl.querymodel.PropertyArgument; import org.alfresco.repo.search.impl.querymodel.PropertyArgument;
@@ -70,7 +70,7 @@ public class CMISResultSetMetaData implements ResultSetMetaData
columnMetaData = new LinkedHashMap<String, CMISResultSetColumn>(); columnMetaData = new LinkedHashMap<String, CMISResultSetColumn>();
for (Column column : query.getColumns()) for (Column column : query.getColumns())
{ {
PropertyDefintionWrapper propertyDefinition = null; PropertyDefinitionWrapper propertyDefinition = null;
PropertyType type = null; PropertyType type = null;
QName alfrescoPropertyQName = null; QName alfrescoPropertyQName = null;
QName alfrescoDataTypeQName = null; QName alfrescoDataTypeQName = null;

File diff suppressed because it is too large Load Diff