Java Code Examples for org.alfresco.repo.transaction.RetryingTransactionHelper#setReadOnly()

The following examples show how to use org.alfresco.repo.transaction.RetryingTransactionHelper#setReadOnly() . 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: AbstractMimeMessage.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void buildMessage(FileInfo fileInfo, ServiceRegistry serviceRegistry) throws MessagingException
{
    checkParameter(serviceRegistry, "ServiceRegistry");
    this.content = null;
    this.serviceRegistry = serviceRegistry;
    this.imapService = serviceRegistry.getImapService();
    this.messageFileInfo = fileInfo;
    this.isMessageInSitesLibrary = imapService.getNodeSiteContainer(messageFileInfo.getNodeRef()) != null ? true : false;
    RetryingTransactionHelper txHelper = serviceRegistry.getTransactionService().getRetryingTransactionHelper();
    txHelper.setMaxRetries(MAX_RETRIES);
    txHelper.setReadOnly(false);
    txHelper.doInTransaction(new RetryingTransactionCallback<Object>() {
        public Object execute() throws Throwable
        {
            buildMessageInternal();
            return null;
        }
    }, false);
    
}
 
Example 2
Source File: AbstractImapFolder.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public T runFeedback(boolean readOnly) throws FolderException
{
    try
    {
        RetryingTransactionHelper txHelper = serviceRegistry.getTransactionService().getRetryingTransactionHelper();
        txHelper.setMaxRetries(MAX_RETRIES);
        txHelper.setReadOnly(readOnly);
        T result = txHelper.doInTransaction(
                new RetryingTransactionCallback<T>()
                {
                    public T execute() throws Throwable
                    {
                        return command();
                    }
                }, readOnly);
        return result;
    }
    catch (Exception e)
    {
        Throwable cause = e.getCause();
        
        if (logger.isDebugEnabled())
        {
            logger.debug("Exception is thrown : " + e + "\nCause : " + cause);
        }
        
        String message;
        if (cause != null)
        {
            message = cause.getMessage();
        }
        else
        {
            message = e.getMessage();
        }
        throw new FolderException(message);
    }
}
 
Example 3
Source File: AbstractImapFolder.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public T run(boolean readOnly)
{
    RetryingTransactionHelper txHelper = serviceRegistry.getTransactionService().getRetryingTransactionHelper();
    txHelper.setMaxRetries(MAX_RETRIES);
    txHelper.setReadOnly(readOnly);
    T result = txHelper.doInTransaction(
            new RetryingTransactionCallback<T>()
            {
                public T execute() throws Throwable
                {
                    return command();
                }
            }, readOnly);
    return result;
}