public class RemoteConnectorAdapter extends Object implements RemoteConnector
RemoteConnector implementations to delegate to
an underlying connector| Constructor and Description |
|---|
RemoteConnectorAdapter(RemoteConnector delegate)
Creates a new adapter for the given underlying connector
|
| Modifier and Type | Method and Description |
|---|---|
void |
authorize(String verificationCode)
Authorizes the app.
|
String |
getAccessTokenSecret() |
String |
getAccessTokenValue() |
String |
getAuthorizationURL()
Gets a new authorization URL from the remote server.
|
CSLItemData |
getItem(String itemId)
Requests an item from the service.
|
List<String> |
getItemIDs()
Requests a list of item IDs from the server.
|
Map<String,CSLItemData> |
getItems(List<String> itemIds)
Requests several items from the service.
|
int |
getMaxBulkItems() |
void |
setAccessToken(String token,
String secret)
Authorizes the app.
|
public RemoteConnectorAdapter(RemoteConnector delegate)
delegate - the underlying connectorpublic String getAuthorizationURL() throws IOException
RemoteConnectorRemoteConnector.authorize(String)getAuthorizationURL in interface RemoteConnectorIOException - if the authorization URL could not be retrievedpublic void authorize(String verificationCode) throws IOException
RemoteConnectorRemoteConnector.getAuthorizationURL(), this method has to be
called to finish authorizationauthorize in interface RemoteConnectorverificationCode - the verification code the user received from
the authorization URLIOException - if authorization failedpublic void setAccessToken(String token, String secret)
RemoteConnectorAuthorizes the app. If you already know a valid OAuth access token
(for example if you cached it from previous sessions) you may call
this method instead of RemoteConnector.getAuthorizationURL() and
RemoteConnector.authorize(String).
This method just saves the provided access token. It does not act with the remote service in any way.
setAccessToken in interface RemoteConnectortoken - the access token valuesecret - the access token's secretRemoteConnector.getAccessTokenValue(),
RemoteConnector.getAccessTokenSecret()public String getAccessTokenValue()
getAccessTokenValue in interface RemoteConnectorRemoteConnector.setAccessToken(String, String)public String getAccessTokenSecret()
getAccessTokenSecret in interface RemoteConnectorRemoteConnector.setAccessToken(String, String)public List<String> getItemIDs() throws IOException
RemoteConnectorgetItemIDs in interface RemoteConnectorUnauthorizedException - if the user is not authenticatedRequestException - if the server returns an error codeIOException - if the items could not be read from the serverpublic CSLItemData getItem(String itemId) throws IOException
RemoteConnectorgetItem in interface RemoteConnectoritemId - the item's IDUnauthorizedException - if the user is not authenticatedRequestException - if the server returns an error codeIOException - if the item could not be read from the serverpublic Map<String,CSLItemData> getItems(List<String> itemIds) throws IOException
RemoteConnectorRequests several items from the service. The user has to be authenticated before this method can be called.
Some services support bulk loading. In this case, this method
makes as few requests as possible. The RemoteConnector.getMaxBulkItems()
method returns the maximum number of items that can be queried
within one request.
getItems in interface RemoteConnectoritemIds - the IDs of the items to requestUnauthorizedException - if the user is not authenticatedRequestException - if the server returns an error codeIOException - if one of the items could not be read from the serverRemoteConnector.getMaxBulkItems()public int getMaxBulkItems()
getMaxBulkItems in interface RemoteConnectorRemoteConnector.getItems(List)