PageRenderTime 20ms CodeModel.GetById 7ms RepoModel.GetById 0ms app.codeStats 0ms

/examples/src/main/java/com/mendeley/oapi/services/example/DocumentSample.java

https://code.google.com/p/mendeley-java-sdk/
Java | 65 lines | 23 code | 9 blank | 33 comment | 0 complexity | c5bc96a571f7df25185723a713cf3e57 MD5 | raw file
  1. /*
  2. * Copyright 2011 Nabeel Mukhtar
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *
  16. */
  17. package com.mendeley.oapi.services.example;
  18. import java.util.List;
  19. import com.mendeley.oapi.schema.Document;
  20. import com.mendeley.oapi.services.DocumentService;
  21. import com.mendeley.oapi.services.MendeleyServiceFactory;
  22. import com.mendeley.oapi.services.oauth.MendeleyAccessToken;
  23. /**
  24. * The Class DocumentSample.
  25. */
  26. public class DocumentSample {
  27. /** The Constant CONSUMER_KEY. */
  28. private static final String CONSUMER_KEY = "";
  29. /** The Constant CONSUMER_SECRET. */
  30. private static final String CONSUMER_SECRET = "";
  31. /** The Constant ACCESS_TOKEN. */
  32. private static final String ACCESS_TOKEN = "";
  33. /** The Constant TOKEN_SECRET. */
  34. private static final String TOKEN_SECRET = "";
  35. /**
  36. * The main method.
  37. *
  38. * @param args the arguments
  39. */
  40. public static void main(String[] args) {
  41. MendeleyServiceFactory factory = MendeleyServiceFactory.newInstance(CONSUMER_KEY, CONSUMER_SECRET);
  42. DocumentService service = factory.createDocumentService(new MendeleyAccessToken(ACCESS_TOKEN, TOKEN_SECRET));
  43. List<String> documentIds = service.getDocumentIds();
  44. System.out.println(documentIds);
  45. Document document = service.getDocumentDetails(documentIds.get(0));
  46. printResult(document);
  47. }
  48. /**
  49. * Prints the result.
  50. *
  51. * @param document the document
  52. */
  53. private static void printResult(Document document) {
  54. System.out.println(document);
  55. }
  56. }