use of org.jboss.as.patching.PatchingException in project wildfly-core by wildfly.
the class LocalPatchRollbackLastHandler method execute.
@Override
protected void execute(final OperationContext context, final ModelNode operation, final InstallationManager installationManager, final String patchStream) throws OperationFailedException {
if (installationManager.requiresRestart()) {
throw PatchLogger.ROOT_LOGGER.serverRequiresRestart();
}
final boolean resetConfiguration = PatchResourceDefinition.RESET_CONFIGURATION.resolveModelAttribute(context, operation).asBoolean();
final PatchTool runner = PatchTool.Factory.create(installationManager);
final ContentVerificationPolicy policy = PatchTool.Factory.create(operation);
try {
// Rollback
final PatchingResult result = runner.rollbackLast(patchStream, policy, resetConfiguration);
installationManager.restartRequired();
context.restartRequired();
context.completeStep(new OperationContext.ResultHandler() {
@Override
public void handleResult(OperationContext.ResultAction resultAction, OperationContext context, ModelNode operation) {
if (resultAction == OperationContext.ResultAction.KEEP) {
result.commit();
} else {
installationManager.clearRestartRequired();
context.revertRestartRequired();
result.rollback();
}
}
});
} catch (PatchingException e) {
final ModelNode failureDescription = context.getFailureDescription();
PatchOperationTarget.formatFailedResponse(e, failureDescription);
installationManager.clearRestartRequired();
} finally {
//
}
}
use of org.jboss.as.patching.PatchingException in project wildfly-core by wildfly.
the class LocalAgeoutHistoryHandler method execute.
@Override
protected void execute(OperationContext context, ModelNode operation, InstallationManager instMgr, String patchStream) throws OperationFailedException {
try {
if (patchStream != null) {
final InstalledIdentity installedIdentity = instMgr.getInstalledIdentity(patchStream, null);
ageOutHistory(installedIdentity);
} else {
for (InstalledIdentity installedIdentity : instMgr.getInstalledIdentities()) {
ageOutHistory(installedIdentity);
}
}
} catch (PatchingException e) {
throw new IllegalStateException(PatchLogger.ROOT_LOGGER.failedToLoadIdentity(), e);
}
context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER);
}
use of org.jboss.as.patching.PatchingException in project wildfly-core by wildfly.
the class PatchMerger method copyModificationContent.
private static void copyModificationContent(final File srcPatchDir, final String srcElementId, final File targetPatchDir, final String targetElementId, final ContentModification mod) throws PatchingException {
final ModificationType type = mod.getType();
if (type.equals(ModificationType.REMOVE)) {
return;
}
File modSrcDir = new File(srcPatchDir, srcElementId);
File modTrgDir = new File(targetPatchDir, targetElementId);
final ContentType contentType = mod.getItem().getContentType();
if (ContentType.MISC.equals(contentType)) {
modSrcDir = new File(modSrcDir, Constants.MISC);
modTrgDir = new File(modTrgDir, Constants.MISC);
for (final String path : ((MiscContentItem) mod.getItem()).getPath()) {
modSrcDir = new File(modSrcDir, path);
modTrgDir = new File(modTrgDir, path);
}
copyDir(modSrcDir, modTrgDir);
} else {
final String slot;
if (contentType.equals(ContentType.MODULE)) {
modSrcDir = new File(modSrcDir, Constants.MODULES);
modTrgDir = new File(modTrgDir, Constants.MODULES);
slot = ((ModuleItem) mod.getItem()).getSlot();
} else if (contentType.equals(ContentType.BUNDLE)) {
modSrcDir = new File(modSrcDir, Constants.BUNDLES);
modTrgDir = new File(modTrgDir, Constants.BUNDLES);
slot = ((BundleItem) mod.getItem()).getSlot();
} else {
throw new PatchingException("Unexpected content type " + contentType);
}
for (String name : mod.getItem().getName().split("\\.")) {
modSrcDir = new File(modSrcDir, name);
modTrgDir = new File(modTrgDir, name);
}
modSrcDir = new File(modSrcDir, slot);
modTrgDir = new File(modTrgDir, slot);
copyDir(modSrcDir, modTrgDir);
}
}
use of org.jboss.as.patching.PatchingException in project wildfly-core by wildfly.
the class PatchMerger method expandContent.
private static File expandContent(File patchFile, final File workDir, final String expandDirName) throws PatchingException {
final File patchDir;
try {
if (!patchFile.isDirectory()) {
patchDir = new File(workDir, expandDirName);
// Save the content
final File cachedContent = new File(patchDir, "content");
IoUtils.copy(patchFile, cachedContent);
// Unpack to the work dir
ZipUtils.unzip(cachedContent, patchDir);
} else {
patchDir = patchFile;
}
} catch (IOException e) {
throw new PatchingException("Failed to unzip " + patchFile.getAbsolutePath());
}
return patchDir;
}
use of org.jboss.as.patching.PatchingException in project wildfly-core by wildfly.
the class PatchStepAssertions method assertNotApplied.
static void assertNotApplied(final Patch patch, InstallationManager manager) throws IOException {
InstalledIdentity installedIdentity = null;
try {
installedIdentity = manager.getInstalledIdentity(patch.getIdentity().getName(), patch.getIdentity().getVersion());
} catch (PatchingException e) {
Assert.fail(e.getLocalizedMessage());
}
final PatchableTarget.TargetInfo identity = installedIdentity.getIdentity().loadTargetInfo();
assertNotApplied(patch.getIdentity().getPatchType(), patch.getPatchId(), identity);
assertDoesNotExists(identity.getDirectoryStructure().getInstalledImage().getPatchHistoryDir(patch.getPatchId()));
for (final PatchElement element : patch.getElements()) {
final PatchElementProvider provider = element.getProvider();
final PatchableTarget target = provider.isAddOn() ? installedIdentity.getAddOn(provider.getName()) : installedIdentity.getLayer(provider.getName());
Assert.assertNotNull(target);
assertNotApplied(provider.getPatchType(), element.getId(), target.loadTargetInfo());
}
}
Aggregations