use of io.imunity.furms.api.validation.exceptions.InvitationNotExistingException in project furms by unity-idm.
the class InvitationsView method createContextMenu.
private Component createContextMenu(InvitationId id) {
GridActionMenu contextMenu = new GridActionMenu();
contextMenu.addItem(new MenuButton(getTranslation("view.user-settings.invitations.grid.context-menu.confirm"), CHECK_CIRCLE), event -> {
try {
inviteeService.acceptBy(id);
} catch (InvitationNotExistingException e) {
showErrorNotification(getTranslation("invitation.already.removed"));
} catch (Exception e) {
LOG.warn("Could not accept Invitation. ", e);
showErrorNotification(getTranslation("base.error.message"));
}
loadGrid();
});
Dialog confirmDialog = createConfirmDialog(id);
contextMenu.addItem(new MenuButton(getTranslation("view.user-settings.invitations.grid.context-menu.reject"), CLOSE_CIRCLE), event -> confirmDialog.open());
return contextMenu.getTarget();
}
use of io.imunity.furms.api.validation.exceptions.InvitationNotExistingException in project furms by unity-idm.
the class InviteeServiceImpl method acceptBy.
@Override
@FurmsAuthorize(capability = AUTHENTICATED)
public void acceptBy(InvitationId id) {
FURMSUser user = authzService.getCurrentAuthNUser();
Invitation invitation = invitationRepository.findBy(id).orElseThrow(() -> new InvitationNotExistingException(String.format("Invitation id %s doesn't exist for user %s", id, user.fenixUserId)));
switch(invitation.resourceId.type) {
case APP_LEVEL:
fenixUsersDAO.addFenixAdminRole(user.id.get());
break;
case SITE:
siteGroupDAO.addSiteUser(invitation.resourceId.id.toString(), user.id.get(), invitation.role);
break;
case COMMUNITY:
communityGroupsDAO.addAdmin(invitation.resourceId.id.toString(), user.id.get());
break;
case PROJECT:
String projectId = invitation.resourceId.id.toString();
String communityId = projectRepository.findById(projectId).get().getCommunityId();
projectGroupsDAO.addProjectUser(communityId, projectId, user.id.get(), invitation.role);
break;
}
invitationRepository.deleteBy(invitation.id);
notifyOriginatorAndSameHierarchyAdmins(invitation, usr -> userInvitationNotificationService.notifyAdminAboutRoleAcceptance(usr.id.get(), invitation.role, invitation.email));
publisher.publishEvent(new InvitationAcceptedEvent(user.fenixUserId.get(), user.email, invitation.resourceId));
publisher.publishEvent(new UserRoleGrantedByInvitationEvent(invitation.originator, user.id.get(), invitation.resourceId, invitation.resourceName, invitation.role));
}
use of io.imunity.furms.api.validation.exceptions.InvitationNotExistingException in project furms by unity-idm.
the class InvitationsView method createMainContextMenu.
private Component createMainContextMenu(InviteeService inviteeService, Map<InvitationId, Checkbox> checkboxes) {
GridActionMenu contextMenu = new GridActionMenu();
contextMenu.addItem(new MenuButton(getTranslation("view.user-settings.invitations.main.context-menu.confirm"), CHECK_CIRCLE), event -> {
try {
checkboxes.entrySet().stream().filter(x -> x.getValue().getValue()).forEach(x -> inviteeService.acceptBy(x.getKey()));
} catch (InvitationNotExistingException e) {
showErrorNotification(getTranslation("invitation.already.removed"));
} catch (Exception e) {
LOG.warn("Could not accept Invitations. ", e);
showErrorNotification(getTranslation("base.error.message"));
}
loadGrid();
});
contextMenu.addItem(new MenuButton(getTranslation("view.user-settings.invitations.main.context-menu.reject"), CLOSE_CIRCLE), event -> {
if (checkboxes.entrySet().stream().anyMatch(x -> x.getValue().getValue()))
createMainConfirmDialog(checkboxes).open();
});
return contextMenu.getTarget();
}
Aggregations