mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-06-30 18:15:39 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)
78372: Merged V4.2-BUG-FIX (4.2.3) to HEAD-BUG-FIX (5.0) 76636 : Merged DEV to V4.2-BUG-FIX (4.2.3) 76604 : MNT-11876 : CMIS extension data is not returned in 1.1 atom binding - Return aspects and aspect properties in extension data. Test for the fix git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@82533 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
d385bc9bb1
commit
a78c593e83
@ -1568,18 +1568,14 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|
||||
});
|
||||
}
|
||||
|
||||
CmisVersion cmisVersion = getRequestCmisVersion();
|
||||
if(cmisVersion.equals(CmisVersion.CMIS_1_0))
|
||||
// add aspects
|
||||
List<CmisExtensionElement> extensions = getAspectExtensions(info, filter, result.getProperties()
|
||||
.getProperties().keySet());
|
||||
if (!extensions.isEmpty())
|
||||
{
|
||||
// add aspects (cmis 1.0)
|
||||
List<CmisExtensionElement> extensions = getAspectExtensions(info, filter, result.getProperties()
|
||||
.getProperties().keySet());
|
||||
if (!extensions.isEmpty())
|
||||
{
|
||||
result.getProperties().setExtensions(
|
||||
Collections.singletonList((CmisExtensionElement) new CmisExtensionElementImpl(
|
||||
ALFRESCO_EXTENSION_NAMESPACE, ASPECTS, null, extensions)));
|
||||
}
|
||||
result.getProperties().setExtensions(
|
||||
Collections.singletonList((CmisExtensionElement) new CmisExtensionElementImpl(
|
||||
ALFRESCO_EXTENSION_NAMESPACE, ASPECTS, null, extensions)));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -1984,12 +1980,17 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
|
||||
continue;
|
||||
}
|
||||
|
||||
AspectDefinition aspectDefinition = dictionaryService.getAspect(aspect);
|
||||
Map<QName, org.alfresco.service.cmr.dictionary.PropertyDefinition> aspectProperties = aspectDefinition.getProperties();
|
||||
|
||||
extensions.add(new CmisExtensionElementImpl(ALFRESCO_EXTENSION_NAMESPACE, APPLIED_ASPECTS, null, aspectType
|
||||
.getTypeId()));
|
||||
|
||||
for (PropertyDefinitionWrapper propDef : aspectType.getProperties())
|
||||
{
|
||||
if (propertyIds.contains(propDef.getPropertyId()))
|
||||
boolean addPropertyToExtensionList = getRequestCmisVersion().equals(CmisVersion.CMIS_1_1) && aspectProperties.keySet().contains(propDef.getAlfrescoName());
|
||||
// MNT-11876 : add property to extension even if it has been returned (CMIS 1.1)
|
||||
if (propertyIds.contains(propDef.getPropertyId()) && !addPropertyToExtensionList)
|
||||
{
|
||||
// skip properties that have already been added
|
||||
continue;
|
||||
|
@ -36,6 +36,7 @@ import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -2439,4 +2440,98 @@ public class CMISTest
|
||||
AuthenticationUtil.popAuthentication();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* MNT-11876 : Test that Alfresco CMIS 1.1 Implementation is returning aspect and aspect properties as extension data
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
public void testExtensionDataIsReturnedViaCmis1_1() throws Exception
|
||||
{
|
||||
AuthenticationUtil.pushAuthentication();
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
||||
|
||||
final String FOLDER = "testExtensionDataIsReturnedViaCmis1_1-" + GUID.generate();
|
||||
final String CONTENT = FOLDER + "-file";
|
||||
|
||||
try
|
||||
{
|
||||
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void execute() throws Throwable
|
||||
{
|
||||
// create folder
|
||||
FileInfo folderInfo = fileFolderService.create(repositoryHelper.getCompanyHome(), FOLDER, ContentModel.TYPE_FOLDER);
|
||||
nodeService.setProperty(folderInfo.getNodeRef(), ContentModel.PROP_NAME, FOLDER);
|
||||
assertNotNull(folderInfo);
|
||||
|
||||
// create document
|
||||
FileInfo document = fileFolderService.create(folderInfo.getNodeRef(), CONTENT, ContentModel.TYPE_CONTENT);
|
||||
assertNotNull(document);
|
||||
nodeService.setProperty(document.getNodeRef(), ContentModel.PROP_NAME, CONTENT);
|
||||
|
||||
// apply aspect with properties
|
||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>();
|
||||
props.put(ContentModel.PROP_LATITUDE, Double.valueOf(1.0d));
|
||||
props.put(ContentModel.PROP_LONGITUDE, Double.valueOf(1.0d));
|
||||
nodeService.addAspect(document.getNodeRef(), ContentModel.ASPECT_GEOGRAPHIC, props);
|
||||
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
final ObjectData objectData = withCmisService(new CmisServiceCallback<ObjectData>()
|
||||
{
|
||||
@Override
|
||||
public ObjectData execute(CmisService cmisService)
|
||||
{
|
||||
List<RepositoryInfo> repositories = cmisService.getRepositoryInfos(null);
|
||||
assertTrue(repositories.size() > 0);
|
||||
RepositoryInfo repo = repositories.get(0);
|
||||
String repositoryId = repo.getId();
|
||||
// get object data
|
||||
ObjectData objectData = cmisService.getObjectByPath(repositoryId, "/" + FOLDER + "/" + CONTENT, null, true,
|
||||
IncludeRelationships.NONE, null, false, true, null);
|
||||
return objectData;
|
||||
}
|
||||
}, CmisVersion.CMIS_1_1);
|
||||
|
||||
// get extension data from object properties
|
||||
List<CmisExtensionElement> extensions = objectData.getProperties().getExtensions().iterator().next().getChildren();
|
||||
|
||||
Set<String> appliedAspects = new HashSet<String>();
|
||||
Set<String> aspectProperties = new HashSet<String>();
|
||||
|
||||
for (CmisExtensionElement extension : extensions)
|
||||
{
|
||||
if (CMISConnector.PROPERTIES.equals(extension.getName()))
|
||||
{
|
||||
// check properties extension
|
||||
List<CmisExtensionElement> propExtensions = extension.getChildren();
|
||||
assertTrue("cmisObject should contain aspect properties", propExtensions.size() > 0);
|
||||
for (CmisExtensionElement prop : propExtensions)
|
||||
{
|
||||
Map<String, String> cmisAspectProperty = prop.getAttributes();
|
||||
Set<String> cmisAspectPropertyNames = cmisAspectProperty.keySet();
|
||||
assertTrue("propertyDefinitionId attribute should be present", cmisAspectPropertyNames.contains("propertyDefinitionId"));
|
||||
aspectProperties.add(cmisAspectProperty.get("propertyDefinitionId"));
|
||||
}
|
||||
}
|
||||
else if (CMISConnector.APPLIED_ASPECTS.equals(extension.getName()))
|
||||
{
|
||||
appliedAspects.add(extension.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
// extension data should contain applied aspects and aspect properties
|
||||
assertTrue("Extensions should contain " + ContentModel.ASPECT_GEOGRAPHIC, appliedAspects.contains("P:cm:geographic"));
|
||||
assertTrue("Extensions should contain " + ContentModel.PROP_LATITUDE, aspectProperties.contains("cm:latitude"));
|
||||
assertTrue("Extensions should contain " + ContentModel.PROP_LONGITUDE, aspectProperties.contains("cm:longitude"));
|
||||
}
|
||||
finally
|
||||
{
|
||||
AuthenticationUtil.popAuthentication();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user