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

feat: add getStatusPurpose method #4172

Conversation

paullatzelsperger
Copy link
Member

@paullatzelsperger paullatzelsperger commented May 13, 2024

What this PR changes/adds

This PR adds a method getStatusPurpose to the RevocationListService that returns either the active status ("suspension", "revocation") or null if no status is active.

Why it does that

In IdentityHub we need to update the internal status of a VerifiableCredentialResource depending on this status.

Further notes

Linked Issue(s)

  • added Result#successNullable(@Nullable T content), because results can be successful and still carry no data.
  • removed the @NotNull annotation from Result#success(T content).

Relates eclipse-edc/IdentityHub#340

Please be sure to take a look at the contributing guidelines and our etiquette for pull requests.

@paullatzelsperger paullatzelsperger force-pushed the feat/add_method_to_get_credentialstatus branch from 63003bc to 36d3f5c Compare May 13, 2024 07:02
@paullatzelsperger paullatzelsperger added the enhancement New feature or request label May 13, 2024
@paullatzelsperger paullatzelsperger force-pushed the feat/add_method_to_get_credentialstatus branch from 3db7149 to cd42a65 Compare May 13, 2024 07:31
@codecov-commenter
Copy link

codecov-commenter commented May 13, 2024

Codecov Report

Attention: Patch coverage is 90.47619% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 75.02%. Comparing base (7f20ba5) to head (37cf986).
Report is 252 commits behind head on main.

Files Patch % Lines
...lecredentials/StatusList2021RevocationService.java 90.47% 1 Missing and 1 partial ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4172      +/-   ##
==========================================
+ Coverage   71.74%   75.02%   +3.28%     
==========================================
  Files         919     1007      +88     
  Lines       18457    20471    +2014     
  Branches     1037     1153     +116     
==========================================
+ Hits        13242    15359    +2117     
+ Misses       4756     4610     -146     
- Partials      459      502      +43     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@paullatzelsperger paullatzelsperger force-pushed the feat/add_method_to_get_credentialstatus branch from cd42a65 to 9d645f0 Compare May 13, 2024 07:36
@paullatzelsperger paullatzelsperger marked this pull request as ready for review May 13, 2024 07:36
Comment on lines 65 to 67
if (credential.getCredentialStatus().isEmpty()) {
return successNullable(null);
}
Copy link
Member

Choose a reason for hiding this comment

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

this guard is not necessary, when the status is empty the method will return a success(null) anyway

Copy link
Member Author

@paullatzelsperger paullatzelsperger May 13, 2024

Choose a reason for hiding this comment

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

it's either the guard here, or I refactor / add a similar check in Line 76 to avoid a NPE:

 var list = res.get(true).stream()
                .filter(r -> r.getContent() != null)
                .map(AbstractResult::getContent).toList();

Copy link
Member

Choose a reason for hiding this comment

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

nope, because the stream will be empty so the filter function will never be evaluated

Copy link
Member Author

@paullatzelsperger paullatzelsperger May 13, 2024

Choose a reason for hiding this comment

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

yes, but the .get(true) will, which is what'll cause the NPE. res is a Map<Boolean, List<Result<...>> due to the grouping

Copy link
Member

Choose a reason for hiding this comment

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

ouch!

Copy link
Member

Choose a reason for hiding this comment

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

in any case, you don't need to get the true, but you can stream directly on the whole credential.getCredentialStatus, because at that point there won't be any failed results.

I'm ok also with the guard anyway

@paullatzelsperger paullatzelsperger requested a review from ndr-brt May 13, 2024 08:18
@paullatzelsperger paullatzelsperger merged commit f3992e2 into eclipse-edc:main May 13, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants