Project

General

Profile

« Previous | Next » 

Revision 942588ed

Added by Andreas Müller 4 months ago

ref #10116 add group submitter to self-registered user if it exists

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/permission/Group.java
51 51
//@Indexed(index = "eu.etaxonomy.cdm.model.common.Group")
52 52
@Table(name = "PermissionGroup")
53 53
public class Group extends CdmBase {
54

  
54 55
    private static final long serialVersionUID = 7216686200093054648L;
55 56
    private static final Logger logger = LogManager.getLogger(Group.class);
56 57

  
......
75 76
    public static final String GROUP_PUBLISH_NAME = "Publish";
76 77
    public final static String GROUP_USER_MANAGER_NAME = "User_Manager";
77 78

  
79
    //Phycobank groups  //for now handled here, might be handled elsewhere later
80
    public final static String GROUP_SUBMITTER = "Submitter";
81

  
78 82
//**************** FIELDS ******************************/
79 83

  
80 84
    @XmlElement(name = "Name")
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/GroupServiceImpl.java
63 63
        return users;
64 64
    }
65 65

  
66
    @Override
67
    public boolean groupExists(String groupName) {
68
        Assert.hasText(groupName, "Parameter 'groupName' must not be empty.");
69
        Group group = dao.findGroupByName(groupName);
70
        return group != null;
71
    }
72

  
73
    @Override
74
    public Group findGroup(String groupName) {
75
        Assert.hasText(groupName, "Parameter 'groupname' must not be empty.");
76
        Group group = dao.findGroupByName(groupName);
77
        return group;
78
    }
66 79

  
67 80
    @Override
68 81
    @Transactional(readOnly=false)
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IGroupService.java
6 6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7 7
* See LICENSE.TXT at the top of this package for the full license terms.
8 8
*/
9

  
10 9
package eu.etaxonomy.cdm.api.service;
11 10

  
12 11
import java.util.List;
......
50 49

  
51 50
    public UUID saveGroup(Group group);
52 51

  
52
    /**
53
     * Checks whether or not a group with the given name exists.
54
     * @param username
55
     */
56
    public boolean groupExists(String groupName);
53 57

  
54
}
58
    /**
59
     * Returns the group with the given group name or <code>null</code> if such a user
60
     * does not exist.
61
     */
62
    public Group findGroup(String groupName);
63
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/security/AccountRegistrationService.java
30 30
import eu.etaxonomy.cdm.api.security.AbstractRequestToken;
31 31
import eu.etaxonomy.cdm.api.security.AccountCreationRequest;
32 32
import eu.etaxonomy.cdm.api.security.IAbstractRequestTokenStore;
33
import eu.etaxonomy.cdm.api.service.IGroupService;
34
import eu.etaxonomy.cdm.model.permission.Group;
33 35
import eu.etaxonomy.cdm.model.permission.User;
34 36

  
35 37
/**
......
46 48

  
47 49
    protected static final String USER_NAME_EXISTS_MSG = "This user name is already being used by someone else.";
48 50

  
49

  
51
    @Autowired
52
    private IGroupService groupService;
50 53

  
51 54
    @Autowired
52 55
    @Qualifier("accountCreationRequestTokenStore")
......
99 102
                    }
100 103
                    User newUser = User.NewInstance(userName, password);
101 104
                    userService.encodeUserPassword(newUser, password);
105
                    //for Phycobank only (preliminary, should be handled in Phycobank explicitly)
106
                    Group submitterGroup = groupService.findGroup(Group.GROUP_SUBMITTER);
107
                    if (submitterGroup != null) {
108
                        submitterGroup.addMember(newUser);
109
                    }
102 110
                    userDao.saveOrUpdate(newUser);
111

  
103 112
                    accountRegistrationTokenStore.remove(token);
104 113
                    sendEmail(creationRequest.get().getUserEmail(), userName,
105 114
                            UserAccountEmailTemplates.REGISTRATION_SUCCESS_EMAIL_SUBJECT_TEMPLATE,

Also available in: Unified diff