Search in sources :

Example 1 with OMEROCredentials

use of net.imagej.omero.OMEROCredentials 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 2 with OMEROCredentials

use of net.imagej.omero.OMEROCredentials 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)

Example 3 with OMEROCredentials

use of net.imagej.omero.OMEROCredentials in project imagej-omero by imagej.

the class OmeroIT method testUploadTable.

@Test
public void testUploadTable() throws ServerError, PermissionDeniedException, CannotCreateSessionException, ExecutionException, DSOutOfServiceException, DSAccessException {
    final byte[][] d = new byte[][] { { 127, 0, -128 }, { -1, -6, -23 }, { 100, 87, 4 } };
    final ByteTable table = new DefaultByteTable(3, 3);
    for (int c = 0; c < table.getColumnCount(); c++) {
        table.setColumnHeader(c, "Heading " + (c + 1));
        for (int r = 0; r < table.getRowCount(); r++) table.set(c, r, d[c][r]);
    }
    final long tableId = omero.uploadTable(cred, "test-table-upload", table, 1);
    // When upload table was called it created a session, which cleared out
    // the username and password from the credentials. The credentials must
    // have a username and password to create security contexts.
    final OMEROCredentials tc = new OMEROCredentials();
    tc.setServer(OMERO_SERVER);
    tc.setPort(OMERO_PORT);
    tc.setUser(OMERO_USER);
    tc.setPassword(OMERO_PASSWORD);
    try (final OMEROSession session = new DefaultOMEROSession(tc)) {
        final TablesFacility tablesFacility = session.getGateway().getFacility(TablesFacility.class);
        final TableData td = tablesFacility.getTableInfo(session.getSecurityContext(), tableId);
        assertEquals(td.getColumns().length, 3);
        assertEquals(td.getColumns()[0].getName(), "Heading 1");
        assertEquals(td.getColumns()[1].getName(), "Heading 2");
        assertEquals(td.getColumns()[2].getName(), "Heading 3");
        assertEquals(td.getNumberOfRows(), 3);
    }
}
Also used : TablesFacility(omero.gateway.facility.TablesFacility) DefaultByteTable(net.imagej.table.DefaultByteTable) DefaultOMEROSession(net.imagej.omero.DefaultOMEROSession) ByteTable(net.imagej.table.ByteTable) DefaultByteTable(net.imagej.table.DefaultByteTable) OMEROSession(net.imagej.omero.OMEROSession) DefaultOMEROSession(net.imagej.omero.DefaultOMEROSession) TableData(omero.gateway.model.TableData) OMEROCredentials(net.imagej.omero.OMEROCredentials) Test(org.junit.Test)

Example 4 with OMEROCredentials

use of net.imagej.omero.OMEROCredentials in project imagej-omero by imagej.

the class OmeroIT method setup.

@Before
public void setup() {
    client = new omero.client(OMERO_SERVER, OMERO_PORT);
    cred = new OMEROCredentials();
    cred.setServer(OMERO_SERVER);
    cred.setPort(OMERO_PORT);
    cred.setUser(OMERO_USER);
    cred.setPassword(OMERO_PASSWORD);
    context = new Context();
    omero = context.getService(OMEROService.class);
}
Also used : Context(org.scijava.Context) OMEROService(net.imagej.omero.OMEROService) OMEROCredentials(net.imagej.omero.OMEROCredentials) Before(org.junit.Before)

Example 5 with OMEROCredentials

use of net.imagej.omero.OMEROCredentials in project imagej-omero by imagej.

the class OmeroIT method testDownloadThenUploadTable.

@Test
public void testDownloadThenUploadTable() throws ServerError, PermissionDeniedException, CannotCreateSessionException, ExecutionException, DSOutOfServiceException, DSAccessException {
    final long originalId = 83;
    final Table<?, ?> ijTable = omero.downloadTable(cred, originalId);
    // When download table was called it created a session, which cleared out
    // the username and password from the credentials. The credentials must
    // have a username and password to create security contexts.
    final OMEROCredentials tc = new OMEROCredentials();
    tc.setServer(OMERO_SERVER);
    tc.setPort(OMERO_PORT);
    tc.setUser(OMERO_USER);
    tc.setPassword(OMERO_PASSWORD);
    final long newId = omero.uploadTable(tc, "table-version2", ijTable, 1);
    assertTrue(originalId != newId);
}
Also used : OMEROCredentials(net.imagej.omero.OMEROCredentials) Test(org.junit.Test)

Aggregations

OMEROCredentials (net.imagej.omero.OMEROCredentials)5 CannotCreateSessionException (Glacier2.CannotCreateSessionException)2 PermissionDeniedException (Glacier2.PermissionDeniedException)2 ExecutionException (java.util.concurrent.ExecutionException)2 ServerError (omero.ServerError)2 DSAccessException (omero.gateway.exception.DSAccessException)2 DSOutOfServiceException (omero.gateway.exception.DSOutOfServiceException)2 Test (org.junit.Test)2 DefaultOMEROService (net.imagej.omero.DefaultOMEROService)1 DefaultOMEROSession (net.imagej.omero.DefaultOMEROSession)1 OMEROService (net.imagej.omero.OMEROService)1 OMEROSession (net.imagej.omero.OMEROSession)1 ByteTable (net.imagej.table.ByteTable)1 DefaultByteTable (net.imagej.table.DefaultByteTable)1 TablesFacility (omero.gateway.facility.TablesFacility)1 TableData (omero.gateway.model.TableData)1 Before (org.junit.Before)1 Context (org.scijava.Context)1