use of io.cdap.cdap.etl.proto.connection.PreconfiguredConnectionCreationRequest in project cdap by caskdata.
the class StudioService method createPreconfiguredConnections.
private void createPreconfiguredConnections(SystemServiceContext context) throws IOException {
ConnectionStore connectionStore = new ConnectionStore(context);
for (PreconfiguredConnectionCreationRequest creationRequest : connectionConfig.getConnections()) {
if (creationRequest.getName() == null || creationRequest.getNamespace() == null) {
continue;
}
NamespaceSummary namespaceSummary = context.getAdmin().getNamespaceSummary(creationRequest.getNamespace());
if (namespaceSummary == null) {
LOG.warn("Namespace {} does not exist, skipping creating connection {}", creationRequest.getNamespace(), creationRequest.getName());
}
ConnectionId connectionId = new ConnectionId(namespaceSummary, creationRequest.getName());
long now = System.currentTimeMillis();
Connection connectionInfo = new Connection(creationRequest.getName(), connectionId.getConnectionId(), creationRequest.getPlugin().getName(), creationRequest.getDescription(), true, creationRequest.getName().equals(connectionConfig.getDefaultConnection()) ? true : false, now, now, creationRequest.getPlugin());
try {
connectionStore.saveConnection(connectionId, connectionInfo, false);
} catch (ConnectionConflictException e) {
// expected if the connection is already created
}
}
}
Aggregations