@Override public Result f(Exception e) { return Results.fail("install module failed!", e); }
/** * Create a failed {@link Result}. */ public static final Failed fail() { return fail(null); }
@Override public void postWizardFailure(UIWizard wizard, UIExecutionContext context, Throwable failure) { synchronized (this) { this.result = Results.fail("Error encountered during command execution.", failure); } }
@Override public void postCommandFailure(UICommand command, UIExecutionContext context, Throwable failure) { if (!wizard) { synchronized (this) { this.result = Results.fail("Error encountered during command execution.", failure); } } }
@Override public void onCommandNotFound(String line, UIContext context) { synchronized (this) { this.result = Results.fail("Command not found: " + line); } }
@Override public Result execute(UIExecutionContext context) throws Exception { return Results.fail("Update was disabled!"); /* temporary disabled update of rules due possible breakage on compatibility and proper * function String updatedTo = updater.replaceRulesetsDirectoryWithLatestReleaseIfAny(); if (updatedTo == null) return Results.fail("The ruleset is already in the most updated version."); else return Results.success("Sucessfully updated the rulesets to version " + updatedTo + " ."); */ }
private Result verifyProject(final Project project) { final Collection<String> problems = getProblems(project); if (problems.isEmpty()) { return Results.success(); } else { final StringBuilder messageBuilder = new StringBuilder(); messageBuilder.append(String.format( "There are some problems with your project (%s) preventing the installation of Errai with this Addon.", project.getRootDirectory().getUnderlyingResourceObject().getAbsolutePath())); for (final String problem : problems) { messageBuilder.append(problem); } return Results.fail(messageBuilder.toString()); } }
@Override public Result execute(UIExecutionContext context) throws Exception { Map<Object, Object> attributeMap = context.getUIContext().getAttributeMap(); LOG.info("devops tab has attributes:: " + attributeMap); try { return Results.success(""); } catch (IllegalArgumentException e) { return Results.fail(e.getMessage()); } }
@Override public Result execute(UIExecutionContext context) throws Exception { Result result = null; try { getSelectedProject(context).getFacet(GitIgnoreFacet.class).update(); result = Results.success("Local gitignore repository updated."); } catch (IOException e) { result = Results.fail("Error reading local repository: " + e.getMessage(), e); } catch (GitAPIException e) { result = Results.fail("Error pulling remote repository: " + e.getMessage(), e); } return result; }
@Override public Result execute(UIExecutionContext shellContext) throws Exception { ResourceTransaction transaction = resourceFactory.getTransaction(); if (!transaction.isStarted()) { return Results.fail("Resource Transaction is not started"); } transaction.rollback(); return Results.success("Resource Transaction was rolled back"); }
@Override public Result execute(UIExecutionContext shellContext) throws Exception { ResourceTransaction transaction = resourceFactory.getTransaction(); if (!transaction.isStarted()) { return Results.fail("Resource Transaction is not started"); } transaction.commit(); return Results.success("Resource Transaction was committed"); }
@Override public Result execute(UIExecutionContext context) throws Exception { StopWatch watch = new StopWatch(); log.debug("Starting to setup fabric8 project"); Project project = getSelectedProject(context.getUIContext()); if (project == null) { return Results.fail("No pom.xml available so cannot edit the project!"); } // setup fabric8-maven-plugin setupFabricMavenPlugin(project); log.debug("fabric8-maven-plugin now setup"); // make sure we have resources as we need it later facetFactory.install(project, ResourcesFacet.class); log.info("execute took " + watch.taken()); return Results.success(); }
@Override public Result execute(UIExecutionContext context) throws Exception { Map<Object, Object> attributeMap = context.getUIContext().getAttributeMap(); CommandInvocation commandInvocation = (CommandInvocation) attributeMap.get(CommandInvocation.class); CommandResult result = commandLineParser.getCommand().execute(commandInvocation); if (result == CommandResult.FAILURE) { return Results.fail("Failure while executing aesh command"); } else { return Results.success(); } }
@Override public Result execute(UIExecutionContext context) throws Exception { final Project project = getSelectedProject(context.getUIContext()); final Iterable<Feature> features = featureSelect.getValue(); if (features != null) { for (final Feature feature : features) { try { performOperation(project, feature); } catch (Exception e) { return Results.fail(e.getMessage(), e); } } } return Results.success(); }
@Override public Result execute(UIExecutionContext context) throws Exception { if (!context.getPrompt().promptBoolean( "Are you sure you want to continue? This command will delete current directories: addons, bin, lib, rules/migration-core")) { return Results.fail("Updating distribution was aborted."); } // Find the latest version. Coordinate latestDist = this.updater.getLatestReleaseOf("org.jboss.windup", "windup-distribution"); Version latestVersion = SingleVersion.valueOf(latestDist.getVersion()); Version installedVersion = currentAddon.getId().getVersion(); if (latestVersion.compareTo(installedVersion) <= 0) { return Results.fail(Util.WINDUP_BRAND_NAME_ACRONYM+" CLI is already in the most updated version."); } distUpdater.replaceWindupDirectoryWithDistribution(latestDist); return Results.success("Sucessfully updated "+Util.WINDUP_BRAND_NAME_ACRONYM+" CLI to version " + latestDist.getVersion() + ". Please restart RHAMT CLI."); }
@Override public Result execute(UIExecutionContext context) { final Result result; Project project = getSelectedProject(context.getUIContext()); DependencyFacet deps = project.getFacet(DependencyFacet.class); String urlValue = url.getValue(); DependencyRepository rep = deps.removeRepository(urlValue); if (rep != null) { result = Results.success("Removed repository [" + rep.getId() + "->" + rep.getUrl() + "]"); } else { result = Results.fail("No repository with url [" + urlValue + "]"); } return result; }
@Override public Result execute(UIExecutionContext context) { final Result result; Project project = getSelectedProject(context.getUIContext()); DependencyFacet deps = project.getFacet(DependencyFacet.class); String name = named.getValue(); String urlValue = url.getValue(); if (deps.hasRepository(urlValue)) { result = Results.fail("Repository exists [" + url + "]"); } else { deps.addRepository(name, urlValue); result = Results.success("Added repository [" + name + "->" + urlValue + "]"); } return result; }
@Override public Result execute(UIExecutionContext shellContext) throws Exception { ResourceTransaction transaction = resourceFactory.getTransaction(); if (transaction.isStarted()) { if (trackChangesSettings.isTrackChanges() && !trackChangesSettings.isInForeignTransaction()) transaction.rollback(); else return Results.fail("Resource Transaction is already started"); } if (timeout.getValue() != null) { transaction.setTransactionTimeout(timeout.getValue()); } transaction.begin(); return Results.success("Resource Transaction started"); }
@Override public Result execute(UIExecutionContext context) throws Exception { Project project = getSelectedProject(context); Result result = null; if (project != null) { try (Git git = getGitUtils().git(project.getRoot().reify(DirectoryResource.class))) { getGitUtils().checkout(git, branchName.getValue(), create.getValue(), trackingMode.getValue(), force.getValue()); } result = Results.success(); } else { result = Results.fail("This command should be executed in the context of a project"); } return result; }
@Override public Result execute(UIExecutionContext context) throws Exception { Project project = getSelectedProject(context); UIOutput output = context.getUIContext().getProvider().getOutput(); PackagingFacet packagingFacet = project.getFacet(PackagingFacet.class); try { packagingFacet.createBuilder().addArguments("wildfly-swarm:run").runTests(false).build(output.out(), output.err()); } catch (BuildException ie) { if (!(ie.getCause() instanceof InterruptedException)) { return Results.fail("Error while running the build", ie.getCause()); } } return Results.success(); }