GitHub user mike-jumper opened a pull request:

    https://github.com/apache/incubator-guacamole-client/pull/16

    GUACAMOLE-44: Implement uploads within tunnel REST endpoint

    Similar to apache/incubator-guacamole-client#13, this change implements the 
upload half of the tunnel REST endpoint. While it is possible to upload using 
JavaScript alone via the new `Guacamole.FileWriter` added via 
apache/incubator-guacamole-client#14, doing so instead via native HTTP is 
**much faster**.
    
    To facilitate translation of Guacamole protocol status codes (received via 
"ack" instructions along the stream) to HTTP errors and `APIError` entities, 
this change also:
    
    1. Adds a new `fromGuacamoleStatusCode()` to the `GuacamoleStatus` enum, 
allowing the integer status codes to be directly translated to typesafe 
`GuacamoleStatus` values.
    2. Adds a new `statusCode` property to `APIError` (and it's JavaScript 
sibling `Error`), along with a new error type, `STREAM_ERROR`, for the sake of 
representing errors received along an intercepted Guacamole stream.
    
    The logic surrounding routing a Guacamole stream to an `OutputStream` has 
been extracted and generalized such that the corresponding `InputStream` 
implementation can leverage much of the same logic. This is done through the 
following new classes:
    
    1. `InterceptedStream` - a pairing of `OutputStream` or `InputStream` with 
the stream index used by the Guacamole protocol, here represented by a `String` 
despite its integer nature due to the way such things are represented 
internally. It's only parsed out as an integer when actually needed as such.
    2. `InterceptedStreamMap` - a mapping of stream index (again, in `String` 
form) to the corresponding `InterceptedStream`. This class also automatically 
handles notification of stream closure, and provides its own `waitFor()` 
function that blocks until a given stream has closed. This logic used to be 
part of `StreamInterceptingTunnel` when it was `OutputStream`-specific.
    3. `StreamInterceptingFilter` - a filter which intercepts stream-related 
instructions for streams of an arbitrary type, automatically handling mapping 
of stream indices and blocking. It is up to the implementation to filter the 
instructions it is actually interested in, and route the I/O associated with 
those instructions accordingly.
    4. `OutputStreamInterceptingFilter` - an `OutputStream`-specific 
implementation of `StreamInterceptingFilter`. This contains the remaining logic 
that used to be part of `StreamInterceptingTunnel`.
    5. `InputStreamInterceptingFilter` - an `InputStream`-specific 
implementation of `StreamInterceptingFilter`. This is the new logic, 
implementing support for routing uploaded file data along an established 
Guacamole stream.
    
    As receipt of the error via "ack" happens asynchronously and outside the 
blocking call to `interceptStream()`, errors are instead reported via a call to 
the `setStreamError()` function of the newly-added `InterceptedStream` object.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/mike-jumper/incubator-guacamole-client 
upload-endpoint

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-guacamole-client/pull/16.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #16
    
----
commit f391f00c7ba9d146c5bb1717f80a0bb291fd5bac
Author: Michael Jumper <[email protected]>
Date:   2016-06-04T08:58:01Z

    GUACAMOLE-44: Extract logic of StreamInterceptingTunnel.

commit 131785a442084a2631421daa313541e0a9760b2d
Author: Michael Jumper <[email protected]>
Date:   2016-06-04T09:18:34Z

    GUACAMOLE-44: Implement intercepting of input streams.

commit 75baa69ceadd42b767fe9b70d6fd21f64a647d88
Author: Michael Jumper <[email protected]>
Date:   2016-06-05T22:41:52Z

    GUACAMOLE-44: Add GuacamoleStreamException for reporting errors from 
intercepted streams.

commit 2bb5260144697316e5c93cfca9812511ee0b3354
Author: Michael Jumper <[email protected]>
Date:   2016-06-05T23:01:08Z

    GUACAMOLE-44: Provide for direct translation of status codes into 
GuacamoleStatus values.

commit e79d019fe6253f9bacc16285dc728c6d2c44df40
Author: Michael Jumper <[email protected]>
Date:   2016-06-05T23:00:03Z

    GUACAMOLE-44: Allow intercepted streams to report errors.

commit ef5329dbe1ebdeecfbb81b820d4fef79b201401c
Author: Michael Jumper <[email protected]>
Date:   2016-06-05T23:12:37Z

    GUACAMOLE-44: Implement JavaScript service for uploading files to a stream 
via the REST tunnel endpoint.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to