+ NameDetailsConfigurator config = PreferencesUtil.getPreferredNameDetailsConfiguration();
+ EnumSet<CRUD> requiredCrud;
+ if(getInput() == null || StoreUtil.getCdmEntity(getInput()).getId() == 0) {
+ // new entity, not yet saved
+ requiredCrud = EnumSet.of(CRUD.CREATE);
+ } else {
+ requiredCrud = EnumSet.of(CRUD.UPDATE);
+ }
+ boolean hasPermission = CdmStore.currentAuthentiationHasPermission(StoreUtil.getCdmEntity(getInput()), requiredCrud);
+ if (hasPermission){
+ // check for subtree permissions as well.
+ TaxonBase<?> taxonBase = (TaxonBase<?>)getInput();
+ Taxon acceptedTaxon = null;
+ if (taxonBase instanceof Taxon){
+ acceptedTaxon = (Taxon)taxonBase;
+ }else{
+ acceptedTaxon = ((Synonym)taxonBase).getAcceptedTaxon();
+ }
+ if (acceptedTaxon != null){ //needs discussion if synonyms without accepted taxon should never be filtered by subtree permission(current implementation). See also #8849
+ Set<TaxonNode> nodes = acceptedTaxon.getTaxonNodes();
+ 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;