-
Notifications
You must be signed in to change notification settings - Fork 26
Refactoring: Fix NPE, Extract Catalog Service, and Simplify Hierarchy #1366
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,4 @@ | ||
| eclipse.preferences.version=1 | ||
| org.eclipse.jdt.apt.aptEnabled=false | ||
| org.eclipse.jdt.apt.aptEnabled=true | ||
| org.eclipse.jdt.apt.genSrcDir=target/generated-sources/annotations | ||
| org.eclipse.jdt.apt.genTestSrcDir=target/generated-test-sources/test-annotations |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this has nothing to do in the codebase |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| 29-11-2025 21:20:36: Detecting code smells... | ||
| 29-11-2025 21:20:36: Detecting cyclic dependency... | ||
| 29-11-2025 21:20:36: Detecting architecture smells... | ||
| 29-11-2025 21:20:37: Exporting analysis results... | ||
| 29-11-2025 21:20:45: Done. | ||
| Total time (sec): 17 |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this has nothing to do in the codebase |
Large diffs are not rendered by default.
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this has nothing to do in the codebase |
Large diffs are not rendered by default.
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this has nothing to do in the codebase |
Large diffs are not rendered by default.
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this has nothing to do in the codebase |
Large diffs are not rendered by default.
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this has nothing to do in the codebase |
Large diffs are not rendered by default.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| package com.github.cameltooling.lsp.internal; | ||
|
|
||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.concurrent.CompletableFuture; | ||
| import org.apache.camel.catalog.DefaultCamelCatalog; | ||
| import org.apache.camel.catalog.RuntimeProvider; | ||
| import org.apache.camel.catalog.maven.MavenVersionManager; | ||
| import com.github.cameltooling.lsp.internal.catalog.runtimeprovider.CamelRuntimeProvider; | ||
| import com.github.cameltooling.lsp.internal.settings.JSONUtility; | ||
| import com.google.gson.Gson; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
| public class CamelCatalogService { | ||
|
|
||
| private static final Logger LOGGER = LoggerFactory.getLogger(CamelCatalogService.class); | ||
|
|
||
| public CompletableFuture<org.apache.camel.catalog.CamelCatalog> updateCatalog(String camelVersion, String camelCatalogRuntimeProvider, List<Map<?, ?>> extraComponents) { | ||
| return CompletableFuture.supplyAsync(() -> { | ||
| DefaultCamelCatalog catalog = new DefaultCamelCatalog(true); | ||
| updateCatalogVersion(camelVersion, catalog); | ||
| updateCatalogRuntimeProvider(camelCatalogRuntimeProvider, catalog); | ||
| updateCatalogExtraComponents(extraComponents, catalog); | ||
| return catalog; | ||
| }); | ||
| } | ||
|
|
||
| private void updateCatalogVersion(String camelVersion, DefaultCamelCatalog catalog) { | ||
| if (camelVersion != null && !camelVersion.isEmpty()) { | ||
| MavenVersionManager versionManager = new MavenVersionManager(); | ||
| if (camelVersion.contains("redhat")) { | ||
| versionManager.addMavenRepository("central", "https://repo1.maven.org/maven2/"); | ||
| versionManager.addMavenRepository("maven.redhat.ga", "https://maven.repository.redhat.com/ga/"); | ||
| } | ||
| catalog.setVersionManager(versionManager); | ||
| if (!catalog.loadVersion(camelVersion)) { | ||
| LOGGER.warn("Cannot load Camel catalog with version {}", camelVersion); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private void updateCatalogRuntimeProvider(String camelCatalogRuntimeProvider, DefaultCamelCatalog catalog) { | ||
| if(camelCatalogRuntimeProvider != null && !camelCatalogRuntimeProvider.isEmpty()) { | ||
| RuntimeProvider runtimeProvider = CamelRuntimeProvider.getProvider(camelCatalogRuntimeProvider); | ||
| if(runtimeProvider != null) { | ||
| catalog.setRuntimeProvider(runtimeProvider); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private void updateCatalogExtraComponents(List<Map<?, ?>> extraComponents, DefaultCamelCatalog catalog) { | ||
| if (extraComponents != null) { | ||
| for (Map<?,?> extraComponent : extraComponents) { | ||
| JSONUtility jsonUtility = new JSONUtility(); | ||
| Map<?,?> extraComponentTopLevel = jsonUtility.toModel(extraComponent, Map.class); | ||
| Map<?,?> componentAttributes = jsonUtility.toModel(extraComponentTopLevel.get("component"), Map.class); | ||
| String name = (String) componentAttributes.get("scheme"); | ||
| String className = (String) componentAttributes.get("javaType"); | ||
| catalog.addComponent(name, className, new Gson().toJson(extraComponent)); | ||
| } | ||
| } | ||
| } | ||
| } |
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.
this has nothing to do in the codebase