return AvailabilityType.UP;
}
@Override
public BundleDeployResult deployBundle(BundleDeployRequest request) {
ServerControl control = onServer(request);
Result<Void> check = sanityCheck(control, request.getReferencedConfiguration(),
request.getBundleManagerProvider(), request.getResourceDeployment(),
!isTakeOver(request.getResourceDeployment().getBundleDeployment().getConfiguration()));
if (check.failed()) {
BundleDeployResult result = new BundleDeployResult();
result.setErrorMessage(check.errorMessage);
return result;
}
if (request.isRevert()) {
return handleRevert(request);
}
BundleDeployResult result = new BundleDeployResult();
ASConnection connection = new ASConnection(
ASConnectionParams.createFrom(new ServerPluginConfiguration(request.getReferencedConfiguration())));
ProcessExecutionResults results;
BundleManagerProvider bmp = request.getBundleManagerProvider();
BundleResourceDeployment rd = request.getResourceDeployment();
Result<Boolean> stop = stopIfNeeded(connection, control,
request.getResourceDeployment().getBundleDeployment().getConfiguration(), bmp, rd);
if (stop.failed()) {
result.setErrorMessage(stop.errorMessage);
return result;
}
boolean startUp = stop.result;
try {
StringBuilder command = new StringBuilder("patch apply --path=").append(
request.getPackageVersionFiles().values().iterator().next().getAbsolutePath());
Configuration bundleConfig = request.getResourceDeployment().getBundleDeployment().getConfiguration();
String override = bundleConfig.getSimpleValue("override");
String overrideAll = bundleConfig.getSimpleValue("override-all");
String preserve = bundleConfig.getSimpleValue("preserve");
String overrideModules = bundleConfig.getSimpleValue("override-modules");
if (override != null) {
command.append(" --override=").append(override);
}
if (overrideAll != null) {
command.append(" --override-all=").append(Boolean.valueOf(overrideAll));
}
if (preserve != null) {
command.append(" --preserve=").append(preserve);
}
if (overrideModules != null) {
command.append(" --override-modules=").append(overrideModules);
}
// as a last thing before the deployment, check the patch history
Result<List<PatchDetails>> historyBeforeDeployment = getPatchHistory(control, "deploy");
if (historyBeforeDeployment.failed()) {
result.setErrorMessage(historyBeforeDeployment.errorMessage);
return result;
}
results = control.cli().disconnected(true).executeCliCommand(command.toString());
switch (handleExecutionResults(results, bmp, rd, true)) {
case EXECUTION_ERROR:
result
.setErrorMessage("Error while trying to execute patch command: " + results.getError().getMessage());