PageRenderTime 43ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/connector/src/main/java/com/restfb/LegacyFacebookClient.java

https://github.com/chrbayer84/GoodData-CL
Java | 228 lines | 18 code | 10 blank | 200 comment | 0 complexity | 73c61504c885502785aace2aacc6b0ce MD5 | raw file
Possible License(s): BSD-3-Clause
  1. /*
  2. * Copyright (c) 2010-2011 Mark Allen.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. * THE SOFTWARE.
  21. */
  22. package com.restfb;
  23. import java.util.List;
  24. import java.util.Map;
  25. /**
  26. * Specifies how a <a
  27. * href="http://developers.facebook.com/docs/reference/rest/">Legacy Facebook
  28. * API</a> client must operate.
  29. * <p/>
  30. * Implementors must support Legacy authentication (API Key, Application Secret,
  31. * and Session Key) as well as the <a
  32. * href="http://developers.facebook.com/docs/guides/upgrade#oauth">new OAuth
  33. * authentication</a> method. Using OAuth authentication is much simpler and
  34. * strongly recommended.
  35. * <p/>
  36. * Green-field projects should use the new <a
  37. * href="http://developers.facebook.com/docs/api">Facebook Graph API</a> via
  38. * {@link com.restfb.FacebookClient} instead.
  39. * <p/>
  40. * <ul>
  41. * <li>The {@link #execute(String, Parameter...)} family of methods should be
  42. * used when performing API calls that return a single object.</li>
  43. * <li>The {@link #executeForList(String, Class, Parameter...)} family of
  44. * methods should be used when performing API calls that return a list of
  45. * objects.</li>
  46. * <li>The {@link #executeMultiquery(java.util.Map, Class, Parameter...)} family of
  47. * methods should be used when performing <a
  48. * href="http://wiki.developers.facebook.com/index.php/Fql.multiquery">
  49. * {@code fql.multiquery}</a> API calls.</li>
  50. * </ul>
  51. *
  52. * @author <a href="http://restfb.com">Mark Allen</a>
  53. */
  54. public interface LegacyFacebookClient {
  55. /**
  56. * Executes a Facebook API method with the given {@code parameters}, ignoring
  57. * the response.
  58. *
  59. * @param method The Facebook API method to call, e.g. {@code fql.query}.
  60. * @param parameters Parameters to include in the API call.
  61. * @throws com.restfb.exception.FacebookException
  62. * If an error occurs while performing the API call.
  63. */
  64. void execute(String method, Parameter... parameters);
  65. /**
  66. * Executes a Facebook API method with the given {@code parameters}, ignoring
  67. * the response.
  68. *
  69. * @param method The Facebook API method to call, e.g. {@code fql.query}.
  70. * @param sessionKey A Facebook API session key if you're using the legacy API
  71. * key/Secret key authentication scheme. Must be {@code null} if
  72. * using OAuth access token authentication.
  73. * @param parameters Parameters to include in the API call.
  74. * @throws com.restfb.exception.FacebookException
  75. * If an error occurs while performing the API call.
  76. * @throws IllegalArgumentException If {@code sessionKey} is provided when using OAuth access token
  77. * authentication.
  78. * @deprecated Use {@link #execute(String, Parameter...)} instead. Facebook is
  79. * moving to OAuth and will stop supporting the old session key
  80. * authentication scheme soon.
  81. */
  82. @Deprecated
  83. void execute(String method, String sessionKey, Parameter... parameters);
  84. /**
  85. * Executes a Facebook API method with the given {@code parameters}, mapping
  86. * the API response to a single instance of type {@code resultType}.
  87. *
  88. * @param <T> Java type to map to.
  89. * @param method The Facebook API method to call, e.g. {@code fql.query}.
  90. * @param resultType Result type token.
  91. * @param parameters Parameters to include in the API call.
  92. * @return An instance of type {@code resultType} which contains API response
  93. * data.
  94. * @throws com.restfb.exception.FacebookException
  95. * If an error occurs while performing the API call.
  96. */
  97. <T> T execute(String method, Class<T> resultType, Parameter... parameters);
  98. /**
  99. * Executes a Facebook API method with the given {@code parameters}, mapping
  100. * the API response to a single instance of type {@code resultType}.
  101. *
  102. * @param <T> Java type to map to.
  103. * @param method The Facebook API method to call, e.g. {@code fql.query}.
  104. * @param sessionKey A Facebook API session key if you're using the legacy API
  105. * key/Secret key authentication scheme. Must be {@code null} if
  106. * using OAuth access token authentication.
  107. * @param resultType Result type token.
  108. * @param parameters Parameters to include in the API call.
  109. * @return An instance of type {@code resultType} which contains API response
  110. * data.
  111. * @throws com.restfb.exception.FacebookException
  112. * If an error occurs while performing the API call.
  113. * @throws IllegalArgumentException If {@code sessionKey} is provided when using OAuth access token
  114. * authentication.
  115. * @deprecated Use {@link #execute(String, Class, Parameter...)} instead.
  116. * Facebook is moving to OAuth and will stop supporting the old
  117. * session key authentication scheme soon.
  118. */
  119. @Deprecated
  120. <T> T execute(String method, String sessionKey, Class<T> resultType, Parameter... parameters);
  121. /**
  122. * Executes a Facebook API method with the given {@code parameters}, mapping
  123. * the API response to a {@code List} of instances of type {@code resultType}.
  124. *
  125. * @param <T> Java type to map to.
  126. * @param method The Facebook API method to call, e.g. {@code fql.query}.
  127. * @param resultType Result type token.
  128. * @param parameters Parameters to include in the API call.
  129. * @return A {@code List} of instances of type {@code resultType} which
  130. * contain API response data.
  131. * @throws com.restfb.exception.FacebookException
  132. * If an error occurs while performing the API call.
  133. */
  134. <T> List<T> executeForList(String method, Class<T> resultType, Parameter... parameters);
  135. /**
  136. * Executes a Facebook API method with the given {@code parameters}, mapping
  137. * the API response to a {@code List} of instances of type {@code resultType}.
  138. *
  139. * @param <T> Java type to map to.
  140. * @param method The Facebook API method to call, e.g. {@code fql.query}.
  141. * @param sessionKey A Facebook API session key if you're using the legacy API
  142. * key/Secret key authentication scheme. Must be {@code null} if
  143. * using OAuth access token authentication.
  144. * @param resultType Result type token.
  145. * @param parameters Parameters to include in the API call.
  146. * @return A {@code List} of instances of type {@code resultType} which
  147. * contain API response data.
  148. * @throws com.restfb.exception.FacebookException
  149. * If an error occurs while performing the API call.
  150. * @throws IllegalArgumentException If {@code sessionKey} is provided when using OAuth access token
  151. * authentication.
  152. * @deprecated Use {@link #executeForList(String, Class, Parameter...)}
  153. * instead. Facebook is moving to OAuth and will stop supporting
  154. * the old session key authentication scheme soon.
  155. */
  156. @Deprecated
  157. <T> List<T> executeForList(String method, String sessionKey, Class<T> resultType, Parameter... parameters);
  158. /**
  159. * Executes the <a
  160. * href="http://wiki.developers.facebook.com/index.php/Fql.multiquery">
  161. * {@code fql.multiquery}</a> API call, mapping the API response to a single
  162. * instance of type {@code resultType}.
  163. * <p/>
  164. * This method exists because the standard
  165. * {@link #execute(String, Parameter...)} and
  166. * {@link #executeForList(String, Class, Parameter...)} family of methods are
  167. * not expressive enough to handle {@code fql.multiquery} in a non-verbose
  168. * way.
  169. *
  170. * @param <T> Java type to map to.
  171. * @param queries A mapping of query names to queries. This is marshaled to JSON and
  172. * sent over the wire to the Facebook API endpoint as the
  173. * {@code queries} parameter.
  174. * @param resultType Result type token.
  175. * @param additionalParameters Additional parameters to include in the API call.
  176. * @return An instance of type {@code resultType} which contains API response
  177. * data.
  178. * @throws com.restfb.exception.FacebookException
  179. * If an error occurs while performing the API call.
  180. * @since 1.1
  181. */
  182. <T> T executeMultiquery(Map<String, String> queries, Class<T> resultType, Parameter... additionalParameters);
  183. /**
  184. * Executes the <a
  185. * href="http://wiki.developers.facebook.com/index.php/Fql.multiquery">
  186. * {@code fql.multiquery}</a> API call, mapping the API response to a single
  187. * instance of type {@code resultType}.
  188. * <p/>
  189. * This method exists because the standard
  190. * {@link #execute(String, Parameter...)} and
  191. * {@link #executeForList(String, Class, Parameter...)} family of methods are
  192. * not expressive enough to handle {@code fql.multiquery} in a non-verbose
  193. * way.
  194. *
  195. * @param <T> Java type to map to.
  196. * @param queries A mapping of query names to queries. This is marshaled to JSON and
  197. * sent over the wire to the Facebook API endpoint as the
  198. * {@code queries} parameter.
  199. * @param sessionKey A Facebook API session key if you're using the legacy API
  200. * key/Secret key authentication scheme. Must be {@code null} if
  201. * using OAuth access token authentication.
  202. * @param resultType Result type token.
  203. * @param additionalParameters Additional parameters to include in the API call.
  204. * @return An instance of type {@code resultType} which contains API response
  205. * data.
  206. * @throws com.restfb.exception.FacebookException
  207. * If an error occurs while performing the API call.
  208. * @throws IllegalArgumentException If {@code sessionKey} is provided when using OAuth access token
  209. * authentication.
  210. * @since 1.1
  211. * @deprecated Use {@link #executeMultiquery(java.util.Map, Class, Parameter...)}
  212. * instead. Facebook is moving to OAuth and will stop supporting
  213. * the old session key authentication scheme soon.
  214. */
  215. @Deprecated
  216. <T> T executeMultiquery(Map<String, String> queries, String sessionKey, Class<T> resultType,
  217. Parameter... additionalParameters);
  218. }