Exemplo n.º 1
0
  protected AMD_submit submitRequest(
      final ServiceFactoryI sf, final omero.cmd.Request req, final Ice.Current current)
      throws ServerError, InternalException {

    final AMD_submit submit = new AMD_submit();
    sf.submit_async(submit, req, current);
    if (submit.ex != null) {
      IceMapper mapper = new IceMapper();
      throw mapper.handleServerError(submit.ex, context);
    } else if (submit.ret == null) {
      throw new omero.InternalException(null, null, "No handle proxy found for: " + req);
    }
    return submit;
  }
Exemplo n.º 2
0
  /**
   * Create, initialize, and register an {@link RepoRawFileStoreI} with the proper setting (read or
   * write).
   *
   * @param checked The file that will be read. Can't be null, and must have ID set.
   * @param mode The mode for writing. If null, read-only.
   * @param __current The current user's session information.
   * @return A proxy ready to be returned to the user.
   * @throws ServerError
   * @throws InternalException
   */
  protected RawFileStorePrx createRepoRFS(CheckedPath checked, String mode, Current __current)
      throws ServerError, InternalException {

    final Ice.Current adjustedCurr = makeAdjustedCurrent(__current);
    final BlitzExecutor be = context.getBean("throttlingStrategy", BlitzExecutor.class);

    RepoRawFileStoreI rfs;
    try {
      final RawFileStore service =
          repositoryDao.getRawFileStore(checked.getId(), checked, mode, __current);
      rfs = new RepoRawFileStoreI(be, service, adjustedCurr);
      rfs.setApplicationContext(this.context);
    } catch (Throwable t) {
      if (t instanceof ServerError) {
        throw (ServerError) t;
      } else {
        omero.InternalException ie = new omero.InternalException();
        IceMapper.fillServerError(ie, t);
        throw ie;
      }
    }

    final _RawFileStoreTie tie = new _RawFileStoreTie(rfs);
    Ice.ObjectPrx prx = registerServant(tie, rfs, adjustedCurr);
    return RawFileStorePrxHelper.uncheckedCast(prx);
  }
Exemplo n.º 3
0
  public RawPixelsStorePrx pixels(String path, Current __current) throws ServerError {
    final CheckedPath checked = checkPath(path, null, __current);

    // See comment below in RawFileStorePrx
    Ice.Current adjustedCurr = makeAdjustedCurrent(__current);

    // Check that the file is in the DB and has minimally "r" permissions
    // Sets the ID value on the checked object.
    findInDb(checked, "r", adjustedCurr);

    BfPixelsStoreI rps;
    try {
      // FIXME ImportConfig should be injected
      rps = new BfPixelsStoreI(path, new OMEROWrapper(new ImportConfig()).getImageReader());
    } catch (Throwable t) {
      if (t instanceof ServerError) {
        throw (ServerError) t;
      } else {
        omero.InternalException ie = new omero.InternalException();
        IceMapper.fillServerError(ie, t);
        throw ie;
      }
    }

    // See comment below in RawFileStorePrx
    _RawPixelsStoreTie tie = new _RawPixelsStoreTie(rps);
    RegisterServantMessage msg = new RegisterServantMessage(this, tie, adjustedCurr);
    publishMessage(msg);
    Ice.ObjectPrx prx = msg.getProxy();
    if (prx == null) {
      throw new omero.InternalException(null, null, "No ServantHolder for proxy.");
    }
    return RawPixelsStorePrxHelper.uncheckedCast(prx);
  }
Exemplo n.º 4
0
 private void assertFindDir(final CheckedPath checked, Session s, ServiceFactory sf, SqlAction sql)
     throws omero.ServerError {
   if (null == repositoryDao.findRepoFile(sf, sql, repoUuid, checked, null)) {
     omero.ResourceError re = new omero.ResourceError();
     IceMapper.fillServerError(
         re, new RuntimeException("Directory exists but is not registered: " + checked));
     throw re;
   }
 }
Exemplo n.º 5
0
 protected void publishMessage(final InternalMessage msg) throws ServerError, InternalException {
   try {
     this.context.publishMessage(msg);
   } catch (Throwable t) {
     if (t instanceof ServerError) {
       throw (ServerError) t;
     } else {
       omero.InternalException ie = new omero.InternalException();
       IceMapper.fillServerError(ie, t);
       throw ie;
     }
   }
 }
Exemplo n.º 6
0
  private String loadText(final OriginalFile file, final Ice.Current current) throws ServerError {

    if (scripts.isInRepo(file.getId())) {
      try {
        return scripts.read(file.getPath() + file.getName());
      } catch (IOException e) {
        omero.ResourceError re = new omero.ResourceError(null, null, "Failed to load " + file);
        IceMapper.fillServerError(re, e);
        throw re;
      }
    }

    final Long size = file.getSize();
    if (size == null || size.longValue() > Integer.MAX_VALUE || size.longValue() < 0) {
      throw new ValidationException(
          null, null, "Script size : " + size + " invalid on Blitz.OMERO server.");
    }

    return (String)
        factory.executor.execute(
            current.ctx,
            factory.principal,
            new Executor.SimpleWork(this, "getScriptWithDetails") {
              @Transactional(readOnly = true)
              public Object doWork(Session session, ServiceFactory sf) {
                RawFileStore rawFileStore = sf.createRawFileStore();
                try {
                  rawFileStore.setFileId(file.getId());
                  String script =
                      new String(rawFileStore.read(0L, (int) file.getSize().longValue()));

                  return script;
                } finally {
                  rawFileStore.close();
                }
              }
            });
  }