PageRenderTime 47ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/odata4j-jersey/src/main/java/org/odata4j/jersey/consumer/ODataJerseyConsumers.java

https://code.google.com/p/odata4j/
Java | 61 lines | 19 code | 11 blank | 31 comment | 0 complexity | fe52c6f0f3d5500db0ea50abe13d9265 MD5 | raw file
  1. package org.odata4j.jersey.consumer;
  2. import org.odata4j.consumer.ODataConsumer;
  3. import org.odata4j.consumer.behaviors.OClientBehavior;
  4. import org.odata4j.consumer.behaviors.OClientBehaviors;
  5. /**
  6. * A static factory to create {@link ODataJerseyConsumer} instances preconfigured for specific services.
  7. */
  8. public class ODataJerseyConsumers {
  9. private ODataJerseyConsumers() {}
  10. /**
  11. * Creates a new OData consumer for the Azure Table Storage service.
  12. *
  13. * @param account azure account key
  14. * @param key azure secret key
  15. * @return a new OData consumer for the Azure Table Storage service
  16. * @see <a href="http://msdn.microsoft.com/en-us/library/dd179423.aspx">[msdn] Table Service API</a>
  17. */
  18. public static ODataConsumer azureTables(String account, String key) {
  19. String url = "http://" + account + ".table.core.windows.net/";
  20. return ODataJerseyConsumer.newBuilder(url).setClientBehaviors(OClientBehaviors.azureTables(account, key)).build();
  21. }
  22. /**
  23. * Creates a new OData consumer for the (now obsolete?) "dallas" service.
  24. *
  25. * @param serviceRootUri the service uri
  26. * @param accountKey dallas account key
  27. * @param uniqueUserId dallas user id
  28. * @return a new OData consumer for the (now obsolete?) "dallas" service
  29. */
  30. public static ODataConsumer dallas(String serviceRootUri, String accountKey, String uniqueUserId) {
  31. // CTP2
  32. //OClientBehavior dallasAuth = new DallasCtp2AuthenticationBehavior(accountKey, uniqueUserId);
  33. //OClientBehavior paging = new OldStylePagingBehavior(50, 1);
  34. //return ODataConsumer.create(serviceRootUri, dallasAuth, paging);
  35. // CTP3
  36. OClientBehavior basicAuth = OClientBehaviors.basicAuth("accountKey", accountKey);
  37. return ODataJerseyConsumer.newBuilder(serviceRootUri).setClientBehaviors(basicAuth).build();
  38. }
  39. /**
  40. * Creates a new OData consumer for the Windows Azure DataMarket service.
  41. *
  42. * @param serviceRootUri the service uri
  43. * @param accountKey account key for basic authentication
  44. * @return a new OData consumer for the Windows Azure DataMarket service
  45. */
  46. public static ODataConsumer dataMarket(String serviceRootUri, String accountKey) {
  47. OClientBehavior basicAuth = OClientBehaviors.basicAuth("accountKey", accountKey);
  48. return ODataJerseyConsumer.newBuilder(serviceRootUri).setClientBehaviors(basicAuth).build();
  49. }
  50. }