Project

General

Profile

Revision 37f70555

ID37f70555ea9d0cce385e8e0a6b65c78cb14bc8ef
Parent 9d35d224
Child a2728ed2

Added by Andreas Kohlbecker about 2 years ago

ref #7550 moving the actual CdmUserHelper to cdmlib and making it available in cdm-vaadin by extending the UserHelper class and interface hierarchy

View differences:

src/main/java/eu/etaxonomy/cdm/persistence/hibernate/GrantedAuthorityRevokingRegistrationUpdateLister.java
97 97
    /**
98 98
     * Walks the entity graph of the Registration instance and collects all authorities which
99 99
     * could have been granted to users. Code parts in which this could have happened can be
100
     * found by searching for usage of the methods {@link eu.etaxonomy.cdm.vaadin.permission.UserHelper#createAuthorityForCurrentUser(eu.etaxonomy.cdm.model.common.CdmBase, EnumSet, String)
101
     * UserHelper.createAuthorityForCurrentUser(eu.etaxonomy.cdm.model.common.CdmBase, EnumSet, String)} and {@link eu.etaxonomy.cdm.vaadin.permission.UserHelper#createAuthorityForCurrentUser(Class, Integer, EnumSet, String)
102
     * UserHelper.createAuthorityForCurrentUser(Class, Integer, EnumSet, String)}
100
     * found by searching for usage of the methods {@link eu.etaxonomy.cdm.vaadin.permission.VaadinUserHelper#createAuthorityForCurrentUser(eu.etaxonomy.cdm.model.common.CdmBase, EnumSet, String)
101
     * VaadinUserHelper.createAuthorityForCurrentUser(eu.etaxonomy.cdm.model.common.CdmBase, EnumSet, String)} and {@link eu.etaxonomy.cdm.vaadin.permission.VaadinUserHelper#createAuthorityForCurrentUser(Class, Integer, EnumSet, String)
102
     * VaadinUserHelper.createAuthorityForCurrentUser(Class, Integer, EnumSet, String)}
103 103
     * <p>
104 104
     * At the time of implementing this function these places are:
105 105
     * <ul>
src/main/java/eu/etaxonomy/cdm/service/VaadinCdmUserHelper.java
1
/**
2
* Copyright (C) 2017 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.service;
10

  
11
import java.io.Serializable;
12
import java.util.Collection;
13
import java.util.EnumSet;
14
import java.util.UUID;
15

  
16
import org.apache.log4j.Logger;
17
import org.springframework.beans.factory.annotation.Autowired;
18
import org.springframework.beans.factory.annotation.Qualifier;
19
import org.springframework.security.core.Authentication;
20
import org.springframework.security.core.context.SecurityContext;
21
import org.springframework.security.core.context.SecurityContextHolder;
22

  
23
import com.vaadin.spring.annotation.SpringComponent;
24
import com.vaadin.spring.annotation.UIScope;
25

  
26
import eu.etaxonomy.cdm.api.utility.SecurityContextAccess;
27
import eu.etaxonomy.cdm.api.utility.UserHelper;
28
import eu.etaxonomy.cdm.model.common.CdmBase;
29
import eu.etaxonomy.cdm.model.common.User;
30
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
31
import eu.etaxonomy.cdm.persistence.hibernate.permission.CdmAuthority;
32
import eu.etaxonomy.cdm.vaadin.permission.AbstractVaadinUserHelper;
33
import eu.etaxonomy.cdm.vaadin.permission.RolesAndPermissions;
34

  
35
/**
36
 * @author a.kohlbecker
37
 * @since May 19, 2017
38
 *
39
 */
40
@SpringComponent
41
@UIScope
42
public class VaadinCdmUserHelper extends AbstractVaadinUserHelper implements SecurityContextAccess, Serializable {
43

  
44
    private static final long serialVersionUID = -2521474709047255979L;
45

  
46
    public static final Logger logger = Logger.getLogger(VaadinCdmUserHelper.class);
47

  
48
    private UserHelper userHelper;
49
    @Autowired
50
    @Qualifier("cdmUserHelper")
51
    public void setUserHelper(UserHelper userHelper){
52
        this.userHelper = userHelper;
53
        userHelper.setSecurityContextAccess(this);
54
    }
55

  
56
    public VaadinCdmUserHelper(){
57
        super();
58

  
59
    }
60

  
61
    @Override
62
    public boolean userIsAutheticated() {
63
        return userHelper.userIsAutheticated();
64
    }
65

  
66

  
67
    @Override
68
    public boolean userIsAnnonymous() {
69
        return userHelper.userIsAnnonymous();
70
    }
71

  
72
    @Override
73
    public User user() {
74
        return userHelper.user();
75
    }
76

  
77
    @Override
78
    public String userName() {
79
        return userHelper.userName();
80
    }
81

  
82
    @Override
83
    public boolean userIsAdmin() {
84
        return userHelper.userIsAdmin();
85
    }
86

  
87
    @Override
88
    public boolean userIsRegistrationCurator() {
89
        Authentication authentication = userHelper.getAuthentication();
90
        if(authentication != null) {
91
            return authentication.getAuthorities().stream().anyMatch(a -> {
92
                return a.equals(RolesAndPermissions.ROLE_CURATION)
93
                        // doing faster regex check here instreas of using CdmAuthoritiy.fromString()
94
                        || a.getAuthority().matches("^Registration\\.\\[.*UPDATE");
95
            });
96
        }
97
        return false;
98
    }
99

  
100
    @Override
101
    public boolean userHasPermission(CdmBase entity, Object ... args){
102
        return userHelper.userHasPermission(entity, args);
103
    }
104

  
105
    @Override
106
    public boolean userHasPermission(Class<? extends CdmBase> cdmType, Integer entitiyId, Object ... args){
107
        return userHelper.userHasPermission(cdmType, entitiyId, args);
108
    }
109

  
110
    @Override
111
    public boolean userHasPermission(Class<? extends CdmBase> cdmType, UUID entitiyUuid, Object ... args){
112
        return userHelper.userHasPermission(cdmType, entitiyUuid, args);
113
    }
114

  
115
    @Override
116
    public boolean userHasPermission(Class<? extends CdmBase> cdmType, Object ... args){
117
        return userHelper.userHasPermission(cdmType, args);
118
    }
119

  
120
    @Override
121
    public void logout() {
122
        userHelper.logout();
123
    }
124

  
125

  
126
    /**
127
     * @return
128
     *
129
     * FIXME is it ok to use the SecurityContextHolder or do we need to hold the context in the vaadin session?
130
     */
131
    @Override
132
    public SecurityContext currentSecurityContext() {
133
        return SecurityContextHolder.getContext();
134
    }
135

  
136

  
137
    @Override
138
    public CdmAuthority createAuthorityFor(String username, CdmBase cdmEntity, EnumSet<CRUD> crud, String property) {
139
        return userHelper.createAuthorityFor(username, cdmEntity, crud, property);
140
    }
141

  
142

  
143
    @Override
144
    public CdmAuthority createAuthorityFor(String username, Class<? extends CdmBase> cdmType, Integer entitiyId, EnumSet<CRUD> crud, String property) {
145
        return userHelper.createAuthorityFor(username, cdmType, entitiyId, crud, property);
146
    }
147

  
148

  
149
    @Override
150
    public CdmAuthority createAuthorityFor(String username, Class<? extends CdmBase> cdmType, UUID entitiyUuid, EnumSet<CRUD> crud, String property) {
151
        return userHelper.createAuthorityFor(username, cdmType, entitiyUuid, crud, property);
152
    }
153

  
154

  
155
    @Override
156
    public CdmAuthority createAuthorityForCurrentUser(CdmBase cdmEntity, EnumSet<CRUD> crud, String property) {
157
        return userHelper.createAuthorityForCurrentUser(cdmEntity, crud, property);
158

  
159
    }
160

  
161

  
162
    @Override
163
    public CdmAuthority createAuthorityForCurrentUser(Class<? extends CdmBase> cdmType, Integer entitiyId, EnumSet<CRUD> crud, String property) {
164
        return createAuthorityFor(userName(), cdmType, entitiyId, crud, property);
165
    }
166

  
167

  
168
    @Override
169
    public CdmAuthority createAuthorityForCurrentUser(Class<? extends CdmBase> cdmType, UUID entitiyUuid, EnumSet<CRUD> crud, String property) {
170
        return userHelper.createAuthorityForCurrentUser(cdmType, entitiyUuid, crud, property);
171
    }
172

  
173

  
174
    @Override
175
    public void removeAuthorityForCurrentUser(CdmAuthority cdmAuthority) {
176
        userHelper.removeAuthorityForCurrentUser(cdmAuthority);
177
    }
178

  
179

  
180
    @Override
181
    public void removeAuthorityForCurrentUser(String username, CdmAuthority cdmAuthority) {
182
        userHelper.removeAuthorityForCurrentUser(username, cdmAuthority);
183
    }
184

  
185

  
186
    @Override
187
    public Collection<CdmAuthority> findUserPermissions(CdmBase cdmEntity, EnumSet<CRUD> crud) {
188
        return userHelper.findUserPermissions(cdmEntity, crud);
189
    }
190

  
191
    /**
192
     * {@inheritDoc}
193
     */
194
    @Override
195
    public void setSecurityContextAccess(SecurityContextAccess securityContextAccess) {
196
        userHelper.setSecurityContextAccess(securityContextAccess);
197
    }
198

  
199
    /**
200
     * {@inheritDoc}
201
     */
202
    @Override
203
    public Authentication getAuthentication() {
204
        return userHelper.getAuthentication();
205
    }
206

  
207
}
src/main/java/eu/etaxonomy/cdm/vaadin/component/common/PersonField.java
30 30
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
31 31
import eu.etaxonomy.cdm.vaadin.component.ButtonFactory;
32 32
import eu.etaxonomy.cdm.vaadin.component.TextFieldNFix;
33
import eu.etaxonomy.cdm.vaadin.permission.UserHelper;
33
import eu.etaxonomy.cdm.vaadin.permission.VaadinUserHelper;
34 34
import eu.etaxonomy.vaadin.component.CompositeCustomField;
35 35
import eu.etaxonomy.vaadin.component.SwitchButton;
36 36

  
......
132 132
     *
133 133
     */
134 134
    private void checkUserPermissions(Person newValue) {
135
        boolean userCanEdit = newValue == null || !newValue.isPersited() || UserHelper.fromSession().userHasPermission(newValue, "DELETE", "UPDATE");
135
        boolean userCanEdit = newValue == null || !newValue.isPersited() || VaadinUserHelper.fromSession().userHasPermission(newValue, "DELETE", "UPDATE");
136 136
        setEnabled(userCanEdit);
137 137
    }
138 138

  
......
368 368
            }
369 369
            boolean isUnsaved = bean.getId() == 0;
370 370
            if(isUnsaved && !(hasNullContent() && !allowNewEmptyEntity)){
371
                UserHelper.fromSession().createAuthorityForCurrentUser(bean, EnumSet.of(CRUD.UPDATE, CRUD.DELETE), null);
371
                VaadinUserHelper.fromSession().createAuthorityForCurrentUser(bean, EnumSet.of(CRUD.UPDATE, CRUD.DELETE), null);
372 372
            }
373 373
        }
374 374
    }
src/main/java/eu/etaxonomy/cdm/vaadin/component/common/TeamOrPersonField.java
36 36
import eu.etaxonomy.cdm.service.CdmFilterablePagingProvider;
37 37
import eu.etaxonomy.cdm.vaadin.component.ButtonFactory;
38 38
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityReloader;
39
import eu.etaxonomy.cdm.vaadin.permission.UserHelper;
39
import eu.etaxonomy.cdm.vaadin.permission.VaadinUserHelper;
40 40
import eu.etaxonomy.cdm.vaadin.util.TeamOrPersonBaseCaptionGenerator;
41 41
import eu.etaxonomy.cdm.vaadin.util.converter.CdmBaseDeproxyConverter;
42 42
import eu.etaxonomy.cdm.vaadin.view.name.CachingPresenter;
......
160 160

  
161 161
    private void updateToolBarButtonStates(){
162 162
        TeamOrPersonBase<?> val = getInternalValue();
163
        boolean userCanCreate = UserHelper.fromSession().userHasPermission(Person.class, "CREATE");
163
        boolean userCanCreate = VaadinUserHelper.fromSession().userHasPermission(Person.class, "CREATE");
164 164

  
165 165
        teamOrPersonSelect.setVisible(val == null);
166 166
        if(teamOrPersonSelect.getValue() != val){
......
239 239

  
240 240
    private void adaptToUserPermissions(TeamOrPersonBase teamOrPerson) {
241 241

  
242
        UserHelper userHelper = UserHelper.fromSession();
242
        VaadinUserHelper userHelper = VaadinUserHelper.fromSession();
243 243
        boolean canEdit = teamOrPerson == null || !teamOrPerson.isPersited() || userHelper.userHasPermission(teamOrPerson, CRUD.UPDATE);
244 244
        if(!canEdit){
245 245
            getPropertyDataSource().setReadOnly(true);
......
304 304
        if(bean != null && bean instanceof Team){
305 305
            boolean isUnsaved = bean.getId() == 0;
306 306
            if(isUnsaved){
307
                UserHelper.fromSession().createAuthorityForCurrentUser(bean, EnumSet.of(CRUD.UPDATE, CRUD.DELETE), null);
307
                VaadinUserHelper.fromSession().createAuthorityForCurrentUser(bean, EnumSet.of(CRUD.UPDATE, CRUD.DELETE), null);
308 308
            }
309 309
        }
310 310
    }
src/main/java/eu/etaxonomy/cdm/vaadin/component/distributionStatus/DistributionToolbar.java
19 19

  
20 20
import eu.etaxonomy.cdm.api.application.CdmRepository;
21 21
import eu.etaxonomy.cdm.i18n.Messages;
22
import eu.etaxonomy.cdm.service.CdmUserHelper;
22
import eu.etaxonomy.cdm.service.VaadinCdmUserHelper;
23 23
import eu.etaxonomy.cdm.vaadin.event.AuthenticationSuccessEvent;
24 24
import eu.etaxonomy.vaadin.ui.navigation.NavigationEvent;
25 25
import eu.etaxonomy.vaadin.ui.navigation.NavigationManager;
......
52 52
    private NavigationManager navigationManager;
53 53

  
54 54
    @Autowired
55
    private CdmUserHelper userHelper;
55
    private VaadinCdmUserHelper userHelper;
56 56

  
57 57
    private final Button loginButton = new Button(Messages.getLocalizedString(Messages.DistributionToolbar_LOGIN));
58 58

  
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationItem.java
35 35
import com.vaadin.ui.themes.ValoTheme;
36 36

  
37 37
import eu.etaxonomy.cdm.api.service.dto.RegistrationDTO;
38
import eu.etaxonomy.cdm.api.service.dto.RegistrationWorkingSet;
38 39
import eu.etaxonomy.cdm.model.common.TimePeriod;
39 40
import eu.etaxonomy.cdm.model.name.RegistrationStatus;
40 41
import eu.etaxonomy.cdm.model.reference.Reference;
41 42
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
42 43
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction;
43 44
import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent;
44
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet;
45 45
import eu.etaxonomy.cdm.vaadin.permission.PermissionDebugUtils;
46
import eu.etaxonomy.cdm.vaadin.permission.UserHelper;
46
import eu.etaxonomy.cdm.vaadin.permission.VaadinUserHelper;
47 47
import eu.etaxonomy.cdm.vaadin.theme.EditValoTheme;
48 48
import eu.etaxonomy.cdm.vaadin.util.formatter.DateTimeFormat;
49 49
import eu.etaxonomy.cdm.vaadin.util.formatter.TimePeriodFormatter;
......
207 207

  
208 208
        ReferenceEditorAction referenceEditorAction = null;
209 209
        if(workingSet.getCitationUuid() != null){
210
            if(UserHelper.fromSession().userHasPermission(Reference.class, workingSet.getCitationUuid(), CRUD.UPDATE)){
210
            if(VaadinUserHelper.fromSession().userHasPermission(Reference.class, workingSet.getCitationUuid(), CRUD.UPDATE)){
211 211
                referenceEditorAction = new ReferenceEditorAction(EditorActionType.EDIT, workingSet.getCitationUuid(), null, null, parentView);
212 212
            }
213 213
            PermissionDebugUtils.addGainPerEntityPermissionButton(this, Reference.class, workingSet.getCitationUuid(), EnumSet.of(CRUD.UPDATE, CRUD.DELETE), null);
214 214
        } else {
215
            if(UserHelper.fromSession().userHasPermission(Reference.class, CRUD.CREATE, null, null, parentView)){
215
            if(VaadinUserHelper.fromSession().userHasPermission(Reference.class, CRUD.CREATE, null, null, parentView)){
216 216
                referenceEditorAction = new ReferenceEditorAction(EditorActionType.ADD);
217 217
            }
218 218
        }
src/main/java/eu/etaxonomy/cdm/vaadin/component/registration/RegistrationItemNameAndTypeButtons.java
33 33
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
34 34
import eu.etaxonomy.cdm.vaadin.component.ButtonFactory;
35 35
import eu.etaxonomy.cdm.vaadin.permission.PermissionDebugUtils;
36
import eu.etaxonomy.cdm.vaadin.permission.UserHelper;
36
import eu.etaxonomy.cdm.vaadin.permission.VaadinUserHelper;
37 37
import eu.etaxonomy.vaadin.component.CompositeStyledComponent;
38 38

  
39 39
/**
......
78 78
            nameIdButton = new IdButton<TaxonName>(TaxonName.class, regDto.getNameRef().getUuid(), nameButton);
79 79
            Label nameLabel = new Label(regDto.getNameRef().getLabel());
80 80
            nameLabel.setWidthUndefined();
81
            boolean userHasPermission = UserHelper.fromSession().userHasPermission(regDto.registration().getName(), CRUD.UPDATE);
81
            boolean userHasPermission = VaadinUserHelper.fromSession().userHasPermission(regDto.registration().getName(), CRUD.UPDATE);
82 82
            nameButton.setReadOnly(isRegistrationLocked || ! userHasPermission);
83 83

  
84 84
            addComponent(nameIdButton.getButton());
......
92 92
                addComponent(nameLabel);
93 93
            }
94 94
        }
95
        boolean userHasAddPermission = UserHelper.fromSession().userHasPermission(Registration.class, regDto.getUuid(), CRUD.UPDATE);
95
        boolean userHasAddPermission = VaadinUserHelper.fromSession().userHasPermission(Registration.class, regDto.getUuid(), CRUD.UPDATE);
96 96
        if(regDto.getOrderdTypeDesignationWorkingSets() != null){
97 97
            for(TypedEntityReference<TypeDesignationBase<?>> baseEntityRef : regDto.getOrderdTypeDesignationWorkingSets().keySet()) {
98 98
                TypeDesignationWorkingSet typeDesignationWorkingSet = regDto.getOrderdTypeDesignationWorkingSets().get(baseEntityRef);
......
100 100
                String buttonLabel = SpecimenOrObservationBase.class.isAssignableFrom(baseEntityRef.getType()) ? "Type": "NameType";
101 101
                Button tdButton = new Button(buttonLabel + ":");
102 102
                tdButton.setDescription("Edit the type designation working set");
103
                boolean userHasUpdatePermission = UserHelper.fromSession().userHasPermission(baseEntityRef.getType(), baseEntityRef.getUuid(), CRUD.UPDATE, CRUD.DELETE);
103
                boolean userHasUpdatePermission = VaadinUserHelper.fromSession().userHasPermission(baseEntityRef.getType(), baseEntityRef.getUuid(), CRUD.UPDATE, CRUD.DELETE);
104 104
                tdButton.setReadOnly(isRegistrationLocked || !userHasUpdatePermission);
105 105
                addComponent(tdButton);
106 106

  
src/main/java/eu/etaxonomy/cdm/vaadin/event/ToOneRelatedEntityButtonUpdater.java
12 12

  
13 13
import eu.etaxonomy.cdm.model.common.CdmBase;
14 14
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
15
import eu.etaxonomy.cdm.vaadin.permission.UserHelper;
15
import eu.etaxonomy.cdm.vaadin.permission.VaadinUserHelper;
16 16
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityField;
17 17

  
18 18
/**
......
43 43

  
44 44
        CdmBase value = (CdmBase)event.getProperty().getValue();
45 45

  
46
        boolean userIsAllowedToUpdate = value != null && UserHelper.fromSession().userHasPermission(value, CRUD.UPDATE);
47
        boolean userIsAllowedToCreate = UserHelper.fromSession().userHasPermission(type, CRUD.CREATE);
46
        boolean userIsAllowedToUpdate = value != null && VaadinUserHelper.fromSession().userHasPermission(value, CRUD.UPDATE);
47
        boolean userIsAllowedToCreate = VaadinUserHelper.fromSession().userHasPermission(type, CRUD.CREATE);
48 48

  
49 49
        toOneRelatedEntityField.setAddButtonEnabled(userIsAllowedToCreate);
50 50
        toOneRelatedEntityField.setEditButtonEnabled(userIsAllowedToUpdate);
src/main/java/eu/etaxonomy/cdm/vaadin/permission/AbstractVaadinUserHelper.java
1
/**
2
* Copyright (C) 2017 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 com.vaadin.server.VaadinSession;
12

  
13
/**
14
 * Abstract VaadinUserHelper which auto registers in the VaadinSession.
15
 *
16
 * @author a.kohlbecker
17
 * @since May 23, 2017
18
 *
19
 */
20
public abstract class AbstractVaadinUserHelper implements VaadinUserHelper {
21

  
22
    public AbstractVaadinUserHelper() {
23
        VaadinSession.getCurrent().setAttribute(VADDIN_SESSION_KEY, this);
24
    }
25

  
26

  
27
}
src/main/java/eu/etaxonomy/cdm/vaadin/permission/CdmEditDeletePermissionTester.java
22 22
public class CdmEditDeletePermissionTester implements EditPermissionTester {
23 23
    @Override
24 24
    public boolean userHasEditPermission(Object bean) {
25
        return  UserHelper.fromSession().userHasPermission((CdmBase)bean, CRUD.UPDATE, CRUD.DELETE);
25
        return  VaadinUserHelper.fromSession().userHasPermission((CdmBase)bean, CRUD.UPDATE, CRUD.DELETE);
26 26
    }
27 27
}
src/main/java/eu/etaxonomy/cdm/vaadin/permission/PermissionDebugUtils.java
82 82
    public Button gainPerEntityPermissionButton(Class<? extends CdmBase> cdmType, UUID entitiyUuid, EnumSet<CRUD> crud, String property){
83 83

  
84 84
       Button button = new Button(FontAwesome.BOLT);
85
       button.addClickListener(e -> UserHelper.fromSession().createAuthorityFor(UserHelper.fromSession().userName(), cdmType, entitiyUuid, crud, property));
85
       button.addClickListener(e -> VaadinUserHelper.fromSession().createAuthorityFor(VaadinUserHelper.fromSession().userName(), cdmType, entitiyUuid, crud, property));
86 86
       button.addStyleName(ValoTheme.BUTTON_DANGER);
87 87
       return button;
88 88

  
src/main/java/eu/etaxonomy/cdm/vaadin/permission/VaadinUserHelper.java
10 10

  
11 11
import com.vaadin.server.VaadinSession;
12 12

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

  
13 15
/**
14
 * Abstract UserHelper which auto registers in the VaadinSession.
16
 * VaadinUserHelper interface. Implementations should use the {@link #VADDIN_SESSION_KEY} to auto registers
17
 * in the VaadinSession.
15 18
 *
16 19
 * @author a.kohlbecker
17 20
 * @since May 23, 2017
18 21
 *
19 22
 */
20
public abstract class VaadinUserHelper implements UserHelper {
23
public interface VaadinUserHelper extends UserHelper {
24

  
25
    public static final String VADDIN_SESSION_KEY = "USER_HELPER";
21 26

  
22
    public VaadinUserHelper() {
23
        VaadinSession.getCurrent().setAttribute(VADDIN_SESSION_KEY, this);
27
    /**
28
     * Static accessor method to obtain the auto-registered VaadinUserHelper-Bean from the
29
     * VaadinSession.
30
     *
31
     * @return
32
     */
33
    public static VaadinUserHelper fromSession() {
34
       return (VaadinUserHelper)VaadinSession.getCurrent().getAttribute(VADDIN_SESSION_KEY);
24 35
    }
25 36

  
37
    // ---- methods special to the registration ------------
38

  
39
    public boolean userIsRegistrationCurator();
40

  
41

  
26 42
}
src/main/java/eu/etaxonomy/cdm/vaadin/toolbar/RegistrationToolbar.java
24 24
import com.vaadin.ui.themes.ValoTheme;
25 25

  
26 26
import eu.etaxonomy.cdm.api.application.CdmRepository;
27
import eu.etaxonomy.cdm.service.CdmUserHelper;
27
import eu.etaxonomy.cdm.service.VaadinCdmUserHelper;
28 28
import eu.etaxonomy.cdm.vaadin.event.AuthenticationSuccessEvent;
29 29
import eu.etaxonomy.vaadin.ui.navigation.NavigationEvent;
30 30
import eu.etaxonomy.vaadin.ui.navigation.NavigationManager;
......
57 57
    protected NavigationManager navigationManager;
58 58

  
59 59
    @Autowired
60
    CdmUserHelper userHelper;
60
    VaadinCdmUserHelper userHelper;
61 61

  
62 62
    CssLayout buttonGroup = new CssLayout();
63 63
    Button messageButton;
src/main/java/eu/etaxonomy/cdm/vaadin/view/distributionStatus/DistributionTablePresenter.java
51 51
import eu.etaxonomy.cdm.model.taxon.Classification;
52 52
import eu.etaxonomy.cdm.model.taxon.Taxon;
53 53
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
54
import eu.etaxonomy.cdm.service.CdmUserHelper;
54
import eu.etaxonomy.cdm.service.VaadinCdmUserHelper;
55 55
import eu.etaxonomy.cdm.vaadin.container.CdmSQLContainer;
56 56
import eu.etaxonomy.cdm.vaadin.container.PresenceAbsenceTermContainer;
57 57
import eu.etaxonomy.cdm.vaadin.util.CdmQueryFactory;
......
72 72
	private static final long serialVersionUID = 3313043335587777217L;
73 73

  
74 74
    @Autowired
75
    private CdmUserHelper userHelper;
75
    private VaadinCdmUserHelper userHelper;
76 76

  
77 77
    @Autowired
78 78
    @Qualifier("cdmRepository")
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/NameTypeDesignationPresenter.java
25 25
import eu.etaxonomy.cdm.api.service.IService;
26 26
import eu.etaxonomy.cdm.api.service.dto.RegistrationDTO;
27 27
import eu.etaxonomy.cdm.api.service.name.TypeDesignationSetManager.TypeDesignationWorkingSet;
28
import eu.etaxonomy.cdm.api.service.registration.IRegistrationWorkingSetService;
28 29
import eu.etaxonomy.cdm.model.common.Annotation;
29 30
import eu.etaxonomy.cdm.model.name.NameTypeDesignation;
30 31
import eu.etaxonomy.cdm.model.name.NameTypeDesignationStatus;
......
33 34
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
34 35
import eu.etaxonomy.cdm.service.CdmFilterablePagingProvider;
35 36
import eu.etaxonomy.cdm.service.CdmStore;
36
import eu.etaxonomy.cdm.service.IRegistrationWorkingSetService;
37 37
import eu.etaxonomy.cdm.vaadin.component.CdmBeanItemContainerFactory;
38 38
import eu.etaxonomy.cdm.vaadin.event.EditorActionTypeFilter;
39 39
import eu.etaxonomy.cdm.vaadin.event.EntityChangeEvent;
......
41 41
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction;
42 42
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityButtonUpdater;
43 43
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityReloader;
44
import eu.etaxonomy.cdm.vaadin.permission.UserHelper;
44
import eu.etaxonomy.cdm.vaadin.permission.VaadinUserHelper;
45 45
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator;
46 46
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter;
47 47
import eu.etaxonomy.vaadin.mvp.AbstractView;
......
159 159
    @Override
160 160
    protected void guaranteePerEntityCRUDPermissions(UUID identifier) {
161 161
        if(crud != null){
162
            newAuthorityCreated = UserHelper.fromSession().createAuthorityForCurrentUser(NameTypeDesignation.class, identifier, crud, null);
162
            newAuthorityCreated = VaadinUserHelper.fromSession().createAuthorityForCurrentUser(NameTypeDesignation.class, identifier, crud, null);
163 163
        }
164 164
    }
165 165

  
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/SpecimenTypeDesignationWorkingsetEditorPresenter.java
49 49
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationTermLists;
50 50
import eu.etaxonomy.cdm.vaadin.model.registration.SpecimenTypeDesignationDTO;
51 51
import eu.etaxonomy.cdm.vaadin.model.registration.SpecimenTypeDesignationWorkingSetDTO;
52
import eu.etaxonomy.cdm.vaadin.permission.UserHelper;
52
import eu.etaxonomy.cdm.vaadin.permission.VaadinUserHelper;
53 53
import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults;
54 54
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator;
55 55
import eu.etaxonomy.cdm.vaadin.view.occurrence.CollectionPopupEditor;
......
254 254
    protected void saveBean(SpecimenTypeDesignationWorkingSetDTO dto) {
255 255

  
256 256
        if(crud != null){
257
            UserHelper.fromSession().createAuthorityForCurrentUser(dto.getFieldUnit(), crud, null);
257
            VaadinUserHelper.fromSession().createAuthorityForCurrentUser(dto.getFieldUnit(), crud, null);
258 258
        }
259 259

  
260 260
        specimenTypeDesignationWorkingSetService.save(dto);
src/main/java/eu/etaxonomy/cdm/vaadin/view/name/TaxonNameEditorPresenter.java
49 49
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityButtonUpdater;
50 50
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityReloader;
51 51
import eu.etaxonomy.cdm.vaadin.model.name.TaxonNameDTO;
52
import eu.etaxonomy.cdm.vaadin.permission.UserHelper;
52
import eu.etaxonomy.cdm.vaadin.permission.VaadinUserHelper;
53 53
import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults;
54 54
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator;
55 55
import eu.etaxonomy.cdm.vaadin.view.reference.ReferencePopupEditor;
......
256 256
    @Override
257 257
    protected void guaranteePerEntityCRUDPermissions(UUID identifier) {
258 258
        if(crud != null){
259
            newAuthorityCreated = UserHelper.fromSession().createAuthorityForCurrentUser(TaxonName.class, identifier, crud, null);
259
            newAuthorityCreated = VaadinUserHelper.fromSession().createAuthorityForCurrentUser(TaxonName.class, identifier, crud, null);
260 260
        }
261 261

  
262 262
    }
......
267 267
    @Override
268 268
    protected void guaranteePerEntityCRUDPermissions(TaxonName bean) {
269 269
        if(crud != null){
270
            newAuthorityCreated = UserHelper.fromSession().createAuthorityForCurrentUser(bean, crud, null);
270
            newAuthorityCreated = VaadinUserHelper.fromSession().createAuthorityForCurrentUser(bean, crud, null);
271 271
        }
272 272
    }
273 273

  
src/main/java/eu/etaxonomy/cdm/vaadin/view/occurrence/CollectionEditorPresenter.java
24 24
import eu.etaxonomy.cdm.vaadin.event.EditorActionTypeFilter;
25 25
import eu.etaxonomy.cdm.vaadin.event.EntityChangeEvent;
26 26
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityReloader;
27
import eu.etaxonomy.cdm.vaadin.permission.UserHelper;
27
import eu.etaxonomy.cdm.vaadin.permission.VaadinUserHelper;
28 28
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter;
29 29
import eu.etaxonomy.vaadin.mvp.BoundField;
30 30
import eu.etaxonomy.vaadin.ui.view.PopupView;
......
70 70
    @Override
71 71
    protected void guaranteePerEntityCRUDPermissions(UUID identifier) {
72 72
        if(crud != null){
73
            newAuthorityCreated = UserHelper.fromSession().createAuthorityForCurrentUser(Collection.class, identifier, crud, null);
73
            newAuthorityCreated = VaadinUserHelper.fromSession().createAuthorityForCurrentUser(Collection.class, identifier, crud, null);
74 74
        }
75 75

  
76 76
    }
......
81 81
    @Override
82 82
    protected void guaranteePerEntityCRUDPermissions(Collection bean) {
83 83
        if(crud != null){
84
            newAuthorityCreated = UserHelper.fromSession().createAuthorityForCurrentUser(bean, crud, null);
84
            newAuthorityCreated = VaadinUserHelper.fromSession().createAuthorityForCurrentUser(bean, crud, null);
85 85
        }
86 86

  
87 87
    }
src/main/java/eu/etaxonomy/cdm/vaadin/view/reference/ReferenceEditorPresenter.java
30 30
import eu.etaxonomy.cdm.vaadin.event.ReferenceEditorAction;
31 31
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityButtonUpdater;
32 32
import eu.etaxonomy.cdm.vaadin.event.ToOneRelatedEntityReloader;
33
import eu.etaxonomy.cdm.vaadin.permission.UserHelper;
33
import eu.etaxonomy.cdm.vaadin.permission.VaadinUserHelper;
34 34
import eu.etaxonomy.vaadin.component.ToOneRelatedEntityField;
35 35
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter;
36 36

  
......
120 120
    @Override
121 121
    protected void guaranteePerEntityCRUDPermissions(UUID identifier) {
122 122
        if(crud != null){
123
            newAuthorityCreated = UserHelper.fromSession().createAuthorityForCurrentUser(Reference.class, identifier, crud, null);
123
            newAuthorityCreated = VaadinUserHelper.fromSession().createAuthorityForCurrentUser(Reference.class, identifier, crud, null);
124 124
        }
125 125

  
126 126
    }
......
131 131
    @Override
132 132
    protected void guaranteePerEntityCRUDPermissions(Reference bean) {
133 133
        if(crud != null){
134
            newAuthorityCreated = UserHelper.fromSession().createAuthorityForCurrentUser(bean, crud, null);
134
            newAuthorityCreated = VaadinUserHelper.fromSession().createAuthorityForCurrentUser(bean, crud, null);
135 135
        }
136 136
    }
137 137

  
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListPresenter.java
31 31

  
32 32
import eu.etaxonomy.cdm.api.service.dto.RegistrationDTO;
33 33
import eu.etaxonomy.cdm.api.service.pager.Pager;
34
import eu.etaxonomy.cdm.api.service.registration.IRegistrationWorkingSetService;
34 35
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
35 36
import eu.etaxonomy.cdm.model.common.User;
36 37
import eu.etaxonomy.cdm.model.name.NameTypeDesignationStatus;
......
38 39
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus;
39 40
import eu.etaxonomy.cdm.model.name.TypeDesignationStatusBase;
40 41
import eu.etaxonomy.cdm.model.reference.Reference;
41
import eu.etaxonomy.cdm.service.IRegistrationWorkingSetService;
42 42
import eu.etaxonomy.cdm.vaadin.component.CdmBeanItemContainerFactory;
43 43
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItem;
44 44
import eu.etaxonomy.cdm.vaadin.event.EntityChangeEvent;
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/ListViewBean.java
47 47
import eu.etaxonomy.cdm.vaadin.event.ShowDetailsEvent;
48 48
import eu.etaxonomy.cdm.vaadin.event.UpdateResultsEvent;
49 49
import eu.etaxonomy.cdm.vaadin.permission.AccessRestrictedView;
50
import eu.etaxonomy.cdm.vaadin.permission.UserHelper;
50
import eu.etaxonomy.cdm.vaadin.permission.VaadinUserHelper;
51 51
import eu.etaxonomy.cdm.vaadin.view.AbstractPageView;
52 52

  
53 53
/**
......
97 97

  
98 98
        toolBar.addComponent(filterInstructionLabel);
99 99

  
100
        if(UserHelper.fromSession().userIsRegistrationCurator() || UserHelper.fromSession().userIsAdmin()){
100
        if(VaadinUserHelper.fromSession().userIsRegistrationCurator() || VaadinUserHelper.fromSession().userIsAdmin()){
101 101

  
102 102
            submitterFilter = new ListSelect("Submitter");
103 103
            submitterFilter.setRows(1);
......
188 188
    public void populateList(Collection<RegistrationDTO> registrations) {
189 189

  
190 190
        listContainer.removeAllComponents();
191
        boolean isCurator = UserHelper.fromSession().userIsRegistrationCurator() || UserHelper.fromSession().userIsAdmin();
191
        boolean isCurator = VaadinUserHelper.fromSession().userIsRegistrationCurator() || VaadinUserHelper.fromSession().userIsAdmin();
192 192
        for(RegistrationDTO regDto : registrations) {
193 193
            RegistrationItem item = new RegistrationItem(regDto, this);
194 194
            item.getSubmitterLabel().setVisible(isCurator);
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationEditorPresenter.java
21 21
import eu.etaxonomy.cdm.model.common.User;
22 22
import eu.etaxonomy.cdm.model.name.Registration;
23 23
import eu.etaxonomy.cdm.vaadin.component.CdmBeanItemContainerFactory;
24
import eu.etaxonomy.cdm.vaadin.permission.UserHelper;
24
import eu.etaxonomy.cdm.vaadin.permission.VaadinUserHelper;
25 25
import eu.etaxonomy.vaadin.mvp.AbstractCdmEditorPresenter;
26 26

  
27 27
/**
......
65 65
    @Override
66 66
    protected void guaranteePerEntityCRUDPermissions(UUID identifier) {
67 67
        if(crud != null){
68
            newAuthorityCreated = UserHelper.fromSession().createAuthorityForCurrentUser(Registration.class, identifier, crud, null);
68
            newAuthorityCreated = VaadinUserHelper.fromSession().createAuthorityForCurrentUser(Registration.class, identifier, crud, null);
69 69
        }
70 70

  
71 71
    }
......
76 76
    @Override
77 77
    protected void guaranteePerEntityCRUDPermissions(Registration bean) {
78 78
        if(crud != null){
79
            newAuthorityCreated = UserHelper.fromSession().createAuthorityForCurrentUser(bean, crud, null);
79
            newAuthorityCreated = VaadinUserHelper.fromSession().createAuthorityForCurrentUser(bean, crud, null);
80 80
        }
81 81
    }
82 82

  
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationMessagesPresenter.java
25 25
import eu.etaxonomy.cdm.model.common.User;
26 26
import eu.etaxonomy.cdm.model.name.Registration;
27 27
import eu.etaxonomy.cdm.vaadin.event.error.ExternalServiceExceptionHandler;
28
import eu.etaxonomy.cdm.vaadin.permission.UserHelper;
28
import eu.etaxonomy.cdm.vaadin.permission.VaadinUserHelper;
29 29
import eu.etaxonomy.vaadin.mvp.AbstractPresenter;
30 30

  
31 31
/**
......
75 75
     */
76 76
    public void postMessage(String message) {
77 77

  
78
        User user = UserHelper.fromSession().user();
78
        User user = VaadinUserHelper.fromSession().user();
79 79
        List<Message> activeMessages;
80 80
        try {
81 81
            activeMessages = messageService.listActiveMessagesFor(registration, user);
......
83 83
            throw new RuntimeException(e);
84 84
        }
85 85
        User toUser = null;
86
        if(UserHelper.fromSession().userIsRegistrationCurator()){
86
        if(VaadinUserHelper.fromSession().userIsRegistrationCurator()){
87 87
            toUser = registration.getSubmitter();
88 88
        } else {
89 89
            Stack<Message> stack = new Stack<>();
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetPresenter.java
41 41
import eu.etaxonomy.cdm.api.service.config.RegistrationStatusTransitions;
42 42
import eu.etaxonomy.cdm.api.service.dto.EntityReference;
43 43
import eu.etaxonomy.cdm.api.service.dto.RegistrationDTO;
44
import eu.etaxonomy.cdm.api.service.dto.RegistrationWorkingSet;
44 45
import eu.etaxonomy.cdm.api.service.dto.TypedEntityReference;
45 46
import eu.etaxonomy.cdm.api.service.exception.RegistrationValidationException;
46 47
import eu.etaxonomy.cdm.api.service.idminter.IdentifierMinter.Identifier;
47 48
import eu.etaxonomy.cdm.api.service.idminter.RegistrationIdentifierMinter;
48 49
import eu.etaxonomy.cdm.api.service.name.TypeDesignationSetManager.TypeDesignationWorkingSetType;
50
import eu.etaxonomy.cdm.api.service.registration.IRegistrationWorkingSetService;
49 51
import eu.etaxonomy.cdm.ext.common.ExternalServiceException;
50 52
import eu.etaxonomy.cdm.ext.registration.messages.IRegistrationMessageService;
51 53
import eu.etaxonomy.cdm.model.common.User;
......
62 64
import eu.etaxonomy.cdm.persistence.hibernate.permission.Operation;
63 65
import eu.etaxonomy.cdm.service.CdmFilterablePagingProvider;
64 66
import eu.etaxonomy.cdm.service.CdmStore;
65
import eu.etaxonomy.cdm.service.IRegistrationWorkingSetService;
66 67
import eu.etaxonomy.cdm.vaadin.component.CdmBeanItemContainerFactory;
67 68
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationItem;
68 69
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStatusFieldInstantiator;
......
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.model.registration.RegistrationWorkingSet;
81
import eu.etaxonomy.cdm.vaadin.permission.UserHelper;
81
import eu.etaxonomy.cdm.vaadin.permission.VaadinUserHelper;
82 82
import eu.etaxonomy.cdm.vaadin.theme.EditValoTheme;
83 83
import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults;
84 84
import eu.etaxonomy.cdm.vaadin.util.CdmTitleCacheCaptionGenerator;
......
208 208
        Authentication authentication = currentSecurityContext().getAuthentication();
209 209
        reg.setSubmitter((User)authentication.getPrincipal());
210 210
        EntityChangeEvent event = getRegistrationStore().saveBean(reg, (AbstractView) getView());
211
        UserHelper.fromSession().createAuthorityForCurrentUser(Registration.class, event.getEntityUuid(), Operation.UPDATE, RegistrationStatus.PREPARATION.name());
211
        VaadinUserHelper.fromSession().createAuthorityForCurrentUser(Registration.class, event.getEntityUuid(), Operation.UPDATE, RegistrationStatus.PREPARATION.name());
212 212
        getRepo().commitTransaction(txStatus);
213 213
        // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
214 214
        return getRepo().getRegistrationService().load(event.getEntityUuid(), Arrays.asList(new String []{"blockedBy"}));
......
245 245

  
246 246
                CdmBeanItemContainerFactory selectFieldFactory = new CdmBeanItemContainerFactory(getRepo());
247 247
                // submitters have GrantedAuthorities like REGISTRATION(PREPARATION).[UPDATE]{ab4459eb-3b96-40ba-bfaa-36915107d59e}
248
                UserHelper userHelper = UserHelper.fromSession();
248
                VaadinUserHelper userHelper = VaadinUserHelper.fromSession();
249 249
                Set<RegistrationStatus> availableStatus = new HashSet<>();
250 250

  
251 251
                boolean canChangeStatus = userHelper.userHasPermission(regDto.registration(), CRUD.UPDATE);
......
299 299
     *
300 300
     */
301 301
    protected void updateMessages() {
302
        User user = UserHelper.fromSession().user();
302
        User user = VaadinUserHelper.fromSession().user();
303 303
        for (UUID registrationUuid : getView().getRegistrationItemMap().keySet()) {
304 304
            Button messageButton = getView().getRegistrationItemMap().get(registrationUuid).regItemButtons.getMessagesButton();
305 305

  
......
308 308
                int messageCount = messageService.countActiveMessagesFor(regDto.registration(), user);
309 309

  
310 310
                boolean activeMessages = messageCount > 0;
311
                boolean currentUserIsSubmitter = regDto.getSubmitterUserName() != null && regDto.getSubmitterUserName().equals(UserHelper.fromSession().userName());
312
                boolean currentUserIsCurator = UserHelper.fromSession().userIsRegistrationCurator();
311
                boolean currentUserIsSubmitter = regDto.getSubmitterUserName() != null && regDto.getSubmitterUserName().equals(VaadinUserHelper.fromSession().userName());
312
                boolean currentUserIsCurator = VaadinUserHelper.fromSession().userIsRegistrationCurator();
313 313
                messageButton.setEnabled(false);
314 314
                if(currentUserIsCurator){
315 315
                    if(currentUserIsSubmitter){
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorkingsetView.java
18 18
import com.vaadin.ui.Button;
19 19

  
20 20
import eu.etaxonomy.cdm.api.service.dto.RegistrationDTO;
21
import eu.etaxonomy.cdm.api.service.dto.RegistrationWorkingSet;
21 22
import eu.etaxonomy.cdm.model.name.TaxonName;
22 23
import eu.etaxonomy.cdm.vaadin.component.registration.RegistrationStatusFieldInstantiator;
23
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet;
24 24
import eu.etaxonomy.vaadin.mvp.ApplicationView;
25 25

  
26 26
/**
src/main/java/eu/etaxonomy/cdm/vaadin/view/registration/RegistrationWorksetViewBean.java
50 50
import eu.etaxonomy.cdm.api.service.dto.EntityReference;
51 51
import eu.etaxonomy.cdm.api.service.dto.RegistrationDTO;
52 52
import eu.etaxonomy.cdm.api.service.dto.RegistrationType;
53
import eu.etaxonomy.cdm.api.service.dto.RegistrationWorkingSet;
53 54
import eu.etaxonomy.cdm.api.service.dto.TypedEntityReference;
54 55
import eu.etaxonomy.cdm.api.service.name.TypeDesignationSetManager.TypeDesignationWorkingSetType;
55 56
import eu.etaxonomy.cdm.model.name.Registration;
......
70 71
import eu.etaxonomy.cdm.vaadin.event.TaxonNameEditorAction;
71 72
import eu.etaxonomy.cdm.vaadin.event.TypeDesignationWorkingsetEditorAction;
72 73
import eu.etaxonomy.cdm.vaadin.event.registration.RegistrationWorkingsetAction;
73
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet;
74 74
import eu.etaxonomy.cdm.vaadin.permission.AccessRestrictedView;
75 75
import eu.etaxonomy.cdm.vaadin.permission.PermissionDebugUtils;
76
import eu.etaxonomy.cdm.vaadin.permission.UserHelper;
76
import eu.etaxonomy.cdm.vaadin.permission.VaadinUserHelper;
77 77
import eu.etaxonomy.cdm.vaadin.theme.EditValoTheme;
78 78
import eu.etaxonomy.cdm.vaadin.view.AbstractPageView;
79 79
import eu.etaxonomy.vaadin.event.EditorActionType;
......
243 243
            row = putRegistrationListComponent(row, dto);
244 244
        }
245 245

  
246
        // --- Footer with UI to create new registrations ----
246 247
        Label addRegistrationLabel_1 = new Label("Add a new registration for a");
247 248
        Label addRegistrationLabel_2 = new Label("or an");
248 249

  
......
451 452
        CssLayout stateAndSubmitter = new CssLayout(statusComponent, submitterLabel);
452 453

  
453 454

  
454
        if(UserHelper.fromSession().userIsRegistrationCurator() || UserHelper.fromSession().userIsAdmin()) {
455
        if(VaadinUserHelper.fromSession().userIsRegistrationCurator() || VaadinUserHelper.fromSession().userIsAdmin()) {
455 456
            Button editRegistrationButton = new Button(FontAwesome.COG);
456 457
            editRegistrationButton.setStyleName(ValoTheme.BUTTON_TINY);
457 458
            editRegistrationButton.setDescription("Edit registration");
src/main/java/eu/etaxonomy/vaadin/mvp/CdmEditorPresenterBase.java
28 28
import eu.etaxonomy.cdm.service.CdmFilterablePagingProviderFactory;
29 29
import eu.etaxonomy.cdm.service.CdmStore;
30 30
import eu.etaxonomy.cdm.vaadin.event.EntityChangeEvent;
31
import eu.etaxonomy.cdm.vaadin.permission.UserHelper;
31
import eu.etaxonomy.cdm.vaadin.permission.VaadinUserHelper;
32 32
import eu.etaxonomy.cdm.vaadin.view.name.CachingPresenter;
33 33
import eu.etaxonomy.vaadin.mvp.event.EditorPreSaveEvent;
34 34
import eu.etaxonomy.vaadin.mvp.event.EditorSaveEvent;
......
117 117

  
118 118
        CDM cdmEntitiy = cdmEntity(dto);
119 119

  
120
        UserHelper userHelper = UserHelper.fromSession();
120
        VaadinUserHelper userHelper = VaadinUserHelper.fromSession();
121 121
        boolean canDelte = userHelper.userHasPermission(cdmEntitiy, CRUD.DELETE);
122 122
        boolean canEdit = userHelper.userHasPermission(cdmEntitiy, CRUD.UPDATE);
123 123

  
......
211 211
            }
212 212
        } catch (HibernateException e){
213 213
            if(newAuthorityCreated != null){
214
                UserHelper.fromSession().removeAuthorityForCurrentUser(newAuthorityCreated);
214
                VaadinUserHelper.fromSession().removeAuthorityForCurrentUser(newAuthorityCreated);
215 215
            }
216 216
            throw e;
217 217
        } finally {
src/main/java/eu/etaxonomy/vaadin/ui/navigation/NavigationManagerBean.java
24 24

  
25 25
import eu.etaxonomy.cdm.vaadin.event.AbstractEditorAction.EditorActionContext;
26 26
import eu.etaxonomy.cdm.vaadin.permission.PermissionDebugUtils;
27
import eu.etaxonomy.cdm.vaadin.permission.UserHelper;
27
import eu.etaxonomy.cdm.vaadin.permission.VaadinUserHelper;
28 28
import eu.etaxonomy.vaadin.mvp.AbstractEditorPresenter;
29 29
import eu.etaxonomy.vaadin.mvp.AbstractPopupEditor;
30 30
import eu.etaxonomy.vaadin.mvp.ApplicationView;
......
66 66

  
67 67

  
68 68
	/**
69
	 * This reference will cause the scoped UserHelper being initialized
69
	 * This reference will cause the scoped VaadinUserHelper being initialized
70 70
	 * It is not used in this class but attaches itself to the vaadin session
71
	 * from where it will be accessible via UserHelper.fromSession()
71
	 * from where it will be accessible via VaadinUserHelper.fromSession()
72 72
	 */
73 73
	@Autowired
74
    private UserHelper userHelper;
74
    private VaadinUserHelper userHelper;
75 75

  
76 76
    /**
77 77
     * This reference will cause the scoped PermissionDebugUtils being initialized.
78 78
     * It is not used in this class but attaches itself to the vaadin session
79
     * from where it will be accessible via UserHelper.fromSession()
79
     * from where it will be accessible via VaadinUserHelper.fromSession()
80 80
     *
81 81
     * <b>NOTE:</b> PermissionDebugUtils is only available if the spring profile "debug" is active,
82 82
     * See
src/test/java/eu/etaxonomy/cdm/vaadin/model/RegistrationWorkingSetTest.java
17 17
import org.junit.Test;
18 18

  
19 19
import eu.etaxonomy.cdm.api.service.dto.RegistrationDTO;
20
import eu.etaxonomy.cdm.api.service.dto.RegistrationWorkingSet;
20 21
import eu.etaxonomy.cdm.api.service.exception.RegistrationValidationException;
21 22
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
22 23
import eu.etaxonomy.cdm.model.name.Rank;
......
28 29
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType;
29 30
import eu.etaxonomy.cdm.model.reference.Reference;
30 31
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
31
import eu.etaxonomy.cdm.vaadin.model.registration.RegistrationWorkingSet;
32 32

  
33 33
/**
34 34
 * @author a.kohlbecker

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)