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

[CMTOOL-365] Fixes server id for eap8 and eapxp5 servers #314

Merged
merged 1 commit into from
Apr 1, 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 @@ -34,17 +34,29 @@ private ManifestProductInfo(String name, String version) {
}

/**
* Retrieves the product info from the specified manifest.
* Retrieves the product info from the specified manifest, with default attr names "JBoss-Product-Release-Name","JBoss-Product-Release-Version".
* @param manifest the manifest file
* @return the product info from the specified manifest inputstream
* @throws ServerMigrationFailureException if there is an error reading the manifest input stream
*/
public static ManifestProductInfo from(Manifest manifest) throws ServerMigrationFailureException {
final String productName = manifest.getMainAttributes().getValue("JBoss-Product-Release-Name");
return from(manifest, "JBoss-Product-Release-Name","JBoss-Product-Release-Version");
}

/**
* Retrieves the product info from the specified manifest, from attributes with the specified prefix.
* @param manifest the manifest file
* @param productNameAttr the product name's attribute name
* @param productVersionAttr the product version's attribute name
* @return the product info from the specified manifest inputstream
* @throws ServerMigrationFailureException if there is an error reading the manifest input stream
*/
public static ManifestProductInfo from(Manifest manifest, String productNameAttr, String productVersionAttr) throws ServerMigrationFailureException {
final String productName = manifest.getMainAttributes().getValue(productNameAttr);
if (productName == null) {
throw new IllegalArgumentException();
}
final String productVersion = manifest.getMainAttributes().getValue("JBoss-Product-Release-Version");
final String productVersion = manifest.getMainAttributes().getValue(productVersionAttr);
if (productVersion == null) {
throw new IllegalArgumentException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,31 @@ protected ProductInfo getProductInfo(Path baseDir, MigrationEnvironment migratio

@Override
protected String getProductVersionRegex() {
return "8.0\\..*";
return "8\\.0.*";
}

@Override
protected Server constructServer(String migrationName, ProductInfo productInfo, Path baseDir, MigrationEnvironment migrationEnvironment) {
return isXp(baseDir) ? new EAPXPServer8_0(migrationName, new ProductInfo("JBoss EAP XP", productInfo.getVersion()), baseDir, migrationEnvironment) : new EAPServer8_0(migrationName, productInfo, baseDir, migrationEnvironment);
final ManifestProductInfo xpManifestProductInfo = getXpManifestProductInfo(baseDir);
return xpManifestProductInfo != null ? new EAPXPServer8_0(migrationName, new ProductInfo("JBoss EAP XP", xpManifestProductInfo.getVersion()), baseDir, migrationEnvironment) : new EAPServer8_0(migrationName, productInfo, baseDir, migrationEnvironment);
}

protected boolean isXp(Path baseDir) {
if (Files.exists(baseDir.resolve(".installation").resolve("jboss-eap-xp-5.0.conf"))) {
return true;
protected ManifestProductInfo getXpManifestProductInfo(Path baseDir) {
final JBossServer.Module module = new JBossServer.Modules(baseDir).getModule("org.jboss.eap.expansion.pack:main");
if (module == null) {
return null;
}
// fallback for internal XP builds
if (Files.isDirectory(baseDir.resolve("modules").resolve("system").resolve("layers").resolve("microprofile").resolve("org").resolve("wildfly").resolve("extension").resolve("microprofile"))) {
return true;
try {
Path moduleJar = Files.list(module.getModuleDir()).filter(path -> path.toString().endsWith(".jar")).findFirst().get();
if (moduleJar == null || !Files.isRegularFile(moduleJar)) {
return null;
}
try (JarInputStream jarStream = new JarInputStream(Files.newInputStream(moduleJar))) {
return ManifestProductInfo.from(jarStream.getManifest(), "Implementation-Title", "Implementation-Version");
}
} catch (IOException e) {
throw new ServerMigrationFailureException(e);
}
return false;
}

@Override
Expand Down