Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Accelerator 4] Adding event notification endpoint implementation #169

Merged
merged 5 commits into from
Dec 12, 2024

Conversation

Ashi1993
Copy link
Contributor

@Ashi1993 Ashi1993 commented Oct 31, 2024

Adding Event Notification Endpoint Implementation

This PR add Event Notification Endpoint Implementation

Issue link: https://github.com/wso2-enterprise/solutions-bfsi/issues/20

Doc Issue: Optional, link issue from documentation repository

Applicable Labels: Spec, product, version, type (specify requested labels)


Development Checklist

  1. Build complete solution with pull request in place.
  2. Ran checkstyle plugin with pull request in place.
  3. Ran Findbugs plugin with pull request in place.
  4. Ran FindSecurityBugs plugin and verified report.
  5. Formatted code according to WSO2 code style.
  6. Have you verified the PR doesn't commit any keys, passwords, tokens, usernames, or other secrets?
  7. Migration scripts written (if applicable).
  8. Have you followed secure coding standards in WSO2 Secure Engineering Guidelines?

Testing Checklist

  1. Written unit tests.
  2. Verified tests in multiple database environments (if applicable).
  3. Tested with BI enabled (if applicable).

@Ashi1993 Ashi1993 changed the title Adding event notification endpoint implementation [Accelerator 4] Adding event notification endpoint implementation Dec 9, 2024
if (!parameterMap.isEmpty() && parameterMap.containsKey(EventNotificationEndPointConstants.REQUEST)) {

requestData = parameterMap.get(EventNotificationEndPointConstants.REQUEST).
toString().replaceAll("\\\\r|\\\\n|\\r|\\n|\\[|]| ", StringUtils.EMPTY);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we move this to a constant? "\\\\r|\\\\n|\\r|\\n|\\[|]| "

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIxed in 1f79f12

//set events to notificationCreationDTO
JSONObject finalNotificationEvents = notificationEvents;
notificationEvents.keySet().forEach(eventName -> {
JSONObject eventInformation = (JSONObject) finalNotificationEvents.get(eventName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
JSONObject eventInformation = (JSONObject) finalNotificationEvents.get(eventName);
JSONObject eventInformation = finalNotificationEvents.getJSONObject(eventName);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIxed in 1f79f12

}

//set events to notificationCreationDTO
JSONObject finalNotificationEvents = notificationEvents;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this variable here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIxed in 1f79f12

.getErrorDTO(EventNotificationEndPointConstants.INVALID_REQUEST_PAYLOAD,
EventNotificationEndPointConstants.REQUEST_PAYLOAD_ERROR)).build();
} catch (FSEventNotificationException e) {
return Response.status(e.getStatus()).entity(EventNotificationServiceUtil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed the log here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIxed in 1f79f12

@Path("/events")
public class EventPollingEndpoint {

private static final Log log = LogFactory.getLog(EventCreationEndpoint.class);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private static final Log log = LogFactory.getLog(EventCreationEndpoint.class);
private static final Log log = LogFactory.getLog(EventPollingEndpoint.class);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIxed in 1f79f12

public class EventPollingEndpoint {

private static final Log log = LogFactory.getLog(EventCreationEndpoint.class);
private static final EventPollingServiceHandler eventPollingServiceHandler = EventNotificationUtils.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may get difficult to write unit tests with this approach. may be we could introduce a constructor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIxed in 1f79f12

/**
* Events Notification Subscription API Utils.
*/
public class EventSubscriptionUtils {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a private constructor. applicable to other relevant places too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FIxed in 1f79f12

@Ashi1993 Ashi1993 closed this Dec 12, 2024
@Ashi1993 Ashi1993 deleted the event-endpoint branch December 12, 2024 03:44
@Ashi1993 Ashi1993 restored the event-endpoint branch December 12, 2024 03:50
@Ashi1993 Ashi1993 reopened this Dec 12, 2024
@VimukthiRajapaksha VimukthiRajapaksha merged commit 2980a40 into wso2:main Dec 12, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants