Search in sources :

Example 1 with Extension

use of io.syndesis.common.model.extension.Extension in project syndesis by syndesisio.

the class ProjectGeneratorTest method testGenerateProject.

// ***************************
// Tests
// ***************************
@Test
public void testGenerateProject() throws Exception {
    TestResourceManager resourceManager = new TestResourceManager();
    Integration integration = resourceManager.newIntegration(new Step.Builder().stepKind(StepKind.endpoint).connection(new Connection.Builder().id("timer-connection").connector(TestConstants.TIMER_CONNECTOR).build()).putConfiguredProperty("period", "5000").action(TestConstants.PERIODIC_TIMER_ACTION).build(), new Step.Builder().stepKind(StepKind.mapper).putConfiguredProperty("atlasmapping", "{}").build(), new Step.Builder().stepKind(StepKind.ruleFilter).putConfiguredProperty("predicate", "AND").putConfiguredProperty("rules", "[{ \"path\": \"in.header.counter\", \"op\": \">\", \"value\": \"10\" }]").build(), new Step.Builder().stepKind(StepKind.extension).extension(new Extension.Builder().id("my-extension-1").extensionId("my-extension-1").addDependency(Dependency.maven("org.slf4j:slf4j-api:1.7.11")).addDependency(Dependency.maven("org.slf4j:slf4j-simple:1.7.11")).addDependency(Dependency.maven("org.apache.camel:camel-spring-boot-starter:2.10.0")).build()).putConfiguredProperty("key-1", "val-1").putConfiguredProperty("key-2", "val-2").action(new StepAction.Builder().id("my-extension-1-action-1").descriptor(new StepDescriptor.Builder().kind(StepAction.Kind.ENDPOINT).entrypoint("direct:extension").build()).build()).build(), new Step.Builder().stepKind(StepKind.extension).extension(new Extension.Builder().id("my-extension-2").extensionId("my-extension-2").build()).putConfiguredProperty("key-1", "val-1").putConfiguredProperty("key-2", "val-2").action(new StepAction.Builder().id("my-extension-1-action-1").descriptor(new StepDescriptor.Builder().kind(StepAction.Kind.BEAN).entrypoint("com.example.MyExtension::action").build()).build()).build(), new Step.Builder().stepKind(StepKind.extension).extension(new Extension.Builder().id("my-extension-3").extensionId("my-extension-3").build()).putConfiguredProperty("key-1", "val-1").putConfiguredProperty("key-2", "val-2").action(new StepAction.Builder().id("my-extension-2-action-1").descriptor(new StepDescriptor.Builder().kind(StepAction.Kind.STEP).entrypoint("com.example.MyStep").build()).build()).build(), new Step.Builder().stepKind(StepKind.endpoint).connection(new Connection.Builder().id("http-connection").connector(TestConstants.HTTP_CONNECTOR).build()).putConfiguredProperty("httpUri", "http://localhost:8080/hello").putConfiguredProperty("username", "admin").putConfiguredProperty("password", "admin").putConfiguredProperty("token", "mytoken").action(TestConstants.HTTP_GET_ACTION).build());
    ProjectGeneratorConfiguration configuration = new ProjectGeneratorConfiguration();
    configuration.getTemplates().setOverridePath(this.basePath);
    configuration.getTemplates().getAdditionalResources().addAll(this.additionalResources);
    configuration.setSecretMaskingEnabled(true);
    Path runtimeDir = generate(integration, configuration, resourceManager);
    assertFileContents(configuration, runtimeDir.resolve("pom.xml"), "pom.xml");
    assertFileContentsJson(configuration, runtimeDir.resolve("src/main/resources/syndesis/integration/integration.json"), "integration.json");
    assertFileContents(configuration, runtimeDir.resolve("src/main/resources/application.properties"), "application.properties");
    assertFileContents(configuration, runtimeDir.resolve("src/main/resources/loader.properties"), "loader.properties");
    assertFileContents(configuration, runtimeDir.resolve(".s2i/bin/assemble"), "assemble");
    assertFileContents(configuration, runtimeDir.resolve("prometheus-config.yml"), "prometheus-config.yml");
    assertThat(runtimeDir.resolve("extensions/my-extension-1.jar")).exists();
    assertThat(runtimeDir.resolve("extensions/my-extension-2.jar")).exists();
    assertThat(runtimeDir.resolve("extensions/my-extension-3.jar")).exists();
    assertThat(runtimeDir.resolve("src/main/resources/mapping-step-2.json")).exists();
}
Also used : Extension(io.syndesis.common.model.extension.Extension) Path(java.nio.file.Path) Integration(io.syndesis.common.model.integration.Integration) Connection(io.syndesis.common.model.connection.Connection) Step(io.syndesis.common.model.integration.Step) Test(org.junit.Test)

Example 2 with Extension

use of io.syndesis.common.model.extension.Extension in project syndesis by syndesisio.

the class NoDuplicateExtensionValidator method isValid.

@Override
public boolean isValid(final Extension value, final ConstraintValidatorContext context) {
    if (value.getExtensionId() == null) {
        return true;
    }
    Set<String> ids = dataManager.fetchIdsByPropertyValue(Extension.class, "extensionId", value.getExtensionId());
    if (value.getId().isPresent()) {
        ids.remove(value.getId().get());
    }
    for (String id : ids) {
        Extension other = dataManager.fetch(Extension.class, id);
        boolean installed = other.getStatus().isPresent() && other.getStatus().get() == Extension.Status.Installed;
        if (installed) {
            return false;
        }
    }
    return true;
}
Also used : NoDuplicateExtension(io.syndesis.common.model.validation.extension.NoDuplicateExtension) Extension(io.syndesis.common.model.extension.Extension)

Example 3 with Extension

use of io.syndesis.common.model.extension.Extension in project syndesis by syndesisio.

the class ExtensionActivator method doDelete.

private void doDelete(Extension extension) {
    Date rightNow = new Date();
    dataManager.update(new Extension.Builder().createFrom(extension).status(Extension.Status.Deleted).lastUpdated(rightNow).build());
}
Also used : Extension(io.syndesis.common.model.extension.Extension) Date(java.util.Date)

Example 4 with Extension

use of io.syndesis.common.model.extension.Extension in project syndesis by syndesisio.

the class ExtensionHandler method install.

@POST
@Path(value = "/{id}/install")
@ApiResponses({ @ApiResponse(code = 200, message = "Installed"), @ApiResponse(code = 400, message = "Found violations in validation", responseContainer = "Set", response = Violation.class) })
public void install(@NotNull @PathParam("id") final String id) {
    Extension extension = getDataManager().fetch(Extension.class, id);
    doValidate(extension);
    extensionActivator.activateExtension(extension);
}
Also used : Extension(io.syndesis.common.model.extension.Extension) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) ApiResponses(io.swagger.annotations.ApiResponses)

Example 5 with Extension

use of io.syndesis.common.model.extension.Extension in project syndesis by syndesisio.

the class ExtensionsITCase method extensionData.

// ===========================================================
private byte[] extensionData(int prg) throws IOException {
    try (ByteArrayOutputStream data = new ByteArrayOutputStream();
        JarOutputStream jar = new JarOutputStream(data)) {
        JarEntry definition = new JarEntry("META-INF/syndesis/syndesis-extension-definition.json");
        jar.putNextEntry(definition);
        Extension extension = new Extension.Builder().schemaVersion(ExtensionConverter.getCurrentSchemaVersion()).extensionId("com.company:extension" + prg).name("Extension " + prg).description("Extension Description " + prg).version("1.0").extensionType(Extension.Type.Steps).build();
        JsonNode extensionTree = ExtensionConverter.getDefault().toPublicExtension(extension);
        byte[] content = Json.writer().writeValueAsBytes(extensionTree);
        IOUtils.write(content, jar);
        jar.closeEntry();
        jar.flush();
        return data.toByteArray();
    }
}
Also used : Extension(io.syndesis.common.model.extension.Extension) JarOutputStream(java.util.jar.JarOutputStream) JsonNode(com.fasterxml.jackson.databind.JsonNode) ByteArrayOutputStream(java.io.ByteArrayOutputStream) JarEntry(java.util.jar.JarEntry)

Aggregations

Extension (io.syndesis.common.model.extension.Extension)19 JsonNode (com.fasterxml.jackson.databind.JsonNode)5 Test (org.junit.Test)5 Connection (io.syndesis.common.model.connection.Connection)4 Step (io.syndesis.common.model.integration.Step)4 ProcessingReport (com.github.fge.jsonschema.core.report.ProcessingReport)3 JsonSchema (com.github.fge.jsonschema.main.JsonSchema)3 Connector (io.syndesis.common.model.connection.Connector)3 Integration (io.syndesis.common.model.integration.Integration)3 Date (java.util.Date)3 Action (io.syndesis.common.model.action.Action)2 ConnectorAction (io.syndesis.common.model.action.ConnectorAction)2 StepAction (io.syndesis.common.model.action.StepAction)2 DataManager (io.syndesis.server.dao.manager.DataManager)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 POST (javax.ws.rs.POST)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 ApiResponses (io.swagger.annotations.ApiResponses)1