本文整理汇总了Java中org.alfresco.repo.tenant.TenantUtil.runAsDefaultTenant方法的典型用法代码示例。如果您正苦于以下问题:Java TenantUtil.runAsDefaultTenant方法的具体用法?Java TenantUtil.runAsDefaultTenant怎么用?Java TenantUtil.runAsDefaultTenant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.repo.tenant.TenantUtil
的用法示例。
在下文中一共展示了TenantUtil.runAsDefaultTenant方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeSharedId
import org.alfresco.repo.tenant.TenantUtil; //导入方法依赖的package包/类
private void removeSharedId(final String sharedId)
{
TenantUtil.runAsDefaultTenant(new TenantRunAsWork<Void>()
{
public Void doWork() throws Exception
{
attributeService.removeAttribute(ATTR_KEY_SHAREDIDS_ROOT, sharedId);
return null;
}
});
try
{
// Remove scheduled expiry action if any
NodeRef expiryActionNodeRef = getQuickShareLinkExpiryActionNode(sharedId);
if (expiryActionNodeRef != null)
{
deleteQuickShareLinkExpiryAction(expiryActionNodeRef);
}
}
catch (Exception ex)
{
throw new QuickShareLinkExpiryActionException("Couldn't delete the quick share link expiry action for the sharedId:" + sharedId);
}
}
示例2: deleteQuickShareLinkExpiryAction
import org.alfresco.repo.tenant.TenantUtil; //导入方法依赖的package包/类
/**
* Removes (hard deletes) the previously persisted {@link QuickShareLinkExpiryAction} and its related
* schedule {@link ScheduledPersistedAction} from the repository.
*/
protected void deleteQuickShareLinkExpiryAction(NodeRef linkExpiryActionNodeRef)
{
TenantUtil.runAsDefaultTenant(() -> {
QuickShareLinkExpiryAction linkExpiryAction = quickShareLinkExpiryActionPersister.loadQuickShareLinkExpiryAction(linkExpiryActionNodeRef);
// Delete the expiry action and its related persisted schedule
deleteQuickShareLinkExpiryActionImpl(linkExpiryAction);
return null;
});
}
示例3: getTenantNodeRefFromSharedId
import org.alfresco.repo.tenant.TenantUtil; //导入方法依赖的package包/类
@Override
public Pair<String, NodeRef> getTenantNodeRefFromSharedId(final String sharedId)
{
NodeRef nodeRef = TenantUtil.runAsDefaultTenant(new TenantRunAsWork<NodeRef>()
{
public NodeRef doWork() throws Exception
{
return (NodeRef) attributeService.getAttribute(ATTR_KEY_SHAREDIDS_ROOT, sharedId);
}
});
if (nodeRef == null)
{
/* TODO
* Temporary fix for RA-1093 and MNT-16224. The extra lookup should be
* removed (the same as before, just throw the 'InvalidSharedIdException' exception) when we
* have a system wide patch to remove the 'shared' aspect of the nodes that have been archived while shared.
*/
// TMDQ
final String query = "+TYPE:\"cm:content\" AND +ASPECT:\"qshare:shared\" AND =qshare:sharedId:\"" + sharedId + "\"";
SearchParameters sp = new SearchParameters();
sp.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO);
sp.setQuery(query);
sp.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
List<NodeRef> nodeRefs = null;
ResultSet results = null;
try
{
results = searchService.query(sp);
nodeRefs = results.getNodeRefs();
}
catch (Exception ex)
{
throw new InvalidSharedIdException(sharedId);
}
finally
{
if (results != null)
{
results.close();
}
}
if (nodeRefs.size() != 1)
{
throw new InvalidSharedIdException(sharedId);
}
nodeRef = tenantService.getName(nodeRefs.get(0));
}
// note: relies on tenant-specific (ie. mangled) nodeRef
String tenantDomain = tenantService.getDomain(nodeRef.getStoreRef().getIdentifier());
return new Pair<>(tenantDomain, tenantService.getBaseName(nodeRef));
}
示例4: saveSharedLinkExpiryAction
import org.alfresco.repo.tenant.TenantUtil; //导入方法依赖的package包/类
/**
* Creates and persists the quick share link expiry action and its related schedule.
*/
protected void saveSharedLinkExpiryAction(String sharedId, Date expiryDate)
{
ParameterCheck.mandatory("expiryDate", expiryDate);
// Validate the given expiry date
checkExpiryDate(expiryDate);
if (logger.isDebugEnabled())
{
logger.debug("Creating shared link expiry action for the sharedId:" + sharedId);
}
final NodeRef expiryActionNodeRef = getQuickShareLinkExpiryActionNode(sharedId);
// If an expiry action already exists for the specified shared Id, first remove it, before creating a new one.
if (expiryActionNodeRef != null)
{
deleteQuickShareLinkExpiryAction(expiryActionNodeRef);
}
// Create the expiry action
final QuickShareLinkExpiryAction expiryAction = new QuickShareLinkExpiryActionImpl(java.util.UUID.randomUUID().toString(), sharedId,
"QuickShare link expiry action");
// Create the persisted schedule
final ScheduledPersistedAction schedule = scheduledPersistedActionService.createSchedule(expiryAction);
// first set the scheduledAction so we can set the other information
expiryAction.setSchedule(schedule);
expiryAction.setScheduleStart(expiryDate);
try
{
TenantUtil.runAsDefaultTenant((TenantRunAsWork<Void>) () -> {
quickShareLinkExpiryActionPersister.saveQuickShareLinkExpiryAction(expiryAction);
scheduledPersistedActionService.saveSchedule(schedule);
return null;
});
}
catch (Exception ex)
{
throw new QuickShareLinkExpiryActionException("Couldn't create quick share link expiry action.", ex);
}
if (logger.isDebugEnabled())
{
logger.debug("Quick share link expiry action is created for sharedId[" + sharedId + "] and it's scheduled to be executed on: "
+ expiryDate);
}
}
示例5: getQuickShareLinkExpiryActionNode
import org.alfresco.repo.tenant.TenantUtil; //导入方法依赖的package包/类
private NodeRef getQuickShareLinkExpiryActionNode(String sharedId)
{
final QName expiryActionQName = QuickShareLinkExpiryActionImpl.createQName(sharedId);
return TenantUtil.runAsDefaultTenant(() -> quickShareLinkExpiryActionPersister.getQuickShareLinkExpiryActionNode(expiryActionQName));
}