Search in sources :

Example 16 with DictionaryDAO

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

the class ConcurrentNodeServiceTest method setUp.

protected void setUp() throws Exception {
    ctx = ApplicationContextHelper.getApplicationContext();
    DictionaryDAO dictionaryDao = (DictionaryDAO) ctx.getBean("dictionaryDAO");
    // load the system model
    ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
    InputStream modelStream = cl.getResourceAsStream("alfresco/model/systemModel.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);
    ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    nodeService = serviceRegistry.getNodeService();
    nodeDAO = (NodeDAO) ctx.getBean("nodeDAO");
    transactionService = serviceRegistry.getTransactionService();
    authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
    this.authenticationComponent.setSystemUserAsCurrentUser();
    // create a first store directly
    RetryingTransactionCallback<Object> createRootNodeCallback = new RetryingTransactionCallback<Object>() {

        public Object execute() throws Exception {
            StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
            rootNodeRef = nodeService.getRootNode(storeRef);
            return null;
        }
    };
    transactionService.getRetryingTransactionHelper().doInTransaction(createRootNodeCallback);
}
Also used : StoreRef(org.alfresco.service.cmr.repository.StoreRef) DictionaryDAO(org.alfresco.repo.dictionary.DictionaryDAO) RetryingTransactionCallback(org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback) InputStream(java.io.InputStream) M2Model(org.alfresco.repo.dictionary.M2Model) ServiceRegistry(org.alfresco.service.ServiceRegistry)

Example 17 with DictionaryDAO

use of org.alfresco.repo.dictionary.DictionaryDAO 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 18 with DictionaryDAO

use of org.alfresco.repo.dictionary.DictionaryDAO 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 19 with DictionaryDAO

use of org.alfresco.repo.dictionary.DictionaryDAO 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

DictionaryDAO (org.alfresco.repo.dictionary.DictionaryDAO)19 M2Model (org.alfresco.repo.dictionary.M2Model)16 InputStream (java.io.InputStream)13 DictionaryComponent (org.alfresco.repo.dictionary.DictionaryComponent)8 StoreRef (org.alfresco.service.cmr.repository.StoreRef)8 RetryingTransactionCallback (org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback)4 NodeRef (org.alfresco.service.cmr.repository.NodeRef)4 QName (org.alfresco.service.namespace.QName)4 ServiceRegistry (org.alfresco.service.ServiceRegistry)3 TransactionService (org.alfresco.service.transaction.TransactionService)3 Before (org.junit.Before)3 ApplicationContext (org.springframework.context.ApplicationContext)3 M2Property (org.alfresco.repo.dictionary.M2Property)2 PermissionService (org.alfresco.service.cmr.security.PermissionService)2 PropertyMap (org.alfresco.util.PropertyMap)2 IOException (java.io.IOException)1 Serializable (java.io.Serializable)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1