use of io.cdap.cdap.datapipeline.connection.ConnectionStore in project cdap by caskdata.
the class ConnectionHandler method initialize.
@Override
public void initialize(SystemHttpServiceContext context) throws Exception {
super.initialize(context);
contextAccessEnforcer = context.getContextAccessEnforcer();
store = new ConnectionStore(context);
String disabledTypesStr = context.getSpecification().getProperty(DISABLED_TYPES);
this.disabledTypes = GSON.fromJson(disabledTypesStr, SET_STRING_TYPE);
}
use of io.cdap.cdap.datapipeline.connection.ConnectionStore 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