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


Java TxnReadState.TXN_READ_WRITE属性代码示例

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


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

示例1: checkTxnState

/**
 * 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,代码行数:21,代码来源:RepoUsageComponentImpl.java

示例2: invalidateParentAssocsCached

/**
 * 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,代码行数:18,代码来源:AbstractNodeDAOImpl.java

示例3: getPersonImpl

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,代码行数:33,代码来源:PersonServiceImpl.java

示例4: makeHomeFolderIfRequired

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,代码行数:28,代码来源:PersonServiceImpl.java

示例5: isPendingDelete

/**
 * @return      Returns <tt>true</tt> if the node is being deleted
 * 
 * @see #KEY_PENDING_DELETE_NODES
 */
private boolean isPendingDelete(NodeRef nodeRef)
{
    // Avoid creating a Set if the transaction is read-only
    if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_READ_WRITE)
    {
        return false;
    }
    Set<NodeRef> nodesPendingDelete = TransactionalResourceHelper.getSet(KEY_PENDING_DELETE_NODES);
    return nodesPendingDelete.contains(nodeRef);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:15,代码来源:DbNodeServiceImpl.java

示例6: getCurrentTransaction

/**
 * @return          Returns a new transaction or an existing one if already active
 */
private TransactionEntity getCurrentTransaction()
{
    TransactionEntity txn = AlfrescoTransactionSupport.getResource(KEY_TRANSACTION);
    if (txn != null)
    {
        // We have been busy here before
        return txn;
    }
    // Check that this is a writable txn
    if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_READ_WRITE)
    {
        throw new ReadOnlyServerException();
    }
    // Have to create a new transaction entry
    Long serverId = getServerId();
    Long now = System.currentTimeMillis();
    String changeTxnId = AlfrescoTransactionSupport.getTransactionId();
    Long txnId = insertTransaction(serverId, changeTxnId, now);
    // Store it for later
    if (isDebugEnabled)
    {
        logger.debug("Create txn: " + txnId);
    }
    txn = new TransactionEntity();
    txn.setId(txnId);
    txn.setChangeTxnId(changeTxnId);
    txn.setCommitTimeMs(now);
    ServerEntity server = new ServerEntity();
    server.setId(serverId);
    txn.setServer(server);
    
    AlfrescoTransactionSupport.bindResource(KEY_TRANSACTION, txn);
    // Listen for the end of the transaction
    AlfrescoTransactionSupport.bindDaoService(updateTransactionListener);
    // Done
    return txn;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:40,代码来源:AbstractNodeDAOImpl.java

示例7: getTransactionRequired

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

示例8: createThumbnail

/**
 * @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,代码行数:64,代码来源:ThumbnailServiceImpl.java

示例9: getChildAssoc

@Override
public Pair<Long, ChildAssociationRef> getChildAssoc(
        Long parentNodeId,
        Long childNodeId,
        QName assocTypeQName,
        QName assocQName)
{
    List<ChildAssocEntity> assocs = selectChildAssoc(parentNodeId, childNodeId, assocTypeQName, assocQName);
    if (assocs.size() == 0)
    {
        return null;
    }
    else if (assocs.size() == 1)
    {
        return assocs.get(0).getPair(qnameDAO);
    }
    // Keep the primary association or, if there isn't one, the association with the smallest ID
    Map<Long, ChildAssocEntity> assocsToDeleteById = new HashMap<Long, ChildAssocEntity>(assocs.size() * 2);
    Long minId = null;
    Long primaryId = null;
    for (ChildAssocEntity assoc : assocs)
    {
        // First store it
        Long assocId = assoc.getId();
        assocsToDeleteById.put(assocId, assoc);
        if (minId == null || minId.compareTo(assocId) > 0)
        {
            minId = assocId;
        }
        if (assoc.isPrimary())
        {
            primaryId = assocId;
        }
    }
    // Remove either the primary or min assoc
    Long assocToKeepId = primaryId == null ? minId : primaryId;
    ChildAssocEntity assocToKeep = assocsToDeleteById.remove(assocToKeepId);
    // If the current transaction allows, remove the other associations
    if (AlfrescoTransactionSupport.getTransactionReadState() == TxnReadState.TXN_READ_WRITE)
    {
        for (Long assocIdToDelete : assocsToDeleteById.keySet())
        {
            deleteChildAssoc(assocIdToDelete);
        }
    }
    // Done
    return assocToKeep.getPair(qnameDAO);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:48,代码来源:AbstractNodeDAOImpl.java


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