• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java RunAsWork类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork的典型用法代码示例。如果您正苦于以下问题:Java RunAsWork类的具体用法?Java RunAsWork怎么用?Java RunAsWork使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RunAsWork类属于org.alfresco.repo.security.authentication.AuthenticationUtil包,在下文中一共展示了RunAsWork类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onBootstrap

import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; //导入依赖的package包/类
@Override
protected void onBootstrap(ApplicationEvent event)
{
    PropertyCheck.mandatory(this, "moduleService", moduleService);
    final RetryingTransactionCallback<Object> startModulesCallback = new RetryingTransactionCallback<Object>()
    {
        public Object execute() throws Throwable
        {
            moduleService.startModules();
            return null;
        }
    };
    
    AuthenticationUtil.runAs(new RunAsWork<Object>()
    {
        @Override
        public Object doWork() throws Exception 
        {
            transactionService.getRetryingTransactionHelper().doInTransaction(startModulesCallback, transactionService.isReadOnly());
            return null;
        }
    	
    }, AuthenticationUtil.getSystemUserName());       
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:ModuleStarter.java


示例2: calculateDisplayPath

import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; //导入依赖的package包/类
private StringBuilder calculateDisplayPath(final NodeRef nodeRef)
{
    return AuthenticationUtil.runAs(new RunAsWork<StringBuilder>()
    {
        @Override
        public StringBuilder doWork() throws Exception
        {
            // Get the full path to the file/folder node
            Path nodePath = m_nodeService.getPath(nodeRef);
            String fName = (String) m_nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);

            // Build the share relative path to the node
            StringBuilder result = new StringBuilder();
            result.append(nodePath.toDisplayPath(m_nodeService, m_permissionService));
            if ((0 == result.length()) || ('/' != (result.charAt(result.length() - 1)) && ('\\' != result.charAt(result.length() - 1))))
            {
                result.append("\\");
            }
            return result.append(fName);
        }
    }, AuthenticationUtil.SYSTEM_USER_NAME);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:23,代码来源:NodeMonitor.java


示例3: tearDown

import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; //导入依赖的package包/类
@Override
public void tearDown() throws Exception
{
    RunAsWork<Void> tearDownWork = new RunAsWork<Void>()
    {
        @Override
        public Void doWork() throws Exception
        {
            fileFolderService.delete(hiddenFolderNodeRef);
            fileFolderService.delete(readOnlyFolderNodeRef);
            fileFolderService.delete(writeFolderNodeRef);
            // Done
            return null;
        }
    };
    AuthenticationUtil.runAsSystem(tearDownWork);

    AuthenticationUtil.popAuthentication();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:FileFolderLoaderTest.java


示例4: hasAuthority

import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; //导入依赖的package包/类
public boolean hasAuthority(final NodeRef nodeRef, final String userName)
{
    return AuthenticationUtil.runAs(new RunAsWork<Boolean>(){

        public Boolean doWork() throws Exception
        {
            if (lockService.getLockStatus(nodeRef, userName) == LockStatus.LOCK_OWNER)
            {
                return true;
            }
            NodeRef original = checkOutCheckInService.getCheckedOut(nodeRef);
            if (original != null)
            {
                return (lockService.getLockStatus(original, userName) == LockStatus.LOCK_OWNER);
            }
            else
            {
                return false;
            }
        }}, AuthenticationUtil.getSystemUserName());
    
    
    
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:LockOwnerDynamicAuthority.java


示例5: testDeleteLinks

import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; //导入依赖的package包/类
/**
 * Tests the deletion of a document's links, with and without write
 * permissions
 * 
 * @throws Exception
 */
public void testDeleteLinks() throws Exception
{
    DeleteLinksStatusReport report = AuthenticationUtil.runAs(new RunAsWork<DeleteLinksStatusReport>()
    {
        @Override
        public DeleteLinksStatusReport doWork() throws Exception
        {
            return documentLinkService.deleteLinksToDocument(site1File2);
        }
    }, TEST_USER);

    // check if the service found 2 links of the document
    assertEquals(2, report.getTotalLinksFoundCount());

    // check if the service successfully deleted one
    assertEquals(1, report.getDeletedLinksCount());

    assertEquals(true, nodeService.hasAspect(site1File2, ApplicationModel.ASPECT_LINKED));

    // check if the second one failed with access denied
    Throwable ex = report.getErrorDetails().get(linkOfFile1Site2);
    assertNotNull(ex);
    assertEquals(ex.getClass(), AccessDeniedException.class);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:31,代码来源:DocumentLinkServiceImplTest.java


示例6: getAllAuthoritiesInTxn

import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; //导入依赖的package包/类
private Set<String> getAllAuthoritiesInTxn(final String systemUserName)
{
    return AuthenticationUtil.runAs(new RunAsWork<Set<String>>()
    {
        public Set<String> doWork() throws Exception
        {
            RetryingTransactionHelper txnHelper = transactionService.getRetryingTransactionHelper();
            RetryingTransactionCallback<Set<String>> restoreCallback =
                new RetryingTransactionCallback<Set<String>>()
            {
                public Set<String> execute() throws Exception
                {
                    // Returns a sorted set (using natural ordering) rather than a hashCode
                    // so that it is more obvious what the order is for processing users.
                    Set<String> result = new TreeSet<String>();
                    result.addAll(authorityService.getAllAuthorities(AuthorityType.USER));
                    return result;
                }
            };
            return txnHelper.doInTransaction(restoreCallback, false, true);
        }
    }, systemUserName);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:24,代码来源:HomeFolderProviderSynchronizer.java


示例7: testETHREEOH_520

import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; //导入依赖的package包/类
/**
 * https://issues.alfresco.com/jira/browse/ETHREEOH-520
 */
public void testETHREEOH_520()
    throws Exception
{
    final String userName = "userInviteServiceTest" + GUID.generate();
    final String emailAddress = " ";

    // Create a person with a blank email address and
    AuthenticationUtil.runAs(new RunAsWork<Object>()
    {
        public Object doWork() throws Exception
        {
            createPerson(PERSON_FIRSTNAME, PERSON_LASTNAME, userName, " ");
            return null;
        }

    }, AuthenticationUtil.getSystemUserName());

    // Try and add an existing person to the site with no email address
    // Should return bad request since the email address has not been provided
    startInvite(PERSON_FIRSTNAME, PERSON_LASTNAME, emailAddress, INVITEE_SITE_ROLE, SITE_SHORT_NAME_INVITE_1, Status.STATUS_BAD_REQUEST);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:25,代码来源:InviteServiceTest.java


示例8: cloud928

import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; //导入依赖的package包/类
@Test public void cloud928()
{
    final NodeRef node = testNodes.createNodeWithTextContent(userHome,
            "CLOUD-928 Test Node",
            ContentModel.TYPE_CONTENT, 
            user1.getUsername(),
            "Quick Share Test Node Content");
    
    QuickShareDTO dto = share(node, user1.getUsername());

    attributeService.removeAttribute(QuickShareServiceImpl.ATTR_KEY_SHAREDIDS_ROOT, dto.getId());
    
    AuthenticationUtil.runAs(new RunAsWork<Object>(){

        @Override
        public Object doWork() throws Exception {
            nodeService.deleteNode(node);
            return null;
        }
    }, user1.getUsername());
 
    AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
    Assert.assertFalse(nodeService.exists(node));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:QuickShareServiceIntegrationTest.java


示例9: save

import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; //导入依赖的package包/类
/**
 * Saves any outstanding updates to the site details.
 * <p>
 * If properties of the site are changed and save is not called, those changes will be lost.
 */
public void save()
{
    if (this.isDirty == true)
    {
        if (siteService.isSiteAdmin(AuthenticationUtil.getFullyAuthenticatedUser()))
        {
            AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Void>()
            {
                public Void doWork() throws Exception
                {
                    // Update the site details as a site-admin
                    siteService.updateSite(siteInfo);
                    return null;
                }
            }, AuthenticationUtil.getAdminUserName());
        }
        else
        {
            // Update the site details
            this.siteService.updateSite(this.siteInfo);
        }
        // Reset the dirty flag
        this.isDirty = false;
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:31,代码来源:Site.java


示例10: getDownloadStatus

import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; //导入依赖的package包/类
public DownloadStatus getDownloadStatus(final NodeRef downloadNode)
{
    return AuthenticationUtil.runAsSystem(new RunAsWork<DownloadStatus>()
    {
        @Override
        public DownloadStatus doWork() throws Exception
        {
            return transactionHelper.doInTransaction(new RetryingTransactionCallback<DownloadStatus>()
            {
                @Override
                public DownloadStatus execute() throws Throwable
                {
                    return downloadService.getDownloadStatus(downloadNode);
                }
            });
        }
    });

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


示例11: testSearchAdminCanGetFacets

import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; //导入依赖的package包/类
public void testSearchAdminCanGetFacets() throws Exception
{
    AuthenticationUtil.runAs(new RunAsWork<Void>()
    {
        @Override public Void doWork() throws Exception
        {
            Response rsp = sendRequest(new GetRequest(GET_FACETS_URL), 200);

            String contentAsString = rsp.getContentAsString();
            JSONObject jsonRsp = new JSONObject(new JSONTokener(contentAsString));

            // FIXME The JSON payload should be contained within a 'data' object.
            JSONArray facetsArray = (JSONArray)jsonRsp.get(FACETS);
            assertNotNull("JSON 'facets' array was null", facetsArray);

            // We'll not add any further assertions on the JSON content. If we've
            // got valid JSON at this point, then that's good enough.
            return null;
        }
    }, SEARCH_ADMIN_USER);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:22,代码来源:FacetRestApiTest.java


示例12: createTenantDictionaryRegistry

import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; //导入依赖的package包/类
private DictionaryRegistry createTenantDictionaryRegistry(
        final String tenant)
{
    DictionaryRegistry result = AuthenticationUtil.runAs(
            new RunAsWork<DictionaryRegistry>()
            {
                public DictionaryRegistry doWork()
                {
                    DictionaryRegistry dictionaryRegistry = new TenantDictionaryRegistryImpl(
                            DictionaryDAOImpl.this, tenant);
                    return dictionaryRegistry;
                }
            }, tenantService.getDomainUser(
                    AuthenticationUtil.getSystemUserName(), tenant));

    return result;
}
 
开发者ID:Alfresco,项目名称:alfresco-data-model,代码行数:18,代码来源:DictionaryDAOImpl.java


示例13: testGetFacetablePropertiesForSpecificContentClasses

import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; //导入依赖的package包/类
public void testGetFacetablePropertiesForSpecificContentClasses() throws Exception
{
    AuthenticationUtil.runAs(new RunAsWork<Void>()
    {
        @Override public Void doWork() throws Exception
        {
            final Response rsp = sendRequest(new GetRequest(GET_SPECIFIC_FACETABLE_PROPERTIES_URL.replace("{classname}", "cm:content")), 200);
            
            // For now, we'll only perform limited testing of the response as we primarily
            // want to know that the GET call succeeded and that it correctly identified
            // *some* facetable properties.
            JSONObject jsonRsp = new JSONObject(new JSONTokener(rsp.getContentAsString()));
            
            JSONObject data = jsonRsp.getJSONObject("data");
            JSONArray properties = data.getJSONArray(FacetablePropertiesGet.PROPERTIES_KEY);
            
            final int arbitraryLimit = 100;
            assertTrue("Expected 'not very many' properties, but found 'many'", properties.length() < arbitraryLimit);
            
            return null;
        }
    }, SEARCH_ADMIN_USER);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:24,代码来源:FacetRestApiTest.java


示例14: onBootstrap

import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; //导入依赖的package包/类
@Override
protected void onBootstrap(ApplicationEvent event)
{
    RetryingTransactionCallback<Object> checkWork = new RetryingTransactionCallback<Object>()
    {
        public Object execute() throws Throwable {
            // run as System on bootstrap
            return AuthenticationUtil.runAs(new RunAsWork<Object>()
            {
                public Object doWork()
                {
                    check();
                    return null;
                }
            }, AuthenticationUtil.getSystemUserName());
        }
    };
    transactionService.getRetryingTransactionHelper().doInTransaction(checkWork, true);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:ConfigurationChecker.java


示例15: beforeAddAspect

import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; //导入依赖的package包/类
/**
 * Before add aspect policy behaviour
 *
 * @param nodeRef NodeRef
 * @param aspectTypeQName QName
 */
public void beforeAddAspect(final NodeRef nodeRef, QName aspectTypeQName)
{
    AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
    {
        @Override
        public Void doWork() throws Exception
        {
            if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE) == false
                    && versionService.getVersionHistory(nodeRef) != null)
            {
                versionService.deleteVersionHistory(nodeRef);
                logger.warn("The version history of node " + nodeRef
                        + " that doesn't have versionable aspect was deleted");
            }
            return null;
        }
    });
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:25,代码来源:VersionableAspect.java


示例16: createVersionImpl

import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; //导入依赖的package包/类
/**
  * On create version implementation method
  * 
  * @param nodeRef NodeRef
  * @param versionProperties Map<String, Serializable>
  */
 private void createVersionImpl(NodeRef nodeRef, Map<String, Serializable> versionProperties)
 {
 	final VersionService vs = this.versionService;
 	final NodeRef nf = nodeRef;
 	final Map<String, Serializable> vp = versionProperties;
     
 	AuthenticationUtil.runAs(new RunAsWork<Void>() {

 		@Override
public Void doWork() throws Exception {
	recordCreateVersion(nf, null);
       vs.createVersion(nf, vp);
	return null;
}
 	},AuthenticationUtil.getSystemUserName());
 	
 }
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:24,代码来源:VersionableAspect.java


示例17: run

import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; //导入依赖的package包/类
public void run()
{
    RunAsWork<Object> actionRunAs = new RunAsWork<Object>()
    {
        public Object doWork() throws Exception
        {
            return transactionService.getRetryingTransactionHelper().doInTransaction(
                    new RetryingTransactionCallback<Object>()
                    {
                        public Object execute()
                        {
                            commit(transferId);
                            return null;
                        }
                    }, false, true);
        }
    };
    AuthenticationUtil.runAs(actionRunAs, runAsUser);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:RepoTransferReceiverImpl.java


示例18: onRestoreNode

import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; //导入依赖的package包/类
@Override
public void onRestoreNode(final ChildAssociationRef childAssocRef)
{
    doAsSystem(new RunAsWork<Void>()
    {
        @Override
        public Void doWork() throws Exception
        {
            NodeRef childNodeRef = childAssocRef.getChildRef();
            if (serviceRegistry.getDictionaryService().isSubClass(nodeService.getType(childNodeRef), ContentModel.TYPE_CONTENT))
            {
                setFlag(childNodeRef, Flags.Flag.DELETED, false);
                setFlag(childNodeRef, Flags.Flag.SEEN, false);
            }

            NodeRef folderRef = childAssocRef.getParentRef();
            long newId = (Long) nodeService.getProperty(childNodeRef, ContentModel.PROP_NODE_DBID);
            if (nodeService.hasAspect(folderRef, ImapModel.ASPECT_IMAP_FOLDER))
            {
                // Force generation of a new change token and updating the UIDVALIDITY 
                getUidValidityTransactionListener(folderRef).recordNewUid(newId);
            }
            return null;
        }
    });
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:ImapServiceImpl.java


示例19: tenantExists

import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; //导入依赖的package包/类
/**
 * Determine whether tenant exists and enabled
 * 
 * @param tenant String
 * @return  true => it exists, no it doesn't
 */
public boolean tenantExists(final String tenant)
{
    if (tenant == null || TenantService.DEFAULT_DOMAIN.equalsIgnoreCase(tenant))
    {
        return true;
    }
    
    return AuthenticationUtil.runAsSystem(new RunAsWork<Boolean>()
    {
        public Boolean doWork() throws Exception
        {
            return tenantAdminService.existsTenant(tenant) && tenantAdminService.isEnabled();
        }
    });
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:22,代码来源:PublicApiTenantAuthentication.java


示例20: getPathFromSites

import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork; //导入依赖的package包/类
@Override
public String getPathFromSites(final NodeRef ref)
{
    return doAsSystem(new RunAsWork<String>()
    {
        @Override
        public String doWork() throws Exception
        {
            String name = ((String) nodeService.getProperty(ref, ContentModel.PROP_NAME)).toLowerCase();
            if (nodeService.getType(ref).equals(SiteModel.TYPE_SITE))
            {
                return name;
            }
            else
            {
                NodeRef parent = nodeService.getPrimaryParent(ref).getParentRef();
                return getPathFromSites(parent) + "/" + name;
            }
        }
    });
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:22,代码来源:ImapServiceImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CompactEndpointSerializationHelper类代码示例发布时间:2022-05-22
下一篇:
Java MidiManager类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap