public Optional<String> getConnectorId() { return value.getConnectorId(); }
private static Connector resolveConnector(Connection connection, DataManager dataManager) { final Connector connector; if (connection.getConnector().isPresent()) { connector = connection.getConnector().get(); } else { connector = dataManager.fetch(Connector.class, connection.getConnectorId().get()); if (connector == null) { throw new IllegalArgumentException("No connector with id: " + connection.getConnectorId().get()); } } return connector; } }
private static Connector resolveConnector(Connection connection, DataManager dataManager) { final Connector connector; if (connection.getConnector().isPresent()) { connector = connection.getConnector().get(); } else { connector = dataManager.fetch(Connector.class, connection.getConnectorId().get()); if (connector == null) { throw new IllegalArgumentException("No connector with id: " + connection.getConnectorId().get()); } } return connector; } }
private List<Connection> findAssociatedConnections(Connector connector) { return dataManager.fetchAll(Connection.class).getItems().stream() .filter(c -> connector.getId().equals(c.getConnectorId())) .collect(Collectors.toList()); }
@Override public Connection get(final String id) { Connection connection = Getter.super.get(id); if (connection.getConnectorId().isPresent()) { final Connector connector = getDataManager().fetch(Connector.class, connection.getConnectorId().get()); connection = new Connection.Builder().createFrom(connection).connector(connector).build(); } return connection; }
.filter(c -> Objects.nonNull(dataManager)) .filter(c -> !c.getConnector().isPresent()) .filter(c -> c.getConnectorId().isPresent()) .map(c -> c.getConnectorId().get()) .map(c -> dataManager.fetch(Connector.class, c)) .filter(Objects::nonNull)
public Connection toCurrentConnection(Connection c) { Connection connection = getDataManager().fetch(Connection.class, c.getId().get()); if (connection.getConnectorId().isPresent()) { final Connector connector = getDataManager().fetch(Connector.class, connection.getConnectorId().get()); connection = new Connection.Builder().createFrom(connection).connector(connector).build(); } return connection; }
@Override public Connection create(@Context SecurityContext sec, @ConvertGroup(from = Default.class, to = AllValidations.class) final Connection connection) { final Date rightNow = new Date(); // Lets make sure we store encrypt secrets. Map<String, String> configuredProperties =connection.getConfiguredProperties(); if( connection.getConnectorId().isPresent() ) { Map<String, ConfigurationProperty> connectorProperties = getConnectorProperties(connection.getConnectorId().get()); configuredProperties = encryptionComponent.encryptPropertyValues(configuredProperties, connectorProperties); } final Connection updatedConnection = new Connection.Builder() .createFrom(connection) .createdDate(rightNow) .lastUpdated(rightNow) .configuredProperties(configuredProperties) .userId(sec.getUserPrincipal().getName()) .build(); final Set<CredentialFlowState> flowStates = CredentialFlowState.Builder.restoreFrom(state::restoreFrom, request); final Connection connectionToCreate = flowStates.stream().map(s -> { final Cookie removal = new Cookie(s.persistenceKey(), ""); removal.setPath("/"); removal.setMaxAge(0); response.addCookie(removal); return credentials.apply(updatedConnection, s); }).findFirst().orElse(updatedConnection); return Creator.super.create(sec, connectionToCreate); }
private void addToExport(JsonDB export, Integration integration) { addModelToExport(export, integration); for (Step step : integration.getSteps()) { Optional<Connection> c = step.getConnection(); if (c.isPresent()) { Connection connection = c.get(); addModelToExport(export, connection); Connector connector = integrationHandler.getDataManager().fetch(Connector.class, connection.getConnectorId().get()); if (connector != null) { addModelToExport(export, connector); } } Optional<Extension> e = step.getExtension(); if (e.isPresent()) { Extension extension = e.get(); addModelToExport(export, extension); } } }
@Override public void update(final String id, @ConvertGroup(from = Default.class, to = AllValidations.class) final Connection connection) { // Lets make sure we store encrypt secrets. Map<String, String> configuredProperties = connection.getConfiguredProperties(); if( connection.getConnectorId().isPresent() ) { Map<String, ConfigurationProperty> connectorProperties = getConnectorProperties(connection.getConnectorId().get()); configuredProperties = encryptionComponent.encryptPropertyValues(configuredProperties, connectorProperties); } final Connection updatedConnection = new Connection.Builder() .createFrom(connection) .configuredProperties(configuredProperties) .lastUpdated(new Date()) .build(); Updater.super.update(id, updatedConnection); // TODO: do this async perhaps.. // We may need to trigger creating bulletins for some integrations. for (String integrationId : getDataManager().fetchIds(Integration.class)) { integrationHandler.updateBulletinBoard(integrationId); } }
if (connection.getConnectorId().isPresent() && !connection.getConnector().isPresent()) { Connector connector = dataManager.fetch(Connector.class, connection.getConnectorId().get()); ); } else { throw new IllegalArgumentException("Unable to fetch connector: " + connection.getConnectorId().get());