当前位置: 首页>>代码示例>>Java>>正文


Java EvernoteAuth类代码示例

本文整理汇总了Java中com.evernote.auth.EvernoteAuth的典型用法代码示例。如果您正苦于以下问题:Java EvernoteAuth类的具体用法?Java EvernoteAuth怎么用?Java EvernoteAuth使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EvernoteAuth类属于com.evernote.auth包,在下文中一共展示了EvernoteAuth类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: MyEvernoteService

import com.evernote.auth.EvernoteAuth; //导入依赖的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.auth.EvernoteAuth; //导入依赖的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.auth.EvernoteAuth; //导入依赖的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.auth.EvernoteAuth; //导入依赖的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.auth.EvernoteAuth; //导入依赖的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: HelpEverNote

import com.evernote.auth.EvernoteAuth; //导入依赖的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

示例7: EverNoteHelp

import com.evernote.auth.EvernoteAuth; //导入依赖的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

示例8: EvernoteTemplate

import com.evernote.auth.EvernoteAuth; //导入依赖的package包/类
public EvernoteTemplate(EvernoteService evernoteService, EvernoteOAuthToken accessToken) {

		int userId = 0;
		try {
			userId = Integer.parseInt(accessToken.getEdamUserId());
		} catch (NumberFormatException e) {
		}
		this.evernoteAuth = new EvernoteAuth(evernoteService, accessToken.getValue(), accessToken.getEdamNoteStoreUrl(), accessToken.getEdamWebApiUrlPrefix(), userId);

		this.evernoteService = evernoteService;
		this.clientFactory = new ClientFactory(this.evernoteAuth);
	}
 
开发者ID:ttddyy,项目名称:spring-social-evernote,代码行数:13,代码来源:EvernoteTemplate.java

示例9: testGetEvernoteAuth

import com.evernote.auth.EvernoteAuth; //导入依赖的package包/类
@Test
public void testGetEvernoteAuth() {
	EvernoteTemplate template = new EvernoteTemplate(EvernoteService.SANDBOX, "access_token");
	EvernoteAuth auth = template.getEvernoteAuth();
	assertThat(auth, is(notNullValue()));
	assertThat(auth.getToken(), is("access_token"));
}
 
开发者ID:ttddyy,项目名称:spring-social-evernote,代码行数:8,代码来源:EvernoteTemplateTest.java

示例10: retrieveEvernoteAuth

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

示例11: retrieveEvernoteService

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

示例12: run

import com.evernote.auth.EvernoteAuth; //导入依赖的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

示例13: auth

import com.evernote.auth.EvernoteAuth; //导入依赖的package包/类
private ClientFactory auth(final String token) {
    EvernoteAuth evernoteAuth = new EvernoteAuth(EvernoteUtil.evernoteService(), token);
    return new ClientFactory(evernoteAuth);
}
 
开发者ID:LTTPP,项目名称:Eemory,代码行数:5,代码来源:StoreClientFactory.java

示例14: evernoteNoteStoreGet

import com.evernote.auth.EvernoteAuth; //导入依赖的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

示例15: getEvernoteAuth

import com.evernote.auth.EvernoteAuth; //导入依赖的package包/类
public EvernoteAuth getEvernoteAuth() {
	return evernoteAuth;
}
 
开发者ID:ttddyy,项目名称:spring-social-evernote,代码行数:4,代码来源:EvernoteTemplate.java


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