mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)
94326: Merged 5.0.N (5.0.1) to HEAD-BUG-FIX (5.1/Cloud) 94249: Merged V4.2-BUG-FIX (4.2.5) to 5.0.N (5.0.1) 94198: MNT-12956: Merged DEV to V4.2-BUG-FIX (4.2.5) 94044: MNT-12956: Querying secondary objectTypes like Aspects towards 1.1 CMIS endpoint fails with: Invalid column for cmis:document cmis:secondaryObjectTypeIds - For Solr configure search.OpenCMISQueryService1.1 to use OpenCMISDictionaryService1.1. Add unit test. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@95074 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2014 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2015 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -116,6 +116,7 @@ import org.apache.chemistry.opencmis.commons.SessionParameter;
|
||||
import org.apache.chemistry.opencmis.commons.data.ContentStream;
|
||||
import org.apache.chemistry.opencmis.commons.enums.IncludeRelationships;
|
||||
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
|
||||
import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
|
||||
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
|
||||
import org.apache.chemistry.opencmis.commons.exceptions.CmisUpdateConflictException;
|
||||
import org.apache.chemistry.opencmis.commons.impl.dataobjects.ContentStreamImpl;
|
||||
@@ -2267,4 +2268,69 @@ public class TestCMIS extends EnterpriseTestApi
|
||||
assertEquals(rootNodeRef.getId(), rootFolderId);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMNT12956QueryingCMIS11UsesDictionary11() throws Exception
|
||||
{
|
||||
final TestNetwork network1 = getTestFixture().getRandomNetwork();
|
||||
|
||||
String username = "user" + System.currentTimeMillis();
|
||||
PersonInfo personInfo = new PersonInfo(username, username, username, TEST_PASSWORD, null, null, null, null, null, null, null);
|
||||
TestPerson person = network1.createUser(personInfo);
|
||||
String personId = person.getId();
|
||||
|
||||
final List<NodeRef> documents = new ArrayList<NodeRef>();
|
||||
final String filename = GUID.generate();
|
||||
|
||||
TenantUtil.runAsUserTenant(new TenantRunAsWork<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void doWork() throws Exception
|
||||
{
|
||||
String siteName = "site" + System.currentTimeMillis();
|
||||
SiteInformation siteInfo = new SiteInformation(siteName, siteName, siteName, SiteVisibility.PRIVATE);
|
||||
TestSite site = repoService.createSite(null, siteInfo);
|
||||
NodeRef docNodeRef = repoService.createDocument(site.getContainerNodeRef(DOCUMENT_LIBRARY_CONTAINER_NAME), filename, "test content");
|
||||
documents.add(docNodeRef);
|
||||
|
||||
return null;
|
||||
}
|
||||
}, personId, network1.getId());
|
||||
|
||||
NodeRef docNodeRef = documents.get(0);
|
||||
publicApiClient.setRequestContext(new RequestContext(network1.getId(), personId));
|
||||
CmisSession atomCmisSession10 = publicApiClient.createPublicApiCMISSession(Binding.atom, CMIS_VERSION_10, AlfrescoObjectFactoryImpl.class.getName());
|
||||
CmisSession atomCmisSession11 = publicApiClient.createPublicApiCMISSession(Binding.atom, CMIS_VERSION_11);
|
||||
|
||||
// query
|
||||
{
|
||||
// searching by NodeRef, expect result objectIds to be objectId
|
||||
Set<String> expectedObjectIds = new HashSet<String>();
|
||||
expectedObjectIds.add(docNodeRef.getId());
|
||||
int numMatchingDocs = 0;
|
||||
|
||||
// NodeRef input
|
||||
List<CMISNode> results = atomCmisSession11.query("SELECT cmis:objectId,cmis:name,cmis:secondaryObjectTypeIds FROM cmis:document WHERE cmis:name LIKE '" + filename + "'", false, 0, Integer.MAX_VALUE);
|
||||
assertEquals(expectedObjectIds.size(), results.size());
|
||||
for(CMISNode node : results)
|
||||
{
|
||||
String objectId = stripCMISSuffix((String)node.getProperties().get(PropertyIds.OBJECT_ID));
|
||||
if(expectedObjectIds.contains(objectId))
|
||||
{
|
||||
numMatchingDocs++;
|
||||
}
|
||||
}
|
||||
assertEquals(expectedObjectIds.size(), numMatchingDocs);
|
||||
|
||||
try
|
||||
{
|
||||
results = atomCmisSession10.query("SELECT cmis:objectId,cmis:name,cmis:secondaryObjectTypeIds FROM cmis:document WHERE cmis:name LIKE '" + filename + "'", false, 0, Integer.MAX_VALUE);
|
||||
fail("OpenCMIS 1.0 knows nothing about cmis:secondaryObjectTypeIds");
|
||||
}
|
||||
catch (CmisInvalidArgumentException expectedException)
|
||||
{
|
||||
// ok
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user