Search in sources :

Example 1 with ConnectionException

use of cbit.vcell.server.ConnectionException in project vcell by virtualcell.

the class ClientServerManager method connectToServer.

/**
 * Insert the method's description here.
 * Creation date: (5/12/2004 4:48:13 PM)
 */
private VCellConnection connectToServer(InteractiveContext requester) {
    VCellThreadChecker.checkRemoteInvocation();
    VCellConnection newVCellConnection = null;
    VCellConnectionFactory vcConnFactory = null;
    String badConnStr = "";
    try {
        switch(getClientServerInfo().getServerType()) {
            case SERVER_REMOTE:
                {
                    String apihost = getClientServerInfo().getApihost();
                    Integer apiport = getClientServerInfo().getApiport();
                    try {
                        badConnStr += apihost + ":" + apiport;
                        vcConnFactory = new RemoteProxyVCellConnectionFactory(apihost, apiport, getClientServerInfo().getUserLoginInfo());
                        setConnectionStatus(new ClientConnectionStatus(getClientServerInfo().getUsername(), apihost, apiport, ConnectionStatus.INITIALIZING));
                        newVCellConnection = vcConnFactory.createVCellConnection();
                    } catch (AuthenticationException ex) {
                        throw ex;
                    }
                    break;
                }
            case SERVER_LOCAL:
                {
                    new PropertyLoader();
                    LocalVCellConnectionService localVCellConnectionService = VCellServiceHelper.getInstance().loadService(LocalVCellConnectionService.class);
                    vcConnFactory = localVCellConnectionService.getLocalVCellConnectionFactory(getClientServerInfo().getUserLoginInfo());
                    setConnectionStatus(new ClientConnectionStatus(getClientServerInfo().getUsername(), null, null, ConnectionStatus.INITIALIZING));
                    newVCellConnection = vcConnFactory.createVCellConnection();
                    break;
                }
        }
        requester.clearConnectWarning();
        reconnectStat = ReconnectStatus.NOT;
    } catch (AuthenticationException aexc) {
        aexc.printStackTrace(System.out);
        requester.showErrorDialog(aexc.getMessage());
    } catch (ConnectionException cexc) {
        String msg = badConnectMessage(badConnStr) + "\n" + cexc.getMessage();
        cexc.printStackTrace(System.out);
        ErrorUtils.sendRemoteLogMessage(getClientServerInfo().getUserLoginInfo(), msg);
        if (reconnectStat != ReconnectStatus.SUBSEQUENT) {
            requester.showConnectWarning(msg);
        }
    } catch (Exception exc) {
        exc.printStackTrace(System.out);
        String msg = badConnectMessage(badConnStr) + "\nException:\n" + exc.getMessage();
        ErrorUtils.sendRemoteLogMessage(getClientServerInfo().getUserLoginInfo(), msg);
        requester.showErrorDialog(msg);
    }
    return newVCellConnection;
}
Also used : VCellConnection(cbit.vcell.server.VCellConnection) RemoteProxyVCellConnectionFactory(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory) AuthenticationException(org.vcell.util.AuthenticationException) LocalVCellConnectionService(cbit.vcell.server.LocalVCellConnectionService) PropertyLoader(cbit.vcell.resource.PropertyLoader) VCellConnectionFactory(cbit.vcell.server.VCellConnectionFactory) RemoteProxyVCellConnectionFactory(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory) ConnectionException(cbit.vcell.server.ConnectionException) ConnectionException(cbit.vcell.server.ConnectionException) AuthenticationException(org.vcell.util.AuthenticationException) RemoteProxyException(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException)

Example 2 with ConnectionException

use of cbit.vcell.server.ConnectionException in project vcell by virtualcell.

the class ClientServerManager method connectToServer.

/**
 * Insert the method's description here.
 * Creation date: (5/12/2004 4:48:13 PM)
 */
private VCellConnection connectToServer(InteractiveContext requester, boolean bShowErrors) {
    BeanUtils.updateDynamicClientProperties();
    VCellThreadChecker.checkRemoteInvocation();
    VCellConnection newVCellConnection = null;
    VCellConnectionFactory vcConnFactory = null;
    String badConnStr = "";
    try {
        try {
            switch(getClientServerInfo().getServerType()) {
                case SERVER_REMOTE:
                    {
                        String apihost = getClientServerInfo().getApihost();
                        Integer apiport = getClientServerInfo().getApiport();
                        try {
                            badConnStr += apihost + ":" + apiport;
                            vcConnFactory = new RemoteProxyVCellConnectionFactory(apihost, apiport, getClientServerInfo().getUserLoginInfo());
                            setConnectionStatus(new ClientConnectionStatus(getClientServerInfo().getUsername(), apihost, apiport, ConnectionStatus.INITIALIZING));
                            newVCellConnection = vcConnFactory.createVCellConnection();
                        } catch (AuthenticationException ex) {
                            throw ex;
                        }
                        break;
                    }
                case SERVER_LOCAL:
                    {
                        new PropertyLoader();
                        LocalVCellConnectionService localVCellConnectionService = VCellServiceHelper.getInstance().loadService(LocalVCellConnectionService.class);
                        vcConnFactory = localVCellConnectionService.getLocalVCellConnectionFactory(getClientServerInfo().getUserLoginInfo());
                        setConnectionStatus(new ClientConnectionStatus(getClientServerInfo().getUsername(), null, null, ConnectionStatus.INITIALIZING));
                        newVCellConnection = vcConnFactory.createVCellConnection();
                        break;
                    }
            }
            requester.clearConnectWarning();
            reconnectStat = ReconnectStatus.NOT;
        } catch (Exception e) {
            e.printStackTrace();
            if (bShowErrors) {
                throw e;
            }
        }
    } catch (AuthenticationException aexc) {
        aexc.printStackTrace(System.out);
        requester.showErrorDialog(aexc.getMessage());
    } catch (ConnectionException cexc) {
        String msg = badConnectMessage(badConnStr) + "\n" + cexc.getMessage();
        cexc.printStackTrace(System.out);
        ErrorUtils.sendRemoteLogMessage(getClientServerInfo().getUserLoginInfo(), msg);
        if (reconnectStat != ReconnectStatus.SUBSEQUENT) {
            requester.showConnectWarning(msg);
        }
    } catch (HttpResponseException httpexc) {
        httpexc.printStackTrace(System.out);
        if (httpexc.getStatusCode() == HttpStatus.SC_UNAUTHORIZED) {
            requester.showErrorDialog("Invalid Userid or Password\n\n" + httpexc.getMessage());
        } else {
            String msg = "Exception: " + httpexc.getMessage() + "\n\n" + badConnectMessage(badConnStr);
            ErrorUtils.sendRemoteLogMessage(getClientServerInfo().getUserLoginInfo(), msg);
            requester.showErrorDialog(msg);
        }
    } catch (Exception exc) {
        exc.printStackTrace(System.out);
        String msg = "Exception: " + exc.getMessage() + "\n\n" + badConnectMessage(badConnStr);
        ErrorUtils.sendRemoteLogMessage(getClientServerInfo().getUserLoginInfo(), msg);
        requester.showErrorDialog(msg);
    }
    return newVCellConnection;
}
Also used : VCellConnection(cbit.vcell.server.VCellConnection) RemoteProxyVCellConnectionFactory(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory) AuthenticationException(org.vcell.util.AuthenticationException) LocalVCellConnectionService(cbit.vcell.server.LocalVCellConnectionService) HttpResponseException(org.apache.http.client.HttpResponseException) PropertyLoader(cbit.vcell.resource.PropertyLoader) VCellConnectionFactory(cbit.vcell.server.VCellConnectionFactory) RemoteProxyVCellConnectionFactory(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory) ConnectionException(cbit.vcell.server.ConnectionException) HttpHostConnectException(org.apache.http.conn.HttpHostConnectException) AuthenticationException(org.vcell.util.AuthenticationException) RemoteProxyException(cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException) HttpResponseException(org.apache.http.client.HttpResponseException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) ConnectionException(cbit.vcell.server.ConnectionException)

Example 3 with ConnectionException

use of cbit.vcell.server.ConnectionException in project vcell by virtualcell.

the class LocalVCellConnectionFactory method createVCellConnection.

/**
 * This method was created in VisualAge.
 * @return cbit.vcell.server.VCellConnection
 */
public VCellConnection createVCellConnection() throws AuthenticationException, ConnectionException {
    try {
        if (connectionFactory == null) {
            connectionFactory = DatabaseService.getInstance().createConnectionFactory();
        }
        KeyFactory keyFactory = connectionFactory.getKeyFactory();
        LocalVCellConnection.setDatabaseResources(connectionFactory, keyFactory);
        AdminDBTopLevel adminDbTopLevel = new AdminDBTopLevel(connectionFactory);
        boolean bEnableRetry = false;
        boolean isLocal = true;
        User user = adminDbTopLevel.getUser(userLoginInfo.getUserName(), userLoginInfo.getDigestedPassword(), bEnableRetry, isLocal);
        if (user != null) {
            userLoginInfo.setUser(user);
        } else {
            throw new AuthenticationException("failed to authenticate as user " + userLoginInfo.getUserName());
        }
        DatabaseServerImpl databaseServerImpl = new DatabaseServerImpl(connectionFactory, keyFactory);
        boolean bCache = false;
        Cachetable cacheTable = null;
        DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(cacheTable, new File(PropertyLoader.getRequiredProperty(PropertyLoader.primarySimDataDirInternalProperty)), new File(PropertyLoader.getRequiredProperty(PropertyLoader.secondarySimDataDirInternalProperty)));
        SimulationDatabaseDirect simulationDatabase = new SimulationDatabaseDirect(adminDbTopLevel, databaseServerImpl, bCache);
        ExportServiceImpl exportServiceImpl = new ExportServiceImpl();
        LocalVCellConnection vcConn = new LocalVCellConnection(userLoginInfo, simulationDatabase, dataSetControllerImpl, exportServiceImpl);
        linkHDFLib();
        return vcConn;
    } catch (Throwable exc) {
        lg.error(exc.getMessage(), exc);
        throw new ConnectionException(exc.getMessage());
    }
}
Also used : Cachetable(cbit.vcell.simdata.Cachetable) AdminDBTopLevel(cbit.vcell.modeldb.AdminDBTopLevel) User(org.vcell.util.document.User) AuthenticationException(org.vcell.util.AuthenticationException) SimulationDatabaseDirect(cbit.vcell.message.server.dispatcher.SimulationDatabaseDirect) DatabaseServerImpl(cbit.vcell.modeldb.DatabaseServerImpl) DataSetControllerImpl(cbit.vcell.simdata.DataSetControllerImpl) ExportServiceImpl(cbit.vcell.export.server.ExportServiceImpl) File(java.io.File) KeyFactory(org.vcell.db.KeyFactory) ConnectionException(cbit.vcell.server.ConnectionException)

Aggregations

ConnectionException (cbit.vcell.server.ConnectionException)3 AuthenticationException (org.vcell.util.AuthenticationException)3 RemoteProxyVCellConnectionFactory (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory)2 RemoteProxyException (cbit.vcell.message.server.bootstrap.client.RemoteProxyVCellConnectionFactory.RemoteProxyException)2 PropertyLoader (cbit.vcell.resource.PropertyLoader)2 LocalVCellConnectionService (cbit.vcell.server.LocalVCellConnectionService)2 VCellConnection (cbit.vcell.server.VCellConnection)2 VCellConnectionFactory (cbit.vcell.server.VCellConnectionFactory)2 IOException (java.io.IOException)2 DataAccessException (org.vcell.util.DataAccessException)2 ExportServiceImpl (cbit.vcell.export.server.ExportServiceImpl)1 SimulationDatabaseDirect (cbit.vcell.message.server.dispatcher.SimulationDatabaseDirect)1 AdminDBTopLevel (cbit.vcell.modeldb.AdminDBTopLevel)1 DatabaseServerImpl (cbit.vcell.modeldb.DatabaseServerImpl)1 Cachetable (cbit.vcell.simdata.Cachetable)1 DataSetControllerImpl (cbit.vcell.simdata.DataSetControllerImpl)1 File (java.io.File)1 HttpResponseException (org.apache.http.client.HttpResponseException)1 HttpHostConnectException (org.apache.http.conn.HttpHostConnectException)1 KeyFactory (org.vcell.db.KeyFactory)1