本文整理汇总了Java中org.alfresco.repo.transaction.AlfrescoTransactionSupport.getTransactionReadState方法的典型用法代码示例。如果您正苦于以下问题:Java AlfrescoTransactionSupport.getTransactionReadState方法的具体用法?Java AlfrescoTransactionSupport.getTransactionReadState怎么用?Java AlfrescoTransactionSupport.getTransactionReadState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.repo.transaction.AlfrescoTransactionSupport
的用法示例。
在下文中一共展示了AlfrescoTransactionSupport.getTransactionReadState方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkTxnState
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的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;
}
}
示例2: getTransactionData
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的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;
}
示例3: setUp
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的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();
}
示例4: invalidateParentAssocsCached
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的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));
}
}
}
示例5: setUp
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的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
示例6: getPersonImpl
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的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;
}
示例7: tearDown
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的package包/类
@Override
protected void tearDown() throws Exception
{
if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE)
{
fail("Test is not transaction-safe. Fix up transaction handling and re-test.");
}
}
示例8: isPendingDelete
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的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);
}
示例9: execute
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的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.");
}
}
}
示例10: getWithWriteLock
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的package包/类
public Long getWithWriteLock() throws Throwable
{
if (serverIdStorage.get() != null)
{
return serverIdStorage.get();
}
// Avoid write operations in read-only transactions
// ALF-5456: IP address change can cause read-write errors on startup
if (AlfrescoTransactionSupport.getTransactionReadState() == TxnReadState.TXN_READ_ONLY)
{
return null;
}
// Server IP address
String ipAddress = null;
try
{
ipAddress = InetAddress.getLocalHost().getHostAddress();
}
catch (UnknownHostException e)
{
throw new AlfrescoRuntimeException("Failed to get server IP address", e);
}
// Get the server instance
ServerEntity serverEntity = selectServer(ipAddress);
if (serverEntity != null)
{
serverIdStorage.put(serverEntity.getId());
return serverEntity.getId();
}
// Doesn't exist, so create it
Long serverId = insertServer(ipAddress);
serverIdStorage.put(serverId);
if (isDebugEnabled)
{
logger.debug("Created server entity: " + serverEntity);
}
return serverId;
}
示例11: onSetUp
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的package包/类
/**
* Called during the transaction setup
*/
protected void onSetUp() throws Exception
{
// Catch transactions left dangling by inadequate transaction handling during test failures
if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE)
{
fail("Dangling transaction at start of test.");
}
super.onSetUp();
// Get the required services
this.transferService = (TransferService)this.applicationContext.getBean("TransferService");
this.contentService = (ContentService)this.applicationContext.getBean("ContentService");
this.transferServiceImpl = (TransferServiceImpl2)this.applicationContext.getBean("transferService2");
this.searchService = (SearchService)this.applicationContext.getBean("SearchService");
this.transactionService = (TransactionService)this.applicationContext.getBean("TransactionService");
this.nodeService = (NodeService) this.applicationContext.getBean("nodeService");
this.contentService = (ContentService) this.applicationContext.getBean("contentService");
this.authenticationService = (MutableAuthenticationService) this.applicationContext.getBean("authenticationService");
this.actionService = (ActionService)this.applicationContext.getBean("actionService");
this.permissionService = (PermissionService)this.applicationContext.getBean("permissionService");
this.receiver = (TransferReceiver)this.applicationContext.getBean("transferReceiver");
this.transferManifestNodeFactory = (TransferManifestNodeFactory)this.applicationContext.getBean("transferManifestNodeFactory");
this.authenticationComponent = (AuthenticationComponent) this.applicationContext.getBean("authenticationComponent");
this.lockService = (LockService) this.applicationContext.getBean("lockService");
this.personService = (PersonService)this.applicationContext.getBean("PersonService");
this.descriptorService = (DescriptorService)this.applicationContext.getBean("DescriptorService");
this.copyService = (CopyService)this.applicationContext.getBean("CopyService");
this.serverDescriptor = descriptorService.getServerDescriptor();
this.repositoryHelper = (Repository) this.applicationContext.getBean("repositoryHelper");
REPO_ID_B = descriptorService.getCurrentRepositoryDescriptor().getId();
authenticationComponent.setSystemUserAsCurrentUser();
setTransactionDefinition(new DefaultTransactionDefinition(TransactionDefinition.PROPAGATION_REQUIRES_NEW));
assertNotNull("receiver is null", this.receiver);
}
示例12: setUp
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public void setUp() throws Exception
{
ctx = ApplicationContextHelper.getApplicationContext(
new String[] { "classpath:cache-test/cache-test-context.xml", ApplicationContextHelper.CONFIG_LOCATIONS[0] });
if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE)
{
fail("A transaction is still running");
}
serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
objectCache = (SimpleCache<String, Object>) ctx.getBean("objectCache");
backingCache = (SimpleCache<String, ValueHolder<Object>>) ctx.getBean("backingCache");
backingCacheNoStats = (SimpleCache<String, ValueHolder<Object>>) ctx.getBean("backingCacheNoStats");
transactionalCache = (TransactionalCache<String, Object>) ctx.getBean("transactionalCache");
transactionalCacheNoStats = (TransactionalCache<String, Object>) ctx.getBean("transactionalCacheNoStats");
cacheStats = (CacheStatistics) ctx.getBean("cacheStatistics");
// Make sure that the backing cache is empty
backingCache.clear();
backingCacheNoStats.clear();
// Make the cache mutable (default)
transactionalCache.setMutable(true);
transactionalCache.setAllowEqualsChecks(false);
transactionalCacheNoStats.setMutable(true);
transactionalCacheNoStats.setAllowEqualsChecks(false);
}
示例13: setUp
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的package包/类
public void setUp() throws Exception
{
if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE)
{
throw new AlfrescoRuntimeException(
"A previous tests did not clean up transaction: " +
AlfrescoTransactionSupport.getTransactionId());
}
serviceRegistry = (ServiceRegistry)ctx.getBean("ServiceRegistry");
SimpleCache<String, RepositoryAuthenticationDao.CacheEntry> authenticationCache = (SimpleCache<String, RepositoryAuthenticationDao.CacheEntry>) ctx.getBean("authenticationCache");
SimpleCache<String, NodeRef> immutableSingletonCache = (SimpleCache<String, NodeRef>) ctx.getBean("immutableSingletonCache");
TenantService tenantService = (TenantService) ctx.getBean("tenantService");
compositePasswordEncoder = (CompositePasswordEncoder) ctx.getBean("compositePasswordEncoder");
PolicyComponent policyComponent = (PolicyComponent) ctx.getBean("policyComponent");
repositoryAuthenticationDao = new RepositoryAuthenticationDao();
repositoryAuthenticationDao.setTransactionService(serviceRegistry.getTransactionService());
repositoryAuthenticationDao.setAuthorityService(serviceRegistry.getAuthorityService());
repositoryAuthenticationDao.setTenantService(tenantService);
repositoryAuthenticationDao.setNodeService(serviceRegistry.getNodeService());
repositoryAuthenticationDao.setNamespaceService(serviceRegistry.getNamespaceService());
repositoryAuthenticationDao.setCompositePasswordEncoder(compositePasswordEncoder);
repositoryAuthenticationDao.setPolicyComponent(policyComponent);
repositoryAuthenticationDao.setAuthenticationCache(authenticationCache);
repositoryAuthenticationDao.setSingletonCache(immutableSingletonCache);
upgradePasswordHashWorker = (UpgradePasswordHashWorker)ctx.getBean("upgradePasswordHashWorker");
nodeService = serviceRegistry.getNodeService();
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
}
示例14: setUp
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public void setUp() throws Exception
{
AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE)
{
throw new AlfrescoRuntimeException(
"A previous tests did not clean up transaction: " +
AlfrescoTransactionSupport.getTransactionId());
}
transactionService = (TransactionService) ctx.getBean("transactionService");
personService = (PersonService) ctx.getBean("personService");
userNameMatcher = (UserNameMatcherImpl) ctx.getBean("userNameMatcher");
nodeService = (NodeService) ctx.getBean("nodeService");
permissionService = (PermissionService) ctx.getBean("permissionService");
authorityService = (AuthorityService) ctx.getBean("authorityService");
authenticationDAO = (MutableAuthenticationDao) ctx.getBean("authenticationDao");
policyBehaviourFilter = (BehaviourFilter) ctx.getBean("policyBehaviourFilter");
testTX = transactionService.getUserTransaction();
testTX.begin();
//Set a max number of users.
RepoUsageComponentImpl repoUsageComponent = (RepoUsageComponentImpl) ctx.getBean("repoUsageComponent");
RepoUsage r = repoUsageComponent.getRestrictions();
repoUsageComponent.setRestrictions(
new RepoUsage(r.getLastUpdate(),
10000l,
r.getDocuments(),
r.getLicenseMode(),
r.getLicenseExpiryDate(),
r.isReadOnly()));
StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
rootNodeRef = nodeService.getRootNode(storeRef);
for (NodeRef nodeRef : personService.getAllPeople())
{
String uid = DefaultTypeConverter.INSTANCE.convert(String.class, nodeService.getProperty(nodeRef, ContentModel.PROP_USERNAME));
if (!uid.equals(AuthenticationUtil.getAdminUserName()) && !uid.equals(AuthenticationUtil.getGuestUserName()))
{
personService.deletePerson(nodeRef);
}
}
personService.setCreateMissingPeople(true);
testTX.commit();
testTX = transactionService.getUserTransaction();
testTX.begin();
}
示例15: createThumbnail
import org.alfresco.repo.transaction.AlfrescoTransactionSupport; //导入方法依赖的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);
}