本文整理汇总了Java中org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork类的典型用法代码示例。如果您正苦于以下问题:Java RunAsWork类的具体用法?Java RunAsWork怎么用?Java RunAsWork使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RunAsWork类属于org.alfresco.repo.security.authentication.AuthenticationUtil包,在下文中一共展示了RunAsWork类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
示例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);
}
示例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();
}
示例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());
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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;
}
}
示例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);
}
});
}
});
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
});
}