本文整理汇总了Java中org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState类的典型用法代码示例。如果您正苦于以下问题:Java TxnReadState类的具体用法?Java TxnReadState怎么用?Java TxnReadState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TxnReadState类属于org.alfresco.repo.transaction.AlfrescoTransactionSupport包,在下文中一共展示了TxnReadState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: makeHomeFolderIfRequired
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; //导入依赖的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
示例17: invoke
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; //导入依赖的package包/类
public Object invoke(final MethodInvocation methodInvocation) throws Throwable
{
// Just check for any transaction
if (AlfrescoTransactionSupport.getTransactionReadState() == TxnReadState.TXN_NONE)
{
String methodName = methodInvocation.getMethod().getName();
String className = methodInvocation.getMethod().getDeclaringClass().getName();
throw new AlfrescoRuntimeException(
"A transaction has not be started for method '" + methodName + "' on " + className);
}
return methodInvocation.proceed();
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:13,代码来源:CheckTransactionAdvice.java
示例18: updateUsage
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; //导入依赖的package包/类
private boolean updateUsage(UsageType usageType, boolean reset)
{
checkTxnState(TxnReadState.TXN_READ_WRITE);
boolean updateUsers = false;
boolean updateDocuments = false;
switch (usageType)
{
case USAGE_DOCUMENTS:
updateDocuments = true;
break;
case USAGE_USERS:
updateUsers = true;
break;
case USAGE_ALL:
updateUsers = true;
updateDocuments = true;
}
if (updateUsers && !updateUsers(reset))
{
return false;
}
if (updateDocuments && !updateDocuments(reset))
{
return false;
}
// Done
if (logger.isDebugEnabled())
{
RepoUsage usage = getUsageImpl();
logger.debug("Updated repo usage: " + usage);
}
// The update succeeded and the locks held
return true;
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:38,代码来源:RepoUsageComponentImpl.java
示例19: isPendingDelete
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; //导入依赖的package包/类
/**
* @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,代码行数:16,代码来源:DbNodeServiceImpl.java
示例20: execute
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public void execute(Action action, NodeRef actionedUponNodeRef)
{
if (AlfrescoTransactionSupport.getTransactionReadState() == TxnReadState.TXN_NONE)
{
throw new IllegalStateException("Actions invariably access the repository. Doing so without a transaction is not recommended.");
}
// Check the mandatory properties
checkMandatoryProperties(action, getActionDefinition());
// Only execute the action if this action is read only or the actioned upon node reference doesn't
// have a lock applied for this user.
boolean nodeIsLockedForThisUser = false;
// null nodeRefs can't be locked and some actions can be run against 'null' nodes.
// non-existent nodes can't be locked.
if (!ignoreLock &&
actionedUponNodeRef != null &&
mlAwareNodeService.exists(actionedUponNodeRef))
{
nodeIsLockedForThisUser = lockService.isLockedAndReadOnly(actionedUponNodeRef);
}
if ( !nodeIsLockedForThisUser)
{
// Execute the implementation
executeImpl(action, actionedUponNodeRef);
}
else
{
if (logger.isWarnEnabled() == true)
{
logger.warn("Action (" + action.getActionDefinitionName() +
") ignored because actioned upon node (" + actionedUponNodeRef +
") is locked.");
}
}
}
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:42,代码来源:ActionExecuterAbstractBase.java
注:本文中的org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论