24
24
import pl .edu .icm .unity .engine .api .GroupsManagement ;
25
25
import pl .edu .icm .unity .engine .api .InvitationManagement ;
26
26
import pl .edu .icm .unity .engine .api .RegistrationsManagement ;
27
- import pl .edu .icm .unity .engine .api .bulk .BulkGroupQueryService ;
28
- import pl .edu .icm .unity .engine .api .bulk .GroupMembershipData ;
29
- import pl .edu .icm .unity .engine .api .bulk .EntityInGroupData ;
30
27
import pl .edu .icm .unity .engine .api .endpoint .SharedEndpointManagement ;
31
28
import pl .edu .icm .unity .engine .api .project .ProjectInvitation ;
32
29
import pl .edu .icm .unity .engine .api .project .ProjectInvitationParam ;
33
30
import pl .edu .icm .unity .engine .api .project .ProjectInvitationsManagement ;
34
31
import pl .edu .icm .unity .engine .api .registration .PublicRegistrationURLSupport ;
35
32
import pl .edu .icm .unity .exceptions .EngineException ;
36
33
import pl .edu .icm .unity .stdext .identity .EmailIdentity ;
37
- import pl .edu .icm .unity .stdext .utils .ContactEmailMetadataProvider ;
38
- import pl .edu .icm .unity .types .basic .Attribute ;
39
34
import pl .edu .icm .unity .types .basic .EntityParam ;
40
35
import pl .edu .icm .unity .types .basic .GroupContents ;
41
36
import pl .edu .icm .unity .types .basic .GroupDelegationConfiguration ;
42
37
import pl .edu .icm .unity .types .basic .GroupMembership ;
43
- import pl .edu .icm .unity .types .basic .Identity ;
44
38
import pl .edu .icm .unity .types .basic .IdentityParam ;
45
- import pl .edu .icm .unity .types .basic .VerifiableElementBase ;
46
39
import pl .edu .icm .unity .types .confirmation .ConfirmationInfo ;
47
40
import pl .edu .icm .unity .types .registration .BaseForm ;
48
41
import pl .edu .icm .unity .types .registration .EnquiryForm ;
56
49
import pl .edu .icm .unity .types .registration .invite .PrefilledEntryMode ;
57
50
import pl .edu .icm .unity .types .registration .invite .RegistrationInvitationParam ;
58
51
59
- /**
60
- * Implementation of {@link ProjectInvitationsManagement}
61
- *
62
- * @author P.Piernik
63
- */
64
52
@ Component
65
53
@ Primary
66
54
public class ProjectInvitationsManagementImpl implements ProjectInvitationsManagement
@@ -71,37 +59,34 @@ public class ProjectInvitationsManagementImpl implements ProjectInvitationsManag
71
59
private final SharedEndpointManagement sharedEndpointMan ;
72
60
private final RegistrationsManagement registrationMan ;
73
61
private final EnquiryManagement enquiryMan ;
74
- private final BulkGroupQueryService bulkService ;
75
- private final ProjectAttributeHelper attrHelper ;
76
62
private final EntityManagement entityMan ;
63
+ private final ExistingUserFinder existingUserFinder ;
77
64
78
65
public ProjectInvitationsManagementImpl (@ Qualifier ("insecure" ) InvitationManagement invitationMan ,
79
66
@ Qualifier ("insecure" ) GroupsManagement groupMan ,
80
67
@ Qualifier ("insecure" ) RegistrationsManagement registrationMan ,
81
68
@ Qualifier ("insecure" ) EnquiryManagement enquiryMan ,
82
- @ Qualifier ("insecure" ) BulkGroupQueryService bulkService ,
83
69
@ Qualifier ("insecure" ) EntityManagement entityMan ,
84
- ProjectAttributeHelper attrHelper ,
85
70
SharedEndpointManagement sharedEndpointMan ,
86
- ProjectAuthorizationManager authz )
71
+ ProjectAuthorizationManager authz ,
72
+ ExistingUserFinder existingUserFinder )
87
73
{
88
74
this .invitationMan = invitationMan ;
89
75
this .groupMan = groupMan ;
90
76
this .entityMan = entityMan ;
91
77
this .sharedEndpointMan = sharedEndpointMan ;
92
78
this .registrationMan = registrationMan ;
93
79
this .enquiryMan = enquiryMan ;
94
- this .bulkService = bulkService ;
95
- this .attrHelper = attrHelper ;
96
80
this .authz = authz ;
81
+ this .existingUserFinder = existingUserFinder ;
97
82
}
98
83
99
84
@ Override
100
85
public String addInvitation (ProjectInvitationParam param ) throws EngineException
101
86
{
102
87
authz .assertManagerAuthorization (param .project );
103
88
104
- Long entity = getEntityByContactAddress (param .contactAddress );
89
+ Long entity = existingUserFinder . getEntityIdByContactAddress (param .contactAddress );
105
90
String code = null ;
106
91
if (entity == null )
107
92
{
@@ -123,45 +108,6 @@ private void assertNotMemberAlready(long entityId, String projectGroup) throws E
123
108
throw new AlreadyMemberException ();
124
109
}
125
110
126
- private Long getEntityByContactAddress (String contactAddress ) throws EngineException
127
- {
128
- GroupMembershipData bulkMembershipData = bulkService .getBulkMembershipData ("/" );
129
- Map <Long , EntityInGroupData > members = bulkService .getMembershipInfo (bulkMembershipData );
130
-
131
- for (EntityInGroupData info : members .values ())
132
- {
133
- Identity emailId = info .entity .getIdentities ().stream ()
134
- .filter (id -> id .getTypeId ().equals (EmailIdentity .ID )
135
- && id .getValue ().equals (contactAddress ))
136
- .findAny ().orElse (null );
137
- if (emailId != null )
138
- {
139
- return info .entity .getId ();
140
- }
141
-
142
- }
143
-
144
- return searchEntityByEmailAttr (members , contactAddress );
145
- }
146
-
147
- private Long searchEntityByEmailAttr (Map <Long , EntityInGroupData > membersWithGroups , String contactAddress )
148
- throws EngineException
149
- {
150
- for (EntityInGroupData info : membersWithGroups .values ())
151
- {
152
- VerifiableElementBase contactEmail = attrHelper .searchVerifiableAttributeValueByMeta (ContactEmailMetadataProvider .NAME ,
153
- info .groupAttributesByName .values ().stream ().map (e -> (Attribute ) e )
154
- .collect (Collectors .toList ()));
155
- if (contactEmail != null && contactEmail .getValue () != null
156
- && contactEmail .getValue ().equals (contactAddress ))
157
- {
158
- return info .entity .getId ();
159
- }
160
- }
161
-
162
- return null ;
163
- }
164
-
165
111
private EnquiryInvitationParam getEnquiryInvitation (ProjectInvitationParam param , Long entityId )
166
112
throws EngineException
167
113
{
0 commit comments