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());
}
}
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());
}
}
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);
}
}
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);
}
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);
}
Aggregations