Skip to content
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 @@ -47,13 +47,16 @@ public class PatchConfigXml {
MAPPER.registerRootElement(new QName(Namespace.PATCH_1_0.getNamespace(), PatchConfigXml_1_0.Element.PATCH_CONFIG.name), INSTANCE);
MAPPER.registerRootElement(new QName(Namespace.PATCH_1_2.getNamespace(), PatchConfigXml_1_0.Element.PATCH_CONFIG.name), INSTANCE);
MAPPER.registerRootElement(new QName(Namespace.PATCH_1_3.getNamespace(), PatchConfigXml_1_0.Element.PATCH_CONFIG.name), INSTANCE);
MAPPER.registerRootElement(new QName(Namespace.PATCH_1_4.getNamespace(), PatchConfigXml_1_0.Element.PATCH_CONFIG.name), INSTANCE);

}

enum Namespace {

PATCH_1_0("urn:jboss:patch-config:1.0"),
PATCH_1_2("urn:jboss:patch-config:1.2"),
PATCH_1_3("urn:jboss:patch-config:1.3"),
PATCH_1_4("urn:jboss:patch-config:1.4"),
UNKNOWN(null);

private final String namespace;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ private void parseOneOffPatchType(final XMLExtendedStreamReader reader, final Pa

String name = null;
String appliesTo = null;
boolean overrideIdentity = false;

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

Expand All @@ -458,6 +459,9 @@ private void parseOneOffPatchType(final XMLExtendedStreamReader reader, final Pa
case APPLIES_TO_VERSION:
appliesTo = value;
break;
case OVERRIDE_IDENTITY:;
overrideIdentity = Boolean.parseBoolean(value);
break;
default:
throw unexpectedAttribute(reader, i);
}
Expand All @@ -469,8 +473,17 @@ private void parseOneOffPatchType(final XMLExtendedStreamReader reader, final Pa
throw missingRequired(reader, required);
}

if (overrideIdentity && (name == null || appliesTo == null)) {
String msg = String.format("When %s=\"true\", all of %s and %s must be set",
Attribute.OVERRIDE_IDENTITY.name,
Attribute.NAME.name,
Attribute.APPLIES_TO_VERSION.name);
throw new XMLStreamException(msg, reader.getLocation());
}

builder.setOneOffType(appliesTo);
builder.setAppliesToName(name);
builder.setOverrideIdentity(overrideIdentity);

patchTypeConfigured = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,13 @@ private void process() throws PatchingException, IOException, XMLStreamException
}
builder.upgradeIdentity(name, version, toVersion);
} else {
builder.oneOffPatchIdentity(base.getName(), base.getVersion());
if (patchConfig.isOverrideIdentity()) {
// This allows to build one-off patch based on "name" and "applies-to-version", to e.g.
// have a totally separately named and versioned patch stream from the servers used to create the diff.
builder.oneOffPatchIdentity(patchConfig.getAppliesToProduct(), patchConfig.getAppliesToVersion());
} else {
builder.oneOffPatchIdentity(base.getName(), base.getVersion());
}
}

// Create the resulting patch
Expand Down
Loading