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);
}
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();
}
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;
}
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;
}
});
}
Aggregations