Fixed OpenCMIS server getObjectRelationships() operation

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29064 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Florian Mü
2011-07-15 09:53:41 +00:00
parent 6ba169f641
commit c6172b79ee
2 changed files with 74 additions and 42 deletions

View File

@@ -542,7 +542,8 @@ public class AlfrescoCmisService extends AbstractCmisService
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{ {
logger.debug("Too many sort properties in 'orderBy' - ignore those above max (max="+maxSortProps+",actual="+len+")"); logger.debug("Too many sort properties in 'orderBy' - ignore those above max (max="
+ maxSortProps + ",actual=" + len + ")");
} }
len = maxSortProps; len = maxSortProps;
} }
@@ -552,7 +553,8 @@ public class AlfrescoCmisService extends AbstractCmisService
if (sort.length > 0) if (sort.length > 0)
{ {
PropertyDefintionWrapper propDef = connector.getOpenCMISDictionaryService().findPropertyByQueryName(sort[0]); PropertyDefintionWrapper propDef = connector.getOpenCMISDictionaryService()
.findPropertyByQueryName(sort[0]);
if (propDef != null) if (propDef != null)
{ {
QName sortProp = propDef.getPropertyAccessor().getMappedProperty(); QName sortProp = propDef.getPropertyAccessor().getMappedProperty();
@@ -560,16 +562,14 @@ public class AlfrescoCmisService extends AbstractCmisService
{ {
boolean sortAsc = ((sort.length == 1) || (sortAsc = (sort[1].equalsIgnoreCase("asc")))); boolean sortAsc = ((sort.length == 1) || (sortAsc = (sort[1].equalsIgnoreCase("asc"))));
sortProps.add(new Pair<QName, Boolean>(sortProp, sortAsc)); sortProps.add(new Pair<QName, Boolean>(sortProp, sortAsc));
} } else
else
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{ {
logger.debug("Ignore sort property '" + sort[0] + " - mapping not found"); logger.debug("Ignore sort property '" + sort[0] + " - mapping not found");
} }
} }
} } else
else
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{ {
@@ -582,16 +582,26 @@ public class AlfrescoCmisService extends AbstractCmisService
if (sortProps.size() < origLen) if (sortProps.size() < origLen)
{ {
logger.warn("Sort properties trimmed - either too many and/or not found: \n" + logger.warn("Sort properties trimmed - either too many and/or not found: \n" + " orig: " + orderBy
" orig: " + orderBy + "\n" + + "\n" + " final: " + sortProps);
" final: " + sortProps);
} }
} }
PagingRequest pageRequest = new PagingRequest(skipCount.intValue(), maxItems.intValue(), null); PagingRequest pageRequest = new PagingRequest(skipCount.intValue(), maxItems.intValue(), null);
pageRequest.setRequestTotalCountMax(skipCount.intValue() + 1000); // TODO make this optional/configurable - affects whether numItems may be returned pageRequest.setRequestTotalCountMax(skipCount.intValue() + 1000); // TODO
// make
// this
// optional/configurable
// -
// affects
// whether
// numItems
// may
// be
// returned
PagingResults<FileInfo> pageOfNodeInfos = connector.getFileFolderService().list(folderNodeRef, true, true, null, sortProps, pageRequest); PagingResults<FileInfo> pageOfNodeInfos = connector.getFileFolderService().list(folderNodeRef, true, true,
null, sortProps, pageRequest);
List<FileInfo> childrenList = pageOfNodeInfos.getPage(); List<FileInfo> childrenList = pageOfNodeInfos.getPage();
if (max > 0) if (max > 0)
@@ -604,8 +614,8 @@ public class AlfrescoCmisService extends AbstractCmisService
try try
{ {
// create a child CMIS object // create a child CMIS object
ObjectData object = connector.createCMISObject(child, filter, ObjectData object = connector.createCMISObject(child, filter, includeAllowableActions,
includeAllowableActions, includeRelationships, renditionFilter, false, false); includeRelationships, renditionFilter, false, false);
if (context.isObjectInfoRequired()) if (context.isObjectInfoRequired())
{ {
@@ -648,7 +658,8 @@ public class AlfrescoCmisService extends AbstractCmisService
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{ {
logger.debug("getChildren: "+childrenList.size()+" in "+(System.currentTimeMillis()-start)+" msecs"); logger.debug("getChildren: " + childrenList.size() + " in " + (System.currentTimeMillis() - start)
+ " msecs");
} }
return result; return result;
@@ -2301,6 +2312,27 @@ public class AlfrescoCmisService extends AbstractCmisService
throw new CmisInvalidArgumentException("Object is a relationship!"); throw new CmisInvalidArgumentException("Object is a relationship!");
} }
// check if the relationship base type is requested
if (BaseTypeId.CMIS_RELATIONSHIP.value().equals(typeId))
{
boolean isrt = (includeSubRelationshipTypes == null ? false : includeSubRelationshipTypes.booleanValue());
if (isrt)
{
// all relationships are a direct subtype of the base type in
// Alfresco -> remove filter
typeId = null;
} else
{
// there are no relationships of the base type in ALfresco ->
// return empty list
ObjectListImpl result = new ObjectListImpl();
result.setHasMoreItems(false);
result.setNumItems(BigInteger.ZERO);
result.setObjects(new ArrayList<ObjectData>());
return result;
}
}
NodeRef nodeRef = connector.getNodeRefIfCurrent("Object", objectId); NodeRef nodeRef = connector.getNodeRefIfCurrent("Object", objectId);
return connector.getObjectRelationships(nodeRef, relationshipDirection, typeId, filter, return connector.getObjectRelationships(nodeRef, relationshipDirection, typeId, filter,
includeAllowableActions, maxItems, skipCount); includeAllowableActions, maxItems, skipCount);

View File

@@ -1903,7 +1903,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
continue; continue;
} }
if ((typeId != null) && !assocRef.getId().equals(typeId)) if ((typeId != null) && !assocTypeDef.getTypeId().equals(typeId))
{ {
continue; continue;
} }