Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#5129 - Dynamic workflow may kick in for curator when try to view document from non-curator #5165

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ protected void onInitialize()
{
super.onInitialize();

var page = (AnnotationPageBase) getPage();
for (var ext : getExtensions()) {
ext.onInitialize((AnnotationPageBase) getPage());
ext.onInitialize(page);
activeExtensions.add(ext.getId());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package de.tudarmstadt.ukp.inception.workload.dynamic.annotation;

import static de.tudarmstadt.ukp.clarin.webanno.model.PermissionLevel.CURATOR;
import static de.tudarmstadt.ukp.clarin.webanno.model.PermissionLevel.MANAGER;
import static de.tudarmstadt.ukp.inception.workload.dynamic.DynamicWorkloadExtension.DYNAMIC_WORKLOAD_MANAGER_EXTENSION_ID;

import java.io.Serializable;
Expand All @@ -30,6 +29,7 @@

import de.tudarmstadt.ukp.clarin.webanno.api.annotation.actionbar.ActionBarExtension;
import de.tudarmstadt.ukp.clarin.webanno.api.annotation.page.AnnotationPageBase;
import de.tudarmstadt.ukp.clarin.webanno.security.UserDao;
import de.tudarmstadt.ukp.inception.documents.api.DocumentService;
import de.tudarmstadt.ukp.inception.project.api.ProjectService;
import de.tudarmstadt.ukp.inception.rendering.editorstate.AnnotatorState;
Expand All @@ -56,18 +56,21 @@ public class DynamicWorkflowDocumentNavigationActionBarExtension
private final WorkloadManagementService workloadManagementService;
private final DynamicWorkloadExtension dynamicWorkloadExtension;
private final ProjectService projectService;
private final UserDao userService;

private AnnotatorState annotatorState;

@Autowired
public DynamicWorkflowDocumentNavigationActionBarExtension(DocumentService aDocumentService,
WorkloadManagementService aWorkloadManagementService,
DynamicWorkloadExtension aDynamicWorkloadExtension, ProjectService aProjectService)
DynamicWorkloadExtension aDynamicWorkloadExtension, ProjectService aProjectService,
UserDao aUserService)
{
documentService = aDocumentService;
workloadManagementService = aWorkloadManagementService;
dynamicWorkloadExtension = aDynamicWorkloadExtension;
projectService = aProjectService;
userService = aUserService;
}

@Override
Expand All @@ -86,16 +89,16 @@ public int getPriority()
public boolean accepts(AnnotationPageBase aPage)
{
// #Issue 1813 fix
if (aPage.getModelObject().getProject() == null) {
var project = aPage.getModelObject().getProject();
if (project == null) {
return false;
}

// Curator are excluded from the feature
return DYNAMIC_WORKLOAD_MANAGER_EXTENSION_ID
.equals(workloadManagementService.loadOrCreateWorkloadManagerConfiguration(
aPage.getModelObject().getProject()).getType())
&& !projectService.hasRole(aPage.getModelObject().getUser(),
aPage.getModelObject().getProject(), CURATOR, MANAGER);
var sessionOwner = userService.getCurrentUser();
var workloadConfig = workloadManagementService
.loadOrCreateWorkloadManagerConfiguration(aPage.getModelObject().getProject());
return DYNAMIC_WORKLOAD_MANAGER_EXTENSION_ID.equals(workloadConfig.getType())
&& !projectService.hasRole(sessionOwner, project, CURATOR);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,11 @@ public DynamicWorkflowActionBarExtension dynamicWorkflowActionBarExtension(
@Bean
public DynamicWorkflowDocumentNavigationActionBarExtension dynamicWorkflowDocumentNavigationActionBarExtension(
DocumentService aDocumentService, WorkloadManagementService aWorkloadManagementService,
DynamicWorkloadExtension aDynamicWorkloadExtension, ProjectService aProjectService)
DynamicWorkloadExtension aDynamicWorkloadExtension, ProjectService aProjectService,
UserDao aUserService)
{
return new DynamicWorkflowDocumentNavigationActionBarExtension(aDocumentService,
aWorkloadManagementService, aDynamicWorkloadExtension, aProjectService);
aWorkloadManagementService, aDynamicWorkloadExtension, aProjectService,
aUserService);
}
}