Search in sources :

Example 6 with IConnection

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

the class CDKOpenshiftUtility method findExistingOpenshiftConnections.

/**
 * Return all existing openshift connections that match this server
 *
 * @param server
 * @param adb
 * @return
 */
public IConnection[] findExistingOpenshiftConnections(IServer server, ServiceManagerEnvironment adb) {
    Collection<IConnection> connections = ConnectionsRegistrySingleton.getInstance().getAll();
    ArrayList<IConnection> ret = new ArrayList<IConnection>();
    for (IConnection c : connections) {
        if (serverMatchesConnection(server, c, adb)) {
            ret.add(c);
        }
    }
    return (IConnection[]) ret.toArray(new IConnection[ret.size()]);
}
Also used : ArrayList(java.util.ArrayList) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection)

Example 7 with IConnection

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

the class OpenShiftCommonUIActivator method start.

@Override
public void start(BundleContext context) throws Exception {
    super.start(context);
    plugin = this;
    connectionsRegistryListener = new ConnectionsRegistryAdapter() {

        @Override
        public void connectionAdded(IConnection connection) {
            try {
                OpenShiftUIUtils.showOpenShiftExplorer();
            } catch (Exception e) {
            // Can happen during workbench startup, while the core
            // plugins are starting.
            // Since mutiple connections would cause multiple errors,
            // it's probably better to swallow the exception, else a
            // user would see multiple
            // errors in the log, every time the workbench starts.
            }
        }
    };
    ConnectionsRegistrySingleton.getInstance().addListener(connectionsRegistryListener);
}
Also used : IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) ConnectionsRegistryAdapter(org.jboss.tools.openshift.common.core.connection.ConnectionsRegistryAdapter)

Example 8 with IConnection

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

the class CDKOpenshiftUtilityTest method testOpenshiftConnectionAdded.

@Test
public void testOpenshiftConnectionAdded() throws Exception {
    CDKOpenshiftUtility util = new CDKOpenshiftUtility();
    IServer s = mockServer("openshift33");
    createCDKFile("Basic", null, null);
    ServiceManagerEnvironment adb = createLoader(s);
    ConnectionsRegistry registry = (ConnectionsRegistry) mock(ConnectionsRegistry.class);
    IConnection con = util.createOpenshiftConnection(adb, registry);
    assertNotNull(con);
    verify(registry).add(con);
}
Also used : IServer(org.eclipse.wst.server.core.IServer) ConnectionsRegistry(org.jboss.tools.openshift.common.core.connection.ConnectionsRegistry) CDKOpenshiftUtility(org.jboss.tools.openshift.cdk.server.core.internal.listeners.CDKOpenshiftUtility) ServiceManagerEnvironment(org.jboss.tools.openshift.cdk.server.core.internal.listeners.ServiceManagerEnvironment) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) Test(org.junit.Test)

Example 9 with IConnection

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

the class CDKRegistryTest method testRegistryURL.

@Test
public void testRegistryURL() throws Exception {
    ConfigureDependentFrameworksListener configureListener = (ConfigureDependentFrameworksListener) CDKCoreActivator.getDefault().getConfigureDependentFrameworksListener();
    configureListener.disable();
    CredentialService.getCredentialModel().addDomain("redhat.com", "redhat.com", true);
    CredentialService.getCredentialModel().addCredentials(CredentialService.getCredentialModel().getDomain("redhat.com"), "user", "password");
    CDKOpenshiftUtility util = new CDKOpenshiftUtility();
    createCDKFile("Basic", null, null);
    IServer cdkServer = createServer("openshift33");
    ServiceManagerEnvironment adb = createLoader(cdkServer);
    IConnection con = util.createOpenshiftConnection(adb, ConnectionsRegistrySingleton.getInstance());
    assertNotNull(con);
    // Can't test the registry provider model bc it hides the internal details
    CDKRegistryProvider prov = new CDKRegistryProvider() {

        protected ServiceManagerEnvironment getServiceManagerEnvironment(IServer server) {
            try {
                return createLoader(server);
            } catch (Exception e) {
                fail(e.getMessage());
            }
            return null;
        }
    };
    IStatus reg = prov.getRegistryURL(con);
    assertNotNull(reg);
    assertFalse(reg.isOK());
    ControllableServerBehavior beh = (ControllableServerBehavior) cdkServer.loadAdapter(ControllableServerBehavior.class, new NullProgressMonitor());
    beh.setServerStarted();
    reg = prov.getRegistryURL(con);
    assertNotNull(reg);
    assertTrue(reg.isOK());
    configureListener.enable();
    beh.setServerStopped();
}
Also used : CDKRegistryProvider(org.jboss.tools.openshift.cdk.server.core.internal.registry.CDKRegistryProvider) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServer(org.eclipse.wst.server.core.IServer) IStatus(org.eclipse.core.runtime.IStatus) CDKOpenshiftUtility(org.jboss.tools.openshift.cdk.server.core.internal.listeners.CDKOpenshiftUtility) ServiceManagerEnvironment(org.jboss.tools.openshift.cdk.server.core.internal.listeners.ServiceManagerEnvironment) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) ControllableServerBehavior(org.jboss.ide.eclipse.as.wtp.core.server.behavior.ControllableServerBehavior) ConfigureDependentFrameworksListener(org.jboss.tools.openshift.cdk.server.core.internal.listeners.ConfigureDependentFrameworksListener) URISyntaxException(java.net.URISyntaxException) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) Test(org.junit.Test)

Example 10 with IConnection

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

the class Connection method clone.

@Override
public IConnection clone() {
    IClient clone = client.clone();
    Connection connection = new Connection(clone, credentialsPrompter);
    connection.passwordLoaded = this.passwordLoaded;
    connection.tokenLoaded = this.tokenLoaded;
    connection.rememberPassword = this.rememberPassword;
    connection.rememberToken = this.rememberToken;
    connection.promptCredentialsEnabled = promptCredentialsEnabled;
    return connection;
}
Also used : IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) IClient(com.openshift.restclient.IClient)

Aggregations

IConnection (org.jboss.tools.openshift.common.core.connection.IConnection)40 Test (org.junit.Test)13 Connection (org.jboss.tools.openshift.core.connection.Connection)9 IStatus (org.eclipse.core.runtime.IStatus)5 IServer (org.eclipse.wst.server.core.IServer)5 CDKOpenshiftUtility (org.jboss.tools.openshift.cdk.server.core.internal.listeners.CDKOpenshiftUtility)5 ServiceManagerEnvironment (org.jboss.tools.openshift.cdk.server.core.internal.listeners.ServiceManagerEnvironment)5 ArrayList (java.util.ArrayList)3 MultiValidator (org.eclipse.core.databinding.validation.MultiValidator)3 Label (org.eclipse.swt.widgets.Label)3 IRoute (com.openshift.restclient.model.route.IRoute)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)2 ISelection (org.eclipse.jface.viewers.ISelection)2 ConnectionsRegistry (org.jboss.tools.openshift.common.core.connection.ConnectionsRegistry)2 NewConnectionMarker (org.jboss.tools.openshift.common.core.connection.NewConnectionMarker)2 IClient (com.openshift.restclient.IClient)1 ResourceKind (com.openshift.restclient.ResourceKind)1 IAuthorizationContext (com.openshift.restclient.authorization.IAuthorizationContext)1