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


Java RetryingTransactionHelper.RetryingTransactionCallback方法代码示例

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


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

示例1: doInTransaction

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
/**
 * Does work in a transaction. This will be a writeable transaction unless the system is in read-only mode.
 * 
 * @param callback
 *            a callback that does the work
 * @return the result, or <code>null</code> if not applicable
 */
protected <T> T doInTransaction(RetryingTransactionHelper.RetryingTransactionCallback<T> callback)
{
    // Get the transaction service

    TransactionService txService = getTransactionService();
    
 // the repository is read-only, we settle for a read-only transaction
 if (txService.isReadOnly() || !txService.getAllowWrite())
 {
     return txService.getRetryingTransactionHelper().doInTransaction(callback, 
     		/* READ ONLY */ true, 
     		/* DOES NOT REQUIRE NEW TRAN */false);
 }
	
 // otherwise we want force a writable transaction 
    return txService.getRetryingTransactionHelper().doInTransaction(callback, 
            /* READ/WRITE */ false, 
            /* DOES NOT REQUIRE NEW TRAN */false);

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

示例2: testIsTenantName

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
/**
 * Format of a valid domain string is "@[email protected]" 
 */
@Test
public void testIsTenantName()
{
    RetryingTransactionHelper.RetryingTransactionCallback<Void> work = new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
    {
        @Override
        public Void execute() throws Throwable
        {

    boolean result = tenantService.isTenantName(STRING);
    assertFalse("The string was reported as domain, but it is not", result);
    
    result = tenantService.isTenantName(STRING_WITH_EXISTENT_DOMAIN);
    assertTrue("The string was not reported as domain.", result);
            return null;
        }
    };
    transactionService.getRetryingTransactionHelper().doInTransaction(work);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:23,代码来源:MultiTServiceImplTest.java

示例3: testGetPrimaryDomain

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
@Test
public void testGetPrimaryDomain()
{
    RetryingTransactionHelper.RetryingTransactionCallback<Void> work = new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
    {
        @Override
        public Void execute() throws Throwable
        {
            String result = tenantService.getPrimaryDomain(USER1);
            assertNull("The primary domain should be null for a non tenant user without a tenant in name.", result);

            result = tenantService.getPrimaryDomain(USER2_WITH_DOMAIN);
            assertNull("The primary domain should be null for a tenant user if multi tenancy is not enabled.", result);

            createTenant(DOMAIN);
            result = tenantService.getPrimaryDomain(USER2_WITH_DOMAIN);
            assertEquals("The primary domain of the USER2 should be " + DOMAIN + ", but was reported as " + result, DOMAIN, result);

            result = tenantService.getPrimaryDomain(USER1);
            assertTrue("The primary domain should be the default one (empty string) for a non tenant user without a tenant in name.", result.equals(TenantService.DEFAULT_DOMAIN));
            return null;
        }
    };
    transactionService.getRetryingTransactionHelper().doInTransaction(work);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:26,代码来源:MultiTServiceImplTest.java

示例4: testGetTenant

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
@Test
public void testGetTenant()
{
    RetryingTransactionHelper.RetryingTransactionCallback<Void> work = new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
    {
        @Override
        public Void execute() throws Throwable
        {
            Tenant tenant = tenantService.getTenant(DOMAIN);
            assertNull("The tenant should not exist.", tenant);

            createTenant(DOMAIN);
            tenant = tenantService.getTenant(DOMAIN);
            assertNotNull("The tenant should exist.", tenant);
            assertTrue("The tenant should have the correct domain.", DOMAIN.equals(tenant.getTenantDomain()));
            assertTrue("The tenant should be enabled.", tenant.isEnabled());
            return null;
        }
    };
    transactionService.getRetryingTransactionHelper().doInTransaction(work);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:22,代码来源:MultiTServiceImplTest.java

示例5: testGetUserDomain

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
@Test
public void testGetUserDomain()
{
    RetryingTransactionHelper.RetryingTransactionCallback<Void> work = new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
    {
        @Override
        public Void execute() throws Throwable
        {

    String result = tenantService.getUserDomain(USER1);
    assertEquals("The user domain should be the default one for a non tenant user without a tenant in name.", TenantService.DEFAULT_DOMAIN, result);
    
    result = tenantService.getUserDomain(USER2_WITH_DOMAIN);
    assertEquals("The user domain should be the default one for a user with email like name if multi tenancy is not enabled.", TenantService.DEFAULT_DOMAIN, result);
    
    createTenant(DOMAIN);
    result = tenantService.getUserDomain(USER2_WITH_DOMAIN);
    assertEquals("The user domain should be of the USER2 is " + DOMAIN + ", but was reported as " + result, DOMAIN, result);
    
    result = tenantService.getUserDomain(USER1);
    assertTrue("The user domain should be the default one (empty string) for a non tenant user without a tenant in name.", result.equals(TenantService.DEFAULT_DOMAIN));
            return null;
        }
    };
    transactionService.getRetryingTransactionHelper().doInTransaction(work);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:MultiTServiceImplTest.java

示例6: doInTransaction

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
/**
 * Does work in a transaction. This will be a writeable transaction unless the system is in read-only mode.
 * 
 * @param callback
 *            a callback that does the work
 * @return the result, or <code>null</code> if not applicable
 */
protected <T> T doInTransaction(RetryingTransactionHelper.RetryingTransactionCallback<T> callback)
{
    // Get the transaction service
    
    TransactionService txService = getTransactionService(); 
    
    // DEBUG
    
    if ( logger.isDebugEnabled())
        logger.debug("Using " + (txService.isReadOnly() ? "ReadOnly" : "Write") + " transaction");
    
    return txService.getRetryingTransactionHelper().doInTransaction(callback, txService.isReadOnly());
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:AlfrescoRpcAuthenticator.java

示例7: deleteTemporaryNodeRefsAndTempFiles

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
@After
public void deleteTemporaryNodeRefsAndTempFiles()
{
    // Tidy up the test nodes we created
    RetryingTransactionHelper.RetryingTransactionCallback<Void> deleteNodeCallback = new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
    {
        public Void execute() throws Throwable
        {
            // Delete them in reverse order.
            for (Iterator<NodeRef> iter = nodesToDeleteAfterTest.descendingIterator(); iter.hasNext(); )
            {
                NodeRef nextNodeToDelete = iter.next();

                if (nodeService.exists(nextNodeToDelete))
                {
                    if (log.isDebugEnabled())
                    {
                        log.debug("Deleting temporary node " + nextNodeToDelete);
                    }
                    nodeService.deleteNode(nextNodeToDelete);
                }
            }
            return null;
        }
    };
    transactionService.getRetryingTransactionHelper().doInTransaction(deleteNodeCallback);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:28,代码来源:DifferrentMimeTypeTest.java

示例8: testIsTenantUser

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
@Test
public void testIsTenantUser()
{
    RetryingTransactionHelper.RetryingTransactionCallback<Void> work = new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
    {
        @Override
        public Void execute() throws Throwable
        {


    // Create a user with a plain user name without a domain
    NodeRef userNodeRef = createUser(USER1, TenantService.DEFAULT_DOMAIN, PASS);
    assertNotNull("The user was not created.", userNodeRef);
    assertFalse("The user is not from a tenant, but was reported otherwise.", multiTServiceImpl.isTenantUser(USER1));
    
    // Create a user with a name as an email, but not from tenant
    userNodeRef =  createUser(USER2_WITH_DOMAIN, TenantService.DEFAULT_DOMAIN, PASS);
    assertNotNull("The user was not created.", userNodeRef);
    assertFalse("The user is not from a tenant, but was reported otherwise.", multiTServiceImpl.isTenantUser(USER2_WITH_DOMAIN));
    
    // Create a tenant and a user in it
    createTenant(DOMAIN);
    userNodeRef = createUser(USER3, DOMAIN, PASS);
    assertNotNull("The user was not created.", userNodeRef);
    assertTrue("The user is from a tenant, but was reported otherwise.", multiTServiceImpl.isTenantUser(USER3 + MultiTServiceImpl.SEPARATOR + DOMAIN));
            return null;
        }
    };
    transactionService.getRetryingTransactionHelper().doInTransaction(work);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:31,代码来源:MultiTServiceImplTest.java

示例9: before

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
  @Before
  public void before()
  {
  	ServiceRegistry serviceRegistry = (ServiceRegistry)ctx.getBean("ServiceRegistry");
      NamespaceService namespaceService = serviceRegistry.getNamespaceService();
this.transactionService = serviceRegistry.getTransactionService();
this.authenticationService = (MutableAuthenticationService)ctx.getBean("authenticationService");
this.nodeService = serviceRegistry.getNodeService();
this.searchService = serviceRegistry.getSearchService();
this.nodeDAO = (NodeDAO)ctx.getBean("nodeDAO");
this.nodesCache = (SimpleCache<Serializable, Serializable>) ctx.getBean("node.nodesSharedCache");
      this.worker = (DeletedNodeCleanupWorker)ctx.getBean("nodeCleanup.deletedNodeCleanup");
      this.worker.setMinPurgeAgeDays(0);

  	this.helper = transactionService.getRetryingTransactionHelper();
      authenticationService.authenticate("admin", "admin".toCharArray());
      
StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
NodeRef storeRoot = nodeService.getRootNode(storeRef);
List<NodeRef> nodeRefs = searchService.selectNodes(
        storeRoot, "/app:company_home", null, namespaceService, false);
final NodeRef companyHome = nodeRefs.get(0);

  	RetryingTransactionHelper.RetryingTransactionCallback<NodeRef> createNode = new RetryingTransactionHelper.RetryingTransactionCallback<NodeRef>()
  	{
	@Override
	public NodeRef execute() throws Throwable
	{
		return nodeService.createNode(companyHome, ContentModel.ASSOC_CONTAINS, QName.createQName("test", GUID.generate()), ContentModel.TYPE_CONTENT).getChildRef();
	}
  	};
  	this.nodeRef1 = helper.doInTransaction(createNode, false, true);
  	this.nodeRef2 = helper.doInTransaction(createNode, false, true);
  	this.nodeRef3 = helper.doInTransaction(createNode, false, true);
  	this.nodeRef4 = helper.doInTransaction(createNode, false, true);
  	this.nodeRef5 = helper.doInTransaction(createNode, false, true);
  }
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:39,代码来源:TransactionCleanupTest.java

示例10: doInSystemTransaction

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
/**
 * Executes a callback in a transaction as the system user
 * 
 * @param callback
 *            the callback
 * @return the return value from the callback
 */
protected <T> T doInSystemTransaction(final RetryingTransactionHelper.RetryingTransactionCallback<T> callback)
{
    return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<T>()
    {
        public T doWork() throws Exception
        {
            return transactionService.getRetryingTransactionHelper().doInTransaction(callback, transactionService.isReadOnly());
        }
    }, AuthenticationUtil.SYSTEM_USER_NAME);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:18,代码来源:BaseAuthenticationFilter.java

示例11: addUserUsageContent

import org.alfresco.repo.transaction.RetryingTransactionHelper; //导入方法依赖的package包/类
private void addUserUsageContent(final String userName, final int stringDataLength)
{
    RetryingTransactionHelper.RetryingTransactionCallback<Void> usageCallback = new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
    {
        @Override
        public Void execute() throws Throwable
        {
            try
            {
                AuthenticationUtil.pushAuthentication();
                AuthenticationUtil.setFullyAuthenticatedUser(userName);
                String textData = "This is default text added. Add more: ";
                for (int i = 0; i < stringDataLength; i++)
                {
                    textData += "abc";
                }
                NodeRef homeFolder = getHomeSpaceFolderNode(userName);
                NodeRef folder = nodeService.createNode(
                        homeFolder,
                        ContentModel.ASSOC_CONTAINS,
                        QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "testFolder"),
                        ContentModel.TYPE_FOLDER).getChildRef();
                addTextContent(folder, "text1.txt", textData);
            }
            finally
            {
                AuthenticationUtil.popAuthentication();
            }
            return null;
        }
    };

    RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
    txnHelper.doInTransaction(usageCallback);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:36,代码来源:PersonServiceTest.java


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