Java Code Examples for org.jboss.forge.addon.ui.result.Results#fail()
The following examples show how to use
org.jboss.forge.addon.ui.result.Results#fail() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CamelCommandsHelper.java From fabric8-forge with Apache License 2.0 | 6 votes |
public static Result ensureCamelArtifactIdAdded(Project project, CamelComponentDetails details, DependencyInstaller dependencyInstaller) { String groupId = details.getGroupId(); String artifactId = details.getArtifactId(); Dependency core = CamelProjectHelper.findCamelCoreDependency(project); if (core == null) { return Results.fail("The project does not include camel-core"); } // we want to use same version as camel-core if its a camel component // otherwise use the version from the dto String version; if ("org.apache.camel".equals(groupId)) { version = core.getCoordinate().getVersion(); } else { version = details.getVersion(); } DependencyBuilder component = DependencyBuilder.create().setGroupId(groupId) .setArtifactId(artifactId).setVersion(version); // install the component dependencyInstaller.install(project, component); return null; }
Example 2
Source File: EndpointStatsCommand.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } boolean val = "true".equals(decode.getValue()); String[] val2 = null; if (filter.getValue() != null) { String s = filter.getValue().toString(); val2 = s.split(","); } org.apache.camel.commands.EndpointStatisticCommand command = new org.apache.camel.commands.EndpointStatisticCommand(name.getValue(), val, val2); command.execute(getController(), getOutput(context), getError(context)); return Results.success(); }
Example 3
Source File: ConnectedCommand.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public Result execute(UIExecutionContext uiExecutionContext) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } String username = configuration.getString("CamelJolokiaUsername"); JolokiaCamelController controller = getController(); // ping to see if the connection works boolean ok = controller.ping(); if (ok) { return Results.success("Connected to " + url + (username != null ? " using " + username : "")); } else { return Results.fail("Error connecting to " + url); } }
Example 4
Source File: EndpointListCommand.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } boolean val = "true".equals(decode.getValue()); boolean val2 = "true".equals(verbose.getValue()); boolean val3 = "true".equals(explain.getValue()); org.apache.camel.commands.EndpointListCommand command = new org.apache.camel.commands.EndpointListCommand(name.getValue(), val, val2, val3); command.execute(getController(), getOutput(context), getError(context)); return Results.success(); }
Example 5
Source File: Fabric8SetupStep.java From fabric8-forge with Apache License 2.0 | 6 votes |
@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(); }
Example 6
Source File: RunCommand.java From thorntail-addon with Eclipse Public License 1.0 | 6 votes |
@Override public Result execute(UIExecutionContext context) { Project project = getSelectedProject(context); UIOutput output = context.getUIContext().getProvider().getOutput(); PackagingFacet packagingFacet = project.getFacet(PackagingFacet.class); try { packagingFacet.createBuilder().addArguments("thorntail: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(); }
Example 7
Source File: CamelGetRoutesXmlCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { Project project = getSelectedProject(context); String xmlResourceName = xml.getValue(); List<ContextDto> camelContexts = CamelXmlHelper.loadCamelContext(getCamelCatalog(), context.getUIContext(), project, xmlResourceName); if (camelContexts == null) { return Results.fail("No file found for: " + xmlResourceName); } String result = formatResult(camelContexts); return Results.success(result); }
Example 8
Source File: RouteResumeCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } org.apache.camel.commands.RouteResumeCommand command = new org.apache.camel.commands.RouteResumeCommand(route.getValue(), name.getValue()); command.execute(getController(), getOutput(context), getError(context)); return Results.success("Resumed " + route.getValue()); }
Example 9
Source File: RouteSuspendCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } org.apache.camel.commands.RouteSuspendCommand command = new org.apache.camel.commands.RouteSuspendCommand(route.getValue(), name.getValue()); command.execute(getController(), getOutput(context), getError(context)); return Results.success("Suspended " + route.getValue()); }
Example 10
Source File: ContextListCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } org.apache.camel.commands.ContextListCommand command = new org.apache.camel.commands.ContextListCommand(); command.execute(getController(), getOutput(context), getError(context)); return Results.success(); }
Example 11
Source File: RouteStartCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } org.apache.camel.commands.RouteStartCommand command = new org.apache.camel.commands.RouteStartCommand(route.getValue(), name.getValue()); command.execute(getController(), getOutput(context), getError(context)); return Results.success("Started " + route.getValue()); }
Example 12
Source File: ContextSuspendCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } org.apache.camel.commands.ContextSuspendCommand command = new org.apache.camel.commands.ContextSuspendCommand(name.getValue()); command.execute(getController(), getOutput(context), getError(context)); return Results.success("Suspended " + name.getValue()); }
Example 13
Source File: ContextStartCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } org.apache.camel.commands.ContextStartCommand command = new org.apache.camel.commands.ContextStartCommand(name.getValue()); command.execute(getController(), getOutput(context), getError(context)); return Results.success("Started " + name.getValue()); }
Example 14
Source File: ComponentListCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } boolean val = "true".equals(verbose.getValue()); org.apache.camel.commands.ComponentListCommand command = new org.apache.camel.commands.ComponentListCommand(name.getValue(), val); command.execute(getController(), getOutput(context), getError(context)); return Results.success(); }
Example 15
Source File: RouteProfileCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } org.apache.camel.commands.RouteProfileCommand command = new org.apache.camel.commands.RouteProfileCommand(route.getValue(), name.getValue()); command.setStringEscape(new NoopStringEscape()); command.execute(getController(), getOutput(context), getError(context)); return Results.success(); }
Example 16
Source File: CamelCommandsHelper.java From fabric8-forge with Apache License 2.0 | 5 votes |
/** * Populates the details for the given component, returning a Result if it fails. */ public static Result loadCamelComponentDetails(CamelCatalog camelCatalog, String camelComponentName, CamelComponentDetails details) { String json = camelCatalog.componentJSonSchema(camelComponentName); if (json == null) { return Results.fail("Could not find catalog entry for component name: " + camelComponentName); } List<Map<String, String>> data = JSonSchemaHelper.parseJsonSchema("component", json, false); for (Map<String, String> row : data) { String javaType = row.get("javaType"); if (!Strings.isNullOrEmpty(javaType)) { details.setComponentClassQName(javaType); } String groupId = row.get("groupId"); if (!Strings.isNullOrEmpty(groupId)) { details.setGroupId(groupId); } String artifactId = row.get("artifactId"); if (!Strings.isNullOrEmpty(artifactId)) { details.setArtifactId(artifactId); } String version = row.get("version"); if (!Strings.isNullOrEmpty(version)) { details.setVersion(version); } } if (Strings.isNullOrEmpty(details.getComponentClassQName())) { return Results.fail("Could not find fully qualified class name in catalog for component name: " + camelComponentName); } return null; }
Example 17
Source File: CamelProjectAddComponentStep.java From fabric8-forge with Apache License 2.0 | 4 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { Project project = getSelectedProject(context); // does the project already have camel? Dependency core = findCamelCoreDependency(project); if (core == null) { return Results.fail("The project does not include camel-core"); } ComponentDto dto = componentName.getValue(); if (dto != null) { // we want to use same version as camel-core if its a camel component // otherwise use the version from the dto String version; if ("org.apache.camel".equals(dto.getGroupId())) { version = core.getCoordinate().getVersion(); } else { version = dto.getVersion(); } String artifactId = dto.getArtifactId(); // is it spring boot project and Camel is > 2.18.0 then we must use -starter if (isSpringBootProject(project)) { boolean newer = CamelVersionHelper.isGE("2.18.0", version); if (newer) { artifactId = artifactId + "-starter"; } } DependencyBuilder dependency = DependencyBuilder.create().setGroupId(dto.getGroupId()) .setArtifactId(artifactId).setVersion(version); // install the component dependencyInstaller.install(project, dependency); return Results.success("Added Camel component " + dto.getScheme() + " (" + dto.getArtifactId() + ") to the project"); } else { return Results.fail("Unknown Camel component"); } }
Example 18
Source File: CamelNewRouteBuilderCommand.java From fabric8-forge with Apache License 2.0 | 4 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { Project project = getSelectedProject(context); JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class); // does the project already have camel? Dependency core = findCamelCoreDependency(project); if (core == null) { return Results.fail("The project does not include camel-core"); } // do we already have a class with the name String fqn = targetPackage.getValue() != null ? targetPackage.getValue() + "." + name.getValue() : name.getValue(); JavaResource existing = facet.getJavaResource(fqn); if (existing != null && existing.exists()) { return Results.fail("A class with name " + fqn + " already exists"); } // need to parse to be able to extends another class final JavaClassSource javaClass = Roaster.create(JavaClassSource.class); javaClass.setName(name.getValue()); if (targetPackage.getValue() != null) { javaClass.setPackage(targetPackage.getValue()); } javaClass.setSuperType("RouteBuilder"); javaClass.addImport("org.apache.camel.builder.RouteBuilder"); boolean cdi = CamelCommandsHelper.isCdiProject(getSelectedProject(context)); boolean spring = CamelCommandsHelper.isSpringProject(getSelectedProject(context)); if (cdi) { javaClass.addAnnotation("javax.inject.Singleton"); } else if (spring) { javaClass.addAnnotation("org.springframework.stereotype.Component"); } javaClass.addMethod() .setPublic() .setReturnTypeVoid() .setName("configure") .addThrows(Exception.class).setBody(""); JavaResource javaResource = facet.saveJavaSource(javaClass); // if we are in an GUI editor then open the file if (isRunningInGui(context.getUIContext())) { context.getUIContext().setSelection(javaResource); } return Results.success("Created new RouteBuilder class " + name.getValue()); }
Example 19
Source File: WindupCommand.java From windup with Eclipse Public License 1.0 | 4 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { if (!this.promptMessages.isEmpty()) { for (ValidationResult message : promptMessages) { UIOutput output = context.getUIContext().getProvider().getOutput(); output.warn(output.out(), message.getMessage()); } if (context.getPrompt().promptBoolean("Would you like to continue?", true) == false) { return Results.fail("Aborted by the user."); } } WindupConfiguration windupConfiguration = new WindupConfiguration(); for (Entry<ConfigurationOption, InputComponent<?, ?>> entry : this.inputOptions.entrySet()) { ConfigurationOption option = entry.getKey(); String name = option.getName(); Object value = getValueForInput(option, entry.getValue()); windupConfiguration.setOptionValue(name, value); } windupConfiguration.useDefaultDirectories(); Boolean overwrite = (Boolean) windupConfiguration.getOptionMap().get(OverwriteOption.NAME); if (overwrite == null) { overwrite = false; } if (!overwrite && pathNotEmpty(windupConfiguration.getOutputDirectory().toFile())) { String promptMsg = "Overwrite all contents of \"" + windupConfiguration.getOutputDirectory().toString() + "\" (anything already in the directory will be deleted)?"; if (!context.getPrompt().promptBoolean(promptMsg, false)) { String outputPath = windupConfiguration.getOutputDirectory().toString(); return Results.fail("Files exist in " + outputPath + ", but --overwrite not specified. Aborting!"); } } /* * Put this in the context for debugging, and unit tests (or anything else that needs it). */ context.getUIContext().getAttributeMap().put(WindupConfiguration.class, windupConfiguration); FileUtils.deleteQuietly(windupConfiguration.getOutputDirectory().toFile()); Path graphPath = windupConfiguration.getOutputDirectory().resolve("graph"); try (GraphContext graphContext = graphContextFactory.create(graphPath, true)) { context.getUIContext().getAttributeMap().put(GraphContext.class, graphContext); UIProgressMonitor uiProgressMonitor = context.getProgressMonitor(); WindupProgressMonitor progressMonitor = new WindupProgressMonitorAdapter(uiProgressMonitor); windupConfiguration .setProgressMonitor(progressMonitor) .setGraphContext(graphContext); processor.execute(windupConfiguration); uiProgressMonitor.done(); Path indexHtmlPath = windupConfiguration.getOutputDirectory().resolve("index.html").normalize().toAbsolutePath(); return Results.success("Report created: " + indexHtmlPath + System.getProperty("line.separator") + " Access it at this URL: " + indexHtmlPath.toUri()); } }