commit fe9e440df61646b8813e71e046c7a2a07fdbfa0d
Author: k.luther <k.luther@bgbm.org>
Date:   Thu Jan 16 12:06:34 2020 +0100

    ref #8810: check for taxonnode permission and whether the user has taxon node granted authorities

diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/TaxonNameEditorE4.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/TaxonNameEditorE4.java
index 0bc3bfba1..a39c2e584 100644
--- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/TaxonNameEditorE4.java
+++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/TaxonNameEditorE4.java
@@ -67,6 +67,7 @@ import eu.etaxonomy.cdm.model.taxon.Taxon;
 import eu.etaxonomy.cdm.model.taxon.TaxonBase;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
 import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
+import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
 import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
 import eu.etaxonomy.taxeditor.editor.AppModelId;
 import eu.etaxonomy.taxeditor.editor.CdmDataTransfer;
@@ -431,7 +432,7 @@ public class TaxonNameEditorE4 implements IConversationEnabled, IDirtyMarkable,
         conversation.commit(true);
 
         dirty.setDirty(false);
-        EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAVIGATOR, true);
+        EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAVIGATOR, new TaxonNodeDto(input.getTaxonNode()));
         EventUtility.postEvent(WorkbenchEventConstants.SAVE_TAXON, true);
         // Stop the progress monitor.
         monitor.done();
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/defaultHandler/e4/DefaultOpenTaxonNodeWizardHandlerE4.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/defaultHandler/e4/DefaultOpenTaxonNodeWizardHandlerE4.java
index afabd55b4..d4d980446 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/defaultHandler/e4/DefaultOpenTaxonNodeWizardHandlerE4.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/defaultHandler/e4/DefaultOpenTaxonNodeWizardHandlerE4.java
@@ -18,6 +18,7 @@ import org.eclipse.swt.widgets.Shell;
 import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
 import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
 import eu.etaxonomy.cdm.model.taxon.TaxonNode;
+import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
 import eu.etaxonomy.taxeditor.event.EventUtility;
 import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
@@ -43,7 +44,7 @@ public class DefaultOpenTaxonNodeWizardHandlerE4 extends DefaultOpenHandlerBaseE
         taxonNodeWizard.setEntity(entity);
         WizardDialog dialog = new WizardDialog(shell, taxonNodeWizard);
         dialog.open();
-        EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAVIGATOR, true);
+        EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAVIGATOR, new TaxonNodeDto(entity));
 
     }
 
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonBaseDetailElement.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonBaseDetailElement.java
index 62fce8bd7..6ecbb3272 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonBaseDetailElement.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonBaseDetailElement.java
@@ -75,7 +75,7 @@ public class TaxonBaseDetailElement extends AbstractIdentifiableEntityDetailElem
 
 
 
-		selection_secundum = formFactory.createSelectionElement(Reference.class,//getConversationHolder(),
+		selection_secundum = formFactory.createSelectionElement(Reference.class,
 				 formElement, "Secundum",
 				entity.getSec(), EntitySelectionElement.ALL,
 				style);
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmEditorPartE4.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmEditorPartE4.java
index 59f91b165..bb3abcece 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmEditorPartE4.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmEditorPartE4.java
@@ -8,6 +8,7 @@
 */
 package eu.etaxonomy.taxeditor.view.e4;
 
+import java.util.Collection;
 import java.util.Set;
 
 import javax.annotation.PreDestroy;
@@ -28,6 +29,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.viewers.Viewer;
 import org.eclipse.swt.SWTException;
+import org.springframework.security.core.GrantedAuthority;
 
 import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
 import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
@@ -223,6 +225,19 @@ public abstract class AbstractCdmEditorPartE4
                         if (node != null){
                             boolean doEnable = CdmStore.currentAuthentiationHasPermission(node,
                                     RequiredPermissions.TAXON_EDIT);
+                             if (!doEnable){
+                                 //check whether there are explicit TaxonNode rights
+                                 boolean taxonnodePermissionExists = false;
+                                 Collection<? extends GrantedAuthority> authorities = CdmStore.getCurrentAuthentiation().getAuthorities();
+                                 for (GrantedAuthority grantedAuthority: authorities){
+                                     if (grantedAuthority.getAuthority().startsWith("TAXONNODE")){
+                                         taxonnodePermissionExists = true;
+                                     }
+                                 }
+                                 if (!taxonnodePermissionExists){
+                                     doEnable = true;
+                                 }
+                             }
 
                             //TODO: differ between the views
                             this.isEnabled = doEnable;
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsPartE4.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsPartE4.java
index 57597159f..5b0229b18 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsPartE4.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsPartE4.java
@@ -107,7 +107,7 @@ public class DetailsPartE4 extends AbstractCdmEditorPartE4 implements IPartConte
             showViewer(structuredSelection, activePart, viewer);
             if (viewer instanceof DetailsViewerE4){
 
-                ((DetailsViewerE4)viewer).setDetailsEnabled(isEnabled());
+//                ((DetailsViewerE4)viewer).setDetailsEnabled(isEnabled());
             }
 
 
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsViewerE4.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsViewerE4.java
old mode 100755
new mode 100644
index 7f274424b..4046ab9bb
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsViewerE4.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsViewerE4.java
@@ -9,6 +9,7 @@
 
 package eu.etaxonomy.taxeditor.view.e4.details;
 
+import java.util.Collection;
 import java.util.EnumSet;
 import java.util.HashSet;
 import java.util.Set;
@@ -22,6 +23,7 @@ import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.jface.viewers.TreeNode;
 import org.eclipse.swt.SWT;
+import org.springframework.security.core.GrantedAuthority;
 
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
@@ -455,6 +457,19 @@ public class DetailsViewerE4 extends AbstractCdmDataViewerE4 {
         if (hasPermission){
             for (TaxonNode node: nodes){
                 hasPermission &= CdmStore.currentAuthentiationHasPermission(node, requiredCrud);
+                if (!hasPermission){
+                    //check whether there are explicit TaxonNode rights
+                    boolean taxonnodePermissionExists = false;
+                    Collection<? extends GrantedAuthority> authorities = CdmStore.getCurrentAuthentiation().getAuthorities();
+                    for (GrantedAuthority grantedAuthority: authorities){
+                        if (grantedAuthority.getAuthority().startsWith("TAXONNODE")){
+                            taxonnodePermissionExists = true;
+                        }
+                    }
+                    if (!taxonnodePermissionExists){
+                        hasPermission = true;
+                    }
+                }
             }
         }
         detailsEnabled = hasPermission;
