Search in sources :

Example 1 with InstalledImage

use of org.jboss.as.patching.installation.InstalledImage in project wildfly-core by wildfly.

the class IdentityPatchContext method recordRollbackLoader.

/**
 * Add a rollback loader for a give patch.
 *
 * @param patchId the patch id.
 * @param target  the patchable target
 * @throws XMLStreamException
 * @throws IOException
 */
private void recordRollbackLoader(final String patchId, PatchableTarget.TargetInfo target) {
    // setup the content loader paths
    final DirectoryStructure structure = target.getDirectoryStructure();
    final InstalledImage image = structure.getInstalledImage();
    final File historyDir = image.getPatchHistoryDir(patchId);
    final File miscRoot = new File(historyDir, PatchContentLoader.MISC);
    final File modulesRoot = structure.getModulePatchDirectory(patchId);
    final File bundlesRoot = structure.getBundlesPatchDirectory(patchId);
    final PatchContentLoader loader = PatchContentLoader.create(miscRoot, bundlesRoot, modulesRoot);
    // 
    recordContentLoader(patchId, loader);
}
Also used : InstalledImage(org.jboss.as.patching.installation.InstalledImage) File(java.io.File) DirectoryStructure(org.jboss.as.patching.DirectoryStructure)

Example 2 with InstalledImage

use of org.jboss.as.patching.installation.InstalledImage in project wildfly-core by wildfly.

the class IdentityRollbackCallback method completed.

@Override
public void completed(IdentityPatchContext context) {
    final InstalledImage installedImage = directoryStructure.getInstalledImage();
    final File history = installedImage.getPatchHistoryDir(patch.getPatchId());
    if (!recursiveDelete(history)) {
        context.failedToCleanupDir(history);
    }
    // Cleanup all the recorded rollbacks
    cleanupEntry(context.getLayers());
    cleanupEntry(context.getAddOns());
    cleanupEntry(Collections.singleton(context.getIdentityEntry()));
}
Also used : InstalledImage(org.jboss.as.patching.installation.InstalledImage) File(java.io.File)

Example 3 with InstalledImage

use of org.jboss.as.patching.installation.InstalledImage in project wildfly-core by wildfly.

the class IdentityApplyCallback method operationCancelled.

@Override
public void operationCancelled(IdentityPatchContext context) {
    // Cleanup history, bundles and module patch directories
    final InstalledImage image = structure.getInstalledImage();
    IoUtils.recursiveDelete(image.getPatchHistoryDir(patchId));
    IoUtils.recursiveDelete(structure.getBundlesPatchDirectory(patchId));
    IoUtils.recursiveDelete(structure.getModulePatchDirectory(patchId));
    for (final PatchElement element : original.getElements()) {
        boolean addOn = element.getProvider().isAddOn();
        final IdentityPatchContext.PatchEntry entry = context.getEntry(element.getProvider().getName(), addOn);
        final DirectoryStructure structure = entry.getDirectoryStructure();
        IoUtils.recursiveDelete(structure.getBundlesPatchDirectory(element.getId()));
        IoUtils.recursiveDelete(structure.getModulePatchDirectory(element.getId()));
    }
}
Also used : PatchElement(org.jboss.as.patching.metadata.PatchElement) InstalledImage(org.jboss.as.patching.installation.InstalledImage) DirectoryStructure(org.jboss.as.patching.DirectoryStructure)

Example 4 with InstalledImage

use of org.jboss.as.patching.installation.InstalledImage in project wildfly-core by wildfly.

the class TestUtils method createLegacyTestStructure.

/**
 * Create the legacy patch environment based on the default layout.
 *
 * @param jbossHome the $JBOSS_HOME
 * @return the patch environment
 * @deprecated see {@linkplain org.jboss.as.patching.installation.InstallationManager}
 */
@Deprecated
public static DirectoryStructure createLegacyTestStructure(final File jbossHome) {
    final File appClient = new File(jbossHome, APP_CLIENT);
    final File bundles = new File(jbossHome, BUNDLES);
    final File domain = new File(jbossHome, DOMAIN);
    final File modules = new File(jbossHome, MODULES);
    final File installation = new File(jbossHome, Constants.INSTALLATION);
    final File patches = new File(modules, PATCHES);
    final File standalone = new File(jbossHome, STANDALONE);
    return new LegacyDirectoryStructure(new InstalledImage() {

        @Override
        public File getJbossHome() {
            return jbossHome;
        }

        @Override
        public File getBundlesDir() {
            return bundles;
        }

        @Override
        public File getModulesDir() {
            return modules;
        }

        @Override
        public File getInstallationMetadata() {
            return installation;
        }

        @Override
        public File getLayersConf() {
            return new File(getModulesDir(), Constants.LAYERS_CONF);
        }

        @Override
        public File getPatchesDir() {
            return patches;
        }

        @Override
        public File getPatchHistoryDir(String patchId) {
            return newFile(getInstallationMetadata(), PATCHES, patchId);
        }

        @Override
        public File getAppClientDir() {
            return appClient;
        }

        @Override
        public File getDomainDir() {
            return domain;
        }

        @Override
        public File getStandaloneDir() {
            return standalone;
        }
    });
}
Also used : IoUtils.newFile(org.jboss.as.patching.IoUtils.newFile) File(java.io.File) InstalledImage(org.jboss.as.patching.installation.InstalledImage)

Aggregations

InstalledImage (org.jboss.as.patching.installation.InstalledImage)4 File (java.io.File)3 DirectoryStructure (org.jboss.as.patching.DirectoryStructure)2 IoUtils.newFile (org.jboss.as.patching.IoUtils.newFile)1 PatchElement (org.jboss.as.patching.metadata.PatchElement)1