Search in sources :

Example 6 with PatchResult

use of io.fabric8.patch.management.PatchResult in project fabric8 by jboss-fuse.

the class ServiceImplTest method testPatch.

@Test
public void testPatch() throws Exception {
    ComponentContext componentContext = createMock(ComponentContext.class);
    BundleContext bundleContext = createMock(BundleContext.class);
    Bundle sysBundle = createMock(Bundle.class);
    BundleContext sysBundleContext = createMock(BundleContext.class);
    Bundle bundle = createMock(Bundle.class);
    Bundle bundle2 = createMock(Bundle.class);
    FrameworkWiring wiring = createMock(FrameworkWiring.class);
    GitPatchRepository repository = createMock(GitPatchRepository.class);
    // 
    // Create a new service, download a patch
    // 
    expect(componentContext.getBundleContext()).andReturn(bundleContext);
    expect(bundleContext.getBundle(0)).andReturn(sysBundle).anyTimes();
    expect(sysBundle.getBundleContext()).andReturn(sysBundleContext).anyTimes();
    expect(sysBundleContext.getProperty(Service.NEW_PATCH_LOCATION)).andReturn(storage.toString()).anyTimes();
    expect(repository.getManagedPatch(anyString())).andReturn(null).anyTimes();
    expect(repository.findOrCreateMainGitRepository()).andReturn(null).anyTimes();
    expect(sysBundleContext.getProperty("karaf.default.repository")).andReturn("system").anyTimes();
    expect(sysBundleContext.getProperty("karaf.home")).andReturn(karaf.getCanonicalPath()).anyTimes();
    expect(sysBundleContext.getProperty("karaf.base")).andReturn(karaf.getCanonicalPath()).anyTimes();
    expect(sysBundleContext.getProperty("karaf.name")).andReturn("root").anyTimes();
    expect(sysBundleContext.getProperty("karaf.instances")).andReturn(karaf.getCanonicalPath() + "/instances").anyTimes();
    expect(sysBundleContext.getProperty("karaf.data")).andReturn(karaf.getCanonicalPath() + "/data").anyTimes();
    replay(componentContext, sysBundleContext, sysBundle, bundleContext, bundle, repository);
    PatchManagement pm = mockManagementService(bundleContext);
    ((GitPatchManagementServiceImpl) pm).setGitPatchRepository(repository);
    ServiceImpl service = new ServiceImpl();
    setField(service, "patchManagement", pm);
    service.activate(componentContext);
    try {
        service.download(new URL("file:" + storage + "/temp/f00.zip"));
        fail("Should have thrown exception on non existent patch file.");
    } catch (Exception e) {
    }
    Iterable<Patch> patches = service.download(patch132.toURI().toURL());
    assertNotNull(patches);
    Iterator<Patch> it = patches.iterator();
    assertTrue(it.hasNext());
    Patch patch = it.next();
    assertNotNull(patch);
    assertEquals("patch-1.3.2", patch.getPatchData().getId());
    assertNotNull(patch.getPatchData().getBundles());
    assertEquals(1, patch.getPatchData().getBundles().size());
    Iterator<String> itb = patch.getPatchData().getBundles().iterator();
    assertEquals("mvn:foo/my-bsn/1.3.2", itb.next());
    assertNull(patch.getResult());
    verify(componentContext, sysBundleContext, sysBundle, bundleContext, bundle);
    // 
    // Simulate the patch
    // 
    reset(componentContext, sysBundleContext, sysBundle, bundleContext, bundle);
    expect(sysBundleContext.getBundles()).andReturn(new Bundle[] { bundle });
    expect(sysBundleContext.getServiceReference("io.fabric8.api.FabricService")).andReturn(null).anyTimes();
    expect(bundle.getSymbolicName()).andReturn("my-bsn").anyTimes();
    expect(bundle.getVersion()).andReturn(new Version("1.3.1")).anyTimes();
    expect(bundle.getLocation()).andReturn("location").anyTimes();
    expect(bundle.getBundleId()).andReturn(123L).anyTimes();
    BundleStartLevel bsl = createMock(BundleStartLevel.class);
    expect(bsl.getStartLevel()).andReturn(30).anyTimes();
    expect(bundle.adapt(BundleStartLevel.class)).andReturn(bsl).anyTimes();
    expect(bundle.getState()).andReturn(1);
    expect(sysBundleContext.getProperty("karaf.default.repository")).andReturn("system").anyTimes();
    replay(componentContext, sysBundleContext, sysBundle, bundleContext, bundle, bsl);
    PatchResult result = service.install(patch, true);
    assertNotNull(result);
    assertNull(patch.getResult());
    assertTrue(result.isSimulation());
    verify(componentContext, sysBundleContext, sysBundle, bundleContext, bundle, bsl);
    // 
    // Recreate a new service and verify the downloaded patch is still available
    // 
    reset(componentContext, sysBundleContext, sysBundle, bundleContext, bundle, repository, bsl);
    expect(componentContext.getBundleContext()).andReturn(bundleContext);
    expect(bundleContext.getBundle(0)).andReturn(sysBundle);
    expect(sysBundle.getBundleContext()).andReturn(sysBundleContext);
    expect(sysBundleContext.getProperty(Service.NEW_PATCH_LOCATION)).andReturn(storage.toString()).anyTimes();
    expect(sysBundleContext.getProperty("karaf.home")).andReturn(karaf.toString()).anyTimes();
    expect(sysBundleContext.getProperty("karaf.base")).andReturn(karaf.getCanonicalPath()).anyTimes();
    expect(sysBundleContext.getProperty("karaf.name")).andReturn("root").anyTimes();
    expect(sysBundleContext.getProperty("karaf.instances")).andReturn(karaf.getCanonicalPath() + "/instances").anyTimes();
    expect(sysBundleContext.getProperty("karaf.default.repository")).andReturn("system").anyTimes();
    expect(repository.getManagedPatch(anyString())).andReturn(null).anyTimes();
    expect(repository.findOrCreateMainGitRepository()).andReturn(null).anyTimes();
    replay(componentContext, sysBundleContext, sysBundle, bundleContext, bundle, repository, bsl);
    service = new ServiceImpl();
    setField(service, "patchManagement", pm);
    service.activate(componentContext);
    patches = service.getPatches();
    assertNotNull(patches);
    it = patches.iterator();
    assertTrue(it.hasNext());
    patch = it.next();
    assertNotNull(patch);
    assertEquals("patch-1.3.2", patch.getPatchData().getId());
    assertNotNull(patch.getPatchData().getBundles());
    assertEquals(1, patch.getPatchData().getBundles().size());
    itb = patch.getPatchData().getBundles().iterator();
    assertEquals("mvn:foo/my-bsn/1.3.2", itb.next());
    assertNull(patch.getResult());
    verify(componentContext, sysBundleContext, sysBundle, bundleContext, bundle, bsl);
    // 
    // Install the patch
    // 
    reset(componentContext, sysBundleContext, sysBundle, bundleContext, bundle, bsl);
    expect(sysBundleContext.getBundles()).andReturn(new Bundle[] { bundle });
    expect(sysBundleContext.getServiceReference("io.fabric8.api.FabricService")).andReturn(null).anyTimes();
    expect(bundle.getSymbolicName()).andReturn("my-bsn").anyTimes();
    expect(bundle.getVersion()).andReturn(new Version("1.3.1")).anyTimes();
    expect(bundle.getLocation()).andReturn("location").anyTimes();
    expect(bundle.getHeaders()).andReturn(new Hashtable<String, String>()).anyTimes();
    expect(bundle.getBundleId()).andReturn(123L).anyTimes();
    bundle.update(EasyMock.<InputStream>anyObject());
    expect(sysBundleContext.getBundles()).andReturn(new Bundle[] { bundle });
    expect(bundle.getState()).andReturn(Bundle.INSTALLED).anyTimes();
    expect(bundle.getRegisteredServices()).andReturn(null);
    expect(bundle.adapt(BundleStartLevel.class)).andReturn(bsl).anyTimes();
    expect(bsl.getStartLevel()).andReturn(30).anyTimes();
    expect(sysBundleContext.getBundle(0)).andReturn(sysBundle);
    expect(sysBundle.adapt(FrameworkWiring.class)).andReturn(wiring);
    expect(sysBundleContext.getProperty("karaf.default.repository")).andReturn("system").anyTimes();
    bundle.start();
    wiring.refreshBundles(eq(asSet(bundle)), anyObject(FrameworkListener[].class));
    expectLastCall().andAnswer(new IAnswer<Object>() {

        @Override
        public Object answer() throws Throwable {
            ((FrameworkListener) (EasyMock.getCurrentArguments()[1])).frameworkEvent(null);
            return null;
        }
    });
    replay(componentContext, sysBundleContext, sysBundle, bundleContext, bundle, bundle2, wiring, bsl);
    result = service.install(patch, false);
    assertNotNull(result);
    assertSame(result, patch.getResult());
    assertFalse(patch.getResult().isSimulation());
    verify(componentContext, sysBundleContext, sysBundle, bundleContext, bundle, wiring);
    // 
    // Recreate a new service and verify the downloaded patch is still available and installed
    // 
    reset(componentContext, sysBundleContext, sysBundle, bundleContext, bundle, repository);
    expect(componentContext.getBundleContext()).andReturn(bundleContext);
    expect(bundleContext.getBundle(0)).andReturn(sysBundle);
    expect(sysBundle.getBundleContext()).andReturn(sysBundleContext);
    expect(repository.getManagedPatch(anyString())).andReturn(null).anyTimes();
    expect(sysBundleContext.getProperty(Service.NEW_PATCH_LOCATION)).andReturn(storage.toString()).anyTimes();
    expect(sysBundleContext.getProperty("karaf.home")).andReturn(karaf.toString()).anyTimes();
    expect(sysBundleContext.getProperty("karaf.base")).andReturn(karaf.getCanonicalPath()).anyTimes();
    expect(sysBundleContext.getProperty("karaf.name")).andReturn("root").anyTimes();
    expect(sysBundleContext.getProperty("karaf.instances")).andReturn(karaf.getCanonicalPath() + "/instances").anyTimes();
    expect(sysBundleContext.getProperty("karaf.default.repository")).andReturn("system").anyTimes();
    replay(componentContext, sysBundleContext, sysBundle, bundleContext, bundle, repository);
    service = new ServiceImpl();
    setField(service, "patchManagement", pm);
    service.activate(componentContext);
    patches = service.getPatches();
    assertNotNull(patches);
    it = patches.iterator();
    assertTrue(it.hasNext());
    patch = it.next();
    assertNotNull(patch);
    assertEquals("patch-1.3.2", patch.getPatchData().getId());
    assertNotNull(patch.getPatchData().getBundles());
    assertEquals(1, patch.getPatchData().getBundles().size());
    itb = patch.getPatchData().getBundles().iterator();
    assertEquals("mvn:foo/my-bsn/1.3.2", itb.next());
    assertNotNull(patch.getResult());
    verify(componentContext, sysBundleContext, sysBundle, bundleContext, bundle);
}
Also used : BundleStartLevel(org.osgi.framework.startlevel.BundleStartLevel) ComponentContext(org.osgi.service.component.ComponentContext) Bundle(org.osgi.framework.Bundle) GitPatchManagementServiceImpl(io.fabric8.patch.management.impl.GitPatchManagementServiceImpl) Hashtable(java.util.Hashtable) GitPatchRepository(io.fabric8.patch.management.impl.GitPatchRepository) FrameworkWiring(org.osgi.framework.wiring.FrameworkWiring) URL(java.net.URL) PatchException(io.fabric8.patch.management.PatchException) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) IOException(java.io.IOException) GitPatchManagementServiceImpl(io.fabric8.patch.management.impl.GitPatchManagementServiceImpl) Version(org.osgi.framework.Version) PatchManagement(io.fabric8.patch.management.PatchManagement) PatchResult(io.fabric8.patch.management.PatchResult) Patch(io.fabric8.patch.management.Patch) BundleContext(org.osgi.framework.BundleContext) Test(org.junit.Test)

Example 7 with PatchResult

use of io.fabric8.patch.management.PatchResult in project fabric8 by jboss-fuse.

the class SimulateAction method doExecute.

@Override
protected void doExecute(Service service) throws Exception {
    Patch patch = service.getPatch(patchId);
    if (patch == null) {
        throw new PatchException("Patch '" + patchId + "' not found");
    }
    if (patch.isInstalled()) {
        throw new PatchException("Patch '" + patchId + "' is already installed");
    }
    PatchResult result = service.install(patch, true);
// display(result);
}
Also used : PatchResult(io.fabric8.patch.management.PatchResult) PatchException(io.fabric8.patch.management.PatchException) Patch(io.fabric8.patch.management.Patch)

Example 8 with PatchResult

use of io.fabric8.patch.management.PatchResult in project fabric8 by jboss-fuse.

the class FileBackupService method backupDataFiles.

/**
 * Invoked just before Framework is restarted and data/cache directory is removed. We copy existing data
 * directories for current bundles and record for which bundle$$version it is used.
 * @param result used to create backup directories.
 * @param pending
 * @throws IOException
 */
@Override
public void backupDataFiles(PatchResult result, Pending pending) throws IOException {
    Map<String, Bundle> bundlesWithData = new HashMap<>();
    // bundle.getDataFile("xxx") creates data dir if it didn't exist - it's not what we want
    String storageLocation = systemContext.getProperty("org.osgi.framework.storage");
    if (storageLocation == null) {
        Activator.log(LogService.LOG_INFO, "Can't determine \"org.osgi.framework.storage\" property value");
        return;
    }
    File cacheDir = new File(storageLocation);
    if (!cacheDir.isDirectory()) {
        return;
    }
    for (Bundle b : systemContext.getBundles()) {
        if (b.getSymbolicName() != null) {
            String sn = Utils.stripSymbolicName(b.getSymbolicName());
            if ("org.apache.karaf.features.core".equals(sn)) {
                // we start with fresh features service state
                continue;
            }
            // a bit of knowledge of how Felix works below...
            File dataDir = new File(cacheDir, "bundle" + b.getBundleId() + "/data");
            if (dataDir.isDirectory()) {
                String key = String.format("%s$$%s", sn, b.getVersion().toString());
                bundlesWithData.put(key, b);
            }
        }
    }
    // this property file will be used to map full symbolicName$$version to a location where bundle data
    // is stored - the data must be restored both during R patch installation and rollback
    Properties properties = new Properties();
    String dirName = result.getPatchData().getId() + ".datafiles";
    if (result.getParent() != null) {
        dirName = result.getPatchData().getId() + "." + System.getProperty("karaf.name") + ".datafiles";
    }
    File dataBackupDir = new File(result.getPatchData().getPatchLocation(), dirName);
    String prefix = pending == Pending.ROLLUP_INSTALLATION ? "install" : "rollback";
    for (BundleUpdate update : result.getBundleUpdates()) {
        // same update for both updated and reinstalled bundle
        String key = String.format("%s$$%s", update.getSymbolicName(), pending == Pending.ROLLUP_INSTALLATION ? update.getPreviousVersion() : (update.getNewVersion() == null ? update.getPreviousVersion() : update.getNewVersion()));
        if (bundlesWithData.containsKey(key)) {
            File dataFileBackupDir = new File(dataBackupDir, prefix + "/" + key + "/data");
            dataFileBackupDir.mkdirs();
            final Bundle b = bundlesWithData.get(key);
            FileUtils.copyDirectory(b.getDataFile(""), dataFileBackupDir, new FileFilter() {

                @Override
                public boolean accept(File pathname) {
                    return pathname.isDirectory() || !b.getSymbolicName().equals("org.apache.felix.configadmin") || pathname.getName().endsWith(".config");
                }
            });
            properties.setProperty(key, key);
            properties.setProperty(String.format("%s$$%s", update.getSymbolicName(), update.getPreviousVersion()), key);
            if (update.getNewVersion() != null) {
                properties.setProperty(String.format("%s$$%s", update.getSymbolicName(), update.getNewVersion()), key);
            }
        }
    }
    FileOutputStream propsFile = new FileOutputStream(new File(dataBackupDir, "backup-" + prefix + ".properties"));
    properties.store(propsFile, "Data files to restore after \"" + result.getPatchData().getId() + "\" " + (pending == Pending.ROLLUP_INSTALLATION ? "installation" : "rollback"));
    propsFile.close();
}
Also used : HashMap(java.util.HashMap) Bundle(org.osgi.framework.Bundle) FileOutputStream(java.io.FileOutputStream) Properties(java.util.Properties) FileFilter(java.io.FileFilter) File(java.io.File) BundleUpdate(io.fabric8.patch.management.BundleUpdate)

Example 9 with PatchResult

use of io.fabric8.patch.management.PatchResult in project fabric8 by jboss-fuse.

the class GitPatchManagementServiceImpl method installProfiles.

@Override
public void installProfiles(File gitRepository, String versionId, Patch patch, ProfileUpdateStrategy strategy) {
    // remember - we operate on totally different git repository!
    // we should have version branch already checked out.
    // here we don't merge/cherry-pick anything - we're preparing new commit simply by copying
    // one set of profiles (from R patch) over another (current profile definitions from Fabric)
    // we won't have merge conflicts, but we can't simply copy profiles over, because existing profiles
    // may have custom changes
    Git git = null;
    try {
        git = Git.open(gitRepository);
        File src = new File(patch.getPatchData().getPatchDirectory(), "fabric/import/fabric/profiles");
        File dst = new File(git.getRepository().getWorkTree(), "fabric/profiles");
        // ENTESB-6003:
        // let's clean the target directory first, so we can detect file removals in patches (like moving
        // jmx.* and org.apache.karaf.command.* PIDs from jboss-fuse-full to acls profile)
        FileUtils.deleteDirectory(dst);
        dst.mkdir();
        ProfileFileUtils.copyDirectory(src, dst, strategy);
        git.add().addFilepattern(".").call();
        // remove the deletes
        for (String missing : git.status().call().getMissing()) {
            git.rm().addFilepattern(missing).call();
        }
        // commit profile changes in patch branch - ultimate commit will be the merge commit
        git.commit().setMessage("Installing profiles from patch \"" + patch.getPatchData().getId() + "\"").call();
        PatchResult result = patch.getResult();
        if (result == null) {
            result = new PatchResult(patch.getPatchData(), false, new Date().getTime(), null, null);
            patch.setResult(result);
        }
        result.getVersions().add(versionId);
        result.store();
    } catch (Exception e) {
        throw new PatchException(e.getMessage(), e);
    } finally {
        if (git != null) {
            gitPatchRepository.closeRepository(git, false);
        }
    }
}
Also used : Git(org.eclipse.jgit.api.Git) PatchResult(io.fabric8.patch.management.PatchResult) PatchException(io.fabric8.patch.management.PatchException) ZipFile(org.apache.commons.compress.archivers.zip.ZipFile) File(java.io.File) Date(java.util.Date) PatchException(io.fabric8.patch.management.PatchException) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 10 with PatchResult

use of io.fabric8.patch.management.PatchResult in project fabric8 by jboss-fuse.

the class ServiceImpl method resumePendingPatchTasks.

/**
 * Upon startup (activation), we check if there are any *.patch.pending files. if yes, we're finishing the
 * installation
 */
private void resumePendingPatchTasks() throws IOException {
    File[] pendingPatches = patchDir.listFiles(new FileFilter() {

        @Override
        public boolean accept(File pathname) {
            return pathname.exists() && pathname.getName().endsWith(".pending");
        }
    });
    if (pendingPatches == null || pendingPatches.length == 0) {
        return;
    }
    for (File pending : pendingPatches) {
        Pending what = Pending.valueOf(FileUtils.readFileToString(pending));
        String name = pending.getName().replaceFirst("\\.pending$", "");
        if (patchManagement.isStandaloneChild()) {
            if (name.endsWith("." + System.getProperty("karaf.name") + ".patch")) {
                name = name.replaceFirst("\\." + System.getProperty("karaf.name"), "");
            } else {
                continue;
            }
        }
        File patchFile = new File(pending.getParentFile(), name);
        if (!patchFile.isFile()) {
            System.out.println("Ignoring patch result file: " + patchFile.getName());
            continue;
        }
        PatchData patchData = PatchData.load(new FileInputStream(patchFile));
        Patch patch = patchManagement.loadPatch(new PatchDetailsRequest(patchData.getId()));
        System.out.printf("Resume %s of %spatch \"%s\"%n", what == Pending.ROLLUP_INSTALLATION ? "installation" : "rollback", patch.getPatchData().isRollupPatch() ? "rollup " : "", patch.getPatchData().getId());
        PatchResult result = patch.getResult();
        if (patchManagement.isStandaloneChild()) {
            result = result.getChildPatches().get(System.getProperty("karaf.name"));
            if (result == null) {
                System.out.println("Ignoring patch result file: " + patchFile.getName());
                continue;
            }
        }
        // feature time
        Set<String> newRepositories = new LinkedHashSet<>();
        Set<String> features = new LinkedHashSet<>();
        for (FeatureUpdate featureUpdate : result.getFeatureUpdates()) {
            if (featureUpdate.getName() == null && featureUpdate.getPreviousRepository() != null) {
                // feature was not shipped by patch
                newRepositories.add(featureUpdate.getPreviousRepository());
            } else if (featureUpdate.getNewRepository() == null) {
                // feature was not changed by patch
                newRepositories.add(featureUpdate.getPreviousRepository());
                features.add(String.format("%s|%s", featureUpdate.getName(), featureUpdate.getPreviousVersion()));
            } else {
                // feature was shipped by patch
                if (what == Pending.ROLLUP_INSTALLATION) {
                    newRepositories.add(featureUpdate.getNewRepository());
                    features.add(String.format("%s|%s", featureUpdate.getName(), featureUpdate.getNewVersion()));
                } else {
                    newRepositories.add(featureUpdate.getPreviousRepository());
                    features.add(String.format("%s|%s", featureUpdate.getName(), featureUpdate.getPreviousVersion()));
                }
            }
        }
        for (String repo : newRepositories) {
            System.out.println("Restoring feature repository: " + repo);
            try {
                featuresService.addRepository(URI.create(repo));
            } catch (Exception e) {
                System.err.println(e.getMessage());
                e.printStackTrace(System.err);
                System.err.flush();
            }
        }
        for (String f : features) {
            String[] fv = f.split("\\|");
            System.out.printf("Restoring feature %s/%s%n", fv[0], fv[1]);
            try {
                featuresService.installFeature(fv[0], fv[1]);
            } catch (Exception e) {
                System.err.println(e.getMessage());
                e.printStackTrace(System.err);
                System.err.flush();
            }
        }
        for (BundleUpdate update : result.getBundleUpdates()) {
            if (!update.isIndependent()) {
                continue;
            }
            String location = null;
            if (update.getNewVersion() == null) {
                System.out.printf("Restoring bundle %s from %s%n", update.getSymbolicName(), update.getPreviousLocation());
                location = update.getPreviousLocation();
            } else {
                if (what == Pending.ROLLUP_INSTALLATION) {
                    System.out.printf("Updating bundle %s from %s%n", update.getSymbolicName(), update.getNewLocation());
                    location = update.getNewLocation();
                } else {
                    System.out.printf("Downgrading bundle %s from %s%n", update.getSymbolicName(), update.getPreviousLocation());
                    location = update.getPreviousLocation();
                }
            }
            try {
                Bundle b = bundleContext.installBundle(location);
                if (update.getStartLevel() > -1) {
                    b.adapt(BundleStartLevel.class).setStartLevel(update.getStartLevel());
                }
                switch(update.getState()) {
                    // ?
                    case Bundle.UNINSTALLED:
                    case Bundle.INSTALLED:
                    case Bundle.STARTING:
                    case Bundle.STOPPING:
                        break;
                    case Bundle.RESOLVED:
                        // ?bundleContext.getBundle(0L).adapt(org.osgi.framework.wiring.FrameworkWiring.class).resolveBundles(...);
                        break;
                    case Bundle.ACTIVE:
                        b.start();
                        break;
                }
            } catch (BundleException e) {
                System.err.println(" - " + e.getMessage());
                // e.printStackTrace(System.err);
                System.err.flush();
            }
        }
        pending.delete();
        System.out.printf("%spatch \"%s\" %s successfully%n", patch.getPatchData().isRollupPatch() ? "Rollup " : "", patchData.getId(), what == Pending.ROLLUP_INSTALLATION ? "installed" : "rolled back");
        if (what == Pending.ROLLUP_ROLLBACK) {
            List<String> bases = patch.getResult().getKarafBases();
            for (Iterator<String> iterator = bases.iterator(); iterator.hasNext(); ) {
                String s = iterator.next();
                if (s.startsWith(System.getProperty("karaf.name"))) {
                    iterator.remove();
                }
            }
            result.setPending(null);
            patch.getResult().store();
            if (patch.getResult().getKarafBases().size() == 0) {
                File file = new File(patchDir, patchData.getId() + ".patch.result");
                file.delete();
            }
            if (patchManagement.isStandaloneChild()) {
                File file = new File(patchDir, patchData.getId() + "." + System.getProperty("karaf.name") + ".patch.result");
                if (file.isFile()) {
                    file.delete();
                }
            }
        }
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) BundleStartLevel(org.osgi.framework.startlevel.BundleStartLevel) PatchData(io.fabric8.patch.management.PatchData) Bundle(org.osgi.framework.Bundle) PatchDetailsRequest(io.fabric8.patch.management.PatchDetailsRequest) FileInputStream(java.io.FileInputStream) URISyntaxException(java.net.URISyntaxException) PatchException(io.fabric8.patch.management.PatchException) BundleException(org.osgi.framework.BundleException) IOException(java.io.IOException) PatchResult(io.fabric8.patch.management.PatchResult) BundleException(org.osgi.framework.BundleException) FileFilter(java.io.FileFilter) File(java.io.File) Patch(io.fabric8.patch.management.Patch) Pending(io.fabric8.patch.management.Pending) BundleUpdate(io.fabric8.patch.management.BundleUpdate) FeatureUpdate(io.fabric8.patch.management.FeatureUpdate)

Aggregations

PatchResult (io.fabric8.patch.management.PatchResult)13 Patch (io.fabric8.patch.management.Patch)9 BundleUpdate (io.fabric8.patch.management.BundleUpdate)8 PatchException (io.fabric8.patch.management.PatchException)7 File (java.io.File)7 Bundle (org.osgi.framework.Bundle)6 IOException (java.io.IOException)5 Test (org.junit.Test)5 PatchData (io.fabric8.patch.management.PatchData)4 HashMap (java.util.HashMap)4 PatchManagement (io.fabric8.patch.management.PatchManagement)3 GitPatchManagementServiceImpl (io.fabric8.patch.management.impl.GitPatchManagementServiceImpl)3 FileInputStream (java.io.FileInputStream)3 URISyntaxException (java.net.URISyntaxException)3 BundleException (org.osgi.framework.BundleException)3 BundleStartLevel (org.osgi.framework.startlevel.BundleStartLevel)3 FeatureUpdate (io.fabric8.patch.management.FeatureUpdate)2 PatchKind (io.fabric8.patch.management.PatchKind)2 GitPatchRepository (io.fabric8.patch.management.impl.GitPatchRepository)2 FileFilter (java.io.FileFilter)2