Search in sources :

Example 1 with DictionaryBootstrap

use of org.alfresco.repo.dictionary.DictionaryBootstrap in project alfresco-remote-api by Alfresco.

the class TestCMIS method testTypeFiltering.

/**
 * ALF-18968
 *
 * @see QNameFilterImpl#listOfHardCodedExcludedTypes()
 */
@Test
public void testTypeFiltering() throws Exception {
    // Force an exclusion in order to test the exclusion inheritance
    cmisTypeExclusions.setExcluded(ActionModel.TYPE_ACTION_BASE, true);
    // Quick check
    assertTrue(cmisTypeExclusions.isExcluded(ActionModel.TYPE_ACTION_BASE));
    // Test that a type defined with this excluded parent type does not break the CMIS dictionary
    DictionaryBootstrap bootstrap = new DictionaryBootstrap();
    List<String> bootstrapModels = new ArrayList<String>();
    bootstrapModels.add("publicapi/test-model.xml");
    bootstrap.setModels(bootstrapModels);
    bootstrap.setDictionaryDAO(dictionaryDAO);
    bootstrap.setTenantService(tenantService);
    bootstrap.bootstrap();
    cmisDictionary.afterDictionaryInit();
    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 person1 = network1.createUser(personInfo);
    String person1Id = person1.getId();
    // test that this type is excluded; the 'action' model (act prefix) is in the list of hardcoded exclusions
    QName type = QName.createQName("{http://www.alfresco.org/test/testCMIS}type1");
    assertTrue(cmisTypeExclusions.isExcluded(type));
    // and that we can't get to it through CMIS
    publicApiClient.setRequestContext(new RequestContext(network1.getId(), person1Id));
    CmisSession cmisSession = publicApiClient.createPublicApiCMISSession(Binding.atom, CMIS_VERSION_10, AlfrescoObjectFactoryImpl.class.getName());
    try {
        cmisSession.getTypeDefinition("D:testCMIS:type1");
        fail("Type should not be available");
    } catch (CmisObjectNotFoundException e) {
    // ok
    }
}
Also used : AlfrescoObjectFactoryImpl(org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl) CmisSession(org.alfresco.rest.api.tests.client.PublicApiClient.CmisSession) DictionaryBootstrap(org.alfresco.repo.dictionary.DictionaryBootstrap) CmisObjectNotFoundException(org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException) QName(org.alfresco.service.namespace.QName) ArrayList(java.util.ArrayList) TestNetwork(org.alfresco.rest.api.tests.RepoService.TestNetwork) RequestContext(org.alfresco.rest.api.tests.client.RequestContext) TestPerson(org.alfresco.rest.api.tests.RepoService.TestPerson) VersionableAspectTest(org.alfresco.repo.version.VersionableAspectTest) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)1 AlfrescoObjectFactoryImpl (org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl)1 DictionaryBootstrap (org.alfresco.repo.dictionary.DictionaryBootstrap)1 VersionableAspectTest (org.alfresco.repo.version.VersionableAspectTest)1 TestNetwork (org.alfresco.rest.api.tests.RepoService.TestNetwork)1 TestPerson (org.alfresco.rest.api.tests.RepoService.TestPerson)1 CmisSession (org.alfresco.rest.api.tests.client.PublicApiClient.CmisSession)1 RequestContext (org.alfresco.rest.api.tests.client.RequestContext)1 QName (org.alfresco.service.namespace.QName)1 CmisObjectNotFoundException (org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException)1 Test (org.junit.Test)1