Project

General

Profile

1
package eu.dnetlib.repo.manager.service.aai.registry;
2

    
3
import com.google.gson.JsonArray;
4
import com.google.gson.JsonObject;
5
import eu.dnetlib.repo.manager.domain.dto.Role;
6
import eu.dnetlib.repo.manager.domain.dto.User;
7

    
8
import java.util.List;
9
import java.util.Map;
10

    
11
public interface AaiRegistryService {
12

    
13
    /**
14
     * 1.1 Get CoPersonId by authenticated user's Email
15
     *
16
     * @return
17
     */
18
    Integer getCoPersonIdByEmail();
19

    
20
    /**
21
     * 1.2 Get CoPersonId by Email
22
     *
23
     * @param email
24
     * @return
25
     */
26
    Integer getCoPersonIdByEmail(String email);
27

    
28
    /**
29
     * 1. Get CoPersonId List by Email
30
     *
31
     * @param email
32
     * @return
33
     */
34
    List<Integer> getCoPersonIdsByEmail(String email);
35

    
36
    /**
37
     * 2. Get CoPersonId by AAI identifier
38
     *
39
     * @return
40
     */
41
    Integer getCoPersonIdByIdentifier();
42

    
43
    /**
44
     * 3.1 Get OpenAIRE cous with a specific name(or substring)
45
     *
46
     * @param name
47
     * @return
48
     */
49
    JsonArray getCous(String name);
50

    
51
    /**
52
     * 3.2 Get all OpenAIRE cous
53
     *
54
     * @return
55
     */
56
    JsonArray getCous();
57

    
58
    /**
59
     * 4.1 Get a couId by name
60
     *
61
     * @param name
62
     * @return
63
     */
64
    Integer getCouId(String name);
65

    
66
    /**
67
     * 4.2 Get a couId by type.id with/without mapping type
68
     *
69
     * @param type
70
     * @param id
71
     * @return
72
     */
73
    Integer getCouId(String type, String id, boolean communityMap);
74

    
75
    /**
76
     * 4.3 Get a couId by type.id with mapping type
77
     *
78
     * @param type
79
     * @param id
80
     * @return
81
     */
82
    Integer getCouId(String type, String id);
83

    
84
    /**
85
     * 5. Get User non admin roles
86
     *
87
     * @param coPersonId
88
     * @return
89
     */
90
    JsonArray getRoles(Integer coPersonId);
91

    
92
    /**
93
     * 5.2 Get User non admin active roles
94
     *
95
     * @param coPersonId
96
     * @return
97
     */
98
    JsonArray getRolesWithStatus(Integer coPersonId, RoleStatus status);
99

    
100
    /**
101
     * 6. Get Role id of User base on couId.
102
     *
103
     * @param coPersonId
104
     * @param couId
105
     * @return
106
     */
107
    Integer getRoleId(Integer coPersonId, Integer couId);
108

    
109
    /**
110
     * 7. Get User Groups
111
     *
112
     * @param coPersonId
113
     * @return
114
     */
115
    JsonArray getUserGroups(Integer coPersonId);
116

    
117
    /**
118
     * 8. Get User Admin Group of a Cou
119
     *
120
     * @param coPersonId
121
     * @param couId
122
     * @return
123
     */
124
    JsonObject getUserAdminGroup(Integer coPersonId, Integer couId);
125

    
126
    /**
127
     * 9. Get Groups of a Cou
128
     *
129
     * @param couId
130
     * @return
131
     */
132
    JsonArray getCouGroups(Integer couId);
133

    
134
    /**
135
     * 10. Get Admin Group of a Cou
136
     *
137
     * @param couId
138
     * @return
139
     */
140
    JsonObject getCouAdminGroup(Integer couId);
141

    
142
    /**
143
     * 11. Get users of a group
144
     *
145
     * @param coGroupId
146
     * @return
147
     */
148
    JsonArray getGroupMembers(Integer coGroupId);
149

    
150

    
151
    /**
152
     * 12. Get Users' email of a Cou
153
     *
154
     * @param couId
155
     * @param admin
156
     * @return
157
     */
158
    JsonArray getUserEmailByCouId(Integer couId, boolean admin);
159

    
160
    /**
161
     * 12.2 Get All Users that have a specific role // TODO: Keep or delete
162
     *
163
     * @param couId
164
     * @return
165
     */
166
    JsonArray getUsersByCouId(Integer couId);
167

    
168
    /**
169
     * 13. Get Users' names of a Cou
170
     *
171
     * @param couId
172
     * @param admin
173
     * @return
174
     */
175
    JsonArray getUserNamesByCouId(Integer couId, boolean admin);
176

    
177
    /**
178
     * 14. Get Users' identifiers of a Cou
179
     *
180
     * @param couId
181
     * @param admin
182
     * @return
183
     */
184
    JsonArray getUserIdByCouId(Integer couId, boolean admin);
185

    
186
    /**
187
     * 15. Assign a member role to a User
188
     *
189
     * @param coPersonId
190
     * @param couId
191
     * @param id
192
     */
193
    void assignMemberRole(Integer coPersonId, Integer couId, Integer id);
194

    
195
    /**
196
     * 16. Remove a member role from a User
197
     *
198
     * @param coPersonId
199
     * @param couId
200
     * @param id
201
     */
202
    void removeMemberRole(Integer coPersonId, Integer couId, Integer id);
203

    
204
    /**
205
     * 17. Create a new role
206
     *
207
     * @param role
208
     * @return
209
     */
210
    Integer createRole(Role role);
211

    
212
    /**
213
     * 18. Get User's email
214
     *
215
     * @param coPersonId
216
     * @return
217
     */
218
    String getUserEmail(Integer coPersonId);
219

    
220
    /**
221
     * 19. Get User's names
222
     *
223
     * @param coPersonId
224
     * @return
225
     */
226
    String getUserNames(Integer coPersonId);
227

    
228
    /**
229
     * 20. Get User's identifier
230
     *
231
     * @param coPersonId
232
     * @return
233
     */
234
    String getUserId(Integer coPersonId);
235

    
236
    /**
237
     * 21. Assign an admin role to a User
238
     *
239
     * @param coPersonId
240
     * @param couId
241
     */
242
    void assignAdminRole(Integer coPersonId, Integer couId);
243

    
244
    /**
245
     * 22. Remove an admin role from a User
246
     *
247
     * @param coPersonId
248
     * @param couId
249
     */
250
    void removeAdminRole(Integer coPersonId, Integer couId);
251

    
252
    /**
253
     * 23. Get a cou Names from couIds.
254
     *
255
     * @param couIds
256
     * @return
257
     */
258
    Map<Integer, String> getCouNames(List<Integer> couIds);
259

    
260
    // TODO: add description
261
    List<User> getUsers(Integer couId);
262

    
263
    enum RoleStatus {
264
        ACTIVE("Active"),
265
        APPROVED("Approved"),
266
        CONFIRMED("Confirmed"),
267
        DECLINED("Declined"),
268
        DELETED("Deleted"),
269
        DENIED("Denied"),
270
        DUPLICATE("Duplicate"),
271
        EXPIRED("Expired"),
272
        GRACE_PERIOD("GracePeriod"),
273
        INVITED("Invited"),
274
        PENDING("Pending"),
275
        PENDING_APPROVAL("PendingApproval"),
276
        PENDING_CONFIRMATION("PendingConfirmation"),
277
        SUSPENDED("Suspended");
278

    
279
        public final String status;
280

    
281
        RoleStatus(String status) {
282
            this.status = status;
283
        }
284
    }
285
}
(1-1/2)