From 9247a22fe0e5392e59382007b2c5ea78bf69206c Mon Sep 17 00:00:00 2001 From: Shan Chathusanda Jayathilaka Date: Fri, 3 May 2024 17:14:11 +0530 Subject: [PATCH] Add temp logs --- .../management/InvitationCoreServiceImpl.java | 15 ++++++++++++++- .../handler/UserInvitationEventHandler.java | 7 +++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/components/org.wso2.carbon.identity.organization.user.invitation.management/src/main/java/org/wso2/carbon/identity/organization/user/invitation/management/InvitationCoreServiceImpl.java b/components/org.wso2.carbon.identity.organization.user.invitation.management/src/main/java/org/wso2/carbon/identity/organization/user/invitation/management/InvitationCoreServiceImpl.java index 40793e82a..e9ec21838 100644 --- a/components/org.wso2.carbon.identity.organization.user.invitation.management/src/main/java/org/wso2/carbon/identity/organization/user/invitation/management/InvitationCoreServiceImpl.java +++ b/components/org.wso2.carbon.identity.organization.user.invitation.management/src/main/java/org/wso2/carbon/identity/organization/user/invitation/management/InvitationCoreServiceImpl.java @@ -133,6 +133,7 @@ public class InvitationCoreServiceImpl implements InvitationCoreService { @Override public List createInvitations(InvitationDO invitationDO) throws UserInvitationMgtException { + LOG.info("[INVITATION_LOG] Creating invitations for the users: " + invitationDO.getUsernamesList()); List createdInvitationsList = new ArrayList<>(); Invitation invitation = new Invitation(); String orgId = Utils.getOrganizationId(); @@ -147,6 +148,7 @@ public List createInvitations(InvitationDO invitationDO) throw int parentTenantId = IdentityTenantUtil.getTenantId(parentTenantDomain); AbstractUserStoreManager userStoreManager = getAbstractUserStoreManager(parentTenantId); for (String username : invitationDO.getUsernamesList()) { + LOG.info("[INVITATION_LOG] Creating invitation for the user: " + username); String userDomainQualifiedUserName = UserCoreUtil .addDomainToName(username, invitationDO.getUserDomain()); String invitedUserId = userStoreManager.getUserIDFromUserName(userDomainQualifiedUserName); @@ -181,14 +183,21 @@ public List createInvitations(InvitationDO invitationDO) throw invitation.setConfirmationCode(confirmationCode); Map invitationProperties = invitationDO.getInvitationProperties(); invitation.setInvitationProperties(invitationProperties); + LOG.info("[INVITATION_LOG] Storing the invitation for the user: " + username); userInvitationDAO.createInvitation(invitation); Invitation createdInvitationInfo = userInvitationDAO.getInvitationByInvitationId(invitation.getInvitationId()); + LOG.info("[INVITATION_LOG] Invitation created for user: " + username + " with the invitation id: " + + invitation.getInvitationId()); if (isNotificationsInternallyManaged(orgId, invitationProperties)) { // Trigger the event for invitation creation to send notification internally. + LOG.info("[INVITATION_LOG] Triggering the event for invitation creation for the user: " + + username); triggerInvitationAddNotification(createdInvitationInfo); } else { // Send the confirmation code via the response to manage notification externally. + LOG.info("[INVITATION_LOG] Sending the confirmation code in the response for the user: " + + username); validationResult.setConfirmationCode(confirmationCode); } } @@ -472,9 +481,13 @@ private void triggerInvitationAddNotification(Invitation invitation) properties.put(EVENT_PROP_TENANT_DOMAIN, invitation.getInvitedOrganizationId()); properties.put(EVENT_PROP_REDIRECT_URL, invitation.getUserRedirectUrl()); properties.put(EVENT_PROP_PROPERTIES, invitation.getInvitationProperties()); - + LOG.info("[INVITATION_LOG] Triggering the event for invitation creation for the user: " + + invitation.getUsername()); + LOG.info("[INVITATION_LOG] Invitation properties: " + properties); Event invitationEvent = new Event(EVENT_NAME_POST_ADD_INVITATION, properties); try { + LOG.info("[INVITATION_LOG] Handling the event for invitation creation for the user: " + + invitation.getUsername()); UserInvitationMgtDataHolder.getInstance().getIdentityEventService().handleEvent(invitationEvent); } catch (IdentityEventException e) { throw new UserInvitationMgtServerException(ERROR_CODE_EVENT_HANDLE.getCode(), diff --git a/components/org.wso2.carbon.identity.organization.user.invitation.management/src/main/java/org/wso2/carbon/identity/organization/user/invitation/management/handler/UserInvitationEventHandler.java b/components/org.wso2.carbon.identity.organization.user.invitation.management/src/main/java/org/wso2/carbon/identity/organization/user/invitation/management/handler/UserInvitationEventHandler.java index cede27ff7..ffd858446 100644 --- a/components/org.wso2.carbon.identity.organization.user.invitation.management/src/main/java/org/wso2/carbon/identity/organization/user/invitation/management/handler/UserInvitationEventHandler.java +++ b/components/org.wso2.carbon.identity.organization.user.invitation.management/src/main/java/org/wso2/carbon/identity/organization/user/invitation/management/handler/UserInvitationEventHandler.java @@ -69,6 +69,7 @@ public boolean canHandle(MessageContext messageContext) throws IdentityRuntimeEx if (LOG.isDebugEnabled()) { LOG.debug("canHandle() returning True for the event: " + eventName); } + LOG.info("[INVITATION_LOG] Can handle the invitation event: " + eventName); return true; } return false; @@ -78,12 +79,13 @@ public boolean canHandle(MessageContext messageContext) throws IdentityRuntimeEx public void handleEvent(Event event) throws IdentityEventException { String eventName = event.getEventName(); - + LOG.info("[INVITATION_LOG] Handling event: " + eventName); if (EVENT_NAME_POST_ADD_INVITATION.equals(eventName)) { // Trigger the email notification String redirectUrl = event.getEventProperties().get(EVENT_PROP_REDIRECT_URL) + "?code=" + event.getEventProperties().get(EVENT_PROP_CONFIRMATION_CODE); event.getEventProperties().put(EVENT_PROP_REDIRECT_URL, redirectUrl); + LOG.info("[INVITATION_LOG] Triggering email notification for the event: " + eventName); triggerEmailNotification(event); } } @@ -104,12 +106,13 @@ private void triggerEmailNotification(Event event) throws IdentityEventException HashMap properties = new HashMap<>(); properties.put(EVENT_PROP_SEND_TO, event.getEventProperties().get(EVENT_PROP_EMAIL_ADDRESS)); properties.put(EVENT_PROP_TEMPLATE_TYPE, ORGANIZATION_USER_INVITATION_EMAIL_TEMPLATE_TYPE); - + LOG.info("[INVITATION_LOG] Invite event properties: " + event.getEventProperties()); if (CollectionUtils.size(event.getEventProperties()) > 0) { properties.putAll(event.getEventProperties()); } Event identityMgtEvent = new Event(IdentityEventConstants.Event.TRIGGER_NOTIFICATION, properties); try { + LOG.info("[INVITATION_LOG] Triggering the notification for invite event : " + event.getEventProperties()); UserInvitationMgtDataHolder.getInstance().getIdentityEventService().handleEvent(identityMgtEvent); } catch (IdentityEventException e) { throw new IdentityEventException("Error while sending notification for user", e);