• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ClientFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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();
}
 
开发者ID:windsource,项目名称:evernote-markdown-sync,代码行数:30,代码来源:MyEvernoteService.java


示例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()));

}
 
开发者ID:ttddyy,项目名称:evernote-rest-webapp,代码行数:24,代码来源:ApplicationConfigEvernoteBeanTest.java


示例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"));

}
 
开发者ID:ttddyy,项目名称:evernote-rest-webapp,代码行数:27,代码来源:ApplicationConfigEvernoteBeanTest.java


示例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));

}
 
开发者ID:ttddyy,项目名称:evernote-rest-webapp,代码行数:27,代码来源:ApplicationConfigEvernoteBeanTest.java


示例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"));

}
 
开发者ID:ttddyy,项目名称:evernote-rest-webapp,代码行数:23,代码来源:ApplicationConfigEvernoteBeanTest.java


示例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"));

}
 
开发者ID:ttddyy,项目名称:evernote-rest-webapp,代码行数:22,代码来源:ApplicationConfigEvernoteBeanTest.java


示例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();
}
 
开发者ID:winture,项目名称:wt-studio,代码行数:24,代码来源:HelpEverNote.java


示例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"));

}
 
开发者ID:ttddyy,项目名称:evernote-rest-webapp,代码行数:28,代码来源:ApplicationConfigEvernoteBeanTest.java


示例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();
}
 
开发者ID:winture,项目名称:wt-studio,代码行数:15,代码来源:EverNoteHelp.java


示例10: retrieveEvernoteAuth

import com.evernote.clients.ClientFactory; //导入依赖的package包/类
private EvernoteAuth retrieveEvernoteAuth(ClientFactory clientFactory) {
	return (EvernoteAuth) ReflectionTestUtils.getField(clientFactory, "evernoteAuth");
}
 
开发者ID:ttddyy,项目名称:evernote-rest-webapp,代码行数:4,代码来源:ApplicationConfigEvernoteBeanTest.java


示例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());
}
 
开发者ID:tarioch,项目名称:enki,代码行数:68,代码来源:Enki.java


示例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);
}
 
开发者ID:LTTPP,项目名称:Eemory,代码行数:5,代码来源:StoreClientFactory.java


示例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;
    }
  }
 
开发者ID:learning-layers,项目名称:SocialSemanticServer,代码行数:76,代码来源:SSEvernoteImpl.java



注:本文中的com.evernote.clients.ClientFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ICape类代码示例发布时间:2022-05-22
下一篇:
Java CombinerValueUpdater类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap