mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-19942: Failed to displayed Process Engines page in Admin Console after creation of workflow by tenant user
Do special tenant specific filtering for WorkflowInstances and TaskInstances: for default tenant all instances included, for other tenants - only tenant-specific. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@56139 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -64,6 +64,8 @@ public class WorkflowObjectFactory
|
||||
private final String engineId;
|
||||
private final QName defaultStartTaskType;
|
||||
|
||||
private boolean ignoreTenantCheck;
|
||||
|
||||
public WorkflowObjectFactory(WorkflowQNameConverter qNameConverter,
|
||||
TenantService tenantService,
|
||||
MessageService messageService,
|
||||
@@ -364,7 +366,7 @@ public class WorkflowObjectFactory
|
||||
*/
|
||||
public void checkDomain(String defName)
|
||||
{
|
||||
if (tenantService.isEnabled())
|
||||
if (tenantService.isEnabled() && !ignoreTenantCheck)
|
||||
{
|
||||
String processKey = defName;
|
||||
if (isGlobalId(defName))
|
||||
@@ -397,6 +399,24 @@ public class WorkflowObjectFactory
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* For "default" domain return ALL workflows
|
||||
* For tenant-specific workflows exclude "default"
|
||||
*/
|
||||
public <T extends Object> List<T> doSpecialTenantFilter(Collection<T> values, final Function<T, String> processKeyGetter)
|
||||
{
|
||||
final String currentDomain = tenantService.getCurrentUserDomain();
|
||||
return CollectionUtils.filter(values, new Filter<T>()
|
||||
{
|
||||
public Boolean apply(T value)
|
||||
{
|
||||
String key = processKeyGetter.apply(value);
|
||||
String domain = TenantUtil.getTenantDomain(key);
|
||||
return currentDomain.equals(domain) || currentDomain.equals(TenantService.DEFAULT_DOMAIN);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an anonymous {@link TypeDefinition} for the given name with all
|
||||
* the mandatory aspects applied.
|
||||
@@ -467,4 +487,14 @@ public class WorkflowObjectFactory
|
||||
{
|
||||
qNameConverter.clearCache();
|
||||
}
|
||||
|
||||
public boolean isIgnoreTenantCheck()
|
||||
{
|
||||
return ignoreTenantCheck;
|
||||
}
|
||||
|
||||
public void setIgnoreTenantCheck(boolean ignoreTenantCheck)
|
||||
{
|
||||
this.ignoreTenantCheck = ignoreTenantCheck;
|
||||
}
|
||||
}
|
@@ -108,6 +108,30 @@ public class ActivitiTypeConverter
|
||||
return convert(filtered);
|
||||
}
|
||||
|
||||
/**
|
||||
* filters HistoricProcessInstances by domain
|
||||
* including all instances for default domain
|
||||
* and excluding shared instances (THOR-206) for tenants
|
||||
*
|
||||
* @param completedInstances
|
||||
* @param function
|
||||
* @return
|
||||
*/
|
||||
public <F, T> List<T> doSpecialTenantFilterAndSafeConvert(List<F> values, Function<F, String> processKeyGetter)
|
||||
{
|
||||
List<F> filtered = factory.doSpecialTenantFilter(values, processKeyGetter);
|
||||
factory.setIgnoreTenantCheck(factory.isDefaultDomain());
|
||||
try
|
||||
{
|
||||
return convert(filtered, true);
|
||||
}
|
||||
finally
|
||||
{
|
||||
factory.setIgnoreTenantCheck(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a {@link Deployment} into a {@link WorkflowDeployment}.
|
||||
* @param deployment
|
||||
@@ -329,13 +353,29 @@ public class ActivitiTypeConverter
|
||||
return results;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> List<T> convert(List<?> inputs)
|
||||
{
|
||||
return convert(inputs, false);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> List<T> convert(List<?> inputs, boolean ignoreNotDeployed)
|
||||
{
|
||||
ArrayList<T> results = new ArrayList<T>(inputs.size());
|
||||
for (Object in : inputs)
|
||||
{
|
||||
T out = (T) convert(in);
|
||||
T out = null;
|
||||
try
|
||||
{
|
||||
out = (T) convert(in);
|
||||
}
|
||||
catch (NullPointerException npe)
|
||||
{
|
||||
if (!ignoreNotDeployed)
|
||||
{
|
||||
throw npe;
|
||||
}
|
||||
}
|
||||
if(out != null)
|
||||
{
|
||||
results.add(out);
|
||||
|
@@ -1121,7 +1121,7 @@ public class ActivitiWorkflowEngine extends BPMEngine implements WorkflowEngine
|
||||
*/
|
||||
private List<WorkflowTask> getValidWorkflowTasks(List<Task> tasks)
|
||||
{
|
||||
return typeConverter.filterByDomainAndConvert(tasks, new Function<Task, String>()
|
||||
return typeConverter.doSpecialTenantFilterAndSafeConvert(tasks, new Function<Task, String>()
|
||||
{
|
||||
public String apply(Task task)
|
||||
{
|
||||
|
Reference in New Issue
Block a user