Search in sources :

Example 6 with SingleTServiceImpl

use of org.alfresco.repo.tenant.SingleTServiceImpl in project alfresco-repository by Alfresco.

the class RepoDictionaryDAOTest method testADB159.

public void testADB159() throws Exception {
    // source dictionary
    TenantService tenantService = new SingleTServiceImpl();
    DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl();
    dictionaryDAO.setTenantService(tenantService);
    initDictionaryCaches(dictionaryDAO, tenantService);
    // destination dictionary
    DictionaryDAOImpl dictionaryDAO2 = new DictionaryDAOImpl();
    dictionaryDAO2.setTenantService(tenantService);
    initDictionaryCaches(dictionaryDAO2, tenantService);
    List<String> models = new ArrayList<String>();
    models.add("alfresco/model/dictionaryModel.xml");
    models.add("alfresco/model/systemModel.xml");
    models.add("alfresco/model/contentModel.xml");
    models.add("alfresco/model/applicationModel.xml");
    models.add("org/alfresco/repo/security/authentication/userModel.xml");
    models.add("org/alfresco/repo/action/actionModel.xml");
    models.add("org/alfresco/repo/rule/ruleModel.xml");
    models.add("org/alfresco/repo/version/version_model.xml");
    // round-trip default models
    for (String bootstrapModel : models) {
        InputStream modelStream = getClass().getClassLoader().getResourceAsStream(bootstrapModel);
        if (modelStream == null) {
            throw new DictionaryException("Could not find bootstrap model " + bootstrapModel);
        }
        try {
            // parse model from xml
            M2Model model = M2Model.createModel(modelStream);
            dictionaryDAO.putModel(model);
            // regenerate xml from model
            ByteArrayOutputStream xml1 = new ByteArrayOutputStream();
            model.toXML(xml1);
            // register regenerated xml with other dictionary
            M2Model model2 = M2Model.createModel(new ByteArrayInputStream(xml1.toByteArray()));
            dictionaryDAO2.putModel(model2);
        } catch (DictionaryException e) {
            throw new DictionaryException("Could not import bootstrap model " + bootstrapModel, e);
        }
    }
    // specific test case
    M2Model model = M2Model.createModel("test:adb25");
    model.createNamespace(TEST_URL, "test");
    model.createImport(NamespaceService.DICTIONARY_MODEL_1_0_URI, NamespaceService.DICTIONARY_MODEL_PREFIX);
    model.createImport(NamespaceService.SYSTEM_MODEL_1_0_URI, NamespaceService.SYSTEM_MODEL_PREFIX);
    model.createImport(NamespaceService.CONTENT_MODEL_1_0_URI, NamespaceService.CONTENT_MODEL_PREFIX);
    M2Type testType = model.createType("test:adb25");
    testType.setParentName("cm:" + ContentModel.TYPE_CONTENT.getLocalName());
    M2Property prop1 = testType.createProperty("test:prop1");
    prop1.setMandatory(false);
    prop1.setType("d:" + DataTypeDefinition.TEXT.getLocalName());
    prop1.setMultiValued(false);
    ByteArrayOutputStream xml1 = new ByteArrayOutputStream();
    model.toXML(xml1);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) SingleTServiceImpl(org.alfresco.repo.tenant.SingleTServiceImpl) ArrayList(java.util.ArrayList) ByteArrayOutputStream(java.io.ByteArrayOutputStream) DictionaryException(org.alfresco.service.cmr.dictionary.DictionaryException) TenantService(org.alfresco.repo.tenant.TenantService) ByteArrayInputStream(java.io.ByteArrayInputStream)

Aggregations

ArrayList (java.util.ArrayList)6 SingleTServiceImpl (org.alfresco.repo.tenant.SingleTServiceImpl)6 TenantService (org.alfresco.repo.tenant.TenantService)6 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1 DictionaryBootstrap (org.alfresco.repo.dictionary.DictionaryBootstrap)1 DictionaryComponent (org.alfresco.repo.dictionary.DictionaryComponent)1 DictionaryDAOImpl (org.alfresco.repo.dictionary.DictionaryDAOImpl)1 AbstractConstraint (org.alfresco.repo.dictionary.constraint.AbstractConstraint)1 ConstraintRegistry (org.alfresco.repo.dictionary.constraint.ConstraintRegistry)1 UserNameConstraint (org.alfresco.repo.dictionary.constraint.UserNameConstraint)1 StaticMessageLookup (org.alfresco.repo.i18n.StaticMessageLookup)1 DictionaryException (org.alfresco.service.cmr.dictionary.DictionaryException)1 Test (org.junit.Test)1