Skip to content

Introduce a new resource to fetch all resources belonging to a project#535

Open
chathuranga-jayanath-99 wants to merge 1 commit intowso2:mainfrom
chathuranga-jayanath-99:load-connector-from-deps-main
Open

Introduce a new resource to fetch all resources belonging to a project#535
chathuranga-jayanath-99 wants to merge 1 commit intowso2:mainfrom
chathuranga-jayanath-99:load-connector-from-deps-main

Conversation

@chathuranga-jayanath-99
Copy link
Copy Markdown
Contributor

Purpose

A project can contain resources from both the project itself and its integration project dependencies. This resource fetches all the resources that belong to the project itself.

A project can contain resources from both the project itself and its integration project dependencies. This resource fetches all the resources that belong to the project.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

Warning

Rate limit exceeded

@chathuranga-jayanath-99 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 49 minutes and 36 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3d1acdc3-b24a-4387-b822-f97d166bc31f

📥 Commits

Reviewing files that changed from the base of the PR and between dd73ad6 and 2bf64da.

📒 Files selected for processing (5)
  • org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/SynapseLanguageService.java
  • org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/customservice/ISynapseLanguageService.java
  • org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/customservice/synapse/resourceFinder/AbstractResourceFinder.java
  • org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/customservice/synapse/resourceFinder/NewProjectResourceFinder.java
  • org.eclipse.lemminx/src/test/java/org/eclipse/lemminx/synapse/resource/finder/ResourceFinderTest.java
📝 Walkthrough

Walkthrough

This pull request introduces a new resource aggregation feature by adding a getAllResources() method across multiple architectural layers. The method traverses the service layer (ISynapseLanguageService interface and SynapseLanguageService implementation), delegates to a ResourceFinder abstraction, and implements concrete logic in NewProjectResourceFinder that combines resources from the current project with resources from dependent projects using a merge operation. A corresponding test validates the resource merging behavior.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant SynapseLanguageService
    participant NewProjectResourceFinder
    participant CurrentProject as Current Project<br/>(findAllResources)
    participant DependentProjects as Dependent Projects<br/>(getDependentResourcesMap)

    Client->>SynapseLanguageService: getAllResources()
    SynapseLanguageService->>NewProjectResourceFinder: getAllResources(projectUri)
    NewProjectResourceFinder->>CurrentProject: findAllResources()
    CurrentProject-->>NewProjectResourceFinder: Map with artifacts, local, registry resources
    NewProjectResourceFinder->>DependentProjects: getDependentResourcesMap()
    DependentProjects-->>NewProjectResourceFinder: Dependent resources by type
    NewProjectResourceFinder->>NewProjectResourceFinder: For each resource type:<br/>merge dependent into main
    NewProjectResourceFinder-->>SynapseLanguageService: Aggregated Map<String, ResourceResponse>
    SynapseLanguageService-->>Client: CompletableFuture<Map<String, ResourceResponse>>
Loading
🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description provides only the Purpose section with minimal detail; it lacks Goals, Approach, User stories, Release notes, Documentation, Testing, and other required template sections. Complete the PR description by adding at least Goals, Approach, Automation tests, and other critical sections from the template to provide comprehensive context for reviewers.
Docstring Coverage ⚠️ Warning Docstring coverage is 5.88% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title directly describes the main change: introducing a new resource to fetch all resources belonging to a project, which aligns with the implemented API additions across multiple files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 49 minutes and 36 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment on lines +340 to +343
@Override
public CompletableFuture<Map<String, ResourceResponse>> getAllResources() {

Map<String, ResourceResponse> allResources = resourceFinder.getAllResources(projectUri);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 1

Suggested change
@Override
public CompletableFuture<Map<String, ResourceResponse>> getAllResources() {
Map<String, ResourceResponse> allResources = resourceFinder.getAllResources(projectUri);
@Override
public CompletableFuture<Map<String, ResourceResponse>> getAllResources() {
log.info("Fetching all available resources for project: {}", projectUri);
Map<String, ResourceResponse> allResources = resourceFinder.getAllResources(projectUri);

Comment on lines +410 to +413
public Map<String, ResourceResponse> getAllResources(String projectPath) {

return new HashMap<>();
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 3

Suggested change
public Map<String, ResourceResponse> getAllResources(String projectPath) {
return new HashMap<>();
}
public Map<String, ResourceResponse> getAllResources(String projectPath) {
log.debug("Getting all resources for project path: {}", projectPath);
return new HashMap<>();
}

Comment on lines +150 to +153
@Override
public Map<String, ResourceResponse> getAllResources(String projectPath) {

Map<String, ResourceResponse> allResources = findAllResources(projectPath);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 4

Suggested change
@Override
public Map<String, ResourceResponse> getAllResources(String projectPath) {
Map<String, ResourceResponse> allResources = findAllResources(projectPath);
@Override
public Map<String, ResourceResponse> getAllResources(String projectPath) {
log.info("Getting all resources for project: " + projectPath);
Map<String, ResourceResponse> allResources = findAllResources(projectPath);

Comment on lines +153 to +155
Map<String, ResourceResponse> allResources = findAllResources(projectPath);
Map<String, ResourceResponse> dependentResources = getDependentResourcesMap();
for (Map.Entry<String, ResourceResponse> entry : dependentResources.entrySet()) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 5

Suggested change
Map<String, ResourceResponse> allResources = findAllResources(projectPath);
Map<String, ResourceResponse> dependentResources = getDependentResourcesMap();
for (Map.Entry<String, ResourceResponse> entry : dependentResources.entrySet()) {
Map<String, ResourceResponse> allResources = findAllResources(projectPath);
Map<String, ResourceResponse> dependentResources = getDependentResourcesMap();
log.debug("Found " + allResources.size() + " main resources and " + dependentResources.size() + " dependent resource types");
for (Map.Entry<String, ResourceResponse> entry : dependentResources.entrySet()) {

ResourceResponse depApiResponse = new ResourceResponse();
depApiResponse.setResources(new ArrayList<>(List.of(depApi)));
finder.addDependentResources("api", depApiResponse);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 6

Suggested change
Map<String, ResourceResponse> allResources = finder.getAllResources(projectPath);
log.info("Retrieved all resources from finder for project path: {}", projectPath);

Copy link
Copy Markdown

@wso2-engineering wso2-engineering Bot left a comment

Choose a reason for hiding this comment

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

AI Agent Log Improvement Checklist

⚠️ Warning: AI-Generated Review Comments

  • 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: 3
#### Log Improvement Suggestion No: 4
#### Log Improvement Suggestion No: 5
#### Log Improvement Suggestion No: 6

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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
`@org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/customservice/synapse/resourceFinder/AbstractResourceFinder.java`:
- Around line 410-413: The default implementation of
AbstractResourceFinder.getAllResources currently returns an empty map which can
hide bugs; change getAllResources(String projectPath) to delegate to the
existing findAllResources(projectPath) by returning its result (or alternatively
make getAllResources abstract) so subclasses that don't override it inherit
correct behavior; update the method in AbstractResourceFinder to call
findAllResources(projectPath) (or convert getAllResources to abstract) to ensure
consistent resource discovery.

In
`@org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/customservice/synapse/resourceFinder/NewProjectResourceFinder.java`:
- Around line 143-159: getAllResources currently merges dependent-project data
(via getDependentResourcesMap and mergeResourceResponses) into the project
result, violating the project-only contract; change getAllResources to return
only the map produced by findAllResources(projectPath) and remove the code that
obtains getDependentResourcesMap() and merges entries (references:
getAllResources, findAllResources, getDependentResourcesMap,
mergeResourceResponses) so the returned payload contains only project-owned
resources.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5f1600af-619f-484b-825f-6767fc6f60e0

📥 Commits

Reviewing files that changed from the base of the PR and between 163614d and dd73ad6.

📒 Files selected for processing (5)
  • org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/SynapseLanguageService.java
  • org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/customservice/ISynapseLanguageService.java
  • org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/customservice/synapse/resourceFinder/AbstractResourceFinder.java
  • org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/customservice/synapse/resourceFinder/NewProjectResourceFinder.java
  • org.eclipse.lemminx/src/test/java/org/eclipse/lemminx/synapse/resource/finder/ResourceFinderTest.java

Comment on lines +410 to +413
public Map<String, ResourceResponse> getAllResources(String projectPath) {

return new HashMap<>();
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Avoid an empty default implementation for getAllResources.

Returning an empty map here can silently produce incorrect results when a finder does not override this method. Use findAllResources(projectPath) as the default behavior (or make this method abstract).

Suggested fix
 public Map<String, ResourceResponse> getAllResources(String projectPath) {
-
-        return new HashMap<>();
+        return findAllResources(projectPath);
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
public Map<String, ResourceResponse> getAllResources(String projectPath) {
return new HashMap<>();
}
public Map<String, ResourceResponse> getAllResources(String projectPath) {
return findAllResources(projectPath);
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/customservice/synapse/resourceFinder/AbstractResourceFinder.java`
around lines 410 - 413, The default implementation of
AbstractResourceFinder.getAllResources currently returns an empty map which can
hide bugs; change getAllResources(String projectPath) to delegate to the
existing findAllResources(projectPath) by returning its result (or alternatively
make getAllResources abstract) so subclasses that don't override it inherit
correct behavior; update the method in AbstractResourceFinder to call
findAllResources(projectPath) (or convert getAllResources to abstract) to ensure
consistent resource discovery.

Comment on lines +143 to +159
/**
* Returns all resources in the project, including artifacts, local entries, and registry
* resources from both the main project and resolved dependent projects.
*
* @param projectPath the root directory of the project
* @return a map where the key is the resource type and the value is the corresponding ResourceResponse
*/
@Override
public Map<String, ResourceResponse> getAllResources(String projectPath) {

Map<String, ResourceResponse> allResources = findAllResources(projectPath);
Map<String, ResourceResponse> dependentResources = getDependentResourcesMap();
for (Map.Entry<String, ResourceResponse> entry : dependentResources.entrySet()) {
allResources.computeIfAbsent(entry.getKey(), k -> new ResourceResponse());
mergeResourceResponses(allResources.get(entry.getKey()), entry.getValue());
}
return allResources;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

getAllResources currently includes dependent-project resources, which conflicts with the endpoint objective.

This method merges getDependentResourcesMap() into the response, so the returned payload is not project-only. If the endpoint contract is project-owned resources only, return just findAllResources(projectPath).

Suggested fix
 `@Override`
 public Map<String, ResourceResponse> getAllResources(String projectPath) {
-
-        Map<String, ResourceResponse> allResources = findAllResources(projectPath);
-        Map<String, ResourceResponse> dependentResources = getDependentResourcesMap();
-        for (Map.Entry<String, ResourceResponse> entry : dependentResources.entrySet()) {
-            allResources.computeIfAbsent(entry.getKey(), k -> new ResourceResponse());
-            mergeResourceResponses(allResources.get(entry.getKey()), entry.getValue());
-        }
-        return allResources;
+        return findAllResources(projectPath);
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/customservice/synapse/resourceFinder/NewProjectResourceFinder.java`
around lines 143 - 159, getAllResources currently merges dependent-project data
(via getDependentResourcesMap and mergeResourceResponses) into the project
result, violating the project-only contract; change getAllResources to return
only the map produced by findAllResources(projectPath) and remove the code that
obtains getDependentResourcesMap() and merges entries (references:
getAllResources, findAllResources, getDependentResourcesMap,
mergeResourceResponses) so the returned payload contains only project-owned
resources.

@chathuranga-jayanath-99 chathuranga-jayanath-99 force-pushed the load-connector-from-deps-main branch from dd73ad6 to 2bf64da Compare April 29, 2026 11:28
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.

1 participant