当前位置: 首页>>代码示例>>Java>>正文


Java TransactionService.getUserTransaction方法代码示例

本文整理汇总了Java中org.alfresco.service.transaction.TransactionService.getUserTransaction方法的典型用法代码示例。如果您正苦于以下问题:Java TransactionService.getUserTransaction方法的具体用法?Java TransactionService.getUserTransaction怎么用?Java TransactionService.getUserTransaction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.alfresco.service.transaction.TransactionService的用法示例。


在下文中一共展示了TransactionService.getUserTransaction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testNullValue

import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
/**
 * Starts off with a <tt>null</tt> in the backing cache and adds a value to the
 * transactional cache.  There should be no problem with this.
 */
public void testNullValue() throws Throwable
{
    TransactionService transactionService = serviceRegistry.getTransactionService();
    UserTransaction txn = transactionService.getUserTransaction();

    txn.begin();
    
    TransactionalCache.putSharedCacheValue(backingCache, "A", null, null);
    transactionalCache.put("A", "AAA");
    
    try
    {
        txn.commit();
    }
    catch (Throwable e)
    {
        try {txn.rollback();} catch (Throwable ee) {}
        throw e;
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:CacheTest.java

示例2: setup

import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
@Before
public void setup() throws SystemException, NotSupportedException
{
    try
    {
        nodeService = (NodeService)ctx.getBean("nodeService");
        fileFolderService = (FileFolderService)ctx.getBean("fileFolderService");
        transactionService = (TransactionService)ctx.getBean("transactionService");
        bulkImporter = (MultiThreadedBulkFilesystemImporter)ctx.getBean("bulkFilesystemImporter");
        contentService = (ContentService)ctx.getBean("contentService");
        actionService = (ActionService)ctx.getBean("actionService");
        ruleService = (RuleService)ctx.getBean("ruleService");
        versionService = (VersionService)ctx.getBean("versionService");

        AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());

        String s = "BulkFilesystemImport" + System.currentTimeMillis();

        txn = transactionService.getUserTransaction();
        txn.begin();

        AuthenticationUtil.pushAuthentication();
        AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());

        StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, s);
        rootNodeRef = nodeService.getRootNode(storeRef);
        top = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}top"), ContentModel.TYPE_FOLDER).getChildRef();
        
        topLevelFolder = fileFolderService.create(top, s, ContentModel.TYPE_FOLDER);

        txn.commit();
    }
    catch(Throwable e)
    {
        fail(e.getMessage());
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:38,代码来源:AbstractBulkImportTests.java

示例3: setup

import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
@Before
public void setup() throws SystemException, NotSupportedException
{
   	transactionService = (TransactionService)ctx.getBean("transactionService");
   	keyStoreChecker = (KeyStoreChecker)ctx.getBean("keyStoreChecker");
   	encryptionKeysRegistry = (EncryptionKeysRegistry)ctx.getBean("encryptionKeysRegistry");
   	keyResourceLoader = (KeyResourceLoader)ctx.getBean("springKeyResourceLoader");
       backupEncryptor = (DefaultEncryptor)ctx.getBean("backupEncryptor");

   	toDelete = new ArrayList<String>(10);

       AuthenticationUtil.setRunAsUserSystem();
	UserTransaction txn = transactionService.getUserTransaction();
	txn.begin();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:16,代码来源:KeyStoreTests.java

示例4: setUp

import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
public void setUp() throws Exception
{
    if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE)
    {
        throw new AlfrescoRuntimeException(
                "A previous tests did not clean up transaction: " +
                AlfrescoTransactionSupport.getTransactionId());
    }
    
    nodeService = (NodeService) ctx.getBean("nodeService");
    authenticationService = (MutableAuthenticationService) ctx.getBean("authenticationService");
    authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
    ownableService = (OwnableService) ctx.getBean("ownableService");
    permissionService = (PermissionService) ctx.getBean("permissionService");

    authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName());
    authenticationDAO = (MutableAuthenticationDao) ctx.getBean("authenticationDao");
    
    
    TransactionService transactionService = (TransactionService) ctx.getBean(ServiceRegistry.TRANSACTION_SERVICE.getLocalName());
    txn = transactionService.getUserTransaction();
    txn.begin();
    
    StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
    rootNodeRef = nodeService.getRootNode(storeRef);
    permissionService.setPermission(rootNodeRef, PermissionService.ALL_AUTHORITIES, PermissionService.ADD_CHILDREN, true);
    
    if(authenticationDAO.userExists("andy"))
    {
        authenticationService.deleteAuthentication("andy");
    }
    authenticationService.createAuthentication("andy", "andy".toCharArray());
    
    dynamicAuthority = new OwnerDynamicAuthority();
    dynamicAuthority.setOwnableService(ownableService);
   
    authenticationComponent.clearCurrentSecurityContext();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:39,代码来源:OwnableServiceTest.java

示例5: setUp

import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
public void setUp() throws Exception
{

    authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
    serviceRegistry = (ServiceRegistry) ctx.getBean("ServiceRegistry");

    this.authenticationComponent.setSystemUserAsCurrentUser();

    TransactionService transactionService = (TransactionService) ctx.getBean(ServiceRegistry.TRANSACTION_SERVICE
            .getLocalName());
    tx = transactionService.getUserTransaction();
    tx.begin();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:14,代码来源:FreeMarkerModelLuceneFunctionTest.java

示例6: testNotOnlyCurrentLockOwnerCanChangeInfo

import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
@Test
public void testNotOnlyCurrentLockOwnerCanChangeInfo() throws NotSupportedException, SystemException
{
    final TransactionService txService = (TransactionService) ctx.getBean("TransactionService");
    UserTransaction txA = txService.getUserTransaction();
    final NodeRef nodeRef = new NodeRef("workspace://SpacesStore/UUID-1");
    Date now = new Date();
    Date expires = new Date(now.getTime() + 180000);
    final LockState lockState1 = LockState.createLock(nodeRef, LockType.WRITE_LOCK,
                "jbloggs", expires, Lifetime.EPHEMERAL, null);
    
    txA.begin();
    try
    {
        AuthenticationUtil.setFullyAuthenticatedUser("jbloggs");
        
        // Set initial lock state
        lockStore.set(nodeRef, lockState1);
        
        // Set different lock state
        // Current lock owner is still authenticated (jbloggs)
        final LockState lockState2 = LockState.createWithOwner(lockState1, "csmith");
        lockStore.set(nodeRef, lockState2);
        
        // Check update
        assertEquals(lockState2, lockStore.get(nodeRef));

        // Incorrect lock owner - this shouldn't fail. See ACE-2181
        final LockState lockState3 = LockState.createWithOwner(lockState1, "dsmithers");

        lockStore.set(nodeRef, lockState3);
        
        // Check update.
        assertEquals(lockState3, lockStore.get(nodeRef));
    }
    finally
    {
        txA.rollback();
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:41,代码来源:AbstractLockStoreTxTest.java

示例7: executeAndCheck

import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
/** Execute the callback and ensure that the backing cache is left with the expected value */
private void executeAndCheck(
        RetryingTransactionCallback<Object> callback,
        boolean readOnly,
        String key,
        Object expectedValue,
        boolean mustContainKey) throws Throwable
{
    if (expectedValue != null && !mustContainKey)
    {
        throw new IllegalArgumentException("Why have a value when the key should not be there?");
    }
    
    TransactionService transactionService = serviceRegistry.getTransactionService();
    UserTransaction txn = transactionService.getUserTransaction(readOnly);
    try
    {
        txn.begin();
        callback.execute();
        txn.commit();
    }
    finally
    {
        try { txn.rollback(); } catch (Throwable ee) {}
    }
    Object actualValue = TransactionalCache.getSharedCacheValue(backingCache, key, null);
    assertEquals("Backing cache value was not correct", expectedValue, actualValue);
    assertEquals("Backing cache contains(key): ", mustContainKey, backingCache.contains(key));
    
    // Clear the backing cache to ensure that subsequent tests don't run into existing data
    backingCache.clear();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:33,代码来源:CacheTest.java

示例8: testInitializationPerformance

import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
/**
 * Time how long it takes to create and complete a whole lot of transactions
 */
public void testInitializationPerformance() throws Exception
{
    TransactionService transactionService = serviceRegistry.getTransactionService();
    long start = System.nanoTime();
    int count = 10000;
    for (int i = 0; i < count; i++)
    {
        UserTransaction txn = transactionService.getUserTransaction();
        try
        {
            txn.begin();
            transactionalCache.contains("A");
        }
        finally
        {
            try { txn.rollback(); } catch (Throwable ee) {ee.printStackTrace();}
        }
    }
    long end = System.nanoTime();
    
    // report
    System.out.println(
            "Cache initialization performance test: \n" +
            "   count:       " + count + "\n" +
            "   transaction: " + (end-start)/((long)count) + " ns\\count"); 
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:30,代码来源:CacheTest.java

示例9: testMaxSizeOverrun

import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
/**
 * Add 50K objects into the transactional cache and checks that the first object added
 * has been discarded.
 */
public void testMaxSizeOverrun() throws Exception
{
    TransactionService transactionService = serviceRegistry.getTransactionService();
    UserTransaction txn = transactionService.getUserTransaction();
    try
    {
        txn.begin();
        
        Object startValue = new Integer(-1);
        String startKey = startValue.toString();
        transactionalCache.put(startKey, startValue);
        
        assertEquals("The start value isn't correct", startValue, transactionalCache.get(startKey));
        
        for (int i = 0; i < 205000; i++)
        {
            Object value = Integer.valueOf(i);
            String key = value.toString();
            transactionalCache.put(key, value);
        }
        
        // Is the start value here?
        Object checkStartValue = transactionalCache.get(startKey);
        // Now, the cache should no longer contain the first value
        assertNull("The start value didn't drop out of the cache", checkStartValue);
        
        txn.commit();
    }
    finally
    {
        try { txn.rollback(); } catch (Throwable ee) {}
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:38,代码来源:CacheTest.java

示例10: createTransaction

import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
/**
 * Create a transaction, this will be a wrteable transaction unless the system is in read-only mode.
 * 
 * return UserTransaction
 */
protected final UserTransaction createTransaction()
{
	// Get the transaction service
	
	TransactionService txService = getTransactionService();
	
	// DEBUG
	
	if ( logger.isDebugEnabled())
		logger.debug("Using " + (txService.isReadOnly() ? "ReadOnly" : "Write") + " transaction");
	
	// Create the transaction
	
	return txService.getUserTransaction( txService.isReadOnly() ? true : false);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:FTPAuthenticatorBase.java

示例11: setUp

import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception
{
    if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE)
    {
        fail("Dangling transaction detected, left by a previous test.");
    }
    ctx = (ConfigurableApplicationContext) ApplicationContextHelper.getApplicationContext();
    replicationActionExecutor = (ReplicationActionExecutor) ctx.getBean("replicationActionExecutor");
    replicationService = (ReplicationService) ctx.getBean("replicationService");
    replicationParams = (ReplicationParams) ctx.getBean("replicationParams");
    transactionService = (TransactionService) ctx.getBean("transactionService");
    transferService = (TransferService2) ctx.getBean("transferService2");
    contentService = (ContentService) ctx.getBean("contentService");
    jobLockService = (JobLockService) ctx.getBean("jobLockService");
    actionService = (ActionService) ctx.getBean("actionService");
    scriptService = (ScriptService)ctx.getBean("scriptService");
    nodeService = (NodeService) ctx.getBean("NodeService");
    lockService = (LockService) ctx.getBean("lockService");
    repositoryHelper = (Repository) ctx.getBean("repositoryHelper");
    actionTrackingService = (ActionTrackingService) ctx.getBean("actionTrackingService");
    scheduledPersistedActionService = (ScheduledPersistedActionService) ctx.getBean("scheduledPersistedActionService");
    
    // Set the current security context as admin
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    
    replicationParams.setEnabled(true);
    
    UserTransaction txn = transactionService.getUserTransaction();
    txn.begin();
    
    // Zap any existing replication entries
    replicationRoot = ReplicationDefinitionPersisterImpl.REPLICATION_ACTION_ROOT_NODE_REF;
    for(ChildAssociationRef child : nodeService.getChildAssocs(replicationRoot)) {
       QName type = nodeService.getType( child.getChildRef() );
       if(ReplicationDefinitionPersisterImpl.ACTION_TYPES.contains(type)) {
          nodeService.deleteNode(child.getChildRef());
       }
    }
    
    // Create the test folder structure
    destinationFolder = makeNode(repositoryHelper.getCompanyHome(), ContentModel.TYPE_FOLDER, "ReplicationTransferDestination");
    folder1 = makeNode(repositoryHelper.getCompanyHome(), ContentModel.TYPE_FOLDER);
    folder2 = makeNode(repositoryHelper.getCompanyHome(), ContentModel.TYPE_FOLDER);
    folder2a = makeNode(folder2, ContentModel.TYPE_FOLDER);
    folder2b = makeNode(folder2, ContentModel.TYPE_FOLDER);
    
    content1_1 = makeNode(folder1, ContentModel.TYPE_CONTENT);
    content1_2 = makeNode(folder1, ContentModel.TYPE_CONTENT);
    thumbnail1_3 = makeNode(folder1, ContentModel.TYPE_THUMBNAIL);
    authority1_4 = makeNode(folder1, ContentModel.TYPE_AUTHORITY);
    content2a_1 = makeNode(folder2a, ContentModel.TYPE_CONTENT);
    thumbnail2a_2 = makeNode(folder2a, ContentModel.TYPE_THUMBNAIL);
    zone2a_3 = makeNode(folder2a, ContentModel.TYPE_ZONE);
    
    deletedFolder = makeNode(repositoryHelper.getCompanyHome(), ContentModel.TYPE_FOLDER);
    nodeService.deleteNode(deletedFolder);
    
    // Tell the transfer service not to use HTTP
    makeTransferServiceLocal();
    
    // Finish setup
    txn.commit();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:65,代码来源:ReplicationServiceIntegrationTest.java

示例12: setUp

import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
public void setUp() throws Exception
{
    if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE)
    {
        throw new AlfrescoRuntimeException(
                "A previous tests did not clean up transaction: " +
                AlfrescoTransactionSupport.getTransactionId());
    }
    
    aclDaoComponent = (AclDAO) applicationContext.getBean("aclDAO");
    
    nodeService = (NodeService) applicationContext.getBean("nodeService");
    dictionaryService = (DictionaryService) applicationContext.getBean(ServiceRegistry.DICTIONARY_SERVICE
            .getLocalName());
    permissionService = (PermissionServiceSPI) applicationContext.getBean("permissionService");
    namespacePrefixResolver = (NamespacePrefixResolver) applicationContext
            .getBean(ServiceRegistry.NAMESPACE_SERVICE.getLocalName());
    authenticationService = (MutableAuthenticationService) applicationContext.getBean("authenticationService");
    authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent");
    serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
    permissionModelDAO = (ModelDAO) applicationContext.getBean("permissionsModelDAO");
    personService = (PersonService) applicationContext.getBean("personService");
    authorityService = (AuthorityService) applicationContext.getBean("authorityService");
    
    authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName());
    authenticationDAO = (MutableAuthenticationDao) applicationContext.getBean("authenticationDao");
    transactionService = (TransactionService) applicationContext.getBean("transactionComponent");
    
    testTX = transactionService.getUserTransaction();
    testTX.begin();
    this.authenticationComponent.setSystemUserAsCurrentUser();
    
    StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.nanoTime());
    rootNodeRef = nodeService.getRootNode(storeRef);

    QName children = ContentModel.ASSOC_CHILDREN;
    QName system = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "system");
    QName container = ContentModel.TYPE_CONTAINER;
    QName types = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "people");

    systemNodeRef = nodeService.createNode(rootNodeRef, children, system, container).getChildRef();
    NodeRef typesNodeRef = nodeService.createNode(systemNodeRef, children, types, container).getChildRef();
    Map<QName, Serializable> props = createPersonProperties("andy");
    nodeService.createNode(typesNodeRef, children, ContentModel.TYPE_PERSON, container, props).getChildRef();
    props = createPersonProperties("lemur");
    nodeService.createNode(typesNodeRef, children, ContentModel.TYPE_PERSON, container, props).getChildRef();

    // create an authentication object e.g. the user
    if(authenticationDAO.userExists("andy"))
    {
        authenticationService.deleteAuthentication("andy");
    }
    authenticationService.createAuthentication("andy", "andy".toCharArray());

    if(authenticationDAO.userExists("lemur"))
    {
        authenticationService.deleteAuthentication("lemur");
    }
    authenticationService.createAuthentication("lemur", "lemur".toCharArray());
    
    if(authenticationDAO.userExists(AuthenticationUtil.getAdminUserName()))
    {
        authenticationService.deleteAuthentication(AuthenticationUtil.getAdminUserName());
    }
    authenticationService.createAuthentication(AuthenticationUtil.getAdminUserName(), "admin".toCharArray());
    
    authenticationComponent.clearCurrentSecurityContext();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:69,代码来源:AclDaoComponentTest.java

示例13: setUp

import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void setUp() throws Exception
{
    super.setUp();
    ApplicationContext appContext = getServer().getApplicationContext();

    nodeService = (NodeService)appContext.getBean("NodeService");
    replicationService = (ReplicationService)appContext.getBean("ReplicationService");
    actionTrackingService = (ActionTrackingService)appContext.getBean("actionTrackingService");
    repositoryHelper = (Repository)appContext.getBean("repositoryHelper");
    transactionService = (TransactionService)appContext.getBean("transactionService");
    executingActionsCache = (SimpleCache<String, ExecutionDetails>)appContext.getBean("executingActionsCache");
    
    MutableAuthenticationService authenticationService = (MutableAuthenticationService)appContext.getBean("AuthenticationService");
    PersonService personService = (PersonService)appContext.getBean("PersonService");
    personManager = new TestPersonManager(authenticationService, personService, nodeService);

    UserTransaction txn = transactionService.getUserTransaction();
    txn.begin();
    
    personManager.createPerson(USER_NORMAL);
    
    // Ensure we start with no replication definitions
    // (eg another test left them behind)
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    for(ReplicationDefinition rd : replicationService.loadReplicationDefinitions())
    {
       replicationService.deleteReplicationDefinition(rd);
    }
    txn.commit();
    
    // Grab a reference to the data dictionary
    dataDictionary = nodeService.getChildByName(
             repositoryHelper.getCompanyHome(),
             ContentModel.ASSOC_CONTAINS,
             "Data Dictionary"
    );
    
    AuthenticationUtil.clearCurrentSecurityContext();
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:42,代码来源:RunningActionRestApiTest.java

示例14: testValueLockingInTxn

import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
/** Lock values and ensure they don't get modified */
public void testValueLockingInTxn() throws Exception
{
    // add item to global cache
    TransactionalCache.putSharedCacheValue(backingCache, DEFINITIVE_TWO, "initial_two", null);
    TransactionalCache.putSharedCacheValue(backingCache, DEFINITIVE_THREE, "initial_three", null);
    
    TransactionService transactionService = serviceRegistry.getTransactionService();
    UserTransaction txn = transactionService.getUserTransaction();
    try
    {
        // begin a transaction
        txn.begin();
        
        // Add
        {
            assertEquals(null, transactionalCache.get(DEFINITIVE_ONE));
            // Add it
            transactionalCache.put(DEFINITIVE_ONE, DEFINITIVE_ONE);
            assertFalse("Key should not be locked, yet.", transactionalCache.isValueLocked(DEFINITIVE_ONE));
            // Mark it as definitive
            transactionalCache.lockValue(DEFINITIVE_ONE);
            assertTrue("Key should be locked.", transactionalCache.isValueLocked(DEFINITIVE_ONE));
            // Attempt update
            transactionalCache.put(DEFINITIVE_ONE, "update_one");
            assertEquals("Update values should be locked.", DEFINITIVE_ONE, transactionalCache.get(DEFINITIVE_ONE));
        }
        
        // Update
        {
            assertEquals("initial_two", transactionalCache.get(DEFINITIVE_TWO));
            // Update it
            transactionalCache.put(DEFINITIVE_TWO, DEFINITIVE_TWO);
            assertFalse("Key should not be locked, yet.", transactionalCache.isValueLocked(DEFINITIVE_TWO));
            // Mark it as definitive
            transactionalCache.lockValue(DEFINITIVE_TWO);
            assertTrue("Key should be locked.", transactionalCache.isValueLocked(DEFINITIVE_TWO));
            // Attempt update
            transactionalCache.put(DEFINITIVE_TWO, "update_two");
            assertEquals("Update values should be locked.", DEFINITIVE_TWO, transactionalCache.get(DEFINITIVE_TWO));
            // Attempt removal
            transactionalCache.remove(DEFINITIVE_TWO);
            assertEquals("Update values should be locked.", DEFINITIVE_TWO, transactionalCache.get(DEFINITIVE_TWO));
        }
        
        // Remove
        {
            assertEquals("initial_three", transactionalCache.get(DEFINITIVE_THREE));
            // Remove it
            transactionalCache.remove(DEFINITIVE_THREE);
            assertFalse("Key should not be locked, yet.", transactionalCache.isValueLocked(DEFINITIVE_THREE));
            // Mark it as definitive
            transactionalCache.lockValue(DEFINITIVE_THREE);
            assertTrue("Key should be locked.", transactionalCache.isValueLocked(DEFINITIVE_THREE));
            // Attempt update
            transactionalCache.put(DEFINITIVE_THREE, "add_three");
            assertEquals("Removal should be locked.", null, transactionalCache.get(DEFINITIVE_THREE));
        }
        
        txn.commit();

        // Check post-commit values
        assertEquals("Definitive change not written through.", DEFINITIVE_ONE, TransactionalCache.getSharedCacheValue(backingCache, DEFINITIVE_ONE, null));
        assertEquals("Definitive change not written through.", DEFINITIVE_TWO, TransactionalCache.getSharedCacheValue(backingCache, DEFINITIVE_TWO, null));
        assertEquals("Definitive change not written through.", null, TransactionalCache.getSharedCacheValue(backingCache, DEFINITIVE_THREE, null));
    }
    finally
    {
        try { txn.rollback(); } catch (Throwable ee) {}
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:72,代码来源:CacheTest.java

示例15: setUp

import org.alfresco.service.transaction.TransactionService; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception
{
    applicationContext = ApplicationContextHelper.getApplicationContext();

    // Get the required services
    descriptorService = (DescriptorService) this.applicationContext.getBean("DescriptorService");
    transferServiceImpl = (TransferServiceImpl2) this.applicationContext.getBean("transferService2");
    transferService = transferServiceImpl;
    authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent");
    transactionService = (TransactionService) applicationContext.getBean("transactionComponent");
    repository = (Repository) applicationContext.getBean("repositoryHelper");
    fileFolderService = (FileFolderService) applicationContext.getBean("fileFolderService");
           
    localRepositoryId = descriptorService.getCurrentRepositoryDescriptor().getId();
    version =  new TransferVersionImpl(descriptorService.getServerDescriptor());
    
    mockedTransferTransmitter = mock(TransferTransmitter.class);
    mockedCallback = mock(TransferCallback.class);
    transferServiceImpl.setTransmitter(mockedTransferTransmitter);

    authenticationComponent.setCurrentUser("admin");
    
    tx = transactionService.getUserTransaction();
    tx.begin();
    target = createTransferTarget(TRANSFER_TARGET_NAME);
    tx.commit();
        
    tx = transactionService.getUserTransaction();
    tx.begin();
    
    transfer = new Transfer();
    transfer.setTransferTarget(target);
    transfer.setTransferId(GUID.generate());
    transfer.setToVersion(version);
    
    companyHome = repository.getCompanyHome();
    
    folder1 = fileFolderService.create(companyHome, "folder1", ContentModel.TYPE_FOLDER).getNodeRef();

    file1 = fileFolderService.create(folder1, "file1", ContentModel.TYPE_CONTENT).getNodeRef();
    fileFolderService.getWriter(file1).putContent("This is purely test content.");
    file1ContentUrl = fileFolderService.getFileInfo(file1).getContentData().getContentUrl();

    file2 = fileFolderService.create(folder1, "file2", ContentModel.TYPE_CONTENT).getNodeRef();
    fileFolderService.getWriter(file2).putContent("This is purely test content.");
    file2ContentUrl = fileFolderService.getFileInfo(file2).getContentData().getContentUrl();
    
    file3 = fileFolderService.create(folder1, "file3", ContentModel.TYPE_CONTENT).getNodeRef();
    fileFolderService.getWriter(file3).putContent("This is purely test content.");
    file3ContentUrl = fileFolderService.getFileInfo(file3).getContentData().getContentUrl();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:53,代码来源:TransferServiceCallbackTest.java


注:本文中的org.alfresco.service.transaction.TransactionService.getUserTransaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。