Search in sources :

Example 1 with DSOutOfServiceException

use of omero.gateway.exception.DSOutOfServiceException in project imagej-omero by imagej.

the class DefaultOMEROSession method setExperimenter.

/**
 * Attempts to connect to the gateway using the given credentials. If it can
 * successfully connect, then it sets experimenter.
 */
private void setExperimenter(OMEROCredentials credentials) throws ServerError {
    final LoginCredentials cred = new LoginCredentials();
    cred.getServer().setHostname(credentials.getServer());
    cred.getServer().setPort(credentials.getPort());
    cred.getUser().setUsername(credentials.getUser());
    cred.getUser().setPassword(credentials.getPassword());
    if (gateway == null)
        setGateway();
    try {
        experimenter = gateway.connect(cred);
    } catch (DSOutOfServiceException exc) {
        final ServerError err = new ServerError();
        err.initCause(exc);
        throw err;
    }
}
Also used : LoginCredentials(omero.gateway.LoginCredentials) ServerError(omero.ServerError) DSOutOfServiceException(omero.gateway.exception.DSOutOfServiceException)

Example 2 with DSOutOfServiceException

use of omero.gateway.exception.DSOutOfServiceException in project imagej-omero by imagej.

the class ModuleAdapter method createUser.

/**
 * Creates an ExperimenterData OMERO object which is connected to the gateway.
 */
private ExperimenterData createUser() {
    String host = client.getProperty("omero.host");
    if (host.equals("")) {
        String router = client.getProperty("omero.ClientCallback.Router");
        String[] comp = router.split("\\s+");
        for (int i = 0; i < comp.length; i++) {
            if (comp[i].equals("-h")) {
                host = comp[i + 1];
                break;
            }
        }
    }
    final LoginCredentials cred = new LoginCredentials(client.getSessionId(), null, host, Integer.parseInt(client.getProperty("omero.port")));
    try {
        return gateway.connect(cred);
    } catch (final DSOutOfServiceException err) {
        log.error(err.getMessage());
    }
    return null;
}
Also used : LoginCredentials(omero.gateway.LoginCredentials) DSOutOfServiceException(omero.gateway.exception.DSOutOfServiceException)

Example 3 with DSOutOfServiceException

use of omero.gateway.exception.DSOutOfServiceException in project imagej-omero by imagej.

the class OpenTableFromOMERO method run.

@Override
public void run() {
    final OMEROCredentials credentials = new OMEROCredentials();
    credentials.setServer(getServer());
    credentials.setPort(getPort());
    credentials.setUser(getUser());
    credentials.setPassword(getPassword());
    try {
        table = ((DefaultOMEROService) omeroService).downloadTable(credentials, tableID);
    } catch (ServerError exc) {
        log.error(exc);
        exc.printStackTrace();
        cancel("Error talking to OMERO: " + exc.getMessage());
    } catch (PermissionDeniedException exc) {
        log.error(exc);
        exc.printStackTrace();
        cancel("Error talking to OMERO: " + exc.getMessage());
    } catch (CannotCreateSessionException exc) {
        log.error(exc);
        exc.printStackTrace();
        cancel("Error talking to OMERO: " + exc.getMessage());
    } catch (DSOutOfServiceException exc) {
        log.error(exc);
        exc.printStackTrace();
        cancel("Error talking to OMERO: " + exc.getMessage());
    } catch (ExecutionException exc) {
        log.error(exc);
        exc.printStackTrace();
        cancel("Error talking to OMERO: " + exc.getMessage());
    } catch (DSAccessException exc) {
        log.error(exc);
        exc.printStackTrace();
        cancel("Error talking to OMERO: " + exc.getMessage());
    }
}
Also used : CannotCreateSessionException(Glacier2.CannotCreateSessionException) ServerError(omero.ServerError) DSOutOfServiceException(omero.gateway.exception.DSOutOfServiceException) PermissionDeniedException(Glacier2.PermissionDeniedException) ExecutionException(java.util.concurrent.ExecutionException) OMEROCredentials(net.imagej.omero.OMEROCredentials) DSAccessException(omero.gateway.exception.DSAccessException)

Example 4 with DSOutOfServiceException

use of omero.gateway.exception.DSOutOfServiceException in project imagej-omero by imagej.

the class SaveTableToOMERO method run.

@Override
public void run() {
    final OMEROCredentials credentials = new OMEROCredentials();
    credentials.setServer(getServer());
    credentials.setPort(getPort());
    credentials.setUser(getUser());
    credentials.setPassword(getPassword());
    final Table<?, ?> table = tableDisplay.get(0);
    try {
        ((DefaultOMEROService) omeroService).uploadTable(credentials, name, table, imageID);
    } catch (ServerError exc) {
        log.error(exc);
        cancel("Error talking to OMERO: " + exc.message);
    } catch (PermissionDeniedException exc) {
        log.error(exc);
        cancel("Error talking to OMERO: " + exc.getMessage());
    } catch (CannotCreateSessionException exc) {
        log.error(exc);
        cancel("Error talking to OMERO: " + exc.getMessage());
    } catch (ExecutionException exc) {
        log.error(exc);
        cancel("Error attaching table to OMERO image: " + exc.getMessage());
    } catch (DSOutOfServiceException exc) {
        log.error(exc);
        cancel("Error attaching table to OMERO image: " + exc.getMessage());
    } catch (DSAccessException exc) {
        log.error(exc);
        cancel("Error attaching table to OMERO image: " + exc.getMessage());
    }
}
Also used : CannotCreateSessionException(Glacier2.CannotCreateSessionException) DefaultOMEROService(net.imagej.omero.DefaultOMEROService) ServerError(omero.ServerError) DSOutOfServiceException(omero.gateway.exception.DSOutOfServiceException) PermissionDeniedException(Glacier2.PermissionDeniedException) ExecutionException(java.util.concurrent.ExecutionException) OMEROCredentials(net.imagej.omero.OMEROCredentials) DSAccessException(omero.gateway.exception.DSAccessException)

Aggregations

DSOutOfServiceException (omero.gateway.exception.DSOutOfServiceException)4 ServerError (omero.ServerError)3 CannotCreateSessionException (Glacier2.CannotCreateSessionException)2 PermissionDeniedException (Glacier2.PermissionDeniedException)2 ExecutionException (java.util.concurrent.ExecutionException)2 OMEROCredentials (net.imagej.omero.OMEROCredentials)2 LoginCredentials (omero.gateway.LoginCredentials)2 DSAccessException (omero.gateway.exception.DSAccessException)2 DefaultOMEROService (net.imagej.omero.DefaultOMEROService)1