This is a straight-refactor from `omero.gateway`, so this is the functionality that was there. Needs some discussion on what we're doing with exception handling, but is a bit beyond this PR.