Search in sources :

Example 1 with ConnectionsFactoryTracker

use of org.jboss.tools.openshift.common.core.connection.ConnectionsFactoryTracker in project jbosstools-openshift by jbosstools.

the class CDKOpenshiftUtility method createOpenshiftConnection.

public IConnection createOpenshiftConnection(ServiceManagerEnvironment env, ConnectionsRegistry registry) {
    // Create the connection
    String soughtHost = env.openshiftHost + ":" + env.openshiftPort;
    ConnectionsFactoryTracker connectionsFactory = new ConnectionsFactoryTracker();
    connectionsFactory.open();
    IConnectionFactory factory = connectionsFactory.getById(IConnectionsFactory.CONNECTIONFACTORY_OPENSHIFT_ID);
    IConnection con = factory.create(soughtHost);
    // Set some defaults
    String authScheme = env.getAuthorizationScheme();
    String username = env.getUsername();
    String password = env.getPassword();
    if (authScheme != null && !authScheme.isEmpty()) {
        authScheme = new String("" + authScheme.charAt(0)).toUpperCase() + authScheme.substring(1);
    }
    ((Connection) con).setAuthScheme(authScheme);
    ((Connection) con).setUsername(username);
    if (password != null) {
        ((Connection) con).setPassword(password);
    }
    ((Connection) con).setRememberPassword(true);
    String ocLoc = env.get(ServiceManagerEnvironmentLoader.OC_LOCATION_KEY);
    if (ocLoc != null) {
        ((Connection) con).setExtendedProperty(ICommonAttributes.OC_LOCATION_KEY, ocLoc);
        ((Connection) con).setExtendedProperty(ICommonAttributes.OC_OVERRIDE_KEY, true);
    }
    updateOpenshiftConnection(env, con, false);
    if (registry != null)
        registry.add(con);
    return con;
}
Also used : Connection(org.jboss.tools.openshift.core.connection.Connection) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) IConnectionFactory(org.jboss.tools.openshift.common.core.connection.IConnectionFactory) ConnectionsFactoryTracker(org.jboss.tools.openshift.common.core.connection.ConnectionsFactoryTracker)

Example 2 with ConnectionsFactoryTracker

use of org.jboss.tools.openshift.common.core.connection.ConnectionsFactoryTracker in project jbosstools-openshift by jbosstools.

the class ConnectionWizardPageModel method createConnectionsFactory.

protected ConnectionsFactoryTracker createConnectionsFactory() {
    ConnectionsFactoryTracker connectionsFactory = new ConnectionsFactoryTracker();
    connectionsFactory.open();
    return connectionsFactory;
}
Also used : ConnectionsFactoryTracker(org.jboss.tools.openshift.common.core.connection.ConnectionsFactoryTracker)

Aggregations

ConnectionsFactoryTracker (org.jboss.tools.openshift.common.core.connection.ConnectionsFactoryTracker)2 IConnection (org.jboss.tools.openshift.common.core.connection.IConnection)1 IConnectionFactory (org.jboss.tools.openshift.common.core.connection.IConnectionFactory)1 Connection (org.jboss.tools.openshift.core.connection.Connection)1