use of org.apache.chemistry.opencmis.client.runtime.OperationContextImpl in project alfresco-remote-api by Alfresco.
the class TestCMIS method testPublicApi110.
@Test
public void testPublicApi110() throws Exception {
Iterator<TestNetwork> networksIt = getTestFixture().networksIterator();
final TestNetwork network1 = networksIt.next();
Iterator<String> personIt = network1.getPersonIds().iterator();
final String person1Id = personIt.next();
final String person2Id = personIt.next();
final List<NodeRef> nodes = new ArrayList<NodeRef>(5);
// Create some favourite targets, sites, files and folders
TenantUtil.runAsUserTenant(new TenantRunAsWork<Void>() {
@Override
public Void doWork() throws Exception {
String siteName1 = "site" + GUID.generate();
SiteInformation siteInfo1 = new SiteInformation(siteName1, siteName1, siteName1, SiteVisibility.PUBLIC);
TestSite site1 = network1.createSite(siteInfo1);
String siteName2 = "site" + GUID.generate();
SiteInformation siteInfo2 = new SiteInformation(siteName2, siteName2, siteName2, SiteVisibility.PRIVATE);
TestSite site2 = network1.createSite(siteInfo2);
NodeRef nodeRef1 = repoService.createDocument(site1.getContainerNodeRef(DOCUMENT_LIBRARY_CONTAINER_NAME), "Test Doc1", "Test Doc1 Title", "Test Doc1 Description", "Test Content");
nodes.add(nodeRef1);
NodeRef nodeRef2 = repoService.createDocument(site1.getContainerNodeRef(DOCUMENT_LIBRARY_CONTAINER_NAME), "Test Doc2", "Test Doc2 Title", "Test Doc2 Description", "Test Content");
nodes.add(nodeRef2);
NodeRef nodeRef3 = repoService.createDocument(site2.getContainerNodeRef(DOCUMENT_LIBRARY_CONTAINER_NAME), "Test Doc2", "Test Doc2 Title", "Test Doc2 Description", "Test Content");
nodes.add(nodeRef3);
repoService.createAssociation(nodeRef2, nodeRef1, ASSOC_ORIGINAL);
repoService.createAssociation(nodeRef3, nodeRef1, ASSOC_ORIGINAL);
site1.inviteToSite(person2Id, SiteRole.SiteCollaborator);
return null;
}
}, person1Id, network1.getId());
{
OperationContext cmisOperationCtxOverride = new OperationContextImpl();
cmisOperationCtxOverride.setIncludeRelationships(IncludeRelationships.BOTH);
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person2Id, cmisOperationCtxOverride));
CmisSession cmisSession = publicApiClient.createPublicApiCMISSession(Binding.atom, CMIS_VERSION_10, AlfrescoObjectFactoryImpl.class.getName());
CmisObject o1 = cmisSession.getObject(nodes.get(0).getId());
List<Relationship> relationships = o1.getRelationships();
assertEquals(1, relationships.size());
Relationship r = relationships.get(0);
CmisObject source = r.getSource();
CmisObject target = r.getTarget();
String sourceVersionSeriesId = (String) source.getProperty(PropertyIds.VERSION_SERIES_ID).getFirstValue();
String targetVersionSeriesId = (String) target.getProperty(PropertyIds.VERSION_SERIES_ID).getFirstValue();
assertEquals(nodes.get(1).getId(), sourceVersionSeriesId);
assertEquals(nodes.get(0).getId(), targetVersionSeriesId);
}
}
Aggregations