Skip to content

Commit a3b1c4e

Browse files
committed
[JBEAP-23777] Allow to define one-off patch with name and version separated from base server in patch-config file.
1 parent 3b93751 commit a3b1c4e

File tree

7 files changed

+483
-1
lines changed

7 files changed

+483
-1
lines changed

patch-gen/src/main/java/org/jboss/as/patching/generator/PatchConfigXml.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,16 @@ public class PatchConfigXml {
4747
MAPPER.registerRootElement(new QName(Namespace.PATCH_1_0.getNamespace(), PatchConfigXml_1_0.Element.PATCH_CONFIG.name), INSTANCE);
4848
MAPPER.registerRootElement(new QName(Namespace.PATCH_1_2.getNamespace(), PatchConfigXml_1_0.Element.PATCH_CONFIG.name), INSTANCE);
4949
MAPPER.registerRootElement(new QName(Namespace.PATCH_1_3.getNamespace(), PatchConfigXml_1_0.Element.PATCH_CONFIG.name), INSTANCE);
50+
MAPPER.registerRootElement(new QName(Namespace.PATCH_1_4.getNamespace(), PatchConfigXml_1_0.Element.PATCH_CONFIG.name), INSTANCE);
51+
5052
}
5153

5254
enum Namespace {
5355

5456
PATCH_1_0("urn:jboss:patch-config:1.0"),
5557
PATCH_1_2("urn:jboss:patch-config:1.2"),
5658
PATCH_1_3("urn:jboss:patch-config:1.3"),
59+
PATCH_1_4("urn:jboss:patch-config:1.4"),
5760
UNKNOWN(null);
5861

5962
private final String namespace;

patch-gen/src/main/java/org/jboss/as/patching/generator/PatchConfigXml_1_0.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ private void parseOneOffPatchType(final XMLExtendedStreamReader reader, final Pa
443443

444444
String name = null;
445445
String appliesTo = null;
446+
boolean overrideIdentity = false;
446447

447448
Set<Attribute> required = Collections.emptySet(); // EnumSet.of(Attribute.APPLIES_TO_VERSION, Attribute.RESULTING_VERSION);
448449

@@ -458,6 +459,9 @@ private void parseOneOffPatchType(final XMLExtendedStreamReader reader, final Pa
458459
case APPLIES_TO_VERSION:
459460
appliesTo = value;
460461
break;
462+
case OVERRIDE_IDENTITY:;
463+
overrideIdentity = Boolean.parseBoolean(value);
464+
break;
461465
default:
462466
throw unexpectedAttribute(reader, i);
463467
}
@@ -469,8 +473,17 @@ private void parseOneOffPatchType(final XMLExtendedStreamReader reader, final Pa
469473
throw missingRequired(reader, required);
470474
}
471475

476+
if (overrideIdentity && (name == null || appliesTo == null)) {
477+
String msg = String.format("When %s=\"true\", all of %s and %s must be set",
478+
Attribute.OVERRIDE_IDENTITY.name,
479+
Attribute.NAME.name,
480+
Attribute.APPLIES_TO_VERSION.name);
481+
throw new XMLStreamException(msg, reader.getLocation());
482+
}
483+
472484
builder.setOneOffType(appliesTo);
473485
builder.setAppliesToName(name);
486+
builder.setOverrideIdentity(overrideIdentity);
474487

475488
patchTypeConfigured = true;
476489
}

patch-gen/src/main/java/org/jboss/as/patching/generator/PatchGenerator.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,13 @@ private void process() throws PatchingException, IOException, XMLStreamException
165165
}
166166
builder.upgradeIdentity(name, version, toVersion);
167167
} else {
168-
builder.oneOffPatchIdentity(base.getName(), base.getVersion());
168+
if (patchConfig.isOverrideIdentity()) {
169+
// This allows to build one-off patch based on "name" and "applies-to-version", to e.g.
170+
// have a totally separately named and versioned patch stream from the servers used to create the diff.
171+
builder.oneOffPatchIdentity(patchConfig.getAppliesToProduct(), patchConfig.getAppliesToVersion());
172+
} else {
173+
builder.oneOffPatchIdentity(base.getName(), base.getVersion());
174+
}
169175
}
170176

171177
// Create the resulting patch

0 commit comments

Comments
 (0)