use of org.jboss.as.patching.installation.InstalledIdentity in project wildfly-core by wildfly.
the class RollbackTargetArtifact method process.
@Override
public boolean process(PatchingXmlArtifact.XmlArtifactState<RollbackPatch> parent, PatchingArtifactProcessor processor) {
final RollbackPatch patch = parent.getPatch();
final PatchingArtifacts.PatchID patchID = processor.getParentArtifact(PatchingArtifacts.HISTORY_RECORD);
final InstalledIdentity identity = patch.getIdentityState();
processor.getValidationContext().setCurrentPatchIdentity(identity);
final State state = new State(identity, patchID);
if (identity == null) {
processor.getValidationContext().getErrorHandler().addMissing(PatchingArtifacts.ROLLBACK_TARGET, state);
return false;
} else {
return processor.process(this, state);
}
}
use of org.jboss.as.patching.installation.InstalledIdentity in project wildfly-core by wildfly.
the class IdentityPatchContext method createRollbackPatch.
/**
* Create a rollback patch based on the recorded actions.
*
* @param patchId the new patch id, depending on release or one-off
* @param patchType the current patch identity
* @return the rollback patch
*/
protected RollbackPatch createRollbackPatch(final String patchId, final Patch.PatchType patchType) {
// Process elements
final List<PatchElement> elements = new ArrayList<PatchElement>();
// Process layers
for (final PatchEntry entry : getLayers()) {
final PatchElement element = createRollbackElement(entry);
elements.add(element);
}
// Process add-ons
for (final PatchEntry entry : getAddOns()) {
final PatchElement element = createRollbackElement(entry);
elements.add(element);
}
final InstalledIdentity installedIdentity = modification.getUnmodifiedInstallationState();
final String name = installedIdentity.getIdentity().getName();
final IdentityImpl identity = new IdentityImpl(name, modification.getVersion());
if (patchType == Patch.PatchType.CUMULATIVE) {
identity.setPatchType(Patch.PatchType.CUMULATIVE);
identity.setResultingVersion(installedIdentity.getIdentity().getVersion());
} else if (patchType == Patch.PatchType.ONE_OFF) {
identity.setPatchType(Patch.PatchType.ONE_OFF);
}
final List<ContentModification> modifications = identityEntry.rollbackActions;
final Patch delegate = new PatchImpl(patchId, "rollback patch", identity, elements, modifications);
return new PatchImpl.RollbackPatchImpl(delegate, installedIdentity);
}
use of org.jboss.as.patching.installation.InstalledIdentity in project wildfly-core by wildfly.
the class PatchableTargetsArtifact method process.
@Override
public boolean process(PatchingXmlArtifact.XmlArtifactState<Patch> parent, PatchingArtifactProcessor processor) {
final InstalledIdentity identity = processor.getValidationContext().getInstalledIdentity();
final Patch patch = parent.getPatch();
if (Constants.BASE.equals(patch.getPatchId())) {
return true;
}
final List<PatchElement> elements = patch.getElements();
boolean valid = true;
if (elements != null && !elements.isEmpty()) {
for (final PatchElement element : elements) {
final String patchID = element.getId();
final PatchElementProvider provider = element.getProvider();
final String layerName = provider.getName();
final PatchableTarget target = provider.isAddOn() ? identity.getAddOn(layerName) : identity.getLayer(layerName);
boolean modules = false;
boolean bundles = false;
for (final ContentModification modification : element.getModifications()) {
if (modules && bundles) {
break;
}
if (modification.getItem().getContentType() == ContentType.BUNDLE) {
bundles = true;
} else if (modification.getItem().getContentType() == ContentType.MODULE) {
modules = true;
}
}
final PatchableTargetState state = new PatchableTargetState(patchID, layerName, target, bundles, modules);
if (!processor.process(PatchingArtifacts.LAYER, state)) {
valid = false;
}
}
}
// In case there are misc content modifications also validate that misc backup exists
for (final ContentModification modification : patch.getModifications()) {
if (modification.getType() != ModificationType.ADD && modification.getItem().getContentType() == ContentType.MISC) {
final PatchingHistoryDirArtifact.DirectoryArtifactState history = processor.getParentArtifact(PatchingArtifacts.HISTORY_DIR);
PatchingArtifacts.MISC_BACKUP.process(history, processor);
break;
}
}
return valid;
}
use of org.jboss.as.patching.installation.InstalledIdentity 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.installation.InstalledIdentity 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