Project

General

Profile

Revision e080f6de

IDe080f6ded006655d94a94b876eb9c1fb2143d60f
Parent e8e0ad3b
Child 0af671fa

Added by Andreas Kohlbecker 10 months ago

fix #7585 replacing RegistrationCuratorRoleProbe by RoleProber

View differences:

src/main/java/eu/etaxonomy/cdm/vaadin/permission/RegistrationCuratorRoleProbe.java
1
/**
2
* Copyright (C) 2018 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.vaadin.permission;
10

  
11
import org.springframework.security.core.Authentication;
12

  
13
import eu.etaxonomy.cdm.api.utility.RoleProbe;
14

  
15
/**
16
 * @author a.kohlbecker
17
 * @since Jul 16, 2018
18
 *
19
 */
20
public class RegistrationCuratorRoleProbe implements RoleProbe {
21

  
22
    @Override
23
    public boolean checkForRole(Authentication authentication){
24

  
25
        if(authentication != null) {
26
            return authentication.getAuthorities().stream().anyMatch(a -> {
27
                return a.equals(RolesAndPermissions.ROLE_CURATION)
28
                        // doing faster regex check here instead of using CdmAuthoritiy.fromString()
29
                        || a.getAuthority().matches("^Registration\\.\\[.*UPDATE");
30
            });
31
        }
32
        return false;
33
    }
34

  
35
}
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListViewBean.java
38 38

  
39 39
import eu.etaxonomy.cdm.api.service.dto.RegistrationDTO;
40 40
import eu.etaxonomy.cdm.api.service.pager.Pager;
41
import eu.etaxonomy.cdm.api.utility.RoleProber;
41 42
import eu.etaxonomy.cdm.model.name.Registration;
42 43
import eu.etaxonomy.cdm.model.name.RegistrationStatus;
43 44
import eu.etaxonomy.cdm.service.UserHelperAccess;
......
48 49
import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent;
49 50
import eu.etaxonomy.cdm.vaadin.event.UpdateResultsEvent;
50 51
import eu.etaxonomy.cdm.vaadin.permission.AccessRestrictedView;
51
import eu.etaxonomy.cdm.vaadin.permission.RegistrationCuratorRoleProbe;
52
import eu.etaxonomy.cdm.vaadin.permission.RolesAndPermissions;
52 53
import eu.etaxonomy.cdm.vaadin.view.AbstractPageView;
53 54

  
54 55
/**
......
98 99

  
99 100
        toolBar.addComponent(filterInstructionLabel);
100 101

  
101
        boolean userIsCurator = UserHelperAccess.userHelper().userIs(new RegistrationCuratorRoleProbe());
102
        boolean userIsCurator = UserHelperAccess.userHelper().userIs(new RoleProber(RolesAndPermissions.ROLE_CURATION));
102 103
        boolean userIsAdmin = UserHelperAccess.userHelper().userIsAdmin();
103 104
        if(userIsCurator || userIsAdmin){
104 105
            submitterFilter = new ListSelect("Submitter");
......
190 191
    public void populateList(Collection<RegistrationDTO> registrations) {
191 192

  
192 193
        listContainer.removeAllComponents();
193
        boolean isCurator = UserHelperAccess.userHelper().userIs(new RegistrationCuratorRoleProbe()) || UserHelperAccess.userHelper().userIsAdmin();
194
        boolean isCurator = UserHelperAccess.userHelper().userIs(new RoleProber(RolesAndPermissions.ROLE_CURATION)) || UserHelperAccess.userHelper().userIsAdmin();
194 195
        for(RegistrationDTO regDto : registrations) {
195 196
            RegistrationItem item = new RegistrationItem(regDto, this);
196 197
            item.getSubmitterLabel().setVisible(isCurator);
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationMessagesPresenter.java
19 19
import com.vaadin.spring.annotation.SpringComponent;
20 20

  
21 21
import eu.etaxonomy.cdm.api.service.IRegistrationService;
22
import eu.etaxonomy.cdm.api.utility.RoleProber;
22 23
import eu.etaxonomy.cdm.ext.common.ExternalServiceException;
23 24
import eu.etaxonomy.cdm.ext.registration.messages.IRegistrationMessageService;
24 25
import eu.etaxonomy.cdm.ext.registration.messages.Message;
......
26 27
import eu.etaxonomy.cdm.model.name.Registration;
27 28
import eu.etaxonomy.cdm.service.UserHelperAccess;
28 29
import eu.etaxonomy.cdm.vaadin.event.error.ExternalServiceExceptionHandler;
29
import eu.etaxonomy.cdm.vaadin.permission.RegistrationCuratorRoleProbe;
30
import eu.etaxonomy.cdm.vaadin.permission.RolesAndPermissions;
30 31
import eu.etaxonomy.vaadin.mvp.AbstractPresenter;
31 32

  
32 33
/**
......
84 85
            throw new RuntimeException(e);
85 86
        }
86 87
        User toUser = null;
87
        if(UserHelperAccess.userHelper().userIs(new RegistrationCuratorRoleProbe())){
88
        if(UserHelperAccess.userHelper().userIs(new RoleProber(RolesAndPermissions.ROLE_CURATION))){
88 89
            toUser = registration.getSubmitter();
89 90
        } else {
90 91
            Stack<Message> stack = new Stack<>();
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java
44 44
import eu.etaxonomy.cdm.api.service.exception.RegistrationValidationException;
45 45
import eu.etaxonomy.cdm.api.service.name.TypeDesignationSetManager.TypeDesignationWorkingSetType;
46 46
import eu.etaxonomy.cdm.api.service.registration.IRegistrationWorkingSetService;
47
import eu.etaxonomy.cdm.api.utility.RoleProber;
47 48
import eu.etaxonomy.cdm.api.utility.UserHelper;
48 49
import eu.etaxonomy.cdm.ext.common.ExternalServiceException;
49 50
import eu.etaxonomy.cdm.ext.registration.messages.IRegistrationMessageService;
......
77 78
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction;
78 79
import eu.etaxonomy.cdm.vaadin.event.TypeDesignationWorkingsetEditorAction;
79 80
import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkingsetAction;
80
import eu.etaxonomy.cdm.vaadin.permission.RegistrationCuratorRoleProbe;
81
import eu.etaxonomy.cdm.vaadin.permission.RolesAndPermissions;
81 82
import eu.etaxonomy.cdm.vaadin.theme.EditValoTheme;
82 83
import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults;
83 84
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator;
......
287 288

  
288 289
                boolean activeMessages = messageCount > 0;
289 290
                boolean currentUserIsSubmitter = regDto.getSubmitterUserName() != null && regDto.getSubmitterUserName().equals(UserHelperAccess.userHelper().userName());
290
                boolean currentUserIsCurator = UserHelperAccess.userHelper().userIs(new RegistrationCuratorRoleProbe());
291
                boolean currentUserIsCurator = UserHelperAccess.userHelper().userIs(new RoleProber(RolesAndPermissions.ROLE_CURATION));
291 292
                messageButton.setEnabled(false);
292 293
                if(currentUserIsCurator){
293 294
                    if(currentUserIsSubmitter){
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorksetViewBean.java
50 50
import eu.etaxonomy.cdm.api.service.dto.RegistrationType;
51 51
import eu.etaxonomy.cdm.api.service.dto.RegistrationWorkingSet;
52 52
import eu.etaxonomy.cdm.api.service.name.TypeDesignationSetManager.TypeDesignationWorkingSetType;
53
import eu.etaxonomy.cdm.api.utility.RoleProber;
53 54
import eu.etaxonomy.cdm.model.name.Registration;
54 55
import eu.etaxonomy.cdm.model.name.RegistrationStatus;
55 56
import eu.etaxonomy.cdm.model.name.TaxonName;
......
73 74
import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkingsetAction;
74 75
import eu.etaxonomy.cdm.vaadin.permission.AccessRestrictedView;
75 76
import eu.etaxonomy.cdm.vaadin.permission.PermissionDebugUtils;
76
import eu.etaxonomy.cdm.vaadin.permission.RegistrationCuratorRoleProbe;
77
import eu.etaxonomy.cdm.vaadin.permission.RolesAndPermissions;
77 78
import eu.etaxonomy.cdm.vaadin.theme.EditValoTheme;
78 79
import eu.etaxonomy.cdm.vaadin.view.AbstractPageView;
79 80
import eu.etaxonomy.vaadin.event.EditorActionType;
......
440 441
        CssLayout stateAndSubmitter = new CssLayout(statusComponent, submitterLabel);
441 442

  
442 443

  
443
        if(UserHelperAccess.userHelper().userIs(new RegistrationCuratorRoleProbe()) || UserHelperAccess.userHelper().userIsAdmin()) {
444
        if(UserHelperAccess.userHelper().userIs(new RoleProber(RolesAndPermissions.ROLE_CURATION)) || UserHelperAccess.userHelper().userIsAdmin()) {
444 445
            Button editRegistrationButton = new Button(FontAwesome.COG);
445 446
            editRegistrationButton.setStyleName(ValoTheme.BUTTON_TINY);
446 447
            editRegistrationButton.setDescription("Edit registration");

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)