Search in sources :

Example 6 with DictionaryComponent

use of org.alfresco.repo.dictionary.DictionaryComponent in project alfresco-repository by Alfresco.

the class DbNodeServiceImplPropagationTest method loadModel.

/**
 * Loads the test model required for building the node graphs
 */
public static DictionaryService loadModel(ApplicationContext applicationContext) {
    DictionaryDAO dictionaryDao = (DictionaryDAO) applicationContext.getBean("dictionaryDAO");
    // load the system model
    ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
    InputStream modelStream = cl.getResourceAsStream("alfresco/model/contentModel.xml");
    assertNotNull(modelStream);
    M2Model model = M2Model.createModel(modelStream);
    dictionaryDao.putModel(model);
    // load the test model
    modelStream = cl.getResourceAsStream("org/alfresco/repo/node/BaseNodeServiceTest_model.xml");
    assertNotNull(modelStream);
    model = M2Model.createModel(modelStream);
    dictionaryDao.putModel(model);
    DictionaryComponent dictionary = new DictionaryComponent();
    dictionary.setDictionaryDAO(dictionaryDao);
    // done
    return dictionary;
}
Also used : DictionaryComponent(org.alfresco.repo.dictionary.DictionaryComponent) DictionaryDAO(org.alfresco.repo.dictionary.DictionaryDAO) InputStream(java.io.InputStream) M2Model(org.alfresco.repo.dictionary.M2Model)

Example 7 with DictionaryComponent

use of org.alfresco.repo.dictionary.DictionaryComponent in project alfresco-repository by Alfresco.

the class DbNodeServiceImplPropagationTest method before.

@Before
public void before() throws Exception {
    txnService = (TransactionService) applicationContext.getBean("transactionComponent");
    nodeDAO = (NodeDAO) applicationContext.getBean("nodeDAO");
    dialect = (Dialect) applicationContext.getBean("dialect");
    nodeService = (NodeService) applicationContext.getBean("dbNodeService");
    authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent");
    authenticationComponent.setSystemUserAsCurrentUser();
    DictionaryDAO dictionaryDao = (DictionaryDAO) applicationContext.getBean("dictionaryDAO");
    // load the system model
    ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
    InputStream modelStream = cl.getResourceAsStream("alfresco/model/contentModel.xml");
    assertNotNull(modelStream);
    M2Model model = M2Model.createModel(modelStream);
    dictionaryDao.putModel(model);
    // load the test model
    modelStream = cl.getResourceAsStream("org/alfresco/repo/node/BaseNodeServiceTest_model.xml");
    assertNotNull(modelStream);
    model = M2Model.createModel(modelStream);
    dictionaryDao.putModel(model);
    DictionaryComponent dictionary = new DictionaryComponent();
    dictionary.setDictionaryDAO(dictionaryDao);
    dictionaryService = loadModel(applicationContext);
    restartAuditableTxn();
}
Also used : DictionaryComponent(org.alfresco.repo.dictionary.DictionaryComponent) DictionaryDAO(org.alfresco.repo.dictionary.DictionaryDAO) InputStream(java.io.InputStream) M2Model(org.alfresco.repo.dictionary.M2Model) Before(org.junit.Before)

Example 8 with DictionaryComponent

use of org.alfresco.repo.dictionary.DictionaryComponent in project alfresco-repository by Alfresco.

the class BaseNodeServiceTest method before.

@Before
public void before() {
    metadataEncryptor = (MetadataEncryptor) applicationContext.getBean("metadataEncryptor");
    transactionService = (TransactionService) applicationContext.getBean("transactionComponent");
    retryingTransactionHelper = (RetryingTransactionHelper) applicationContext.getBean("retryingTransactionHelper");
    policyComponent = (PolicyComponent) applicationContext.getBean("policyComponent");
    authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent");
    contentService = (ContentService) applicationContext.getBean("contentService");
    authenticationComponent.setSystemUserAsCurrentUser();
    DictionaryDAO dictionaryDao = (DictionaryDAO) applicationContext.getBean("dictionaryDAO");
    // load the system model
    ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
    InputStream modelStream = cl.getResourceAsStream("alfresco/model/contentModel.xml");
    assertNotNull(modelStream);
    M2Model model = M2Model.createModel(modelStream);
    dictionaryDao.putModel(model);
    // load the test model
    modelStream = cl.getResourceAsStream("org/alfresco/repo/node/BaseNodeServiceTest_model.xml");
    assertNotNull(modelStream);
    model = M2Model.createModel(modelStream);
    dictionaryDao.putModel(model);
    DictionaryComponent dictionary = new DictionaryComponent();
    dictionary.setDictionaryDAO(dictionaryDao);
    dictionaryService = loadModel(applicationContext);
    nodeService = getNodeService();
    // create a first store directly
    StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
    rootNodeRef = nodeService.getRootNode(storeRef);
    StoreRef catStoreRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_cat_" + System.currentTimeMillis());
    NodeRef catRootNodeRef = nodeService.getRootNode(catStoreRef);
    cat = nodeService.createNode(catRootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}cat"), ContentModel.TYPE_CATEGORY).getChildRef();
    // downgrade integrity checks
    IntegrityChecker.setWarnInTransaction();
}
Also used : StoreRef(org.alfresco.service.cmr.repository.StoreRef) NodeRef(org.alfresco.service.cmr.repository.NodeRef) DictionaryComponent(org.alfresco.repo.dictionary.DictionaryComponent) DictionaryDAO(org.alfresco.repo.dictionary.DictionaryDAO) InputStream(java.io.InputStream) M2Model(org.alfresco.repo.dictionary.M2Model) Before(org.junit.Before)

Example 9 with DictionaryComponent

use of org.alfresco.repo.dictionary.DictionaryComponent in project alfresco-repository by Alfresco.

the class BaseNodeServiceTest method loadModel.

/**
 * Loads the test model required for building the node graphs
 */
public static DictionaryService loadModel(ApplicationContext applicationContext) {
    DictionaryDAO dictionaryDao = (DictionaryDAO) applicationContext.getBean("dictionaryDAO");
    // load the system model
    ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
    InputStream modelStream = cl.getResourceAsStream("alfresco/model/contentModel.xml");
    assertNotNull(modelStream);
    M2Model model = M2Model.createModel(modelStream);
    dictionaryDao.putModel(model);
    // load the test model
    modelStream = cl.getResourceAsStream("org/alfresco/repo/node/BaseNodeServiceTest_model.xml");
    assertNotNull(modelStream);
    model = M2Model.createModel(modelStream);
    dictionaryDao.putModel(model);
    DictionaryComponent dictionary = new DictionaryComponent();
    dictionary.setDictionaryDAO(dictionaryDao);
    // done
    return dictionary;
}
Also used : DictionaryComponent(org.alfresco.repo.dictionary.DictionaryComponent) DictionaryDAO(org.alfresco.repo.dictionary.DictionaryDAO) InputStream(java.io.InputStream) M2Model(org.alfresco.repo.dictionary.M2Model)

Example 10 with DictionaryComponent

use of org.alfresco.repo.dictionary.DictionaryComponent in project alfresco-repository by Alfresco.

the class TemplateServiceImplTest method setUp.

@Before
public void setUp() throws Exception {
    transactionService = (TransactionService) applicationContext.getBean("transactionComponent");
    nodeService = (NodeService) applicationContext.getBean("nodeService");
    templateService = (TemplateService) applicationContext.getBean("templateService");
    serviceRegistry = (ServiceRegistry) applicationContext.getBean("ServiceRegistry");
    this.authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent");
    this.authenticationComponent.setSystemUserAsCurrentUser();
    DictionaryDAO dictionaryDao = (DictionaryDAO) applicationContext.getBean("dictionaryDAO");
    // load the system model
    ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
    InputStream modelStream = cl.getResourceAsStream("alfresco/model/contentModel.xml");
    assertNotNull(modelStream);
    M2Model model = M2Model.createModel(modelStream);
    dictionaryDao.putModel(model);
    // load the test model
    modelStream = cl.getResourceAsStream("org/alfresco/repo/node/BaseNodeServiceTest_model.xml");
    assertNotNull(modelStream);
    model = M2Model.createModel(modelStream);
    dictionaryDao.putModel(model);
    DictionaryComponent dictionary = new DictionaryComponent();
    dictionary.setDictionaryDAO(dictionaryDao);
    BaseNodeServiceTest.loadModel(applicationContext);
    transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>() {

        @SuppressWarnings("unchecked")
        public Object execute() throws Exception {
            StoreRef store = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "template_" + System.currentTimeMillis());
            root_node = nodeService.getRootNode(store);
            Map<QName, Serializable> properties = new HashMap<QName, Serializable>(11);
            properties.put(ContentModel.PROP_NAME, (Serializable) "subFolder");
            NodeRef subFolderRef = nodeService.createNode(root_node, ContentModel.ASSOC_CHILDREN, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName("subFolder")), ContentModel.TYPE_FOLDER, properties).getChildRef();
            properties.put(ContentModel.PROP_NAME, (Serializable) "subSubFolder");
            NodeRef subSubFolderRef = nodeService.createNode(subFolderRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName("subSubFolder")), ContentModel.TYPE_FOLDER, properties).getChildRef();
            properties.put(ContentModel.PROP_NAME, (Serializable) "subSubSubFolder");
            nodeService.createNode(subSubFolderRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, QName.createValidLocalName("subSubSubFolder")), ContentModel.TYPE_FOLDER, properties);
            BaseNodeServiceTest.buildNodeGraph(nodeService, root_node);
            return null;
        }
    });
}
Also used : StoreRef(org.alfresco.service.cmr.repository.StoreRef) Serializable(java.io.Serializable) InputStream(java.io.InputStream) QName(org.alfresco.service.namespace.QName) M2Model(org.alfresco.repo.dictionary.M2Model) TemplateException(org.alfresco.service.cmr.repository.TemplateException) NodeRef(org.alfresco.service.cmr.repository.NodeRef) DictionaryComponent(org.alfresco.repo.dictionary.DictionaryComponent) DictionaryDAO(org.alfresco.repo.dictionary.DictionaryDAO) HashMap(java.util.HashMap) Map(java.util.Map) Before(org.junit.Before)

Aggregations

DictionaryComponent (org.alfresco.repo.dictionary.DictionaryComponent)10 InputStream (java.io.InputStream)8 DictionaryDAO (org.alfresco.repo.dictionary.DictionaryDAO)8 M2Model (org.alfresco.repo.dictionary.M2Model)8 NodeRef (org.alfresco.service.cmr.repository.NodeRef)4 StoreRef (org.alfresco.service.cmr.repository.StoreRef)4 Before (org.junit.Before)3 ArrayList (java.util.ArrayList)2 DictionaryBootstrap (org.alfresco.repo.dictionary.DictionaryBootstrap)2 DictionaryDAOImpl (org.alfresco.repo.dictionary.DictionaryDAOImpl)2 TenantService (org.alfresco.repo.tenant.TenantService)2 Serializable (java.io.Serializable)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 SingleTServiceImpl (org.alfresco.repo.tenant.SingleTServiceImpl)1 RetryingTransactionCallback (org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)1 TemplateException (org.alfresco.service.cmr.repository.TemplateException)1 QName (org.alfresco.service.namespace.QName)1