Search in sources :

Example 1 with PatchService

use of org.jboss.fuse.patch.PatchService in project fuse-karaf by jboss-fuse.

the class DeleteCommand method doExecute.

@Override
protected void doExecute(PatchService service) throws Exception {
    Patch patch = patchManagement.loadPatch(new PatchDetailsRequest(patchId));
    if (patch == null) {
        throw new PatchException("Patch '" + patchId + "' not found");
    }
    if (patch.getResult() != null && patch.getResult().getKarafBases().size() > 0) {
        throw new PatchException("Patch '" + patchId + "' can't be deleted, as it's installed in these containers: " + patch.getResult().getKarafBases().stream().map(kb -> kb.contains("|") ? kb.split("\\s*\\|\\s*")[0] : kb).collect(Collectors.joining(", ")));
    }
    patchManagement.delete(patch);
    System.out.println("Patch '" + patchId + "' was successfully deleted");
}
Also used : UninstallPatchCompleter(org.jboss.fuse.patch.commands.completers.UninstallPatchCompleter) Argument(org.apache.karaf.shell.api.action.Argument) PatchDetailsRequest(org.jboss.fuse.patch.management.PatchDetailsRequest) Collectors(java.util.stream.Collectors) PatchException(org.jboss.fuse.patch.management.PatchException) BundleContext(org.osgi.framework.BundleContext) Command(org.apache.karaf.shell.api.action.Command) Reference(org.apache.karaf.shell.api.action.lifecycle.Reference) Patch(org.jboss.fuse.patch.management.Patch) Service(org.apache.karaf.shell.api.action.lifecycle.Service) PatchService(org.jboss.fuse.patch.PatchService) PatchManagement(org.jboss.fuse.patch.management.PatchManagement) Completion(org.apache.karaf.shell.api.action.Completion) PatchException(org.jboss.fuse.patch.management.PatchException) Patch(org.jboss.fuse.patch.management.Patch) PatchDetailsRequest(org.jboss.fuse.patch.management.PatchDetailsRequest)

Aggregations

Collectors (java.util.stream.Collectors)1 Argument (org.apache.karaf.shell.api.action.Argument)1 Command (org.apache.karaf.shell.api.action.Command)1 Completion (org.apache.karaf.shell.api.action.Completion)1 Reference (org.apache.karaf.shell.api.action.lifecycle.Reference)1 Service (org.apache.karaf.shell.api.action.lifecycle.Service)1 PatchService (org.jboss.fuse.patch.PatchService)1 UninstallPatchCompleter (org.jboss.fuse.patch.commands.completers.UninstallPatchCompleter)1 Patch (org.jboss.fuse.patch.management.Patch)1 PatchDetailsRequest (org.jboss.fuse.patch.management.PatchDetailsRequest)1 PatchException (org.jboss.fuse.patch.management.PatchException)1 PatchManagement (org.jboss.fuse.patch.management.PatchManagement)1 BundleContext (org.osgi.framework.BundleContext)1