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

Add DB Based Template Management Support #227

Closed
wants to merge 27 commits into from

Conversation

darshanasbg
Copy link
Contributor

Proposed changes in this pull request

$subject

When should this PR be merged

[Please describe any preconditions that need to be addressed before we
can merge this pull request.]

Follow up actions

[List any possible follow-up actions here; for instance, testing data
migrations, software that we need to install on staging and production
environments.]

Checklist (for reviewing)

General

  • Is this PR explained thoroughly? All code changes must be accounted for in the PR description.
  • Is the PR labeled correctly?

Functionality

  • Are all requirements met? Compare implemented functionality with the requirements specification.
  • Does the UI work as expected? There should be no Javascript errors in the console; all resources should load. There should be no unexpected errors. Deliberately try to break the feature to find out if there are corner cases that are not handled.

Code

  • Do you fully understand the introduced changes to the code? If not ask for clarification, it might uncover ways to solve a problem in a more elegant and efficient way.
  • Does the PR introduce any inefficient database requests? Use the debug server to check for duplicate requests.
  • Are all necessary strings marked for translation? All strings that are exposed to users via the UI must be marked for translation.

Tests

  • Are there sufficient test cases? Ensure that all components are tested individually; models, forms, and serializers should be tested in isolation even if a test for a view covers these components.
  • If this is a bug fix, are tests for the issue in place? There must be a test case for the bug to ensure the issue won’t regress. Make sure that the tests break without the new code to fix the issue.
  • If this is a new feature or a significant change to an existing feature? has the manual testing spreadsheet been updated with instructions for manual testing?

Security

  • Confirm this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.
  • Are all UI and API inputs run through forms or serializers?
  • Are all external inputs validated and sanitized appropriately?
  • Does all branching logic have a default case?
  • Does this solution handle outliers and edge cases gracefully?
  • Are all external communications secured and restricted to SSL?

Documentation

  • Are changes to the UI documented in the platform docs? If this PR introduces new platform site functionality or changes existing ones, the changes should be documented.
  • Are changes to the API documented in the API docs? If this PR introduces new API functionality or changes existing ones, the changes must be documented.
  • Are reusable components documented? If this PR introduces components that are relevant to other developers (for instance a mixin for a view or a generic form) they should be documented in the Wiki.

@darshanasbg darshanasbg requested a review from Yoshani March 26, 2024 10:26
}

try {
notificationScenarioDAO.addNotificationScenario(emailTemplateTypeDisplayName, emailTemplateTypeDisplayName,
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we passing the same param twice since the UUID decision is pending?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Improved with https://github.com/wso2-extensions/identity-event-handler-notification/pull/230/files#diff-f5880581b13fef821d04c7ace573dfa7cd6d418e6c21868874e841d674c2e065R42. First parameter used as the (case-insensitive) key and second parameter used as the display name.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@@ -232,4 +245,203 @@ public static String prependOperationScenarioToErrorCode(String exceptionErrorCo
}
return exceptionErrorCode;
}

public static List<EmailTemplate> convertToEmailTemplates(List<NotificationTemplate> notificationTemplates) {

Choose a reason for hiding this comment

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

Add a doc comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +346 to +347
String[] whiteListPatterns = {TEMPLATE_REGEX_KEY};
String[] blackListPatterns = {REGISTRY_INVALID_CHARS};

Choose a reason for hiding this comment

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

Shall we change the variable names 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 with: bb2c28d

throw new NotificationTemplateManagerClientException(errorCode,
I18nMgtConstants.ErrorMessages.ERROR_CODE_EMPTY_LOCALE.getMessage());
}
// Regex check for registry invalid chars.

Choose a reason for hiding this comment

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

When we move out of registry, these lines might not make sense. Though the allowed characters still makes sense, at some point we have to update the comments, variables and constants.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed.. Since the current implementation has a registry based impl, it will be better to keep this.. But this has to be removed when we totally remove the registry dependency. Will keep track this as a part of that task.

@@ -428,6 +433,10 @@
<carbon.kernel.carbon.base.pkg.version>[1.0.0, 2.0.0)</carbon.kernel.carbon.base.pkg.version>
<axis2.osgi.version.range>[1.6.1, 2.0.0)</axis2.osgi.version.range>

<!--Carbon Database Utils Version-->
<org.wso2.carbon.database.utils.version>2.1.0</org.wso2.carbon.database.utils.version>
<org.wso2.carbon.database.utils.version.range>[2.0.0,2.2.0)</org.wso2.carbon.database.utils.version.range>

Choose a reason for hiding this comment

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

If we want to the 2.1.0 version, shall we restrict the range to start with 2.1.0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

// Register EmailTemplateManagerImpl.
ServiceRegistration notificationManagerSR = bundleCtx
.registerService(NotificationTemplateManager.class.getName(), emailTemplateManager, null);
.registerService(NotificationTemplateManager.class.getName(), notificationManager, null);

Choose a reason for hiding this comment

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

EmailTemplateManagerImpl implementes both EmailTemplateManager and NotificationTemplateManager interfaces. Does it makes sense anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.. As of now these both needs to be implemented since NotificationTemplateManager don't have enough functionalities to deprecate the EmailTemplateManager and EmailTemplateManager is not general enough to handle different notification channel types.

This is mainly due to NotificationTemplate management is not fully complete. We will have to work on wso2/product-is#9762 and get NotificationTemplateManager improved to have all needed functionalities and retire EmailTemplateManager..

At that point it should be possible to EmailTemplateManagerImpl to implement only NotificationTemplateManager.. or even more general terms move out from EmailTemplateManagerImpl by having more general notification management service.

@@ -37,8 +37,8 @@ private I18nMgtConstants() {}
public static final String SMS_CONF_DIRECTORY = "sms";
public static final String EMAIL_ADMIN_CONF_FILE = "email-admin-config.xml";
public static final String SMS_TEMPLAE_ADMIN_CONF_FILE = "sms-templates-admin-config.xml";
public static final String DEFAULT_EMAIL_LOCALE = "en_us";
public static final String DEFAULT_SMS_NOTIFICATION_LOCALE = "en_us";
public static final String DEFAULT_EMAIL_LOCALE = "en_US";

Choose a reason for hiding this comment

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

Will there be any impact in changing these constants?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This change no longer needed with new impl: #230

@darshanasbg
Copy link
Contributor Author

Improved impl has been raised with #229 & #230. Hence, closing this PR.

@darshanasbg darshanasbg closed this Apr 8, 2024
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.

4 participants