Project

General

Profile

Actions

Task #2050

closed

Add full identity to LastContractEndNotificationTask

Added by Tomáš Doischer about 4 years ago. Updated about 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Peter Štrunc
Target version:
Start date:
02/11/2020
Due date:
% Done:

100%

Estimated time:
Owner:

Description

Right now, LastContractEndNotificationTask only sends first name, last name, and username. We need to change this to the full identity.


Related issues

Copied to extras - Task #2131: Add full identity to LastContractEndNotificationTaskClosedPeter Štrunc02/11/2020

Actions
Actions #2

Updated by Tomáš Doischer about 4 years ago

  • Status changed from In Progress to Needs feedback
  • % Done changed from 0 to 80

Developed in branch

https://github.com/bcvsolutions/czechidm-extras/tree/tdoischer/2050-add-identity-to-contract-ends-notification

based on branch 1.6.0-RC.

I added the full identity to the notification but kept the full name with login as well for compatibility. I also noticed that there was a possible null pointer when no recipients were found, I fixed that and improved logging. Right now, in IdM, there are three possible scenarios in this task:
1) the notification was not sent and it shouldn't have been sent (i. e., the identity does not fit the criteria for sending the notification) - will be shown in yellow
2) the notification was not sent and it should have been sent but no recipients were found - will be shown in red with an explaining message
3) the notification was sent, shown in green

Actions #3

Updated by Tomáš Doischer about 4 years ago

  • Assignee changed from Tomáš Doischer to Peter Štrunc

@sourek Can you please perform code-review? Compare my branch to 1.6.0-RC? Thank you!

Actions #4

Updated by Peter Štrunc about 4 years ago

  • Target version set to 1.7.0
Actions #5

Updated by Peter Štrunc about 4 years ago

  • Status changed from Needs feedback to In Progress
  • Assignee changed from Peter Štrunc to Tomáš Doischer

Thanks for the fix, i've found a few issues:

  • Avoid using class fields to store state in classes, which are annotated as Service or Component. These are stateless by nature and are always singleton so it could have unpredictable consequences. If i am not mistaken, all of the class fields in LastContractEndNotificationTask, which are not autowired, can and should be refactored into local variables so that you prevent multithreading issues.
  • You can use configurationService.getDateFormat() instead of hard-coded "dd. MM. YYYY" date format

Following code could be refactored into a separate method:

recipients = getRecipients(guarantee);
            if (recipients.isEmpty()) {
                return Optional.of(new OperationResult.Builder(OperationState.EXCEPTION).
                        setModel(new DefaultResultModel(ExtrasResultCode.NO_RECIPIENTS_FOUND)).
                        build()); 
            }
            sendNotification(ExtrasModuleDescriptor.TOPIC_CONTRACT_END, new ArrayList<>(recipients), guarantee);
            return Optional.of(new OperationResult.Builder(OperationState.EXECUTED).build());

Otherwise the functionality looks great. Please update changelog and add this functionality also to current version compatible with 10.x.x.

I created MR here https://github.com/bcvsolutions/czechidm-extras/pull/16

Actions #6

Updated by Tomáš Doischer about 4 years ago

  • Assignee changed from Tomáš Doischer to Peter Štrunc

Thank you, I moved most of the class fields to local variables, some are still remaining (they have to be there). Other comments were implemented.

I updated documentation and will add the changes to current develop in its own branch.

Actions #7

Updated by Peter Štrunc about 4 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 80 to 100

Merged. Thanks for this feature.

Actions #8

Updated by Peter Štrunc about 4 years ago

  • Copied to Task #2131: Add full identity to LastContractEndNotificationTask added
Actions #9

Updated by Peter Štrunc about 4 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF