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

addressing PR review feedback #1183

Merged
merged 1 commit into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,10 @@ public static ConfigBean configure(String[] args) {
options.addOption(verboseOption);

ConfigBean configBean = new ConfigBean();
CommandLineParser parser = new DefaultParser();

CommandLine cmd = null;
try {
cmd = parser.parse(options, args);
CommandLineParser parser = new DefaultParser();
CommandLine cmd = parser.parse(options, args);
configBean.setOutputFolder(Util.getNormalizedFolder(cmd.getOptionValue(outputOption.getOpt())));
configBean.setCatalogsName(cmd.getOptionValue(catalogsNameOption.getOpt()));
configBean.setKameletsVersion(cmd.getOptionValue(kameletsVersionOption.getOpt()));
Expand All @@ -76,7 +75,6 @@ public static ConfigBean configure(String[] args) {
}
} catch (ParseException e) {
LOGGER.severe("Missing required options");
e.printStackTrace();
printHelpAndExit();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ public String getPatternCatalog() throws Exception {
required.add(propertyName);
}

propertySchema.put("group", catalogOp.getGroup());
sortedSchemaProperties.set(propertyName, propertySchema);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

public class CamelCatalogVersionLoader {
private static final Logger LOGGER = Logger.getLogger(CamelCatalogVersionLoader.class.getName());
private final KaotoMavenVersionManager KAOTO_VERSION_MANAGER = new KaotoMavenVersionManager();
private final KaotoMavenVersionManager kaotoVersionManager = new KaotoMavenVersionManager();
private final CamelCatalog camelCatalog = new DefaultCamelCatalog(false);
private final Map<String, String> kameletBoundaries = new HashMap<>();
private final Map<String, String> kamelets = new HashMap<>();
Expand All @@ -48,8 +48,8 @@ public class CamelCatalogVersionLoader {
public CamelCatalogVersionLoader(CatalogRuntime runtime, boolean verbose) {
this.runtime = runtime;
this.verbose = verbose;
KAOTO_VERSION_MANAGER.setLog(verbose);
camelCatalog.setVersionManager(KAOTO_VERSION_MANAGER);
kaotoVersionManager.setLog(verbose);
camelCatalog.setVersionManager(kaotoVersionManager);
}

public CatalogRuntime getRuntime() {
Expand Down Expand Up @@ -115,7 +115,7 @@ public boolean loadCamelYamlDsl() {
MavenCoordinates mavenCoordinates = getYamlDslMavenCoordinates(runtime, yamlDSLModel);
loadDependencyInClasspath(mavenCoordinates);

ClassLoader classLoader = KAOTO_VERSION_MANAGER.getClassLoader();
ClassLoader classLoader = kaotoVersionManager.getClassLoader();
URL resourceURL = classLoader.getResource(Constants.CAMEL_YAML_DSL_ARTIFACT);
if (resourceURL == null) {
return false;
Expand Down Expand Up @@ -174,7 +174,7 @@ public boolean loadCamelKCRDs(String version) {
version);
boolean areCamelKCRDsLoaded = loadDependencyInClasspath(mavenCoordinates);

ClassLoader classLoader = KAOTO_VERSION_MANAGER.getClassLoader();
ClassLoader classLoader = kaotoVersionManager.getClassLoader();

for (String crd : Constants.CAMEL_K_CRDS_ARTIFACTS) {
URL resourceURL = classLoader.getResource(crd);
Expand All @@ -201,16 +201,16 @@ public void loadLocalSchemas() {
}

private void configureRepositories(String version) {
if (KAOTO_VERSION_MANAGER.repositories.get("central") == null)
KAOTO_VERSION_MANAGER.addMavenRepository("central", "https://repo1.maven.org/maven2/");
if (kaotoVersionManager.repositories.get("central") == null)
kaotoVersionManager.addMavenRepository("central", "https://repo1.maven.org/maven2/");

if (version.contains("redhat") && KAOTO_VERSION_MANAGER.repositories.get("maven.redhat.ga") == null)
KAOTO_VERSION_MANAGER.addMavenRepository("maven.redhat.ga", "https://maven.repository.redhat.com/ga/");
if (version.contains("redhat") && kaotoVersionManager.repositories.get("maven.redhat.ga") == null)
kaotoVersionManager.addMavenRepository("maven.redhat.ga", "https://maven.repository.redhat.com/ga/");
}

private void loadResourcesFromFolderAsString(String resourceFolderName, Map<String, String> filesMap,
String fileSuffix) {
ClassLoader classLoader = KAOTO_VERSION_MANAGER.getClassLoader();
ClassLoader classLoader = kaotoVersionManager.getClassLoader();

try {
Iterator<URL> it = classLoader.getResources(resourceFolderName).asIterator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void resolve(MavenDownloader mavenDownloader, String gav, boolean useSnap
} catch (Throwable e) {
if (getLog()) {
LOGGER.log(Level.WARNING,
String.format("Cannot resolve artifact {} due to {}", gav, e.getMessage()), e);
String.format("Error resolving artifact {} due to {}", gav, e.getMessage()), e);
}
}

Expand All @@ -147,31 +147,24 @@ public InputStream getResourceAsStream(String name) {
}

private InputStream doGetResourceAsStream(String name, String version) {
if (version == null) {
return null;
}

try {
URL found = null;
Enumeration<URL> urls = getClassLoader().getResources(name);
while (urls.hasMoreElements()) {
URL url = urls.nextElement();
if (url.getPath().contains(version)) {
found = url;
break;
if (version != null) {
try {
Enumeration<URL> urls = getClassLoader().getResources(name);
while (urls.hasMoreElements()) {
URL url = urls.nextElement();
if (url.getPath().contains(version)) {
return url.openStream();
}
}
}
if (found != null) {
return found.openStream();
}
} catch (IOException e) {
if (getLog()) {
LOGGER.log(Level.WARNING, String.format("Cannot open resource {} and version {} due {}", name, version,
e.getMessage(), e));

} catch (IOException e) {
if (getLog()) {
LOGGER.log(Level.WARNING, String.format("Cannot open resource {} and version {} due {}", name, version,
e.getMessage(), e));

}
}
}

return null;
}
}
Loading