Search in sources :

Example 1 with DataManager

use of io.syndesis.server.dao.manager.DataManager in project syndesis by syndesisio.

the class CredentialProviderRegistryTest method shouldFetchProvidersFromDataManager.

@Test
public void shouldFetchProvidersFromDataManager() {
    final DataManager dataManager = mock(DataManager.class);
    final CredentialProviderRegistry registry = new CredentialProviderRegistry(dataManager);
    final Connector connector = new Connector.Builder().id("test-provider").putProperty("clientId", new ConfigurationProperty.Builder().addTag(Credentials.CLIENT_ID_TAG).build()).putProperty("clientSecret", new ConfigurationProperty.Builder().addTag(Credentials.CLIENT_SECRET_TAG).build()).putConfiguredProperty("clientId", "a-client-id").putConfiguredProperty("clientSecret", "a-client-secret").build();
    when(dataManager.fetch(Connector.class, "test-provider")).thenReturn(connector);
    assertThat(registry.providerWithId("test-provider")).isInstanceOfSatisfying(TestCredentialProvider.class, p -> {
        assertThat(p.getProperties().getAppId()).isEqualTo("a-client-id");
        assertThat(p.getProperties().getAppSecret()).isEqualTo("a-client-secret");
    });
}
Also used : ConfigurationProperty(io.syndesis.common.model.connection.ConfigurationProperty) Connector(io.syndesis.common.model.connection.Connector) DataManager(io.syndesis.server.dao.manager.DataManager) Test(org.junit.Test)

Example 2 with DataManager

use of io.syndesis.server.dao.manager.DataManager in project syndesis by syndesisio.

the class IntegrationHandler method getIntegration.

// **************************
// Helpers
// **************************
public Integration getIntegration(String id) {
    final DataManager dataManager = getDataManager();
    final Integration integration = dataManager.fetch(Integration.class, id);
    if (integration == null) {
        throw new EntityNotFoundException();
    }
    return integration;
}
Also used : Integration(io.syndesis.common.model.integration.Integration) DataManager(io.syndesis.server.dao.manager.DataManager) EntityNotFoundException(javax.persistence.EntityNotFoundException)

Example 3 with DataManager

use of io.syndesis.server.dao.manager.DataManager in project syndesis by syndesisio.

the class IntegrationHandler method toCurrentIntegrationOverview.

public IntegrationOverview toCurrentIntegrationOverview(Integration integration) {
    final DataManager dataManager = getDataManager();
    final String id = integration.getId().get();
    final IntegrationOverview.Builder builder = new IntegrationOverview.Builder().createFrom(integration);
    // add board
    DataManagerSupport.fetchBoard(dataManager, IntegrationBulletinBoard.class, id).ifPresent(builder::board);
    // Defaults
    builder.isDraft(true);
    builder.currentState(IntegrationDeploymentState.Unpublished);
    builder.targetState(IntegrationDeploymentState.Unpublished);
    // Get the latest connection.
    builder.connections(integration.getConnections().stream().map(this::toCurrentConnection).collect(Collectors.toList()));
    // Get the latest steps.
    builder.steps(integration.getSteps().stream().map(this::toCurrentSteps).collect(Collectors.toList()));
    for (IntegrationDeployment deployment : dataManager.fetchAll(IntegrationDeployment.class, new IdPrefixFilter<>(id + ":"), ReverseFilter.getInstance())) {
        builder.addDeployment(IntegrationDeploymentOverview.of(deployment));
        if (deployment.getVersion() == integration.getVersion()) {
            builder.isDraft(deployment.getVersion() != integration.getVersion());
            builder.targetState(deployment.getTargetState());
            builder.currentState(deployment.getCurrentState());
            builder.deploymentVersion(deployment.getVersion());
        }
    }
    return builder.build();
}
Also used : IntegrationOverview(io.syndesis.common.model.integration.IntegrationOverview) IntegrationBulletinBoard(io.syndesis.common.model.bulletin.IntegrationBulletinBoard) IntegrationDeployment(io.syndesis.common.model.integration.IntegrationDeployment) DataManager(io.syndesis.server.dao.manager.DataManager)

Example 4 with DataManager

use of io.syndesis.server.dao.manager.DataManager in project syndesis by syndesisio.

the class ConnectionHandler method list.

@Override
public ListResult<ConnectionOverview> list(@Context UriInfo uriInfo) {
    final DataManager dataManager = getDataManager();
    final ListResult<Connection> connections = fetchAll(Connection.class, uriInfo);
    final List<ConnectionOverview> overviews = new ArrayList<>(connections.getTotalCount());
    for (Connection connection : connections.getItems()) {
        final String id = connection.getId().get();
        final ConnectionOverview.Builder builder = new ConnectionOverview.Builder().createFrom(connection);
        // set the connector
        DataManagerSupport.fetch(dataManager, Connector.class, connection.getConnectorId()).ifPresent(builder::connector);
        // set the board
        DataManagerSupport.fetchBoard(dataManager, ConnectionBulletinBoard.class, id).ifPresent(builder::board);
        overviews.add(builder.build());
    }
    return ListResult.of(overviews);
}
Also used : Connector(io.syndesis.common.model.connection.Connector) ConnectionOverview(io.syndesis.common.model.connection.ConnectionOverview) Connection(io.syndesis.common.model.connection.Connection) ArrayList(java.util.ArrayList) DataManager(io.syndesis.server.dao.manager.DataManager) ConnectionBulletinBoard(io.syndesis.common.model.bulletin.ConnectionBulletinBoard)

Example 5 with DataManager

use of io.syndesis.server.dao.manager.DataManager in project syndesis by syndesisio.

the class ConnectionHandler method get.

@Override
public ConnectionOverview get(final String id) {
    final DataManager dataManager = getDataManager();
    final Connection connection = dataManager.fetch(Connection.class, id);
    if (connection == null) {
        throw new EntityNotFoundException();
    }
    final ConnectionOverview.Builder builder = new ConnectionOverview.Builder().createFrom(connection);
    // set the connector
    DataManagerSupport.fetch(dataManager, Connector.class, connection.getConnectorId()).ifPresent(builder::connector);
    // set the board
    DataManagerSupport.fetchBoard(dataManager, ConnectionBulletinBoard.class, id).ifPresent(builder::board);
    return builder.build();
}
Also used : Connector(io.syndesis.common.model.connection.Connector) ConnectionOverview(io.syndesis.common.model.connection.ConnectionOverview) Connection(io.syndesis.common.model.connection.Connection) DataManager(io.syndesis.server.dao.manager.DataManager) EntityNotFoundException(javax.persistence.EntityNotFoundException) ConnectionBulletinBoard(io.syndesis.common.model.bulletin.ConnectionBulletinBoard)

Aggregations

DataManager (io.syndesis.server.dao.manager.DataManager)15 Connector (io.syndesis.common.model.connection.Connector)6 Connection (io.syndesis.common.model.connection.Connection)5 ConnectionBulletinBoard (io.syndesis.common.model.bulletin.ConnectionBulletinBoard)4 EncryptionComponent (io.syndesis.server.dao.manager.EncryptionComponent)4 ArrayList (java.util.ArrayList)4 LeveledMessage (io.syndesis.common.model.bulletin.LeveledMessage)3 Integration (io.syndesis.common.model.integration.Integration)3 EntityNotFoundException (javax.persistence.EntityNotFoundException)3 Before (org.junit.Before)3 Test (org.junit.Test)3 IntegrationBulletinBoard (io.syndesis.common.model.bulletin.IntegrationBulletinBoard)2 ConnectionOverview (io.syndesis.common.model.connection.ConnectionOverview)2 Extension (io.syndesis.common.model.extension.Extension)2 LRUCacheManager (io.syndesis.common.util.cache.LRUCacheManager)2 Validator (javax.validation.Validator)2 DefaultResourceLoader (org.springframework.core.io.DefaultResourceLoader)2 ResourceLoader (org.springframework.core.io.ResourceLoader)2 ChangeEvent (io.syndesis.common.model.ChangeEvent)1 Kind (io.syndesis.common.model.Kind)1