Search in sources :

Example 1 with DictionaryComponent

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

the class RhinoScriptTest method setUp.

/*
     * @see junit.framework.TestCase#setUp()
     */
protected void setUp() throws Exception {
    super.setUp();
    ctx = ApplicationContextHelper.getApplicationContext();
    transactionService = (TransactionService) ctx.getBean("transactionComponent");
    contentService = (ContentService) ctx.getBean("contentService");
    nodeService = (NodeService) ctx.getBean("nodeService");
    scriptService = (ScriptService) ctx.getBean("scriptService");
    serviceRegistry = (ServiceRegistry) ctx.getBean("ServiceRegistry");
    this.authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
    this.authenticationComponent.setSystemUserAsCurrentUser();
    DictionaryDAO dictionaryDao = (DictionaryDAO) ctx.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(ctx);
}
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 2 with DictionaryComponent

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

the class PolicyComponentTest method setUp.

@Override
protected void setUp() throws Exception {
    // Instantiate Dictionary Service
    TenantService tenantService = new SingleTServiceImpl();
    DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl();
    dictionaryDAO.setTenantService(tenantService);
    initDictionaryCaches(dictionaryDAO, tenantService);
    DictionaryBootstrap bootstrap = new DictionaryBootstrap();
    List<String> bootstrapModels = new ArrayList<String>();
    bootstrapModels.add("alfresco/model/dictionaryModel.xml");
    bootstrapModels.add("alfresco/model/systemModel.xml");
    bootstrapModels.add("org/alfresco/repo/policy/policycomponenttest_model.xml");
    bootstrapModels.add(TEST_MODEL);
    bootstrap.setModels(bootstrapModels);
    bootstrap.setDictionaryDAO(dictionaryDAO);
    bootstrap.setTenantService(new SingleTServiceImpl());
    bootstrap.bootstrap();
    DictionaryComponent dictionary = new DictionaryComponent();
    dictionary.setDictionaryDAO(dictionaryDAO);
    // Instantiate Policy Component
    policyComponent = new PolicyComponentImpl(dictionary);
}
Also used : TenantService(org.alfresco.repo.tenant.TenantService) DictionaryComponent(org.alfresco.repo.dictionary.DictionaryComponent) DictionaryDAOImpl(org.alfresco.repo.dictionary.DictionaryDAOImpl) DictionaryBootstrap(org.alfresco.repo.dictionary.DictionaryBootstrap) SingleTServiceImpl(org.alfresco.repo.tenant.SingleTServiceImpl) ArrayList(java.util.ArrayList)

Example 3 with DictionaryComponent

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

the class PerformanceNodeServiceTest method setUp.

@Override
protected void setUp() throws Exception {
    applicationContext = ApplicationContextHelper.getApplicationContext();
    DictionaryDAO dictionaryDao = (DictionaryDAO) applicationContext.getBean("dictionaryDAO");
    // load the system model
    ClassLoader cl = PerformanceNodeServiceTest.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 = (NodeService) applicationContext.getBean("nodeService");
    txnService = (TransactionService) applicationContext.getBean("transactionComponent");
    contentService = (ContentService) applicationContext.getBean("contentService");
    // create a first store directly
    RetryingTransactionCallback<NodeRef> createStoreWork = new RetryingTransactionCallback<NodeRef>() {

        public NodeRef execute() {
            StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.nanoTime());
            return nodeService.getRootNode(storeRef);
        }
    };
    rootNodeRef = txnService.getRetryingTransactionHelper().doInTransaction(createStoreWork);
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) StoreRef(org.alfresco.service.cmr.repository.StoreRef) DictionaryComponent(org.alfresco.repo.dictionary.DictionaryComponent) DictionaryDAO(org.alfresco.repo.dictionary.DictionaryDAO) RetryingTransactionCallback(org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback) InputStream(java.io.InputStream) M2Model(org.alfresco.repo.dictionary.M2Model)

Example 4 with DictionaryComponent

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

the class MTPolicyComponentTest method setUp.

@Override
protected void setUp() throws Exception {
    TenantService mockTenantService = mock(TenantService.class);
    when(mockTenantService.isEnabled()).thenReturn(true);
    when(mockTenantService.getCurrentUserDomain()).thenReturn("test.com");
    when(mockTenantService.getDomainUser(any(String.class), any(String.class))).thenReturn("System");
    when(mockTenantService.getBaseName(any(NodeRef.class))).thenReturn(new NodeRef(BASE_PROTOCOL, BASE_IDENTIFIER, BASE_ID));
    when(mockTenantService.getBaseName(any(StoreRef.class))).thenReturn(new StoreRef(BASE_PROTOCOL, BASE_IDENTIFIER));
    DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl();
    dictionaryDAO.setTenantService(mockTenantService);
    initDictionaryCaches(dictionaryDAO, mockTenantService);
    DictionaryBootstrap bootstrap = new DictionaryBootstrap();
    List<String> bootstrapModels = new ArrayList<String>();
    bootstrapModels.add("alfresco/model/dictionaryModel.xml");
    bootstrapModels.add("alfresco/model/systemModel.xml");
    bootstrapModels.add("org/alfresco/repo/policy/policycomponenttest_model.xml");
    bootstrapModels.add(TEST_MODEL);
    bootstrap.setModels(bootstrapModels);
    bootstrap.setDictionaryDAO(dictionaryDAO);
    bootstrap.setTenantService(mockTenantService);
    bootstrap.bootstrap();
    DictionaryComponent dictionary = new DictionaryComponent();
    dictionary.setDictionaryDAO(dictionaryDAO);
    // Instantiate Policy Component
    PolicyComponentImpl x = new PolicyComponentImpl(dictionary);
    x.setTenantService(mockTenantService);
    policyComponent = x;
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) StoreRef(org.alfresco.service.cmr.repository.StoreRef) TenantService(org.alfresco.repo.tenant.TenantService) DictionaryComponent(org.alfresco.repo.dictionary.DictionaryComponent) DictionaryDAOImpl(org.alfresco.repo.dictionary.DictionaryDAOImpl) DictionaryBootstrap(org.alfresco.repo.dictionary.DictionaryBootstrap) ArrayList(java.util.ArrayList)

Example 5 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