commit e080f6ded006655d94a94b876eb9c1fb2143d60f
Author: Andreas Kohlbecker <a.kohlbecker@bgbm.org>
Date:   Thu Sep 6 13:51:24 2018 +0200

    fix #7585 replacing RegistrationCuratorRoleProbe by RoleProber

diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/permission/RegistrationCuratorRoleProbe.java b/src/main/java/eu/etaxonomy/cdm/vaadin/permission/RegistrationCuratorRoleProbe.java
deleted file mode 100644
index 15464b8b..00000000
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/permission/RegistrationCuratorRoleProbe.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
-* Copyright (C) 2018 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
-package eu.etaxonomy.cdm.vaadin.permission;
-
-import org.springframework.security.core.Authentication;
-
-import eu.etaxonomy.cdm.api.utility.RoleProbe;
-
-/**
- * @author a.kohlbecker
- * @since Jul 16, 2018
- *
- */
-public class RegistrationCuratorRoleProbe implements RoleProbe {
-
-    @Override
-    public boolean checkForRole(Authentication authentication){
-
-        if(authentication != null) {
-            return authentication.getAuthorities().stream().anyMatch(a -> {
-                return a.equals(RolesAndPermissions.ROLE_CURATION)
-                        // doing faster regex check here instead of using CdmAuthoritiy.fromString()
-                        || a.getAuthority().matches("^Registration\\.\\[.*UPDATE");
-            });
-        }
-        return false;
-    }
-
-}
diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListViewBean.java b/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListViewBean.java
index ded09c4b..b00189dc 100644
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListViewBean.java
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListViewBean.java
@@ -38,6 +38,7 @@ import com.vaadin.ui.themes.ValoTheme;
 
 import eu.etaxonomy.cdm.api.service.dto.RegistrationDTO;
 import eu.etaxonomy.cdm.api.service.pager.Pager;
+import eu.etaxonomy.cdm.api.utility.RoleProber;
 import eu.etaxonomy.cdm.model.name.Registration;
 import eu.etaxonomy.cdm.model.name.RegistrationStatus;
 import eu.etaxonomy.cdm.service.UserHelperAccess;
@@ -48,7 +49,7 @@ import eu.etaxonomy.cdm.vaadin.event.PagingEvent;
 import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent;
 import eu.etaxonomy.cdm.vaadin.event.UpdateResultsEvent;
 import eu.etaxonomy.cdm.vaadin.permission.AccessRestrictedView;
-import eu.etaxonomy.cdm.vaadin.permission.RegistrationCuratorRoleProbe;
+import eu.etaxonomy.cdm.vaadin.permission.RolesAndPermissions;
 import eu.etaxonomy.cdm.vaadin.view.AbstractPageView;
 
 /**
@@ -98,7 +99,7 @@ public class ListViewBean extends AbstractPageView<ListPresenter> implements Lis
 
         toolBar.addComponent(filterInstructionLabel);
 
-        boolean userIsCurator = UserHelperAccess.userHelper().userIs(new RegistrationCuratorRoleProbe());
+        boolean userIsCurator = UserHelperAccess.userHelper().userIs(new RoleProber(RolesAndPermissions.ROLE_CURATION));
         boolean userIsAdmin = UserHelperAccess.userHelper().userIsAdmin();
         if(userIsCurator || userIsAdmin){
             submitterFilter = new ListSelect("Submitter");
@@ -190,7 +191,7 @@ public class ListViewBean extends AbstractPageView<ListPresenter> implements Lis
     public void populateList(Collection<RegistrationDTO> registrations) {
 
         listContainer.removeAllComponents();
-        boolean isCurator = UserHelperAccess.userHelper().userIs(new RegistrationCuratorRoleProbe()) || UserHelperAccess.userHelper().userIsAdmin();
+        boolean isCurator = UserHelperAccess.userHelper().userIs(new RoleProber(RolesAndPermissions.ROLE_CURATION)) || UserHelperAccess.userHelper().userIsAdmin();
         for(RegistrationDTO regDto : registrations) {
             RegistrationItem item = new RegistrationItem(regDto, this);
             item.getSubmitterLabel().setVisible(isCurator);
diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationMessagesPresenter.java b/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationMessagesPresenter.java
index 9ee86bf4..b286153e 100644
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationMessagesPresenter.java
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationMessagesPresenter.java
@@ -19,6 +19,7 @@ import org.springframework.context.annotation.Scope;
 import com.vaadin.spring.annotation.SpringComponent;
 
 import eu.etaxonomy.cdm.api.service.IRegistrationService;
+import eu.etaxonomy.cdm.api.utility.RoleProber;
 import eu.etaxonomy.cdm.ext.common.ExternalServiceException;
 import eu.etaxonomy.cdm.ext.registration.messages.IRegistrationMessageService;
 import eu.etaxonomy.cdm.ext.registration.messages.Message;
@@ -26,7 +27,7 @@ import eu.etaxonomy.cdm.model.common.User;
 import eu.etaxonomy.cdm.model.name.Registration;
 import eu.etaxonomy.cdm.service.UserHelperAccess;
 import eu.etaxonomy.cdm.vaadin.event.error.ExternalServiceExceptionHandler;
-import eu.etaxonomy.cdm.vaadin.permission.RegistrationCuratorRoleProbe;
+import eu.etaxonomy.cdm.vaadin.permission.RolesAndPermissions;
 import eu.etaxonomy.vaadin.mvp.AbstractPresenter;
 
 /**
@@ -84,7 +85,7 @@ public class RegistrationMessagesPresenter extends AbstractPresenter<Registratio
             throw new RuntimeException(e);
         }
         User toUser = null;
-        if(UserHelperAccess.userHelper().userIs(new RegistrationCuratorRoleProbe())){
+        if(UserHelperAccess.userHelper().userIs(new RoleProber(RolesAndPermissions.ROLE_CURATION))){
             toUser = registration.getSubmitter();
         } else {
             Stack<Message> stack = new Stack<>();
diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java b/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java
index dc43f0e3..487aba18 100644
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java
@@ -44,6 +44,7 @@ import eu.etaxonomy.cdm.api.service.dto.RegistrationWorkingSet;
 import eu.etaxonomy.cdm.api.service.exception.RegistrationValidationException;
 import eu.etaxonomy.cdm.api.service.name.TypeDesignationSetManager.TypeDesignationWorkingSetType;
 import eu.etaxonomy.cdm.api.service.registration.IRegistrationWorkingSetService;
+import eu.etaxonomy.cdm.api.utility.RoleProber;
 import eu.etaxonomy.cdm.api.utility.UserHelper;
 import eu.etaxonomy.cdm.ext.common.ExternalServiceException;
 import eu.etaxonomy.cdm.ext.registration.messages.IRegistrationMessageService;
@@ -77,7 +78,7 @@ import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEventEntityTypeFilter;
 import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction;
 import eu.etaxonomy.cdm.vaadin.event.TypeDesignationWorkingsetEditorAction;
 import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkingsetAction;
-import eu.etaxonomy.cdm.vaadin.permission.RegistrationCuratorRoleProbe;
+import eu.etaxonomy.cdm.vaadin.permission.RolesAndPermissions;
 import eu.etaxonomy.cdm.vaadin.theme.EditValoTheme;
 import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults;
 import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator;
@@ -287,7 +288,7 @@ public class RegistrationWorkingsetPresenter extends AbstractPresenter<Registrat
 
                 boolean activeMessages = messageCount > 0;
                 boolean currentUserIsSubmitter = regDto.getSubmitterUserName() != null && regDto.getSubmitterUserName().equals(UserHelperAccess.userHelper().userName());
-                boolean currentUserIsCurator = UserHelperAccess.userHelper().userIs(new RegistrationCuratorRoleProbe());
+                boolean currentUserIsCurator = UserHelperAccess.userHelper().userIs(new RoleProber(RolesAndPermissions.ROLE_CURATION));
                 messageButton.setEnabled(false);
                 if(currentUserIsCurator){
                     if(currentUserIsSubmitter){
diff --git a/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorksetViewBean.java b/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorksetViewBean.java
index 5bc841ed..00ba67aa 100644
--- a/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorksetViewBean.java
+++ b/src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorksetViewBean.java
@@ -50,6 +50,7 @@ import eu.etaxonomy.cdm.api.service.dto.RegistrationDTO;
 import eu.etaxonomy.cdm.api.service.dto.RegistrationType;
 import eu.etaxonomy.cdm.api.service.dto.RegistrationWorkingSet;
 import eu.etaxonomy.cdm.api.service.name.TypeDesignationSetManager.TypeDesignationWorkingSetType;
+import eu.etaxonomy.cdm.api.utility.RoleProber;
 import eu.etaxonomy.cdm.model.name.Registration;
 import eu.etaxonomy.cdm.model.name.RegistrationStatus;
 import eu.etaxonomy.cdm.model.name.TaxonName;
@@ -73,7 +74,7 @@ import eu.etaxonomy.cdm.vaadin.event.TypeDesignationWorkingsetEditorAction;
 import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkingsetAction;
 import eu.etaxonomy.cdm.vaadin.permission.AccessRestrictedView;
 import eu.etaxonomy.cdm.vaadin.permission.PermissionDebugUtils;
-import eu.etaxonomy.cdm.vaadin.permission.RegistrationCuratorRoleProbe;
+import eu.etaxonomy.cdm.vaadin.permission.RolesAndPermissions;
 import eu.etaxonomy.cdm.vaadin.theme.EditValoTheme;
 import eu.etaxonomy.cdm.vaadin.view.AbstractPageView;
 import eu.etaxonomy.vaadin.event.EditorActionType;
@@ -440,7 +441,7 @@ public class RegistrationWorksetViewBean extends AbstractPageView<RegistrationWo
         CssLayout stateAndSubmitter = new CssLayout(statusComponent, submitterLabel);
 
 
-        if(UserHelperAccess.userHelper().userIs(new RegistrationCuratorRoleProbe()) || UserHelperAccess.userHelper().userIsAdmin()) {
+        if(UserHelperAccess.userHelper().userIs(new RoleProber(RolesAndPermissions.ROLE_CURATION)) || UserHelperAccess.userHelper().userIsAdmin()) {
             Button editRegistrationButton = new Button(FontAwesome.COG);
             editRegistrationButton.setStyleName(ValoTheme.BUTTON_TINY);
             editRegistrationButton.setDescription("Edit registration");
