Updating consent PUT to allow partial update#920
Conversation
| String receipt = updateRequestDTO.getReceipt() != null ? updateRequestDTO.getReceipt() | ||
| : storedConsent.getReceipt(); | ||
| String status = updateRequestDTO.getStatus() != null ? updateRequestDTO.getStatus() |
There was a problem hiding this comment.
Log Improvement Suggestion No: 1
| String receipt = updateRequestDTO.getReceipt() != null ? updateRequestDTO.getReceipt() | |
| : storedConsent.getReceipt(); | |
| String status = updateRequestDTO.getStatus() != null ? updateRequestDTO.getStatus() | |
| String receipt = updateRequestDTO.getReceipt() != null ? updateRequestDTO.getReceipt() | |
| : storedConsent.getReceipt(); | |
| log.debug("Processing consent update for consentId: {}", consentId); |
| ArrayList<ConsentMappingResource> consentMappingResources = null; | ||
| if (updateRequestDTO.getAuthorizationResources() != null) { | ||
| authorizationResources = new ArrayList<>(); |
There was a problem hiding this comment.
Log Improvement Suggestion No: 2
| ArrayList<ConsentMappingResource> consentMappingResources = null; | |
| if (updateRequestDTO.getAuthorizationResources() != null) { | |
| authorizationResources = new ArrayList<>(); | |
| if (updateRequestDTO.getAuthorizationResources() != null) { | |
| log.debug("Updating authorization resources for consentId: {}", consentId); | |
| authorizationResources = new ArrayList<>(); |
There was a problem hiding this comment.
AI Agent Log Improvement Checklist
- The log-related comments and suggestions in this review were generated by an AI tool to assist with identifying potential improvements. Purpose of reviewing the code for log improvements is to improve the troubleshooting capabilities of our products.
- Please make sure to manually review and validate all suggestions before applying any changes. Not every code suggestion would make sense or add value to our purpose. Therefore, you have the freedom to decide which of the suggestions are helpful.
✅ Before merging this pull request:
- Review all AI-generated comments for accuracy and relevance.
- Complete and verify the table below. We need your feedback to measure the accuracy of these suggestions and the value they add. If you are rejecting a certain code suggestion, please mention the reason briefly in the suggestion for us to capture it.
| Comment | Accepted (Y/N) | Reason |
|---|---|---|
| #### Log Improvement Suggestion No: 1 | ||
| #### Log Improvement Suggestion No: 2 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughRemoved Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@financial-services-accelerator/components/org.wso2.financial.services.accelerator.consent.mgt.extensions/src/main/java/org/wso2/financial/services/accelerator/consent/mgt/extensions/manage/utils/ConsentManageUtils.java`:
- Around line 346-350: The current code initializes authorizationResources and
consentMappingResources to null and then passes them through to
DetailedConsentResource even when updateRequestDTO.getAuthorizationResources()
is absent, which can unintentionally clear existing associations; change the
logic to only construct and set authorizationResources and
consentMappingResources when updateRequestDTO.getAuthorizationResources() (and
the corresponding mapping list) is non-null—i.e., remove the null passthrough
and guard the assignment to DetailedConsentResource so you only call
setAuthorizationResources(...) and setConsentMappingResources(...) when you've
created non-null lists from updateRequestDTO, leaving existing fields untouched
otherwise (refer to updateRequestDTO, authorizationResources,
consentMappingResources, and DetailedConsentResource to locate the code).
- Around line 343-344: The code sets consentAttributes to null when
updateRequestDTO.getConsentAttributes() is absent, which causes stored
attributes to be erased; change the logic in ConsentManageUtils so that the
local variable consentAttributes keeps the existing stored attributes when
updateRequestDTO.getConsentAttributes() returns null (i.e., only overwrite
consentAttributes when updateRequestDTO.getConsentAttributes() != null),
referencing updateRequestDTO.getConsentAttributes() and the stored consent
attributes retrieval used elsewhere in the method to preserve prior values.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c39eec81-9237-4ca5-b861-e19a858e8e6b
📒 Files selected for processing (2)
financial-services-accelerator/components/org.wso2.financial.services.accelerator.consent.mgt.extensions/src/main/java/org/wso2/financial/services/accelerator/consent/mgt/extensions/manage/model/InternalConsentUpdateRequestDTO.javafinancial-services-accelerator/components/org.wso2.financial.services.accelerator.consent.mgt.extensions/src/main/java/org/wso2/financial/services/accelerator/consent/mgt/extensions/manage/utils/ConsentManageUtils.java
Updating consent PUT to allow partial update
Issue link: #909
Doc Issue: Optional, link issue from documentation repository
Applicable Labels: Spec, product, version, type (specify requested labels)
Development Checklist
Testing Checklist
Summary by CodeRabbit