mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)
63328: Merged V4.2-BUG-FIX (4.2.2) to HEAD-BUG-FIX (Cloud/4.3) 63150: Merged DEV to V4.2-BUG-FIX (4.2.2) 61233 : MNT-10548 : Public API returns invalid JSON if a tag or category has been applied to object - Replace List of NodeRefs with List of String elements in DirectProperty 63129 : MNT-10548 : Public API returns invalid JSON if a tag or category has been applied to object - Fix related test git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@64277 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -19,10 +19,12 @@
|
||||
package org.alfresco.opencmis.mapping;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.opencmis.CMISConnector;
|
||||
import org.alfresco.opencmis.dictionary.CMISNodeInfo;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
|
||||
/**
|
||||
@@ -59,7 +61,24 @@ public class DirectProperty extends AbstractProperty
|
||||
|
||||
if (nodeInfo.getNodeRef() != null)
|
||||
{
|
||||
return getServiceRegistry().getNodeService().getProperty(nodeInfo.getNodeRef(), alfrescoName);
|
||||
/* MNT-10548 fix */
|
||||
Serializable result = getServiceRegistry().getNodeService().getProperty(nodeInfo.getNodeRef(), alfrescoName);
|
||||
|
||||
if (result instanceof List)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Object> resultList = (List<Object>)result;
|
||||
for (int index = 0; index < resultList.size(); index++)
|
||||
{
|
||||
Object element = resultList.get(index);
|
||||
if (element instanceof NodeRef)
|
||||
{
|
||||
resultList.set(index, element.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
else if (nodeInfo.getAssociationRef() != null)
|
||||
{
|
||||
|
@@ -55,6 +55,7 @@ import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.rule.Rule;
|
||||
import org.alfresco.service.cmr.rule.RuleService;
|
||||
import org.alfresco.service.cmr.rule.RuleType;
|
||||
import org.alfresco.service.cmr.tagging.TaggingService;
|
||||
import org.alfresco.service.cmr.version.VersionService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
@@ -109,6 +110,8 @@ public class CMISTest
|
||||
private Repository repositoryHelper;
|
||||
private VersionService versionService;
|
||||
private LockService lockService;
|
||||
private TaggingService taggingService;
|
||||
private NamespaceService namespaceService;
|
||||
|
||||
private AlfrescoCmisServiceFactory factory;
|
||||
|
||||
@@ -1514,4 +1517,78 @@ public class CMISTest
|
||||
AuthenticationUtil.popAuthentication();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mnt10548test() throws Exception
|
||||
{
|
||||
AuthenticationUtil.pushAuthentication();
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
|
||||
|
||||
final Pair<FileInfo, FileInfo> folderAndDocument = transactionService.getRetryingTransactionHelper().doInTransaction(
|
||||
new RetryingTransactionCallback<Pair<FileInfo, FileInfo>>()
|
||||
{
|
||||
private final static String TEST_NAME = "mnt10548test-";
|
||||
|
||||
@Override
|
||||
public Pair<FileInfo, FileInfo> execute() throws Throwable
|
||||
{
|
||||
NodeRef companyHomeNodeRef = repositoryHelper.getCompanyHome();
|
||||
|
||||
/* Create folder within companyHome */
|
||||
String folderName = TEST_NAME + GUID.generate();
|
||||
FileInfo folderInfo = fileFolderService.create(companyHomeNodeRef, folderName, ContentModel.TYPE_FOLDER);
|
||||
nodeService.setProperty(folderInfo.getNodeRef(), ContentModel.PROP_NAME, folderName);
|
||||
assertNotNull(folderInfo);
|
||||
|
||||
/* Create content */
|
||||
String docName = TEST_NAME + GUID.generate();
|
||||
FileInfo document = fileFolderService.create(folderInfo.getNodeRef(), docName, ContentModel.TYPE_CONTENT);
|
||||
assertNotNull(document);
|
||||
nodeService.setProperty(document.getNodeRef(), ContentModel.PROP_NAME, docName);
|
||||
|
||||
/* Add some tags */
|
||||
NodeRef nodeRef = document.getNodeRef();
|
||||
taggingService.addTag(nodeRef, "tag1");
|
||||
taggingService.addTag(nodeRef, "tag2");
|
||||
taggingService.addTag(nodeRef, "tag3");
|
||||
|
||||
return new Pair<FileInfo, FileInfo>(folderInfo, document);
|
||||
}
|
||||
});
|
||||
|
||||
ObjectData objData = withCmisService(
|
||||
new CmisServiceCallback<ObjectData>()
|
||||
{
|
||||
private static final String FILE_FOLDER_SEPARATOR = "/";
|
||||
|
||||
@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();
|
||||
|
||||
String path = FILE_FOLDER_SEPARATOR + folderAndDocument.getFirst().getName() + FILE_FOLDER_SEPARATOR + folderAndDocument.getSecond().getName();
|
||||
/* get CMIS object of document */
|
||||
ObjectData objData = cmisService.getObjectByPath(repositoryId, path, null, false, null, null, false, false, null);
|
||||
return objData;
|
||||
}
|
||||
}, CmisVersion.CMIS_1_1);
|
||||
|
||||
Map<String, PropertyData<?>> cmisProps = objData.getProperties().getProperties();
|
||||
|
||||
String taggable = ContentModel.ASPECT_TAGGABLE.getPrefixedQName(namespaceService).toPrefixString();
|
||||
PropertyData<?> propData = cmisProps.get(taggable);
|
||||
assertNotNull(propData);
|
||||
|
||||
List<?> props = propData.getValues();
|
||||
assertTrue(props.size() == 3);
|
||||
|
||||
/* MNT-10548 fix : CMIS should return List of String, not List of NodeRef */
|
||||
for(Object o : props)
|
||||
{
|
||||
assertTrue(o.getClass() + " found but String expected", o instanceof String);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user