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


Java RetryingTransactionHelper.setForceWritable方法代码示例

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


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

示例1: onBootstrap

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
@Override
  protected void onBootstrap(ApplicationEvent event)
  {
  	RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
  	txnHelper.setForceWritable(true);
  	txnHelper.doInTransaction(new RetryingTransactionCallback<Object>() {

	@Override
	public Object execute() throws Throwable {
		// run as System on bootstrap
        return AuthenticationUtil.runAs(new RunAsWork<Object>()
        {
            public Object doWork()
            {
                init();
                return null;
            }
        }, AuthenticationUtil.getSystemUserName());
	}
  		
}, false, true);
      
      tenantAdminService.register(this);
  }
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:WorkflowDeployer.java

示例2: doWork

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
/**
 * @param progress          the thread-safe progress
 */
private synchronized void doWork(NodeStringLengthWorkResult progress) throws Exception
{
    // Build batch processor
    BatchProcessWorkProvider<NodePropertyEntity> workProvider = new NodeStringLengthWorkProvider(progress);
    BatchProcessWorker<NodePropertyEntity> worker = new NodeStringLengthBatch(progress);
    RetryingTransactionHelper retryingTransactionHelper = transactionService.getRetryingTransactionHelper();
    retryingTransactionHelper.setForceWritable(true);
    
    BatchProcessor<NodePropertyEntity> batchProcessor = new BatchProcessor<NodePropertyEntity>(
            "NodeStringLengthWorker",
            retryingTransactionHelper,
            workProvider,
            threadCount,
            batchSize,
            ctx,
            logger,
            1000);
    batchProcessor.process(worker, true);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:23,代码来源:NodeStringLengthWorker.java

示例3: onBootstrap

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
@Override
protected void onBootstrap(ApplicationEvent event)
{
    RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
    txnHelper.setForceWritable(true);      // Force write in case server is read-only
    
    txnHelper.doInTransaction(new RetryingTransactionCallback<Void>()
    {
        public Void execute() throws Throwable
        {
            try
            {
                keyStoreChecker.validateKeyStores();
            }
            catch(Throwable e)
            {
                // Just throw as a runtime exception
                throw new AlfrescoRuntimeException("Keystores are invalid", e);
            }

            return null;
        }
    });
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:EncryptionChecker.java

示例4: afterCommit

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
@Override
public void afterCommit()
{
    // get transaction helper and force it to be writable in case system is in read only mode
    RetryingTransactionHelper txHelper = transactionService.getRetryingTransactionHelper();
    txHelper.setForceWritable(true);
    txHelper.doInTransaction(new RetryingTransactionCallback<Void>()
    {
        @Override
        public Void execute() throws Throwable
        {
            AuthenticationUtil.pushAuthentication();
            AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
            try
            {
                if (logger.isDebugEnabled())
                {
                    logger.debug("Re-hashing password for user: " + username);
                }
                
                // update the users password to force a new hash to be generated
                authenticationDao.updateUser(username, password);
                
                if (logger.isDebugEnabled())
                {
                    logger.debug("Password for user '" + username + "' has been re-hashed following login");
                }
                
                return null;
            }
            finally
            {
                AuthenticationUtil.popAuthentication();
            }
        }
    }, false, true);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:38,代码来源:HashPasswordTransactionListener.java

示例5: doWork

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
/**
 * @param progress          the thread-safe progress
 */
private synchronized void doWork(UpgradePasswordHashWorkResult progress) throws Exception
{
    // Build batch processor
    BatchProcessWorkProvider<Long> workProvider = new UpgradePasswordHashWorkProvider(progress);
    BatchProcessWorker<Long> worker = new UpgradePasswordHashBatch(progress);
    RetryingTransactionHelper retryingTransactionHelper = transactionService.getRetryingTransactionHelper();
    retryingTransactionHelper.setForceWritable(true);

    //Create the QNames if they don't exist
    retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
    {
        @Override
        public Void execute() throws Throwable
        {
            qnameDAO.getOrCreateQName(ContentModel.PROP_PASSWORD_HASH);
            qnameDAO.getOrCreateQName(ContentModel.PROP_HASH_INDICATOR);
            return null;
        }
    }, false, true);

    BatchProcessor<Long> batchProcessor = new BatchProcessor<Long>(
            "UpgradePasswordHashWorker",
            retryingTransactionHelper,
            workProvider,
            threadCount,
            batchSize,
            ctx,
            logger,
            1000);
    batchProcessor.process(worker, true);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:35,代码来源:UpgradePasswordHashWorker.java

示例6: makeHomeFolderIfRequired

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
private void makeHomeFolderIfRequired(NodeRef person)
{
    if ((person != null) && (homeFolderCreationDisabled == false))
    {
        NodeRef homeFolder = DefaultTypeConverter.INSTANCE.convert(NodeRef.class, nodeService.getProperty(person, ContentModel.PROP_HOMEFOLDER));
        if (homeFolder == null)
        {
            final ChildAssociationRef ref = nodeService.getPrimaryParent(person);
            RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
            txnHelper.setForceWritable(true);
            boolean requiresNew = false;
            if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_READ_WRITE)
            {
                // We can be in a read-only transaction, so force a new transaction
                // Note that the transaction will *always* be in read-only mode if the server read-only veto is there 
                requiresNew = true;
            }
            txnHelper.doInTransaction(new RetryingTransactionCallback<Object>()
            {
                public Object execute() throws Throwable
                {
                    makeHomeFolderAsSystem(ref);
                    return null;
                }
            }, false, requiresNew);
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:29,代码来源:PersonServiceImpl.java

示例7: loadLicense

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public String loadLicense()
{
    // Ensure that we force a writable txn for this operation
    final RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
    txnHelper.setForceWritable(true);
    
    final RetryingTransactionCallback<String> loadCallback = new RetryingTransactionCallback<String>()
    {
        @Override
        public String execute() throws Throwable
        {
            return licenseService.loadLicense();      
        }
    };
    // ... and we have to be 'system' for this, too
    String result = AuthenticationUtil.runAs(new RunAsWork<String>()
    {
        public String doWork() throws Exception
        {
            return txnHelper.doInTransaction(loadCallback, false, true);
        }
    }, AuthenticationUtil.getSystemUserName());

    if (logger.isDebugEnabled())
    {
        logger.debug("Load license call returning: " + result);
    }
    return result;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:34,代码来源:DescriptorServiceImpl.java

示例8: onLicenseFail

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 * <p/>
 * Restrictions are not changed; previous restrictions remain in place.
 */
@Override
public void onLicenseFail()
{
    synchronized (licenseLock)
    {
        // Current restrictions remain in place
        // Make sure that the repo descriptor is updated the first time
        if (isCurrentRepoDescriptorIsNull())
        {
            final RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
            RetryingTransactionCallback<Void> nopLoadLicense = new RetryingTransactionCallback<Void>()
            {
                @Override
                public Void execute()
                {
                    Descriptor newRepoDescriptor = currentRepoDescriptorDAO.updateDescriptor(serverDescriptor, LicenseMode.UNKNOWN);
                    setCurrentRepoDescriptor(newRepoDescriptor);
                    return null;
                }
            };
            txnHelper.setForceWritable(true);
            txnHelper.doInTransaction(nopLoadLicense, false, false);

        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:32,代码来源:DescriptorServiceImpl.java

示例9: createThumbnail

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
/**
 * @see org.alfresco.service.cmr.thumbnail.ThumbnailService#createThumbnail(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.service.namespace.QName, java.lang.String, org.alfresco.service.cmr.repository.TransformationOptions, java.lang.String, org.alfresco.service.cmr.thumbnail.ThumbnailParentAssociationDetails)
 */
public NodeRef createThumbnail(final NodeRef node, final QName contentProperty, final String mimetype,
        final TransformationOptions transformationOptions, final String thumbnailName, final ThumbnailParentAssociationDetails assocDetails)
{
    // Parameter check
    ParameterCheck.mandatory("node", node);
    ParameterCheck.mandatory("contentProperty", contentProperty);
    ParameterCheck.mandatoryString("mimetype", mimetype);
    ParameterCheck.mandatory("transformationOptions", transformationOptions);

    if (logger.isDebugEnabled() == true)
    {
        logger.debug("Creating thumbnail (node=" + node.toString() + "; contentProperty="
                    + contentProperty.toString() + "; mimetype=" + mimetype);
    }
    
    if (thumbnailName != null)
    {
        NodeRef existingThumbnail = getThumbnailByName(node, contentProperty, thumbnailName);
        if (existingThumbnail != null)
        {
            if (logger.isDebugEnabled() == true)
            {
                logger.debug("Creating thumbnail: There is already a thumbnail with the name '" + thumbnailName + "' (node=" + node.toString() + "; contentProperty=" + contentProperty.toString() + "; mimetype=" + mimetype);
            }
            
            // Return the thumbnail that has already been created
            return existingThumbnail;
        }
    }
    
    RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
    txnHelper.setForceWritable(true);
    boolean requiresNew = false;
    if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_READ_WRITE)
    {
        //We can be in a read-only transaction, so force a new transaction 
        requiresNew = true;
    }
    return txnHelper.doInTransaction(new RetryingTransactionCallback<NodeRef>()
    {

        @Override
        public NodeRef execute() throws Throwable
        {
            return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<NodeRef>()
            {
                public NodeRef doWork() throws Exception
                {
                   return createThumbnailNode( node, 
                                               contentProperty,
                                                mimetype, 
                                                transformationOptions, 
                                                thumbnailName, 
                                                assocDetails);
                }
            }, AuthenticationUtil.getSystemUserName());
        }

    }, false, requiresNew);
    
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:65,代码来源:ThumbnailServiceImpl.java

示例10: bootstrap

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
private void bootstrap()
{
    logger.debug("onBootstrap");

    // We force write mode
    RetryingTransactionHelper helper = transactionService.getRetryingTransactionHelper();
    helper.setForceWritable(true);
    
    // create the initial installed descriptor
    RetryingTransactionCallback<Descriptor> getDescriptorCallback = new RetryingTransactionCallback<Descriptor>()
    {
        public Descriptor execute() 
        {
            return installedRepoDescriptorDAO.getDescriptor();
        }
    };
    Descriptor installed =  helper.doInTransaction(getDescriptorCallback, false, false);
    if (installed != null)
    {
        installedRepoDescriptor = installed;
    }
    else
    {
        installedRepoDescriptor = new UnknownDescriptor();
    }
    
    /*
     *  Initialize license service if on classpath.  
     *  If no class exists a dummy license service is used.
     *  Make the LicenseService available in the context.
     */
    licenseService = (LicenseService) constructSpecialService("org.alfresco.enterprise.license.LicenseComponent");
    if (licenseService == null)
    {
        // No license server code - install a dummy license service instead
        licenseService = new NOOPLicenseService();
    } 
    ApplicationContext applicationContext = getApplicationContext();
    if (applicationContext instanceof ConfigurableApplicationContext)
    {
        ((ConfigurableApplicationContext) applicationContext).getBeanFactory().registerSingleton(
                "licenseService", licenseService);
    }

    // Register HeartBeat with LicenseService
    licenseService.registerOnLicenseChange((LicenseChangeHandler) hbDataCollectorService);


    // Now listen for future license changes
    licenseService.registerOnLicenseChange(this);
    
    try
    {   
        // Verify license has side effect of loading any new licenses
        licenseService.verifyLicense();
    }
    catch (LicenseException e)
    {
        // Swallow Licence Exception Here
        // Don't log error: It'll be reported by other means
    };
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:63,代码来源:DescriptorServiceImpl.java

示例11: onLicenseChange

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
@Override
public void onLicenseChange(final LicenseDescriptor licenseDescriptor)
{
    synchronized (licenseLock)
    {
        logger.debug("Received changed license descriptor: " + licenseDescriptor);
                
        RetryingTransactionCallback<RepoUsage> updateLicenseCallback = new RetryingTransactionCallback<RepoUsage>()
        {
            public RepoUsage execute()
            {
                // Configure the license restrictions
                RepoUsage.LicenseMode newMode = licenseDescriptor.getLicenseMode();
                Long expiryTime = licenseDescriptor.getValidUntil() == null ? null : licenseDescriptor.getValidUntil().getTime();
                RepoUsage restrictions = new RepoUsage(
                        System.currentTimeMillis(), 
                        licenseDescriptor.getMaxUsers(), 
                        licenseDescriptor.getMaxDocs(), 
                        newMode,
                        expiryTime,
                        false);
                repoUsageComponent.setRestrictions(restrictions);
                
                // Reset usage upon loading the unlimited license
                if (restrictions.getUsers() == null)
                {
                    repoUsageComponent.resetUsage(UsageType.USAGE_USERS);
                }
                if (restrictions.getDocuments() == null)
                {
                    repoUsageComponent.resetUsage(UsageType.USAGE_DOCUMENTS);
                }

                // persist the server descriptor values in the current repository descriptor
                if (currentRepoDescriptorNullOrModeHasChanged(newMode))
                {
                    if (logger.isDebugEnabled())
                    {
                        logger.debug("Changing license mode in current repo descriptor to: " + newMode);
                    }
                    Descriptor newRepoDescriptor = currentRepoDescriptorDAO.updateDescriptor(
                            serverDescriptor,
                            newMode);
                    setCurrentRepoDescriptor(newRepoDescriptor);
                }
                if (logger.isDebugEnabled())
                {
                    logger.debug("License restrictions updated: " + restrictions);
                }
                return null;
            }
        };
        RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
        txnHelper.setForceWritable(true);
        txnHelper.doInTransaction(updateLicenseCallback);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:58,代码来源:DescriptorServiceImpl.java


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