PageRenderTime 43ms CodeModel.GetById 29ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 1ms

/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 */
17package com.mendeley.oapi.services.example;
18
19import java.util.List;
20
21import com.mendeley.oapi.schema.Document;
22import com.mendeley.oapi.services.DocumentService;
23import com.mendeley.oapi.services.MendeleyServiceFactory;
24import com.mendeley.oapi.services.oauth.MendeleyAccessToken;
25
26/**
27 * The Class DocumentSample.
28 */
29public class DocumentSample {
30
31	/** The Constant CONSUMER_KEY. */
32	private static final String CONSUMER_KEY = "";
33	
34	/** The Constant CONSUMER_SECRET. */
35	private static final String CONSUMER_SECRET = "";
36	
37	/** The Constant ACCESS_TOKEN. */
38	private static final String ACCESS_TOKEN = "";
39	
40	/** The Constant TOKEN_SECRET. */
41	private static final String TOKEN_SECRET = "";
42	
43    /**
44     * The main method.
45     * 
46     * @param args the arguments
47     */
48	public static void main(String[] args) {
49		MendeleyServiceFactory factory = MendeleyServiceFactory.newInstance(CONSUMER_KEY, CONSUMER_SECRET);
50		DocumentService service = factory.createDocumentService(new MendeleyAccessToken(ACCESS_TOKEN, TOKEN_SECRET));
51		List<String> documentIds = service.getDocumentIds();
52		System.out.println(documentIds);
53		Document document = service.getDocumentDetails(documentIds.get(0));
54		printResult(document);
55	}
56
57	/**
58	 * Prints the result.
59	 * 
60	 * @param document the document
61	 */
62	private static void printResult(Document document) {
63		System.out.println(document);
64	}
65}