/** * Fails the Result with an exception. The exception will be passed to * the calling client. * * @param exn the exception */ @Override default void fail(Throwable exn) { try { handle(null, exn); } catch (Exception e) { throw new ServiceExceptionExecution(e); } }
/** * Completes the Result with its value. Services call complete to finish * the response. * * Service: * <pre><code> * void hello(Result<String> result) * { * result.ok("Hello, world"); * } * </code></pre> * * Client: * <pre><code> * hello.hello((x,e)->System.out.println("Hello: " + x)); * </code></pre> * * @param result the result value */ @Override default void ok(T result) { try { handle(result, null); } catch (Exception e) { fail(e); } }
public void moveFile(String src, String dest, Result<Boolean> result) { // XXX: need admin logging log.info("moveFile " + src + " to " + dest); getFile(src, result.then((stream,r) -> { putFile(dest, stream); removeFile(src, (isDeleted,e) -> r.handle(isDeleted, e)); })); }