ALF-20169 "cmis:secondary type properties are not visible " : fix + build tests (though I'm going to do a bit more testing), removal of unused imports, slight refactoring of some tests

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@56189 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Steven Glover
2013-10-01 09:48:22 +00:00
parent 214cea08f6
commit 1d85a91e92
4 changed files with 94 additions and 15 deletions

View File

@@ -728,17 +728,6 @@
<property name="networksService" ref="networksService"/>
</bean>
<bean id="publicApiCMISServiceFactory1.1" class="org.alfresco.opencmis.PublicApiAlfrescoCmisServiceFactory" init-method="init">
<property name="cmisConnector" ref="CMISConnector1.1" />
<property name="cmisTransactions" ref="CMISService_Transactions" />
<property name="cmisExceptions" ref="CMISService_Exceptions" />
<property name="cmisControl" ref="CMISService_Control" />
<property name="cmisStreams" ref="CMISService_Streams" />
<property name="authorityService" ref="AuthorityService" />
<property name="tenantAdminService" ref="tenantAdminService"/>
<property name="networksService" ref="networksService"/>
</bean>
<bean id="cmisDispatcherRegistry" class="org.alfresco.opencmis.CMISDispatcherRegistryImpl">
</bean>
@@ -753,7 +742,7 @@
<bean id="cmisAtomPubDispatcher1.1" class="org.alfresco.opencmis.PublicApiAtomPubCMISDispatcher" init-method="init">
<property name="descriptorService" ref="DescriptorService"/>
<property name="cmisServiceFactory" ref="publicApiCMISServiceFactory1.1"/>
<property name="cmisServiceFactory" ref="publicApiCMISServiceFactory"/>
<property name="registry" ref="cmisDispatcherRegistry" />
<property name="serviceName" value="cmis" />
<property name="baseUrlGenerator" ref="baseUrlGenerator" />
@@ -762,7 +751,7 @@
<bean id="cmisBrowserDispatcher1.1" class="org.alfresco.opencmis.PublicApiBrowserCMISDispatcher" init-method="init">
<property name="descriptorService" ref="DescriptorService"/>
<property name="cmisServiceFactory" ref="publicApiCMISServiceFactory1.1"/>
<property name="cmisServiceFactory" ref="publicApiCMISServiceFactory"/>
<property name="baseUrlGenerator" ref="baseUrlGenerator"/>
<property name="registry" ref="cmisDispatcherRegistry" />
<property name="serviceName" value="cmis" />

View File

@@ -404,7 +404,7 @@
<bean id="webscripts.js.cmis.client" class="org.alfresco.repo.cmis.client.CMISLocalConnectionManagerImpl" init-method="init">
<property name="authenticationService" ref="AuthenticationService" />
<property name="configService" ref="webscripts.config" />
<property name="cmisConnector" ref="CMISConnector1.1" />
<property name="cmisConnector" ref="CMISConnector" />
</bean>
<!--

View File

@@ -18,7 +18,6 @@ import org.apache.chemistry.opencmis.commons.data.ContentStream;
import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
import org.apache.chemistry.opencmis.commons.data.Properties;
import org.apache.chemistry.opencmis.commons.data.RepositoryInfo;
import org.apache.chemistry.opencmis.commons.enums.CmisVersion;
import org.apache.chemistry.opencmis.commons.enums.VersioningState;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.RepositoryInfoImpl;

View File

@@ -1430,4 +1430,95 @@ public class TestCMIS extends EnterpriseTestApi
String content = writer.toString();
assertEquals("Ipsum and so onIpsum and so onIpsum and so onIpsum and so onIpsum and so onIpsum and so onIpsum and so on", content);
}
@Test
public void testSecondaryTypes() throws Exception
{
final TestNetwork network1 = getTestFixture().getRandomNetwork();
String username = "user" + System.currentTimeMillis();
PersonInfo personInfo = new PersonInfo(username, username, username, "password", null, null, null, null, null, null, null);
TestPerson person1 = network1.createUser(personInfo);
String person1Id = person1.getId();
final String siteName = "site" + System.currentTimeMillis();
TenantUtil.runAsUserTenant(new TenantRunAsWork<NodeRef>()
{
@Override
public NodeRef doWork() throws Exception
{
SiteInformation siteInfo = new SiteInformation(siteName, siteName, siteName, SiteVisibility.PRIVATE);
TestSite site = repoService.createSite(null, siteInfo);
String name = GUID.generate();
NodeRef folderNodeRef = repoService.createFolder(site.getContainerNodeRef("documentLibrary"), name);
return folderNodeRef;
}
}, person1Id, network1.getId());
// Create a document...
publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1Id));
CmisSession cmisSession = publicApiClient.createPublicApiCMISSession(Binding.atom, "1.1");
Folder docLibrary = (Folder)cmisSession.getObjectByPath("/Sites/" + siteName + "/documentLibrary");
String name = "mydoc-" + GUID.generate() + ".txt";
final List<String> secondaryTypes = new ArrayList<String>();
secondaryTypes.add("P:cm:summarizable");
Map<String, Object> properties = new HashMap<String, Object>();
{
// create a document with 2 aspects
properties.put(PropertyIds.OBJECT_TYPE_ID, "cmis:document");
properties.put(PropertyIds.SECONDARY_OBJECT_TYPE_IDS, secondaryTypes);
properties.put("cm:summary", "My summary");
properties.put(PropertyIds.NAME, name);
}
ContentStreamImpl fileContent = new ContentStreamImpl();
{
ContentWriter writer = new FileContentWriter(TempFileProvider.createTempFile(GUID.generate(), ".txt"));
writer.putContent("Ipsum and so on");
ContentReader reader = writer.getReader();
fileContent.setMimeType(MimetypeMap.MIMETYPE_TEXT_PLAIN);
fileContent.setStream(reader.getContentInputStream());
}
Document doc = docLibrary.createDocument(properties, fileContent, VersioningState.MAJOR);
{
// check that the secondary types and properties are present
{
checkSecondaryTypes(doc, Collections.singleton("P:cm:summarizable"), null);
String summary = (String)doc.getProperty("cm:summary").getFirstValue();
assertEquals("My summary", summary);
}
{
doc = (Document)cmisSession.getObjectByPath("/Sites/" + siteName + "/documentLibrary/" + name);
checkSecondaryTypes(doc, Collections.singleton("P:cm:summarizable"), null);
String summary = (String)doc.getProperty("cm:summary").getFirstValue();
assertEquals("My summary", summary);
}
}
// update property and check
{
properties = new HashMap<String, Object>();
{
properties.put("cm:summary", "My updated summary");
}
doc.updateProperties(properties);
{
checkSecondaryTypes(doc, Collections.singleton("P:cm:summarizable"), null);
String summary = (String)doc.getProperty("cm:summary").getFirstValue();
assertEquals("My updated summary", summary);
}
{
doc = (Document)cmisSession.getObjectByPath("/Sites/" + siteName + "/documentLibrary/" + name);
checkSecondaryTypes(doc, Collections.singleton("P:cm:summarizable"), null);
String summary = (String)doc.getProperty("cm:summary").getFirstValue();
assertEquals("My updated summary", summary);
}
}
}
}