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

Introduce Generic Organization Resource Resolver #415

Merged
merged 21 commits into from
Dec 4, 2024

Conversation

dhaura
Copy link
Contributor

@dhaura dhaura commented Nov 21, 2024

Purpose

  • This PR implements a generic resource resolver designed for B2B organization hierarchies. It enables the resolution of any given resource through the ancestor hierarchy of an organization.

Public Issues

Related Issues

Related PRs

Copy link

codecov bot commented Nov 21, 2024

Codecov Report

Attention: Patch coverage is 78.16092% with 19 lines in your changes missing coverage. Please review.

Project coverage is 47.29%. Comparing base (a557994) to head (d2107a1).
Report is 22 commits behind head on main.

Files with missing lines Patch % Lines
...ervice/strategy/FirstFoundAggregationStrategy.java 63.63% 4 Missing and 4 partials ⚠️
.../service/strategy/MergeAllAggregationStrategy.java 73.33% 4 Missing and 4 partials ⚠️
...service/util/OrgResourceHierarchyTraverseUtil.java 85.71% 0 Missing and 2 partials ⚠️
...averse/service/OrgResourceResolverServiceImpl.java 95.23% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #415      +/-   ##
============================================
+ Coverage     46.45%   47.29%   +0.83%     
- Complexity     1034     1065      +31     
============================================
  Files           113      117       +4     
  Lines          6806     6956     +150     
  Branches        821      849      +28     
============================================
+ Hits           3162     3290     +128     
- Misses         3353     3363      +10     
- Partials        291      303      +12     
Flag Coverage Δ
unit 31.94% <78.16%> (+2.77%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

/**
* The exception to throw when the code is not implemented.
*/
public class NotImplementedException extends RuntimeException {
Copy link
Member

Choose a reason for hiding this comment

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

Can't we use UnsupportedOperationException instead of this ?

Copy link
Contributor Author

@dhaura dhaura Nov 22, 2024

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

* @return Aggregated resource.
* @throws OrgResourceHierarchyTraverseException If an error occurs while aggregating the resources.
*/
default T aggregate(List<String> organizationHierarchy, Function<String, Optional<T>> resourceRetriever)
Copy link
Member

Choose a reason for hiding this comment

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

Why do we have these as default ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are specified as default to simplify the process of creating a new aggregation strategy, particularly when the strategy only requires implementing a single method.

Ex: If there's a resource type which is available at the org-level but not at the app-level, there is no need to implement the application specific aggregate method.

/**
* Implementation of the OrgResourceResolverService.
*/
public class OrgResourceResolverServiceImpl implements OrgResourceResolverService {
Copy link
Member

Choose a reason for hiding this comment

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

Can we introduce OrganizationManager as a constructor ? This will make writing unit tests easy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Our usual practice with OSGI services is to store all the required services/ managers by the component in the data holder of the component.

@darshanasbg darshanasbg requested a review from Copilot November 29, 2024 04:45

Choose a reason for hiding this comment

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

Copilot reviewed 6 out of 20 changed files in this pull request and generated no suggestions.

Files not reviewed (14)
  • components/org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service/pom.xml: Language not supported
  • components/org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service/src/test/resources/testng.xml: Language not supported
  • features/org.wso2.carbon.identity.organization.management.server.feature/pom.xml: Language not supported
  • pom.xml: Language not supported
  • components/org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service/src/main/java/org/wso2/carbon/identity/organization/resource/hierarchy/traverse/service/strategy/AggregationStrategy.java: Evaluated as low risk
  • components/org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service/src/main/java/org/wso2/carbon/identity/organization/resource/hierarchy/traverse/service/internal/OrgResourceHierarchyTraverseServiceDataHolder.java: Evaluated as low risk
  • components/org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service/src/main/java/org/wso2/carbon/identity/organization/resource/hierarchy/traverse/service/exception/OrgResourceHierarchyTraverseException.java: Evaluated as low risk
  • components/org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service/src/main/java/org/wso2/carbon/identity/organization/resource/hierarchy/traverse/service/exception/NotImplementedException.java: Evaluated as low risk
  • components/org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service/src/main/java/org/wso2/carbon/identity/organization/resource/hierarchy/traverse/service/exception/OrgResourceHierarchyTraverseClientException.java: Evaluated as low risk
  • components/org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service/src/main/java/org/wso2/carbon/identity/organization/resource/hierarchy/traverse/service/OrgResourceResolverServiceImpl.java: Evaluated as low risk
  • components/org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service/src/main/java/org/wso2/carbon/identity/organization/resource/hierarchy/traverse/service/internal/OrgResourceHierarchyTraverseServiceComponent.java: Evaluated as low risk
  • components/org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service/src/main/java/org/wso2/carbon/identity/organization/resource/hierarchy/traverse/service/util/OrgResourceHierarchyTraverseUtil.java: Evaluated as low risk
  • components/org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service/src/main/java/org/wso2/carbon/identity/organization/resource/hierarchy/traverse/service/strategy/MergeAllAggregationStrategy.java: Evaluated as low risk
  • components/org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service/src/test/java/org/wso2/carbon/identity/organization/resource/hierarchy/traverse/service/mock/resource/impl/model/MockResource.java: Evaluated as low risk
@jenkins-is-staging
Copy link

PR builder started
Link: https://github.com/wso2/product-is/actions/runs/12085608306

@jenkins-is-staging
Copy link

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/12085608306
Status: success

Copy link

@jenkins-is-staging jenkins-is-staging left a comment

Choose a reason for hiding this comment

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

Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/12085608306

@jenkins-is-staging
Copy link

PR builder started
Link: https://github.com/wso2/product-is/actions/runs/12153757493

@jenkins-is-staging
Copy link

PR builder completed
Link: https://github.com/wso2/product-is/actions/runs/12153757493
Status: success

Copy link

@jenkins-is-staging jenkins-is-staging left a comment

Choose a reason for hiding this comment

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

Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/12153757493

@AnuradhaSK AnuradhaSK merged commit 5551fc9 into wso2-extensions:main Dec 4, 2024
4 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.

5 participants