Java Code Examples for org.alfresco.repo.dictionary.DictionaryDAO#putModel()

The following examples show how to use org.alfresco.repo.dictionary.DictionaryDAO#putModel() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseNodeServiceTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 2
Source File: DbNodeServiceImplPropagationTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 3
Source File: NodeRefPropertyMethodInterceptorTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Before
public void before() throws Exception
{
    mlAwareNodeService = (NodeService) applicationContext.getBean("mlAwareNodeService");
    nodeService = (NodeService) applicationContext.getBean("nodeService");
    dictionaryDAO = (DictionaryDAO) applicationContext.getBean("dictionaryDAO");

    authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent");

    authenticationComponent.setSystemUserAsCurrentUser();

    ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
    InputStream modelStream = cl.getResourceAsStream("org/alfresco/repo/node/NodeRefTestModel.xml");
    assertNotNull(modelStream);
    M2Model model = M2Model.createModel(modelStream);
    dictionaryDAO.putModel(model);

    StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
    rootNodeRef = nodeService.getRootNode(storeRef);

}
 
Example 4
Source File: PerformanceNodeServiceTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 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 = 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);
    
    return dictionary;
}
 
Example 5
Source File: AbstractEnterpriseOpenCMISTCKTest.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void overrideVersionableAspectProperties(ApplicationContext ctx)
{
    final DictionaryDAO dictionaryDAO = (DictionaryDAO) ctx.getBean("dictionaryDAO");
    dictionaryDAO.removeModel(QName.createQName("cm:contentmodel"));
    M2Model contentModel = M2Model.createModel(getClass().getClassLoader().getResourceAsStream("alfresco/model/contentModel.xml"));

    M2Aspect versionableAspect = contentModel.getAspect("cm:versionable");
    M2Property prop = versionableAspect.getProperty("cm:initialVersion"); 
    prop.setDefaultValue(Boolean.FALSE.toString());
    prop = versionableAspect.getProperty("cm:autoVersion"); 
    prop.setDefaultValue(Boolean.FALSE.toString());
    prop = versionableAspect.getProperty("cm:autoVersionOnUpdateProps"); 
    prop.setDefaultValue(Boolean.FALSE.toString());

    dictionaryDAO.putModel(contentModel);
}
 
Example 6
Source File: RhinoScriptTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 7
Source File: ConcurrentNodeServiceSearchTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
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);

    nodeService = (NodeService) ctx.getBean("dbNodeService");
    transactionService = (TransactionService) ctx.getBean("transactionComponent");
    this.authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");

    this.authenticationComponent.setSystemUserAsCurrentUser();

    // create a first store directly
    UserTransaction tx = transactionService.getUserTransaction();
    tx.begin();
    StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
    rootNodeRef = nodeService.getRootNode(storeRef);
    tx.commit();
}
 
Example 8
Source File: ConcurrentNodeServiceTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
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);
}
 
Example 9
Source File: DbNodeServiceImplPropagationTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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();
}
 
Example 10
Source File: PerformanceNodeServiceTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example 11
Source File: TemporaryModels.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
private QName loadModel(final M2Model model) {
       if (logger.isDebugEnabled())
       {
           logger.debug("Loading model: "+model.getName());
       }
       
       final DictionaryDAO dictionaryDAO = getDictionaryDAO();
	QName modelQName = dictionaryDAO.putModel(model);
	loadedModels.add(modelQName);
	return modelQName;
}
 
Example 12
Source File: TemplateServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@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;
                }
            });
}
 
Example 13
Source File: ArchiveAndRestoreTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void setUp() throws Exception
{
    ctx = ApplicationContextHelper.getApplicationContext();
    
    ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean("ServiceRegistry");
    nodeArchiveService = (NodeArchiveService) ctx.getBean("nodeArchiveService");
    nodeService = serviceRegistry.getNodeService();
    permissionService = serviceRegistry.getPermissionService();
    authenticationService = serviceRegistry.getAuthenticationService();
    authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
    ownableService = (OwnableService) ctx.getBean("ownableService");
    transactionService = serviceRegistry.getTransactionService();
    DictionaryDAO dictionaryDao = (DictionaryDAO) ctx.getBean("dictionaryDAO");

    ClassLoader cl = ArchiveAndRestoreTest.class.getClassLoader();
    // load the test model
    InputStream modelStream = cl.getResourceAsStream("org/alfresco/repo/node/archive/archiveTest_model.xml");
    assertNotNull(modelStream);
    M2Model model = M2Model.createModel(modelStream);
    dictionaryDao.putModel(model);

    // Start a transaction
    txn = transactionService.getUserTransaction();
    txn.begin();
    
    // downgrade integrity checks
    IntegrityChecker.setWarnInTransaction();
    
    try
    {
        authenticationComponent.setSystemUserAsCurrentUser();
        // Create the work store
        workStoreRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, getName() + System.currentTimeMillis());
        workStoreRootNodeRef = nodeService.getRootNode(workStoreRef);
        archiveStoreRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "archive" + getName() + System.currentTimeMillis());
        archiveStoreRootNodeRef = nodeService.getRootNode(archiveStoreRef);
        
        // Map the work store to the archive store.  This will already be wired into the NodeService.
        StoreArchiveMap archiveMap = (StoreArchiveMap) ctx.getBean("storeArchiveMap");
        archiveMap.put(workStoreRef, archiveStoreRef);
        
        TestWithUserUtils.createUser(USER_A, USER_A, workStoreRootNodeRef, nodeService, authenticationService);
        TestWithUserUtils.createUser(USER_B, USER_B, workStoreRootNodeRef, nodeService, authenticationService);
        TestWithUserUtils.createUser(USER_C, USER_C, workStoreRootNodeRef, nodeService, authenticationService);
        // grant A and B rights to the work store
        permissionService.setPermission(
                workStoreRootNodeRef,
                USER_A,
                PermissionService.ALL_PERMISSIONS,
                true);
        permissionService.setPermission(
                workStoreRootNodeRef,
                USER_B,
                PermissionService.ALL_PERMISSIONS,
                true);
        permissionService.setPermission(
                workStoreRootNodeRef,
                USER_C,
                PermissionService.ALL_PERMISSIONS,
                false);
    }
    finally
    {
        authenticationComponent.clearCurrentSecurityContext();
    }
    // authenticate as normal user
    authenticationService.authenticate(USER_A, USER_A.toCharArray());
    createNodeStructure();
}
 
Example 14
Source File: BaseNodeServiceTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@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();
}
 
Example 15
Source File: IncompleteNodeTaggerTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void setUp() throws Exception
{
    ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
    DictionaryDAO dictionaryDao = (DictionaryDAO) ctx.getBean("dictionaryDAO");
    ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
    // load the test model
    InputStream modelStream = cl.getResourceAsStream("org/alfresco/repo/node/integrity/IntegrityTest_model.xml");
    assertNotNull(modelStream);
    M2Model model = M2Model.createModel(modelStream);
    dictionaryDao.putModel(model);

    tagger = (IncompleteNodeTagger) ctx.getBean("incompleteNodeTagger");

    serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    nodeService = serviceRegistry.getNodeService();
    authenticationService = serviceRegistry.getAuthenticationService();
    permissionService = serviceRegistry.getPermissionService();
    this.authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
    
    this.authenticationComponent.setSystemUserAsCurrentUser();
    
    String user = getName();
    if (!authenticationService.authenticationExists(user))
    {
        authenticationService.createAuthentication(user, user.toCharArray());
    }
    
    // begin a transaction
    TransactionService transactionService = serviceRegistry.getTransactionService();
    txn = transactionService.getUserTransaction();
    txn.begin();
    StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, getName());
    if (!nodeService.exists(storeRef))
    {
        nodeService.createStore(storeRef.getProtocol(), storeRef.getIdentifier());
        rootNodeRef = nodeService.getRootNode(storeRef);
        // Make sure our user can do everything
        permissionService.setPermission(rootNodeRef, user, PermissionService.ALL_PERMISSIONS, true);
    }
    else
    {
        rootNodeRef = nodeService.getRootNode(storeRef);
    }
    
    properties = new PropertyMap();
    properties.put(IntegrityTest.TEST_PROP_TEXT_C, "abc");
    
    // Authenticate as a test-specific user
    authenticationComponent.setCurrentUser(user);
}
 
Example 16
Source File: IntegrityTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void setUp() throws Exception
{
    ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
    DictionaryDAO dictionaryDao = (DictionaryDAO) ctx.getBean("dictionaryDAO");
    ClassLoader cl = BaseNodeServiceTest.class.getClassLoader();
    // load the test model
    InputStream modelStream = cl.getResourceAsStream("org/alfresco/repo/node/integrity/IntegrityTest_model.xml");
    assertNotNull(modelStream);
    M2Model model = M2Model.createModel(modelStream);
    dictionaryDao.putModel(model);

    integrityChecker = (IntegrityChecker) ctx.getBean("integrityChecker");
    integrityChecker.setEnabled(true);
    integrityChecker.setFailOnViolation(true);
    integrityChecker.setTraceOn(true);
    integrityChecker.setMaxErrorsPerTransaction(100);   // we want to count the correct number of errors
    
    MetadataEncryptor encryptor = (MetadataEncryptor) ctx.getBean("metadataEncryptor");

    serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    nodeService = serviceRegistry.getNodeService();
    this.authenticationComponent = (AuthenticationComponent)ctx.getBean("authenticationComponent");
    
    this.authenticationComponent.setSystemUserAsCurrentUser();
    
    // begin a transaction
    TransactionService transactionService = serviceRegistry.getTransactionService();
    txn = transactionService.getUserTransaction();
    txn.begin();
    StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, getName());
    if (!nodeService.exists(storeRef))
    {
        nodeService.createStore(storeRef.getProtocol(), storeRef.getIdentifier());
    }
    rootNodeRef = nodeService.getRootNode(storeRef);
    
    allProperties = new PropertyMap();
    allProperties.put(TEST_PROP_TEXT_A, "ABC");
    allProperties.put(TEST_PROP_TEXT_B, "DEF");
    allProperties.put(TEST_PROP_INT_A, "123");
    allProperties.put(TEST_PROP_INT_B, "456");
    allProperties.put(TEST_PROP_ENCRYPTED_A, "ABC");
    allProperties.put(TEST_PROP_ENCRYPTED_B, "DEF");
    allProperties = encryptor.encrypt(allProperties);
}