Skip to content

Commit

Permalink
Revert "Workaround + fixed generator/resolver of bean catalog in mave…
Browse files Browse the repository at this point in the history
…n-plugin (#6554)"

This reverts commit bd3f81d.

Fixes #6556
  • Loading branch information
jamesnetherton committed Dec 4, 2024
1 parent 6f8d488 commit c46acba
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ public CqCatalog(Path baseDir, Flavor flavor) {

public CqCatalog(Flavor flavor, Function<String, InputStream> resourceLocator) {
this.flavor = flavor;
// workaround for catalog `beans/*.json`, see comment on BeansWorkaroundCustomCatalog for more information
final DefaultCamelCatalog c = new BeansWorkaroundCustomCatalog(true);
final DefaultCamelCatalog c = new DefaultCamelCatalog(true);
c.setRuntimeProvider(flavor.createRuntimeProvider(c));
c.setVersionManager(new CqVersionManager(c, resourceLocator));
this.catalog = c;
Expand Down Expand Up @@ -195,8 +194,6 @@ static void serialize(final Path catalogPath, ArtifactModel<?> model) {
switch (model.getKind()) {
case bean:
rawJson = JsonMapper.createParameterJsonSchema((PojoBeanModel) model);
//workaround
rawJson = rawJson.replace("model", "bean");
break;
case component:
rawJson = JsonMapper.createParameterJsonSchema((ComponentModel) model);
Expand Down Expand Up @@ -529,7 +526,7 @@ public List<String> findOtherNames() {
@Override
public List<String> findBeansNames() {
List<String> names = new ArrayList<>();
InputStream is = getCamelCatalog().getVersionManager().getResourceAsStream(getBeansCatalog());
InputStream is = getCamelCatalog().getVersionManager().getResourceAsStream(getPojoBeanJSonSchemaDirectory());
if (is != null) {
try {
CatalogHelper.loadLines(is, names);
Expand Down Expand Up @@ -571,20 +568,4 @@ public void close() {
}
}

/**
* Prior https://github.com/apache/camel/pull/15708, the catalog files from `beans/*json` might have contained
* attribute `model` instead of `bean`. This custom catalog is fixing the json, to be parsable by Camel
* tooling.
*/
public static class BeansWorkaroundCustomCatalog extends DefaultCamelCatalog {
public BeansWorkaroundCustomCatalog(boolean caching) {
super(caching);
}

@Override
public String pojoBeanJSonSchema(String name) {
return getJSonSchemaResolver().getPojoBeanJSonSchema(name).replace("model", "bean");
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
final CqCatalog catalog = CqCatalog.findFirstFromClassPath();
if (extendClassPathCatalog) {
catalog.store(catalogBaseDir.toPath());
catalog.models().forEach(model -> schemesByKind.get(model.getKind().name()).add(model.getName()));
catalog.models().forEach(model -> schemesByKind.get(model.getKind()).add(model.getName()));
}

findExtensions()
Expand Down

0 comments on commit c46acba

Please sign in to comment.