Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)

68111: Merged V4.2-BUG-FIX (4.2.3) to HEAD-BUG-FIX (4.3/Cloud)
      65926: MNT-10021: Merged DEV to V4.2-BUG-FIX
         58137: MNT-10021: CMIS 1.0 aspect properties only provide propertyDefinitionId
            - Fields displayName, localName, queryName added into response
         61316: MNT-10021: CMIS 1.0 aspect properties only provide propertyDefinitionId
            - Add unit test for case


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@68399 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mark Rogers
2014-04-30 16:07:02 +00:00
parent c2c57afa4a
commit c30ffdcab0
2 changed files with 109 additions and 4 deletions

View File

@@ -1946,10 +1946,10 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
* Creates a property extension element.
*/
@SuppressWarnings("rawtypes")
private CmisExtensionElement createAspectPropertyExtension(PropertyDefinition<?> propertyDefintion, Object value)
private CmisExtensionElement createAspectPropertyExtension(PropertyDefinition<?> propertyDefinition, Object value)
{
String name;
switch (propertyDefintion.getPropertyType())
switch (propertyDefinition.getPropertyType())
{
case BOOLEAN:
name = "propertyBoolean";
@@ -1971,7 +1971,19 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
}
Map<String, String> attributes = new HashMap<String, String>();
attributes.put("propertyDefinitionId", propertyDefintion.getId());
attributes.put("propertyDefinitionId", propertyDefinition.getId());
attributes.put("queryName", propertyDefinition.getQueryName());
// optional value
if (propertyDefinition.getDisplayName() !=null && propertyDefinition.getDisplayName().trim().length() > 0)
{
attributes.put("displayName", propertyDefinition.getDisplayName());
}
// optional value
if (propertyDefinition.getLocalName() !=null && propertyDefinition.getLocalName().trim().length() > 0)
{
attributes.put("localName", propertyDefinition.getLocalName());
}
List<CmisExtensionElement> propertyValues = new ArrayList<CmisExtensionElement>();
if (value != null)
@@ -1987,7 +1999,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
}
else
{
logger.warn("Unexpected null entry in list value for property " + propertyDefintion.getDisplayName()
logger.warn("Unexpected null entry in list value for property " + propertyDefinition.getDisplayName()
+ ", value = " + value);
}
}

View File

@@ -35,6 +35,7 @@ import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.alfresco.cmis.CMISDictionaryModel;
import org.alfresco.model.ContentModel;
@@ -1922,4 +1923,96 @@ public class CMISTest
org.alfresco.opencmis.search.CMISResultSet rs = cmisConnector.getOpenCMISQueryService().query(options);
assertEquals(rs.getNumberFound(), 0);
}
/**
* CMIS 1.0 aspect properties should provide the following CMIS attributes:
* propertyDefinitionId, displayName, localName, queryName
*/
@Test
public void testMNT10021() throws Exception
{
final String folderName = "testfolder." + GUID.generate();
final String docName = "testdoc.txt." + GUID.generate();
AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
try
{
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
NodeRef companyHomeNodeRef = repositoryHelper.getCompanyHome();
FileInfo folderInfo = fileFolderService.create(companyHomeNodeRef, folderName, ContentModel.TYPE_FOLDER);
nodeService.setProperty(folderInfo.getNodeRef(), ContentModel.PROP_NAME, folderName);
assertNotNull(folderInfo);
FileInfo document = fileFolderService.create(folderInfo.getNodeRef(), docName, ContentModel.TYPE_CONTENT);
assertNotNull(document);
nodeService.setProperty(document.getNodeRef(), ContentModel.PROP_NAME, docName);
// lock adds aspects to the document with properties: lockIsDeep, lockOwner, lockType, expiryDate, lockLifetime
lockService.lock(document.getNodeRef(), LockType.READ_ONLY_LOCK, 0, true);
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();
ObjectData objectData = cmisService.getObjectByPath(repositoryId, "/" + folderName + "/" + docName, null, true,
IncludeRelationships.NONE, null, false, true, null);
return objectData;
}
}, CmisVersion.CMIS_1_0);
List<CmisExtensionElement> propertyExtensionList = objectData.getProperties().getExtensions();
assertEquals("propertyExtensionList should be singletonList", propertyExtensionList.size(), 1);
List<CmisExtensionElement> extensions = propertyExtensionList.iterator().next().getChildren();
for (CmisExtensionElement extension : extensions)
{
if ("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"));
assertTrue("queryName attribute should be present", cmisAspectPropertyNames.contains("queryName"));
// optional values that are present for test document
assertTrue("displayName attribute should be present for property of test node", cmisAspectPropertyNames.contains("displayName"));
assertTrue("localName attribute should be present for property of test node", cmisAspectPropertyNames.contains("localName"));
assertEquals(cmisAspectPropertyNames.size(), 4);
// check values
for (String aspectPropertyName : cmisAspectPropertyNames)
{
String value = cmisAspectProperty.get(aspectPropertyName);
assertTrue("value for " + aspectPropertyName + " should be present", value != null && value.length() > 0);
}
}
}
}
}
catch (CmisConstraintException e)
{
fail(e.toString());
}
finally
{
AuthenticationUtil.popAuthentication();
}
}
}