Project

General

Profile

Revision fe9e440d

IDfe9e440df61646b8813e71e046c7a2a07fdbfa0d
Parent 9ffe52d4
Child 8e6b3b25

Added by Katja Luther 7 months ago

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

View differences:

eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/name/e4/TaxonNameEditorE4.java
67 67
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
68 68
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
69 69
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship;
70
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
70 71
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
71 72
import eu.etaxonomy.taxeditor.editor.AppModelId;
72 73
import eu.etaxonomy.taxeditor.editor.CdmDataTransfer;
......
431 432
        conversation.commit(true);
432 433

  
433 434
        dirty.setDirty(false);
434
        EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAVIGATOR, true);
435
        EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAVIGATOR, new TaxonNodeDto(input.getTaxonNode()));
435 436
        EventUtility.postEvent(WorkbenchEventConstants.SAVE_TAXON, true);
436 437
        // Stop the progress monitor.
437 438
        monitor.done();
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/handler/defaultHandler/e4/DefaultOpenTaxonNodeWizardHandlerE4.java
18 18
import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
19 19
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
20 20
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
21
import eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto;
21 22
import eu.etaxonomy.taxeditor.event.EventUtility;
22 23
import eu.etaxonomy.taxeditor.event.WorkbenchEventConstants;
23 24
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
......
43 44
        taxonNodeWizard.setEntity(entity);
44 45
        WizardDialog dialog = new WizardDialog(shell, taxonNodeWizard);
45 46
        dialog.open();
46
        EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAVIGATOR, true);
47
        EventUtility.postEvent(WorkbenchEventConstants.REFRESH_NAVIGATOR, new TaxonNodeDto(entity));
47 48

  
48 49
    }
49 50

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/taxon/TaxonBaseDetailElement.java
75 75

  
76 76

  
77 77

  
78
		selection_secundum = formFactory.createSelectionElement(Reference.class,//getConversationHolder(),
78
		selection_secundum = formFactory.createSelectionElement(Reference.class,
79 79
				 formElement, "Secundum",
80 80
				entity.getSec(), EntitySelectionElement.ALL,
81 81
				style);
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/AbstractCdmEditorPartE4.java
8 8
*/
9 9
package eu.etaxonomy.taxeditor.view.e4;
10 10

  
11
import java.util.Collection;
11 12
import java.util.Set;
12 13

  
13 14
import javax.annotation.PreDestroy;
......
28 29
import org.eclipse.jface.viewers.StructuredSelection;
29 30
import org.eclipse.jface.viewers.Viewer;
30 31
import org.eclipse.swt.SWTException;
32
import org.springframework.security.core.GrantedAuthority;
31 33

  
32 34
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
33 35
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
......
223 225
                        if (node != null){
224 226
                            boolean doEnable = CdmStore.currentAuthentiationHasPermission(node,
225 227
                                    RequiredPermissions.TAXON_EDIT);
228
                             if (!doEnable){
229
                                 //check whether there are explicit TaxonNode rights
230
                                 boolean taxonnodePermissionExists = false;
231
                                 Collection<? extends GrantedAuthority> authorities = CdmStore.getCurrentAuthentiation().getAuthorities();
232
                                 for (GrantedAuthority grantedAuthority: authorities){
233
                                     if (grantedAuthority.getAuthority().startsWith("TAXONNODE")){
234
                                         taxonnodePermissionExists = true;
235
                                     }
236
                                 }
237
                                 if (!taxonnodePermissionExists){
238
                                     doEnable = true;
239
                                 }
240
                             }
226 241

  
227 242
                            //TODO: differ between the views
228 243
                            this.isEnabled = doEnable;
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsPartE4.java
107 107
            showViewer(structuredSelection, activePart, viewer);
108 108
            if (viewer instanceof DetailsViewerE4){
109 109

  
110
                ((DetailsViewerE4)viewer).setDetailsEnabled(isEnabled());
110
//                ((DetailsViewerE4)viewer).setDetailsEnabled(isEnabled());
111 111
            }
112 112

  
113 113

  
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/e4/details/DetailsViewerE4.java
9 9

  
10 10
package eu.etaxonomy.taxeditor.view.e4.details;
11 11

  
12
import java.util.Collection;
12 13
import java.util.EnumSet;
13 14
import java.util.HashSet;
14 15
import java.util.Set;
......
22 23
import org.eclipse.jface.viewers.SelectionChangedEvent;
23 24
import org.eclipse.jface.viewers.TreeNode;
24 25
import org.eclipse.swt.SWT;
26
import org.springframework.security.core.GrantedAuthority;
25 27

  
26 28
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
27 29
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeNotSupportedException;
......
455 457
        if (hasPermission){
456 458
            for (TaxonNode node: nodes){
457 459
                hasPermission &= CdmStore.currentAuthentiationHasPermission(node, requiredCrud);
460
                if (!hasPermission){
461
                    //check whether there are explicit TaxonNode rights
462
                    boolean taxonnodePermissionExists = false;
463
                    Collection<? extends GrantedAuthority> authorities = CdmStore.getCurrentAuthentiation().getAuthorities();
464
                    for (GrantedAuthority grantedAuthority: authorities){
465
                        if (grantedAuthority.getAuthority().startsWith("TAXONNODE")){
466
                            taxonnodePermissionExists = true;
467
                        }
468
                    }
469
                    if (!taxonnodePermissionExists){
470
                        hasPermission = true;
471
                    }
472
                }
458 473
            }
459 474
        }
460 475
        detailsEnabled = hasPermission;

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)