...
The Box component provides access to all of the Box.com APIs accessible using box-java-sdk-v2. It allows producing messages to upload and download files, create, edit, and manage folders, etc. It also supports APIs that allow polling for updates to user accounts and even changes to enterprise accounts, etc.
Box.com requires the use of OAuth2.0 for all client application authentication. In order to use camel-box with your account, you'll need to create a new application within Box.com at https://app.box.com/developers/services/edit/. The Box application's client id and secret will allow access to Box APIs which require a current user. A user access token is generated and managed by the API for an end user. Alternatively the Camel application can register an implementation of com.box.boxjavalibv2.authorization.IAuthSecureStorage
to provide an coman com.box.boxjavalibv2.dao.IAuthData
OAuth token.
Maven users will need to add the following dependency to their their pom.xml
for this component:
Code Block | ||
---|---|---|
| ||
<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-box</artifactId> <version>${camel-version}</version> </dependency> |
URI
...
Format
Code Block |
---|
box://endpoint-prefix/endpoint?[options]
|
Endpoint Where the endpoint-prefix
can be one of:
collaborations
comments
events
files
folders
groups
poll-events
search
shared-comments
shared-files
shared-folders
shared-items
users
BoxComponent
The Box Component can be configured with the options below. These options can be provided using the component's bean property configuration
of type org.apache.camel.component.box.BoxConfiguration
. These options can also be specified in the endpoint URI.
Option | Type | Description |
---|---|---|
|
| OAuth Secure Storage callback, can be used to provide and or save OAuth tokens. The callback may returnreturn |
|
| Custom Box SDK configuration, not required normally. |
|
| Box application client ID. |
|
| Box application client secret. |
|
| Custom Box connection manager builder, used to override default settings like max connections for underlying |
|
| Custom HTTP params for settings like proxy host. |
|
| amount Amount of time the component will wait for a response from Box.com , default. Default is 30 seconds. |
|
| OAuth listener for token updates, if the Camel application needs to use the access token outside the route. |
|
| Flag to revoke OAuth refresh token on route shutdown, default false. Will require a fresh refresh token on restart using either a customcustom |
|
| Box shared link forfor |
|
| Password associated with the shared link, MUST be provided with |
|
| Box user name, MUST be provided. |
|
| Box user password, MUST be provided ifif returns |
Producer Endpoints
...
Producer endpoints can use endpoint prefixes followed by endpoint names and associated options described next. A shorthand alias can be used for some endpoints. The endpoint URI MUST contain a prefix.
Endpoint options that are not mandatory are denoted by by []
. When there are no mandatory options for an endpoint, one of the set of []
options MUST be provided. Producer endpoints can also use a special option inBody
that in turn should contain the name of the endpoint option whose value will be contained in the Camel Exchange In message.
...
If a value is not provided for the option option defaultRequest
either in the endpoint URI or in a message header, it will be assumed to be null
. Note that the null
value will only be used if other options do not satisfy matching endpoints.
In case of Box API errors the endpoint will throw a a RuntimeCamelException
with a a com.box.restclientv2.exceptions.BoxSDKException
derived derived exception cause.
Endpoint
...
Prefix - collaborations
For more information on Box collaborations see https://developers.box.com/docs/#collaborations. The The following endpoints can be invoked with the prefix collaborations
as follows:
Code Block |
---|
box://collaborations/endpoint?[options] |
Endpoint | Shorthand Alias | Options | Result Body Type |
---|---|---|---|
|
|
|
|
|
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
URI Options for collaborations
Name | Type |
---|---|
|
|
|
|
|
|
|
|
|
|
Endpoint
...
Prefix - events
For more information on Box events see https://developers.box.com/docs/#events. Although this endpoint can be used by producers, Box events are better used as a consumer endpoint using the poll-events
endpoint prefix. The following endpoints can be invoked The following endpoints can be invoked with the prefix events
as follows:
Code Block |
---|
box://events/endpoint?[options] |
Endpoint | Shorthand Alias | Options | Result Body Type |
---|---|---|---|
|
|
|
|
|
|
|
|
URI Options for events
Name | Type |
---|---|
|
|
|
|
Endpoint
...
Prefix - groups
For more information on Box groups see https://developers.box.com/docs/#groups. The following endpoints can The following endpoints can be invoked with the prefix groups
as follows:
Code Block |
---|
box://groups/endpoint?[options] |
Endpoint | Shorthand Alias | Options | Result Body Type |
---|---|---|---|
|
|
| |
|
|
| |
|
|
| |
|
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
URI Options for groups
Name | Type |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Endpoint
...
Prefix - search
For more information on Box search API see https://developers.box.com/docs/#search. The
...
The following endpoints can be invoked with the prefix search
as follows:
Code Block |
---|
box:box://search/endpoint?[options] |
Endpoint | Shorthand Alias | Options | Result Body Type |
---|---|---|---|
|
|
|
URI Options for search
Name | Type |
---|---|
|
|
|
|
Endpoint Prefix - comments
and shared-comments
For more information on Box comments see https://developers.box.com/docs/#comments. The following endpoints can be invoked with the prefix comments
or shared-comments
as as follows. The shared-comments
prefix requires requires sharedLink
and and sharedPassword
properties.
Code Block |
---|
box://comments/endpoint?[options] box://shared-comments/endpoint?[options] |
Endpoint | Shorthand Alias | Options | Result Body Type |
---|---|---|---|
|
|
| |
|
|
| |
|
|
|
|
|
|
|
|
URI Options for for comments
and shared-comments
Name | Type |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
Endpoint
...
Prefix - files
and shared-files
The following endpoints can For more information on Box files see https://developers.box.com/docs/#files. The following endpoints can be invoked with the prefix files
or shared-files
as follows. The shared-files
prefix requires sharedLink
and and sharedPassword
properties.
Code Block |
---|
box://files/endpoint?[options] box://shared-files/endpoint?[options] |
Endpoint | Shorthand Alias | Options | Result Body Type |
---|---|---|---|
|
|
| |
|
|
|
|
|
| ||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
URI Options for for files
and shared-files
Name | Type |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Endpoint Prefix - folders
and shared-folders
For more information on Box folders see https://developers.box.com/docs/#folders. The following endpoints can be invoked with the prefix folders
or shared-folders
as follows. The prefix prefix shared-folders
requires requires sharedLink
and and sharedPassword
properties.
Code Block |
---|
box://folders/endpoint?[options] box://shared-folders/endpoint?[options] |
Endpoint | Shorthand Alias | Options | Result Body Type |
---|---|---|---|
|
|
| |
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
URI Options for for folders
or shared-folders
Name | Type |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Endpoint
...
Prefix - shared-items
For more information on Box shared items see https://developers.box.com/docs/#shared-items. The following endpoints can be invoked with the prefix shared-items
as follows:
Code Block |
---|
box://shared-items/endpoint?[options] |
Endpoint | Shorthand Alias | Options | Result Body Type |
---|---|---|---|
|
|
|
|
URI Options for shared-items
...
Name | Type |
---|---|
|
|
Endpoint Prefix users
|
Endpoint Prefix - users
For information on Box users see https://developers.box.com/docs/#users. The following endpoints can be invoked with the prefix users
as follows:
Code Block |
---|
box://users/endpoint?[options] |
Endpoint | Shorthand Alias | Options | Result Body Type |
---|---|---|---|
|
|
| |
|
|
|
|
|
| ||
|
| ||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
|
|
|
|
|
|
|
|
URI Options for users
...
Name | Type |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Consumer Endpoints:
|
Consumer Endpoints
For more information on Box events see https://developers.box.com/docs/#events and for long polling see https://developers.box.com/docs/#events-long-polling. Consumer endpoints can only use the endpoint prefix poll-events
as shown in the example next. By default the consumer will split the com.box.boxjavalibv2.dao.BoxEventCollection
from every long poll and create an exchange for every com every com.box.boxjavalibv2.dao.BoxEvent
. To make the consumer return the entire collection in a single exchange, use the URI option consumer.splitResult=false
.
Code Block |
---|
box://poll-events/endpoint?[options] |
Endpoint | Shorthand Alias | Options | Result Body Type |
---|---|---|---|
|
|
or when |
URI Options for poll-events
Name | Type |
---|---|
|
|
|
|
|
|
|
|
Message
...
Header
Any of the options can be provided in a message header for producer endpoints with CamelBox.
prefix.
Message
...
Body
All result message bodies utilize objects provided by the Box Java SDK. Producer endpoints can specify the option name for incoming message body in the the inBody
endpoint parameter.
Type Converter
The Box component also provides a Camel type-converter to convert GenericFile objects from File component to a com.box.restclientv2.requestsbase.BoxFileUploadRequestObject
to upload a new file files to Box.com. The target folderId
for the upload can be specified in the header property exchange property CamelBox.folderId
. If the exchange property is not specified the it value defaults to 0
for the root folder ID.
Use
...
Cases
The following route uploads new files to the user's root folder:
Code Block | ||
---|---|---|
| ||
from("file:...") .to("box://files/upload/inBody=fileUploadRequest"); |
The following route polls user's account for updates:
Code Block | ||
---|---|---|
| ||
from("box://poll-events/poll?streamPosition=-1&streamType=all&limit=100") .to("bean:blah"); |
...
The following route uses a producer with dynamic header options
...
.
...
The The fileId
header property has the Box file id, so its assigned to the the CamelBox.fileId
header in the following routeas follows:
Code Block | ||
---|---|---|
| ||
from("direct:foo") .setHeader("CamelBox.fileId", header("fileId")) .to("box://files/download") .to("file://..."); |