org.jboss.forge.addon.ui.result.Results Java Examples
The following examples show how to use
org.jboss.forge.addon.ui.result.Results.
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: 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 #2
Source File: CreateTestClassCommand.java From thorntail-addon with Eclipse Public License 1.0 | 6 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { Project project = getSelectedProject(context); final DependencyFacet dependencyFacet = project.getFacet(DependencyFacet.class); if (!isArquillianWildflySwarmDependencyInstalled(dependencyFacet)) { installArquillianWildflySwarmDependency(dependencyFacet); } JavaClassSource test = Roaster.create(JavaClassSource.class) .setPackage(targetPackage.getValue()) .setName(named.getValue()); addArquillianRunner(test); addDefaultDeploymentAnnotation(test, project); addArquillianResourceEnricher(test); addTestMethod(test); JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class); facet.saveTestJavaSource(test); return Results.success(String.format("Test Class %s.%s was created", targetPackage.getValue(), named.getValue())); }
Example #3
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 #4
Source File: AddFractionCommand.java From thorntail-addon with Eclipse Public License 1.0 | 6 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { Project project = getSelectedProject(context); ThorntailFacet facet = project.getFacet(ThorntailFacet.class); if (fractionElements.hasValue()) { List<FractionDescriptor> fractions = Lists.toList(fractionElements.getValue()); facet.installFractions(fractions); List<String> artifactIds = fractions.stream().map(FractionDescriptor::getArtifactId) .collect(Collectors.toList()); return Results.success("Thorntail Fractions '" + artifactIds + "' were successfully added to the project descriptor"); } return Results.success(); }
Example #5
Source File: NewIntegrationTestBuildCommand.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { String buildConfigName = buildName.getValue(); Objects.assertNotNull(buildConfigName, "buildName"); Map<String, String> labels = BuildConfigs.createBuildLabels(buildConfigName); String gitUrlText = getOrFindGitUrl(context, gitUri.getValue()); String imageText = image.getValue(); List<EnvVar> envVars = createEnvVars(buildConfigName, gitUrlText, mavenCommand.getValue()); BuildConfig buildConfig = BuildConfigs.createIntegrationTestBuildConfig(buildConfigName, labels, gitUrlText, imageText, envVars); LOG.info("Generated BuildConfig: " + toJson(buildConfig)); ImageStream imageRepository = BuildConfigs.imageRepository(buildConfigName, labels); Controller controller = createController(); controller.applyImageStream(imageRepository, "generated ImageStream: " + toJson(imageRepository)); controller.applyBuildConfig(buildConfig, "generated BuildConfig: " + toJson(buildConfig)); return Results.success("Added BuildConfig: " + Builds.getName(buildConfig) + " to OpenShift at master: " + getKubernetes().getMasterUrl()); }
Example #6
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 #7
Source File: ConfigureEndpointPropertiesStep.java From fabric8-forge with Apache License 2.0 | 6 votes |
private Result editEndpointXml(List<String> lines, String lineNumber, String endpointUrl, String uri, FileResource file, String xml) { // the list is 0-based, and line number is 1-based int idx = Integer.valueOf(lineNumber) - 1; String line = lines.get(idx); // replace uri with new value line = StringHelper.replaceAll(line, endpointUrl, uri); lines.set(idx, line); LOG.info("Updating " + endpointUrl + " to " + uri + " at line " + lineNumber + " in file " + xml); // and save the file back String content = LineNumberHelper.linesToString(lines); file.setContents(content); return Results.success("Update endpoint uri: " + uri + " in file " + xml); }
Example #8
Source File: ConfigureEndpointPropertiesStep.java From fabric8-forge with Apache License 2.0 | 6 votes |
protected Result editEndpointOther(Project project, ResourcesFacet facet, FileResource file, String uri, String endpointUrl, String currentFile, String lineNumber) throws Exception { List<String> lines = LineNumberHelper.readLines(file.getResourceInputStream()); // the list is 0-based, and line number is 1-based int idx = Integer.valueOf(lineNumber) - 1; String line = lines.get(idx); // replace uri with new value line = StringHelper.replaceAll(line, endpointUrl, uri); lines.set(idx, line); LOG.info("Updating " + endpointUrl + " to " + uri + " at line " + lineNumber + " in file " + currentFile); // and save the file back String content = LineNumberHelper.linesToString(lines); file.setContents(content); return Results.success("Update endpoint uri: " + uri + " in file " + currentFile); }
Example #9
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 #10
Source File: WindupUpdateDistributionCommand.java From windup with Eclipse Public License 1.0 | 6 votes |
@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 MTA CLI."); }
Example #11
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 #12
Source File: ConnectCommand.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public Result execute(UIExecutionContext uiExecutionContext) throws Exception { configuration.setProperty("CamelJolokiaUrl", url.getValue()); // username and password is optional configuration.setProperty("CamelJolokiaUsername", username.getValue()); configuration.setProperty("CamelJolokiaPassword", password.getValue()); // ping to see if the connection works JolokiaCamelController controller = new DefaultJolokiaCamelController(); controller.connect(url.getValue(), username.getValue(), password.getValue()); boolean ok = controller.ping(); if (ok) { return Results.success("Connected to " + url.getValue() + (username.getValue() != null ? " using " + username.getValue() : "")); } else { return Results.fail("Error connecting to " + url.getValue()); } }
Example #13
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 #14
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 #15
Source File: RestShowCommand.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.RestShowCommand command = new org.apache.camel.commands.RestShowCommand(name.getValue()); command.execute(getController(), getOutput(context), getError(context)); return Results.success(); }
Example #16
Source File: RouteInfoCommand.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.RouteInfoCommand command = new org.apache.camel.commands.RouteInfoCommand(route.getValue(), name.getValue()); command.setStringEscape(new NoopStringEscape()); command.execute(getController(), getOutput(context), getError(context)); return Results.success(); }
Example #17
Source File: FunktionArchetypeSelectionWizardStep.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { UIContext uiContext = context.getUIContext(); Project project = (Project) uiContext.getAttributeMap().get(Project.class); Archetype chosenArchetype = archetype.getValue(); String coordinate = chosenArchetype.getGroupId() + ":" + chosenArchetype.getArtifactId() + ":" + chosenArchetype.getVersion(); DependencyQueryBuilder depQuery = DependencyQueryBuilder.create(coordinate); String repository = chosenArchetype.getRepository(); if (!Strings.isNullOrEmpty(repository)) { if (repository.endsWith(".xml")) { int lastRepositoryPath = repository.lastIndexOf('/'); if (lastRepositoryPath > -1) repository = repository.substring(0, lastRepositoryPath); } if (!repository.isEmpty()) { depQuery.setRepositories(new DependencyRepository("archetype", repository)); } } Dependency resolvedArtifact = dependencyResolver.resolveArtifact(depQuery); FileResource<?> artifact = resolvedArtifact.getArtifact(); MetadataFacet metadataFacet = project.getFacet(MetadataFacet.class); File fileRoot = project.getRoot().reify(DirectoryResource.class).getUnderlyingResourceObject(); ArchetypeHelper archetypeHelper = new ArchetypeHelper(artifact.getResourceInputStream(), fileRoot, metadataFacet.getProjectGroupName(), metadataFacet.getProjectName(), metadataFacet.getProjectVersion()); JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class); archetypeHelper.setPackageName(facet.getBasePackage()); archetypeHelper.execute(); return Results.success(); }
Example #18
Source File: EndpointExplainCommand.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.EndpointExplainCommand command = new org.apache.camel.commands.EndpointExplainCommand(name.getValue(), val, filter.getValue()); command.execute(getController(), getOutput(context), getError(context)); return Results.success(); }
Example #19
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 #20
Source File: RestApiDocCommand.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.RestApiDocCommand command = new org.apache.camel.commands.RestApiDocCommand(name.getValue()); command.execute(getController(), getOutput(context), getError(context)); return Results.success(); }
Example #21
Source File: RouteListCommand.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.RouteListCommand command = new org.apache.camel.commands.RouteListCommand(name.getValue()); command.execute(getController(), getOutput(context), getError(context)); return Results.success(); }
Example #22
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 #23
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 #24
Source File: ContextInflightCommand.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 value = sortByLongestDuration.getValue(); boolean flag = value != null && value.booleanValue(); org.apache.camel.commands.ContextInflightCommand command = new org.apache.camel.commands.ContextInflightCommand(name.getValue(), route.getValue(), limit.getValue(), flag); command.execute(getController(), getOutput(context), getError(context)); return Results.success(); }
Example #25
Source File: ScaffoldableEntitySelectionWizard.java From angularjs-addon with Eclipse Public License 1.0 | 5 votes |
@Override public NavigationResult next(UINavigationContext context) throws Exception { UIContext uiContext = context.getUIContext(); Map<Object, Object> attributeMap = uiContext.getAttributeMap(); ResourceCollection resourceCollection = new ResourceCollection(); if (targets.getValue() != null) { for (JavaClassSource klass : targets.getValue()) { Project project = getSelectedProject(uiContext); JavaSourceFacet javaSource = project.getFacet(JavaSourceFacet.class); Resource<?> resource = javaSource.getJavaResource(klass); if (resource != null) { resourceCollection.addToCollection(resource); } } } attributeMap.put(ResourceCollection.class, resourceCollection); Boolean shouldGenerateRestResources = generateRestResources.getValue(); if (shouldGenerateRestResources.equals(Boolean.TRUE)) { return Results.navigateTo(JSONRestResourceFromEntityCommand.class); } return null; }
Example #26
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 #27
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 #28
Source File: RouteStopCommand.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.RouteStopCommand command = new org.apache.camel.commands.RouteStopCommand(route.getValue(), name.getValue()); command.execute(getController(), getOutput(context), getError(context)); return Results.success("Stopped " + route.getValue()); }
Example #29
Source File: ListFractionsCommand.java From thorntail-addon with Eclipse Public License 1.0 | 5 votes |
@Override public Result execute(UIExecutionContext executionContext) { UIProvider provider = executionContext.getUIContext().getProvider(); UIOutput output = provider.getOutput(); PrintStream out = output.out(); for (FractionDescriptor fraction : ThorntailFacet.getAllFractionDescriptors()) { if (!fraction.isInternal()) { String msg = String.format("%s: %s (%s)", fraction.getArtifactId(), fraction.getName(), fraction.getDescription()); out.println(msg); } } return Results.success(); }
Example #30
Source File: AddNodeXmlStep.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override protected Result addModelXml(String pattern, List<String> lines, String lineNumber, String lineNumberEnd, String modelXml, FileResource file, String xml) throws Exception { // the list is 0-based, and line number is 1-based int idx = Integer.valueOf(lineNumberEnd); if ("route".equals(pattern)) { // we want to add at the end of the existing route, not after the route idx = idx - 1; } // use the same indent from the parent line int spaces = LineNumberHelper.leadingSpaces(lines, idx - 1); LOG.info("Spaces " + spaces); String[] editLines = modelXml.split("\n"); for (String line : editLines) { // use the same indent from the eip we are replacing line = LineNumberHelper.padString(line, spaces); // add the new line at the old starting position lines.add(idx, line); idx++; } // and save the file back String content = LineNumberHelper.linesToString(lines); file.setContents(content); return Results.success("Added: " + modelXml); }