net.netheos.pcsapi.storage
Class StorageBuilder

java.lang.Object
  extended by net.netheos.pcsapi.storage.StorageBuilder

public class StorageBuilder
extends Object

Class that facilitates the construction of a storage provider


Method Summary
 IStorageProvider build()
          Builds a provider-specific storage implementation, by passing this builder in constructor.
 AppInfo getAppInfo()
           
 org.apache.http.client.HttpClient getHttpClient()
           
 RetryStrategy getRetryStrategy()
           
 UserCredentials<?> getUserCredentials()
           
 UserCredentialsRepository getUserCredentialsRepo()
           
 StorageBuilder setAppInfoRepository(AppInfoRepository appInfoRepo, String appName)
          Set the app informations repository.
 StorageBuilder setForBootstrapping(boolean forBootstrapping)
          OAuth bootstrap is not obvious : storage must be instantiated _without_ users credentials (for retrieving userId thanks to accessToken).
 StorageBuilder setHttpClient(org.apache.http.client.HttpClient httpClient)
          Sets a HTTP client that extends org.apache.http.client.HttpClient.
 StorageBuilder setRetryStrategy(RetryStrategy retryStrategy)
          Sets the retry requests strategy to be used by storage.
 StorageBuilder setUserCredentialsRepository(UserCredentialsRepository userCredentialsRepo, String userId)
          Set the user credentials repository.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setAppInfoRepository

public StorageBuilder setAppInfoRepository(AppInfoRepository appInfoRepo,
                                           String appName)
Set the app informations repository. This setter must always be called during the build

Parameters:
appInfoRepo - The repository to use
appName - The application name
Returns:
The builder

setUserCredentialsRepository

public StorageBuilder setUserCredentialsRepository(UserCredentialsRepository userCredentialsRepo,
                                                   String userId)
Set the user credentials repository. This setter must always be called during the build

Parameters:
userCredentialsRepo - The repository
userId - The user identifier (may be null if the identifier is unknown)
Returns:
The builder

setForBootstrapping

public StorageBuilder setForBootstrapping(boolean forBootstrapping)
OAuth bootstrap is not obvious : storage must be instantiated _without_ users credentials (for retrieving userId thanks to accessToken). As this use case is unlikely (instantiating a storage without user credentials), this method indicates the specificity : no 'missing users credentials' error will be raised.

Parameters:
forBootstrapping - true if it is the first start of the API
Returns:
The builder

build

public IStorageProvider build()
Builds a provider-specific storage implementation, by passing this builder in constructor. Each implementation gets its required information from builder.

Returns:
The storage builder

getAppInfo

public AppInfo getAppInfo()

getUserCredentialsRepo

public UserCredentialsRepository getUserCredentialsRepo()

getUserCredentials

public UserCredentials<?> getUserCredentials()
Returns:
user credentials, or null if this object is for bootstrapping.

getHttpClient

public org.apache.http.client.HttpClient getHttpClient()

setHttpClient

public StorageBuilder setHttpClient(org.apache.http.client.HttpClient httpClient)
Sets a HTTP client that extends org.apache.http.client.HttpClient. Allows users to use a custom HTTP client with custom parameters.

Parameters:
httpClient - The http client to use for issuing requests. This client settings may be modified by pcs_api, thus it is recommended to use a dedicated client for each provider.
Returns:
The builder

getRetryStrategy

public RetryStrategy getRetryStrategy()

setRetryStrategy

public StorageBuilder setRetryStrategy(RetryStrategy retryStrategy)
Sets the retry requests strategy to be used by storage. If not set, a default retry strategy is used : retry 3 times with initial 1 second initial delay

Parameters:
retryStrategy - The retry strategy to use
Returns:
The storage builder


Copyright © 2014. All Rights Reserved.