use of org.jboss.as.patching.tool.PatchOperationBuilder in project wildfly-core by wildfly.
the class PatchHandler method createPatchOperationBuilder.
private PatchOperationBuilder createPatchOperationBuilder(ParsedCommandLine args) throws CommandFormatException {
final String action = this.action.getValue(args, true);
PatchOperationBuilder builder;
if (APPLY.equals(action)) {
final String path = this.path.getValue(args, true);
final File f = new File(path);
if (!f.exists()) {
// i18n is never used for CLI exceptions
throw new CommandFormatException("Path " + f.getAbsolutePath() + " doesn't exist.");
}
if (f.isDirectory()) {
throw new CommandFormatException(f.getAbsolutePath() + " is a directory.");
}
builder = PatchOperationBuilder.Factory.patch(f);
} else if (ROLLBACK.equals(action)) {
String resetConfigValue = resetConfiguration.getValue(args, true);
boolean resetConfig;
if (Util.TRUE.equalsIgnoreCase(resetConfigValue)) {
resetConfig = true;
} else if (Util.FALSE.equalsIgnoreCase(resetConfigValue)) {
resetConfig = false;
} else {
throw new CommandFormatException("Unexpected value for --reset-configuration (only true and false are allowed): " + resetConfigValue);
}
final String patchStream = this.patchStream.getValue(args);
if (patchId.isPresent(args)) {
final String id = patchId.getValue(args, true);
final boolean rollbackTo = this.rollbackTo.isPresent(args);
builder = PatchOperationBuilder.Factory.rollback(patchStream, id, rollbackTo, resetConfig);
} else {
builder = PatchOperationBuilder.Factory.rollbackLast(patchStream, resetConfig);
}
} else if (INFO.equals(action)) {
if (streams.isPresent(args)) {
return PatchOperationBuilder.Factory.streams();
}
final String patchStream = this.patchStream.getValue(args);
final String pId = patchId.getValue(args);
if (pId == null) {
builder = PatchOperationBuilder.Factory.info(patchStream);
} else {
builder = PatchOperationBuilder.Factory.info(patchStream, pId, verbose.isPresent(args));
}
return builder;
} else if (HISTORY.equals(action)) {
final String patchStream = this.patchStream.getValue(args);
builder = PatchOperationBuilder.Factory.history(patchStream, excludeAgedOut.isPresent(args));
return builder;
} else {
throw new CommandFormatException("Unrecognized action '" + action + "'");
}
if (overrideModules.isPresent(args)) {
builder.ignoreModuleChanges();
}
if (overrideAll.isPresent(args)) {
builder.overrideAll();
}
if (override.isPresent(args)) {
final String overrideList = override.getValue(args);
if (overrideList == null || overrideList.isEmpty()) {
throw new CommandFormatException(override.getFullName() + " is missing value.");
}
for (String path : overrideList.split(",+")) {
builder.overrideItem(path);
}
}
if (preserve.isPresent(args)) {
final String preserveList = preserve.getValue(args);
if (preserveList == null || preserveList.isEmpty()) {
throw new CommandFormatException(preserve.getFullName() + " is missing value.");
}
for (String path : preserveList.split(",+")) {
builder.preserveItem(path);
}
}
return builder;
}
use of org.jboss.as.patching.tool.PatchOperationBuilder in project wildfly-core by wildfly.
the class PatchInfo method createPatchOperationBuilder.
@Override
protected PatchOperationBuilder createPatchOperationBuilder(CommandContext ctx) throws CommandException {
if (streams) {
return PatchOperationBuilder.Factory.streams();
}
PatchOperationBuilder builder;
final String pId = getPatchId();
if (pId == null) {
builder = PatchOperationBuilder.Factory.info(patchStream);
} else {
builder = PatchOperationBuilder.Factory.info(patchStream, pId, verbose);
}
return builder;
}
use of org.jboss.as.patching.tool.PatchOperationBuilder in project wildfly-core by wildfly.
the class PatchOverrideCommand method createPatchOperationBuilder.
@Override
protected PatchOperationBuilder createPatchOperationBuilder(CommandContext ctx) throws CommandException {
PatchOperationBuilder builder = createUnconfiguredOperationBuilder(ctx);
configureBuilder(builder);
return builder;
}
Aggregations