-
Notifications
You must be signed in to change notification settings - Fork 66
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
Introduce Generic Organization Resource Resolver #415
Conversation
Codecov ReportAttention: Patch coverage is
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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
.../identity/organization/resource/hierarchy/traverse/service/strategy/AggregationStrategy.java
Show resolved
Hide resolved
...on/identity/organization/resource/hierarchy/traverse/service/OrgResourceResolverService.java
Show resolved
Hide resolved
components/org.wso2.carbon.identity.organization.resource.hierarchy.traverse.service/pom.xml
Outdated
Show resolved
Hide resolved
/** | ||
* The exception to throw when the code is not implemented. | ||
*/ | ||
public class NotImplementedException extends RuntimeException { |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NotImplementedException
was used here since it is the usual practice when it comes to default methods in interfaces.
Examples:
- https://github.com/wso2/carbon-kernel/blob/4.10.x/core/org.wso2.carbon.user.core/src/main/java/org/wso2/carbon/user/core/NotImplementedException.java
- https://github.com/wso2/identity-organization-management-core/blob/main/components/org.wso2.carbon.identity.organization.management.service/src/main/java/org/wso2/carbon/identity/organization/management/service/exception/NotImplementedException.java
Lines 159 to 164 in 021650f
default Map<String, String> getAncestorAppIds(String childAppId, String childOrgId) throws OrganizationManagementException { throw new NotImplementedException( "getAncestorAppIds method is not implemented in " + this.getClass().getName()); }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UnsupportedOperationException
has been mainly used in following places.
- deprecated methods [1]
- to specify that the functionality is not supported at all [2]
- in branching logic (if/else) where we don't support the method for different branches.
[1] - https://github.com/wso2/carbon-kernel/blob/41af87519e8f65e0efcfd3ce9c33cfb51f839e0d/core/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/config/StaticConfiguration.java#L124-L133
[2] - https://github.com/wso2/carbon-kernel/blob/41af87519e8f65e0efcfd3ce9c33cfb51f839e0d/core/org.wso2.carbon.registry.core/src/main/java/org/wso2/carbon/registry/core/jdbc/utils/RegistryDataSource.java#L120-L123
[3] - https://github.com/wso2/carbon-identity-framework/blob/091a62a931a4a65f270cd3253136ba288be2c7a9/components/application-mgt/org.wso2.carbon.identity.application.mgt/src/main/java/org/wso2/carbon/identity/application/mgt/ApplicationManagementServiceImpl.java#L426
* @return Aggregated resource. | ||
* @throws OrgResourceHierarchyTraverseException If an error occurs while aggregating the resources. | ||
*/ | ||
default T aggregate(List<String> organizationHierarchy, Function<String, Optional<T>> resourceRetriever) |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
...dentity/organization/resource/hierarchy/traverse/service/OrgResourceResolverServiceImpl.java
Outdated
Show resolved
Hide resolved
/** | ||
* Implementation of the OrgResourceResolverService. | ||
*/ | ||
public class OrgResourceResolverServiceImpl implements OrgResourceResolverService { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
...dentity/organization/resource/hierarchy/traverse/service/OrgResourceResolverServiceImpl.java
Outdated
Show resolved
Hide resolved
...tity/organization/resource/hierarchy/traverse/service/exception/NotImplementedException.java
Outdated
Show resolved
Hide resolved
...source/hierarchy/traverse/service/exception/OrgResourceHierarchyTraverseClientException.java
Outdated
Show resolved
Hide resolved
...ion/resource/hierarchy/traverse/service/exception/OrgResourceHierarchyTraverseException.java
Outdated
Show resolved
Hide resolved
...ion/resource/hierarchy/traverse/service/exception/OrgResourceHierarchyTraverseException.java
Show resolved
Hide resolved
...source/hierarchy/traverse/service/internal/OrgResourceHierarchyTraverseServiceComponent.java
Outdated
Show resolved
Hide resolved
...source/hierarchy/traverse/service/internal/OrgResourceHierarchyTraverseServiceComponent.java
Outdated
Show resolved
Hide resolved
...ource/hierarchy/traverse/service/internal/OrgResourceHierarchyTraverseServiceDataHolder.java
Outdated
Show resolved
Hide resolved
...ource/hierarchy/traverse/service/internal/OrgResourceHierarchyTraverseServiceDataHolder.java
Outdated
Show resolved
Hide resolved
...ource/hierarchy/traverse/service/internal/OrgResourceHierarchyTraverseServiceDataHolder.java
Outdated
Show resolved
Hide resolved
...organization/resource/hierarchy/traverse/service/strategy/FirstFoundAggregationStrategy.java
Outdated
Show resolved
Hide resolved
...ource/hierarchy/traverse/service/internal/OrgResourceHierarchyTraverseServiceDataHolder.java
Outdated
Show resolved
Hide resolved
PR builder started |
...dentity/organization/resource/hierarchy/traverse/service/OrgResourceResolverServiceTest.java
Outdated
Show resolved
Hide resolved
...dentity/organization/resource/hierarchy/traverse/service/OrgResourceResolverServiceTest.java
Outdated
Show resolved
Hide resolved
PR builder completed |
There was a problem hiding this 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
PR builder started |
PR builder completed |
There was a problem hiding this 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
Purpose
Public Issues
Related Issues
Related PRs