本文整理汇总了Java中com.evernote.clients.ClientFactory类的典型用法代码示例。如果您正苦于以下问题:Java ClientFactory类的具体用法?Java ClientFactory怎么用?Java ClientFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClientFactory类属于com.evernote.clients包,在下文中一共展示了ClientFactory类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: MyEvernoteService
import com.evernote.clients.ClientFactory; //导入依赖的package包/类
/**
* Creates a service used to access Evernote
*
* @param token authentication token
* @param sandbox true for snadox, false for prouction enviroment
* @throws Exception
*/
public MyEvernoteService(String token, boolean sandbox) throws Exception {
this.token = token;
// Set up the UserStore client and check that we can speak to the server
EvernoteService service = EvernoteService.PRODUCTION;
if ( sandbox ) {
service = EvernoteService.SANDBOX;
}
EvernoteAuth evernoteAuth = new EvernoteAuth(service, token);
ClientFactory factory = new ClientFactory(evernoteAuth);
userStore = factory.createUserStoreClient();
boolean versionOk = userStore.checkVersion("EvernoteMarkdownSync",
com.evernote.edam.userstore.Constants.EDAM_VERSION_MAJOR,
com.evernote.edam.userstore.Constants.EDAM_VERSION_MINOR);
if (!versionOk) {
LOG.error("Incompatible Evernote client protocol version");
System.exit(1);
}
// Set up the NoteStore client
noteStore = factory.createNoteStoreClient();
}
示例2: testWithAccessTokenOnly
import com.evernote.clients.ClientFactory; //导入依赖的package包/类
@Test
public void testWithAccessTokenOnly() {
Application application = new Application();
application.evernotePropertiesConfiguration = new Application.EvernotePropertiesConfiguration();
WebRequest request = mock(WebRequest.class);
when(request.getHeader("evernote-rest-accesstoken")).thenReturn("ACCESS_TOKEN");
Evernote evernote = application.evernote(request);
assertThat(evernote, is(notNullValue()));
ClientFactory clientFactory = evernote.clientFactory();
assertThat(clientFactory, is(notNullValue()));
EvernoteAuth evernoteAuth = retrieveEvernoteAuth(clientFactory);
assertThat(evernoteAuth, is(notNullValue()));
assertThat(evernoteAuth.getToken(), is("ACCESS_TOKEN"));
assertThat(evernoteAuth.getNoteStoreUrl(), is(nullValue()));
assertThat(evernoteAuth.getUserId(), is(0)); // default
assertThat(evernoteAuth.getWebApiUrlPrefix(), is(nullValue()));
}
示例3: testWithFullAccessTokenAttributes
import com.evernote.clients.ClientFactory; //导入依赖的package包/类
@Test
public void testWithFullAccessTokenAttributes() {
Application application = new Application();
application.evernotePropertiesConfiguration = new Application.EvernotePropertiesConfiguration();
WebRequest request = mock(WebRequest.class);
when(request.getHeader("evernote-rest-accesstoken")).thenReturn("ACCESS_TOKEN");
when(request.getHeader("evernote-rest-notestoreurl")).thenReturn("NOTE_STORE_URL");
when(request.getHeader("evernote-rest-webapiurlprefix")).thenReturn("WEB_API_URL_PREFIX");
when(request.getHeader("evernote-rest-userid")).thenReturn("100");
Evernote evernote = application.evernote(request);
assertThat(evernote, is(notNullValue()));
ClientFactory clientFactory = evernote.clientFactory();
assertThat(clientFactory, is(notNullValue()));
EvernoteAuth evernoteAuth = retrieveEvernoteAuth(clientFactory);
assertThat(evernoteAuth, is(notNullValue()));
assertThat(evernoteAuth.getToken(), is("ACCESS_TOKEN"));
assertThat(evernoteAuth.getNoteStoreUrl(), is("NOTE_STORE_URL"));
assertThat(evernoteAuth.getUserId(), is(100));
assertThat(evernoteAuth.getWebApiUrlPrefix(), is("WEB_API_URL_PREFIX"));
}
示例4: testAlwaysUseTokenFromConfig
import com.evernote.clients.ClientFactory; //导入依赖的package包/类
@Test
public void testAlwaysUseTokenFromConfig() {
Application.EvernotePropertiesConfiguration config = new Application.EvernotePropertiesConfiguration();
config.setAlwaysUseTokenFromConfig(true);
config.setAccessToken("ACCESS_TOKEN");
Application application = new Application();
application.evernotePropertiesConfiguration = config;
WebRequest request = mock(WebRequest.class);
Evernote evernote = application.evernote(request);
assertThat(evernote, is(notNullValue()));
ClientFactory clientFactory = evernote.clientFactory();
assertThat(clientFactory, is(notNullValue()));
EvernoteAuth evernoteAuth = retrieveEvernoteAuth(clientFactory);
assertThat(evernoteAuth, is(notNullValue()));
assertThat(evernoteAuth.getToken(), is("ACCESS_TOKEN"));
EvernoteService evernoteService = retrieveEvernoteService(evernoteAuth);
assertThat(evernoteService, is(notNullValue()));
assertThat(evernoteService, is(EvernoteService.SANDBOX));
}
示例5: testFallbackToTokenFromConfig
import com.evernote.clients.ClientFactory; //导入依赖的package包/类
@Test
public void testFallbackToTokenFromConfig() {
Application.EvernotePropertiesConfiguration config = new Application.EvernotePropertiesConfiguration();
config.setFallbackToTokenFromConfig(true);
config.setAccessToken("ACCESS_TOKEN_FROM_CONFIG");
Application application = new Application();
application.evernotePropertiesConfiguration = config;
WebRequest request = mock(WebRequest.class);
Evernote evernote = application.evernote(request);
assertThat(evernote, is(notNullValue()));
ClientFactory clientFactory = evernote.clientFactory();
assertThat(clientFactory, is(notNullValue()));
EvernoteAuth evernoteAuth = retrieveEvernoteAuth(clientFactory);
assertThat(evernoteAuth, is(notNullValue()));
assertThat(evernoteAuth.getToken(), is("ACCESS_TOKEN_FROM_CONFIG"));
}
示例6: testUserAgent
import com.evernote.clients.ClientFactory; //导入依赖的package包/类
@Test
public void testUserAgent() {
Application.EvernotePropertiesConfiguration config = new Application.EvernotePropertiesConfiguration();
config.setUserAgent("USER_AGENT");
Application application = new Application();
application.evernotePropertiesConfiguration = config;
WebRequest request = mock(WebRequest.class);
when(request.getHeader("evernote-rest-accesstoken")).thenReturn("ACCESS_TOKEN");
Evernote evernote = application.evernote(request);
assertThat(evernote, is(notNullValue()));
ClientFactory clientFactory = evernote.clientFactory();
assertThat(clientFactory, is(notNullValue()));
String userAgent = (String) ReflectionTestUtils.getField(clientFactory, "userAgent");
assertThat(userAgent, is("USER_AGENT"));
}
示例7: HelpEverNote
import com.evernote.clients.ClientFactory; //导入依赖的package包/类
/**
* Intialize UserStore and NoteStore clients. During this step, we
* authenticate with the Evernote web service. All of this code is
* boilerplate - you can copy it straight into your application.
*/
public HelpEverNote() throws Exception {
// Set up the UserStore client and check that we can speak to the server
EvernoteAuth evernoteAuth = new EvernoteAuth(EvernoteService.SANDBOX,
AUTH_TOKEN);
ClientFactory factory = ClientFactory.getInstance(evernoteAuth);
userStore = factory.createUserStoreClient();
boolean versionOk = userStore.checkVersion("Evernote EDAMDemo (Java)",
com.evernote.edam.userstore.Constants.EDAM_VERSION_MAJOR,
com.evernote.edam.userstore.Constants.EDAM_VERSION_MINOR);
if (!versionOk) {
System.err.println("Incompatible Evernote client protocol version");
System.exit(1);
}
// Set up the NoteStore client
noteStore = factory.createNoteStoreClient();
}
示例8: testCustomHeaders
import com.evernote.clients.ClientFactory; //导入依赖的package包/类
@Test
public void testCustomHeaders() {
Map<String, String> headers = new HashMap<String, String>();
headers.put("foo", "FOO");
headers.put("bar", "BAR");
Application.EvernotePropertiesConfiguration config = new Application.EvernotePropertiesConfiguration();
config.setCustomHeaders(headers);
Application application = new Application();
application.evernotePropertiesConfiguration = config;
WebRequest request = mock(WebRequest.class);
when(request.getHeader("evernote-rest-accesstoken")).thenReturn("ACCESS_TOKEN");
Evernote evernote = application.evernote(request);
assertThat(evernote, is(notNullValue()));
ClientFactory clientFactory = evernote.clientFactory();
assertThat(clientFactory, is(notNullValue()));
Map<String, String> customHeaders = (Map<String, String>) ReflectionTestUtils.getField(clientFactory, "customHeaders");
assertThat(customHeaders, is(notNullValue()));
assertThat(customHeaders.size(), is(2));
assertThat(customHeaders, hasEntry("bar", "BAR"));
assertThat(customHeaders, hasEntry("bar", "BAR"));
}
示例9: EverNoteHelp
import com.evernote.clients.ClientFactory; //导入依赖的package包/类
public EverNoteHelp() throws Exception {
// Set up the UserStore client and check that we can speak to the server
EvernoteAuth evernoteAuth = new EvernoteAuth(EvernoteService.SANDBOX,
AUTH_TOKEN);
ClientFactory factory = ClientFactory.getInstance(evernoteAuth);
userStore = factory.createUserStoreClient();
boolean versionOk = userStore.checkVersion("Evernote EDAMDemo (Java)",
com.evernote.edam.userstore.Constants.EDAM_VERSION_MAJOR,
com.evernote.edam.userstore.Constants.EDAM_VERSION_MINOR);
if (!versionOk) {
}
noteStore = factory.createNoteStoreClient();
}
示例10: retrieveEvernoteAuth
import com.evernote.clients.ClientFactory; //导入依赖的package包/类
private EvernoteAuth retrieveEvernoteAuth(ClientFactory clientFactory) {
return (EvernoteAuth) ReflectionTestUtils.getField(clientFactory, "evernoteAuth");
}
示例11: run
import com.evernote.clients.ClientFactory; //导入依赖的package包/类
public void run() throws Exception {
final EvernoteAuth evernoteAuth = new EvernoteAuth(EvernoteService.PRODUCTION, conf.getDevToken());
evernoteAuth.setNoteStoreUrl(conf.getNoteStore());
final ClientFactory clientFactory = new ClientFactory(evernoteAuth);
final NoteStoreClient noteStoreClient;
noteStoreClient = clientFactory.createNoteStoreClient();
final ICalendar ical = new ICalendar();
ical.setProductId("org.tario.enki");
final Pattern eventDatePattern = conf.getEventDatePattern();
final List<Notebook> notebooks = noteStoreClient.listNotebooks();
for (final Notebook notebook : notebooks) {
if (conf.getEventNotebook().equals(notebook.getName())) {
final NoteFilter filter = new NoteFilter();
filter.setNotebookGuid(notebook.getGuid());
final NoteList notes = noteStoreClient.findNotes(filter, 0, 9000);
for (final Note note : notes.getNotes()) {
final VEvent event = new VEvent();
final String title = note.getTitle();
final Matcher matcher = eventDatePattern.matcher(title);
if (matcher.matches()) {
final String day = matcher.group("day");
final String month = matcher.group("month");
final String year = matcher.group("year");
final String fromHour = matcher.group("fromHour");
final String fromMinute = matcher.group("fromMinute");
final String toHour = matcher.group("toHour");
final String toMinute = matcher.group("toMinute");
final LocalDate fromDate = new LocalDate(Integer.parseInt(year), Integer.parseInt(month),
Integer.parseInt(day));
if (fromHour != null && fromMinute != null) {
final LocalTime fromTime = new LocalTime(Integer.parseInt(fromHour),
Integer.parseInt(fromMinute));
final DateStart dateStart = new DateStart(fromDate.toLocalDateTime(fromTime).toDate());
dateStart.setTimezoneId(conf.getEventTimeZone());
event.setDateStart(dateStart);
if (toHour != null && toMinute != null) {
final LocalTime toTime = new LocalTime(Integer.parseInt(toHour),
Integer.parseInt(toMinute));
final DateEnd dateEnd = new DateEnd(fromDate.toLocalDateTime(toTime).toDate());
dateEnd.setTimezoneId(conf.getEventTimeZone());
event.setDateEnd(dateEnd);
} else {
event.setDuration(Duration.builder().hours(1).build());
}
} else {
event.setDateStart(new DateStart(fromDate.toDate(), false));
event.setDuration(Duration.builder().days(1).build());
}
event.setSummary(title);
ical.addEvent(event);
}
}
}
}
Biweekly.write(ical).go(conf.getEventFile());
}
示例12: auth
import com.evernote.clients.ClientFactory; //导入依赖的package包/类
private ClientFactory auth(final String token) {
EvernoteAuth evernoteAuth = new EvernoteAuth(EvernoteUtil.evernoteService(), token);
return new ClientFactory(evernoteAuth);
}
示例13: evernoteNoteStoreGet
import com.evernote.clients.ClientFactory; //导入依赖的package包/类
@Override
public SSEvernoteInfo evernoteNoteStoreGet(final SSEvernoteNoteStoreGetPar par) throws SSErr {
try{
final EvernoteAuth evernoteAuth = new EvernoteAuth (EvernoteService.PRODUCTION, par.authToken);
final ClientFactory clientFactory = new ClientFactory (evernoteAuth);
final UserStoreClient userStore = clientFactory.createUserStoreClient();
final NoteStoreClient noteStore = clientFactory.createNoteStoreClient();
final SSUri shardUri = SSUri.get(userStore.getPublicUserInfo(userStore.getUser().getUsername()).getWebApiUrlPrefix());
final SyncChunkFilter filter = new SyncChunkFilter();
SyncChunk noteStoreSyncChunk;
Integer lastUSN;
filter.setIncludeNotes (true);
filter.setIncludeNoteResources (true);
filter.setIncludeNoteAttributes (true);
filter.setIncludeNotebooks (true);
filter.setIncludeTags (true);
filter.setIncludeSearches (false);
filter.setIncludeResources (true);
filter.setIncludeLinkedNotebooks (true);
filter.setIncludeExpunged (false);
filter.setIncludeNoteApplicationDataFullMap (true);
filter.setIncludeResourceApplicationDataFullMap (true);
filter.setIncludeNoteResourceApplicationDataFullMap (true);
noteStoreSyncChunk =
noteStore.getFilteredSyncChunk(
sql.getUSN(par, par.authToken),
1000000,
filter);
if(noteStoreSyncChunk.isSetChunkHighUSN()){
lastUSN = noteStoreSyncChunk.getChunkHighUSN();
}else{
lastUSN = noteStoreSyncChunk.getUpdateCount();
}
if(
!noteStoreSyncChunk.isSetUpdateCount() ||
!noteStoreSyncChunk.isSetChunkHighUSN() ||
(lastUSN >= noteStoreSyncChunk.getUpdateCount()) && lastUSN >= sql.getUSN(par, par.authToken)){
SSLogU.debug(par.authEmail + " received full evernote content");
}else{
SSLogU.info(par.authEmail + " needs further syncing to retrieve full evernote content");
}
// if(lastUSN != noteStoreSyncChunk.getUpdateCount()){
// SSLogU.warn(par.authEmail + " didnt receive latest information from evernote | more than 1.000.000 (new) entries available");
// }
return SSEvernoteInfo.get(
userStore,
noteStore,
shardUri,
noteStoreSyncChunk,
par.authToken);
// https://sandbox.evernote.com/shard/s1/sh/72ddd50f-5d13-46e3-b32d-d2b314ced5c1/ea77ae0587d735f39a94868ce3ddab5f
}catch(EDAMSystemException edamError){
if(gotToSleep(edamError, par.authEmail)){
return evernoteNoteStoreGet(par);
}else{
SSServErrReg.regErrThrow(edamError);
return null;
}
}catch(Exception error){
SSServErrReg.regErrThrow(error);
return null;
}
}