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


Java TxnReadState类代码示例

本文整理汇总了Java中org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState的典型用法代码示例。如果您正苦于以下问题:Java TxnReadState类的具体用法?Java TxnReadState怎么用?Java TxnReadState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: newDeleteFileCallbackCommand

import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; //导入依赖的package包/类
/**
 * Called for delete file.
 */
private ResultCallback newDeleteFileCallbackCommand()
{
    return new ResultCallback()
    {
        @Override
        public void execute(Object result)
        {
            if (result instanceof NodeRef)
            {
                logger.debug("got node ref of deleted node");
                originalNodeRef = (NodeRef) result;
            }
        }

        @Override
        public TxnReadState getTransactionRequired()
        {
            return TxnReadState.TXN_NONE;
        }
    };
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:ScenarioRenameDeleteMoveInstance.java

示例2: getTransactionRequired

import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; //导入依赖的package包/类
@Override
public TxnReadState getTransactionRequired()
{
    TxnReadState readState = TxnReadState.TXN_NONE;
    for(Command command : commands)
    {
        TxnReadState x = command.getTransactionRequired();
        
        if(x != null && x.compareTo(readState) > 0)
        {
            readState = x;
        }
    }
    
    return readState;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:17,代码来源:CompoundCommand.java

示例3: newDeleteFileCallbackCommand

import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; //导入依赖的package包/类
/**
 * Called for delete file.
 */
private ResultCallback newDeleteFileCallbackCommand()
{
    return new ResultCallback()
    {
        @Override
        public void execute(Object result)
        {
            if(result instanceof NodeRef)
            {
                logger.debug("got node ref of deleted node");
                originalNodeRef = (NodeRef)result;
            }
        }

        @Override
        public TxnReadState getTransactionRequired()
        {
            return TxnReadState.TXN_NONE;
        }   
    };
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:ScenarioDeleteRestoreInstance.java

示例4: newOpenFileErrorCallbackCommand

import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; //导入依赖的package包/类
/**
 * Called for open file error.
 */
private ResultCallback newOpenFileErrorCallbackCommand()
{
    return new ResultCallback()
    {
        @Override
        public void execute(Object result)
        {
            logger.debug("error handler - set state to error for name:" + name);
            isComplete = true;
            state = InternalState.ERROR;
        }

        @Override
        public TxnReadState getTransactionRequired()
        {
            return TxnReadState.TXN_NONE;
        }   
    };
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:23,代码来源:ScenarioOpenFileInstance.java

示例5: getActiveUserTransaction

import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; //导入依赖的package包/类
/**
 * Utility method to get the active transaction.  The transaction status can be queried and
 * marked for rollback.
 * <p>
 * <b>NOTE:</b> Any attempt to actually commit or rollback the transaction will cause failures.
 * 
 * @return          Returns the currently active user transaction or <tt>null</tt> if
 *                  there isn't one.
 */
public static UserTransaction getActiveUserTransaction()
{
    // Dodge if there is no wrapping transaction
    if (AlfrescoTransactionSupport.getTransactionReadState() == TxnReadState.TXN_NONE)
    {
        return null;
    }
    // Get the current transaction.  There might not be one if the transaction was not started using
    // this class i.e. it wasn't started with retries.
    UserTransaction txn = (UserTransaction) AlfrescoTransactionSupport.getResource(KEY_ACTIVE_TRANSACTION);
    if (txn == null)
    {
        return null;
    }
    // Done
    return txn;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:RetryingTransactionHelper.java

示例6: checkTxnState

import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; //导入依赖的package包/类
/**
 * Checks that the 'System' user is active in a read-write txn.
 */
private final void checkTxnState(TxnReadState txnStateNeeded)
{
    switch (txnStateNeeded)
    {
        case TXN_READ_WRITE:
            if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_READ_WRITE)
            {
                throw AlfrescoRuntimeException.create("system.usage.err.no_txn_readwrite");
            }
            break;
        case TXN_READ_ONLY:
            if (AlfrescoTransactionSupport.getTransactionReadState() == TxnReadState.TXN_NONE)
            {
                throw AlfrescoRuntimeException.create("system.usage.err.no_txn");
            }
            break;
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:22,代码来源:RepoUsageComponentImpl.java

示例7: setRestrictions

import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; //导入依赖的package包/类
@Override
public void setRestrictions(RepoUsage restrictions)
{
    checkTxnState(TxnReadState.TXN_NONE);
    restrictionsWriteLock.lock();
    try
    {
        this.restrictions = restrictions;
    }
    finally
    {
        restrictionsWriteLock.unlock();
    }
    
    // Fire observers
    for(RestrictionObserver observer : restrictionObservers )
    {
        observer.onChangeRestriction(restrictions);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:RepoUsageComponentImpl.java

示例8: getUsage

import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; //导入依赖的package包/类
@Override
public RepoUsage getUsage()
{
    checkTxnState(TxnReadState.TXN_READ_ONLY);
    restrictionsReadLock.lock();
    try
    {
        // Combine with current restrictions
        RepoUsage usage = getUsageImpl();
        // Done
        if (logger.isDebugEnabled())
        {
            logger.debug("Retrieved repo usage: " + usage);
        }
        return usage;
    }
    finally
    {
        restrictionsReadLock.unlock();
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:22,代码来源:RepoUsageComponentImpl.java

示例9: getTransactionData

import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; //导入依赖的package包/类
/**
 * To be used in a transaction only.
 */
private TransactionData getTransactionData()
{
    @SuppressWarnings("unchecked")
    TransactionData data = (TransactionData) AlfrescoTransactionSupport.getResource(resourceKeyTxnData);
    if (data == null)
    {
        data = new TransactionData();
        // create and initialize caches
        data.updatedItemsCache = new LRULinkedHashMap<Serializable, CacheBucket<V>>(23);
        data.removedItemsCache = new HashSet<Serializable>(13);
        data.lockedItemsCache = new HashSet<Serializable>(13);
        data.isReadOnly = AlfrescoTransactionSupport.getTransactionReadState() == TxnReadState.TXN_READ_ONLY;
        data.stats = new TransactionStats();

        // ensure that we get the transaction callbacks as we have bound the unique
        // transactional caches to a common manager
        AlfrescoTransactionSupport.bindListener(this);
        AlfrescoTransactionSupport.bindResource(resourceKeyTxnData, data);
    }
    return data;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:TransactionalCache.java

示例10: invalidateParentAssocsCached

import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; //导入依赖的package包/类
/**
 * Helper method to remove associations relating to a cached node
 */
private void invalidateParentAssocsCached(Node node)
{
    // Invalidate both the node and current transaction ID, just in case
    Long nodeId = node.getId();
    String nodeTransactionId = node.getTransaction().getChangeTxnId();
    parentAssocsCache.remove(new Pair<Long, String>(nodeId, nodeTransactionId));
    if (AlfrescoTransactionSupport.getTransactionReadState() == TxnReadState.TXN_READ_WRITE)
    {
        String currentTransactionId = getCurrentTransaction().getChangeTxnId();
        if (!currentTransactionId.equals(nodeTransactionId))
        {
            parentAssocsCache.remove(new Pair<Long, String>(nodeId, currentTransactionId));
        }
    }                        
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:AbstractNodeDAOImpl.java

示例11: setUp

import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; //导入依赖的package包/类
@Override
public void setUp() throws Exception
{
    if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE)
    {
        throw new AlfrescoRuntimeException(
                "A previous tests did not clean up transaction: " +
                AlfrescoTransactionSupport.getTransactionId());
    }
    
    transactionService = (TransactionService) ctx.getBean(ServiceRegistry.TRANSACTION_SERVICE.getLocalName());
    authorityService = (AuthorityService) ctx.getBean(ServiceRegistry.AUTHORITY_SERVICE.getLocalName());
    tenantAdminService = ctx.getBean("tenantAdminService", TenantAdminService.class);
    personService = (PersonService) ctx.getBean(ServiceRegistry.PERSON_SERVICE.getLocalName());
    tenantService = (TenantService) ctx.getBean("tenantService");
    authorityBridgeTableCache = (AuthorityBridgeTableAsynchronouslyRefreshedCache) ctx.getBean("authorityBridgeTableCache");
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:18,代码来源:AuthorityBridgeTableAsynchronouslyRefreshedCacheTest.java

示例12: setUp

import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; //导入依赖的package包/类
@Override
protected void setUp() throws Exception
{
    applicationContext = ApplicationContextHelper.getApplicationContext();
    if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE)
    {
        fail("Detected a leaked transaction from a previous test.");
    }
    
    // Get the services by name from the application context
    messageService = (MessageService)applicationContext.getBean("messageService");
    nodeService = (NodeService)applicationContext.getBean("NodeService");
    authenticationService = (MutableAuthenticationService)applicationContext.getBean("AuthenticationService");
    contentService = (ContentService) applicationContext.getBean("ContentService");
    transactionService = (TransactionService) applicationContext.getBean("transactionComponent");
    authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent");
    dictionaryDAO = (DictionaryDAO) applicationContext.getBean("dictionaryDAO");
    
    // Re-set the current locale to be the default
    Locale.setDefault(Locale.ENGLISH);
    messageService.setLocale(Locale.getDefault());
    
    testTX = transactionService.getUserTransaction();
    testTX.begin();
    authenticationComponent.setSystemUserAsCurrentUser();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:MessageServiceImplTest.java

示例13: setUp

import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; //导入依赖的package包/类
@Override
protected void setUp() throws Exception
{
    if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE)
    {
        fail("Detected a leaked transaction from a previous test.");
    }
    
    // Get the services by name from the application context
    messageService = (MessageService)applicationContext.getBean("messageService");
    nodeService = (NodeService)applicationContext.getBean("NodeService");
    authenticationService = (MutableAuthenticationService)applicationContext.getBean("AuthenticationService");
    contentService = (ContentService) applicationContext.getBean("ContentService");
    transactionService = (TransactionService) applicationContext.getBean("transactionComponent");
    authenticationComponent = (AuthenticationComponent) applicationContext.getBean("authenticationComponent");
    dictionaryDAO = (DictionaryDAO) applicationContext.getBean("dictionaryDAO");
    
    // Re-set the current locale to be the default
    Locale.setDefault(Locale.ENGLISH);
    messageService.setLocale(Locale.getDefault());
    
    testTX = transactionService.getUserTransaction();
    testTX.begin();
    authenticationComponent.setSystemUserAsCurrentUser();
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:26,代码来源:MessageServiceImplTest.java

示例14: setCurrentUser

import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; //导入依赖的package包/类
public Authentication setCurrentUser(String userName, UserNameValidationMode validationMode)
{
    if (validationMode == UserNameValidationMode.NONE || isSystemUserName(userName))
    {
        return setCurrentUserImpl(userName);
    }
    else
    {
        CurrentUserCallback callback = validationMode == UserNameValidationMode.CHECK_AND_FIX ? new FixCurrentUserCallback(
                userName)
                : new CheckCurrentUserCallback(userName);
        Authentication authentication;
        // If the repository is read only, we have to settle for a read only transaction. Auto user creation
        // will not be possible.
        if (transactionService.isReadOnly())
        {
            authentication = transactionService.getRetryingTransactionHelper().doInTransaction(callback, true,
                    false);
        }
        // Otherwise,
        // - for check-only mode we want a readable txn or
        // - for check-and-fix mode we want a writeable transaction, so if the current transaction is read only we set the
        // requiresNew flag to true
        else
        {
            boolean readOnly = (validationMode ==  UserNameValidationMode.CHECK);
            boolean requiresNew = ((!readOnly) && (AlfrescoTransactionSupport.getTransactionReadState() == TxnReadState.TXN_READ_ONLY));
                    
            authentication = transactionService.getRetryingTransactionHelper().doInTransaction(callback, readOnly, requiresNew);
        }
        if ((authentication == null) || (callback.ae != null))
        {
            throw callback.ae;
        }
        return authentication;
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:38,代码来源:AbstractAuthenticationComponent.java

示例15: getPersonImpl

import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; //导入依赖的package包/类
private NodeRef getPersonImpl(
        final String userName,
        final boolean autoCreateHomeFolderAndMissingPersonIfAllowed,
        final boolean exceptionOrNull)
{
    if (userName == null || userName.length() == 0)
    {
        return null;
    }
    final NodeRef personNode = getPersonOrNullImpl(userName);
    if (personNode == null)
    {
        TxnReadState txnReadState = AlfrescoTransactionSupport.getTransactionReadState();
        if (autoCreateHomeFolderAndMissingPersonIfAllowed && createMissingPeople() &&
            txnReadState == TxnReadState.TXN_READ_WRITE)
        {
            // We create missing people AND are in a read-write txn
            return createMissingPerson(userName, true);
        }
        else
        {
            if (exceptionOrNull)
            {
                throw new NoSuchPersonException(userName);
            }
        }
    }
    else if (autoCreateHomeFolderAndMissingPersonIfAllowed)
    {
        makeHomeFolderIfRequired(personNode);
    }
    return personNode;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:34,代码来源:PersonServiceImpl.java


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