This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch sandbox/camel-3.x in repository https://gitbox.apache.org/repos/asf/camel.git
commit 8f691ed51335bc7c3b4df1955b24cfd95a92a0f3 Author: Christoph Deppisch <cdeppi...@redhat.com> AuthorDate: Thu Nov 22 09:13:18 2018 +0100 Remove gmail related naming from calendar component Conflicts: components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamEndpoint.java --- .../main/docs/google-calendar-stream-component.adoc | 18 +++++++++--------- .../stream/GoogleCalendarStreamComponent.java | 9 ++++----- .../stream/GoogleCalendarStreamConfiguration.java | 21 ++++++++++----------- .../stream/GoogleCalendarStreamConstants.java | 7 +------ .../stream/GoogleCalendarStreamEndpoint.java | 19 ++++++++----------- .../AbstractGoogleCalendarStreamTestSupport.java | 6 +++--- .../GoogleCalendarStreamComponentConfiguration.java | 10 +++++----- 7 files changed, 40 insertions(+), 50 deletions(-) diff --git a/components/camel-google-calendar/src/main/docs/google-calendar-stream-component.adoc b/components/camel-google-calendar/src/main/docs/google-calendar-stream-component.adoc index 93090f4..624e342 100644 --- a/components/camel-google-calendar/src/main/docs/google-calendar-stream-component.adoc +++ b/components/camel-google-calendar/src/main/docs/google-calendar-stream-component.adoc @@ -12,7 +12,7 @@ Google Calendar uses the https://developers.google.com/accounts/docs/OAuth2[OAuth 2.0 protocol] for authenticating a Google account and authorizing access to user data. Before you can use this component, you will need -to https://developers.google.com/gmail/api/auth/web-server[create an +to https://developers.google.com/calendar/auth[create an account and generate OAuth credentials]. Credentials comprise of a clientId, clientSecret, and a refreshToken. A handy resource for generating a long-lived refreshToken is @@ -27,7 +27,7 @@ for this component: <artifactId>camel-google-calendar</artifactId> <version>2.23.0</version> </dependency> - + ------------------------------------------------------ ### URI Format @@ -36,10 +36,10 @@ The Google Calendar Component uses the following URI format: -------------------------------------------------------- google-calendar-stream://index?[options] - + -------------------------------------------------------- -### GoogleMailStreamComponent +### GoogleCalendarStreamComponent // component options: START @@ -88,14 +88,14 @@ with the following path and query parameters: | *applicationName* (consumer) | Google Calendar application name. Example would be camel-google-calendar/1.0 | | String | *bridgeErrorHandler* (consumer) | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | boolean | *calendarId* (consumer) | The calendarId to be used | primary | String -| *clientId* (consumer) | Client ID of the mail application | | String -| *clientSecret* (consumer) | Client secret of the mail application | | String +| *clientId* (consumer) | Client ID of the calendar application | | String +| *clientSecret* (consumer) | Client secret of the calendar application | | String | *considerLastUpdate* (consumer) | Take into account the lastUpdate of the last event polled as start date for the next poll | false | boolean | *consumeFromNow* (consumer) | Consume events in the selected calendar from now on | true | boolean | *maxResults* (consumer) | Max results to be returned | 10 | int | *query* (consumer) | The query to execute on calendar | | String | *refreshToken* (consumer) | OAuth 2 refresh token. Using this, the Google Calendar component can obtain a new accessToken whenever the current one expires - a necessity if the application is long-lived. | | String -| *scopes* (consumer) | Specifies the level of permissions you want a mail application to have to a user account. See https://developers.google.com/calendar/api/auth/scopes for more info. | | List +| *scopes* (consumer) | Specifies the level of permissions you want a calendar application to have to a user account. See https://developers.google.com/calendar/auth for more info. | | List | *sendEmptyMessageWhenIdle* (consumer) | If the polling consumer did not poll any files, you can enable this option to send an empty message (no body) instead. | false | boolean | *exceptionHandler* (consumer) | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored. | | ExceptionHandler | *exchangePattern* (consumer) | Sets the exchange pattern when the consumer creates an exchange. | | ExchangePattern @@ -148,7 +148,7 @@ The component supports 15 options, which are listed below. ### Consumer -The consumer will poll by default with maxResults equals to 10. +The consumer will poll by default with maxResults equals to 5. For example @@ -157,6 +157,6 @@ For example from("google-calendar-stream://test?markAsRead=true&delay=5000&maxResults=5").to("mock:result"); --------------------------------------------------------- -This route will consume the next ten events starting from the date of polling. +This route will consume the next five events starting from the date of polling. diff --git a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamComponent.java b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamComponent.java index c52caf0..de0a404 100644 --- a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamComponent.java +++ b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamComponent.java @@ -19,7 +19,6 @@ package org.apache.camel.component.google.calendar.stream; import java.util.Map; import com.google.api.services.calendar.Calendar; - import org.apache.camel.CamelContext; import org.apache.camel.Endpoint; import org.apache.camel.component.google.calendar.BatchGoogleCalendarClientFactory; @@ -49,11 +48,11 @@ public class GoogleCalendarStreamComponent extends DefaultComponent { this.configuration = new GoogleCalendarStreamConfiguration(); } - public Calendar getClient(GoogleCalendarStreamConfiguration googleMailConfiguration) { + public Calendar getClient(GoogleCalendarStreamConfiguration endpointConfiguration) { if (client == null) { - client = getClientFactory().makeClient(googleMailConfiguration.getClientId(), googleMailConfiguration.getClientSecret(), configuration.getScopes(), - googleMailConfiguration.getApplicationName(), googleMailConfiguration.getRefreshToken(), - googleMailConfiguration.getAccessToken(), null, null, "me"); + client = getClientFactory().makeClient(endpointConfiguration.getClientId(), endpointConfiguration.getClientSecret(), endpointConfiguration.getScopes(), + endpointConfiguration.getApplicationName(), endpointConfiguration.getRefreshToken(), + endpointConfiguration.getAccessToken(), null, null, "me"); } return client; } diff --git a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConfiguration.java b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConfiguration.java index 8b5648d..4fbc43e 100644 --- a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConfiguration.java +++ b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConfiguration.java @@ -16,11 +16,10 @@ */ package org.apache.camel.component.google.calendar.stream; -import java.util.Arrays; +import java.util.Collections; import java.util.List; import com.google.api.services.calendar.CalendarScopes; - import org.apache.camel.RuntimeCamelException; import org.apache.camel.spi.UriParam; import org.apache.camel.spi.UriParams; @@ -31,7 +30,7 @@ import org.apache.camel.spi.UriPath; */ @UriParams public class GoogleCalendarStreamConfiguration implements Cloneable { - private static final List<String> DEFAULT_SCOPES = Arrays.asList(CalendarScopes.CALENDAR); + private static final List<String> DEFAULT_SCOPES = Collections.singletonList(CalendarScopes.CALENDAR); @UriPath private String index; @@ -59,13 +58,13 @@ public class GoogleCalendarStreamConfiguration implements Cloneable { @UriParam(defaultValue = "10") private int maxResults = 10; - + @UriParam(defaultValue = "primary") private String calendarId = "primary"; - + @UriParam(defaultValue = "true") private boolean consumeFromNow = true; - + @UriParam(defaultValue = "false") private boolean considerLastUpdate; @@ -74,7 +73,7 @@ public class GoogleCalendarStreamConfiguration implements Cloneable { } /** - * Client ID of the mail application + * Client ID of the calendar application */ public void setClientId(String clientId) { this.clientId = clientId; @@ -85,7 +84,7 @@ public class GoogleCalendarStreamConfiguration implements Cloneable { } /** - * Client secret of the mail application + * Client secret of the calendar application */ public void setClientSecret(String clientSecret) { this.clientSecret = clientSecret; @@ -132,8 +131,8 @@ public class GoogleCalendarStreamConfiguration implements Cloneable { } /** - * Specifies the level of permissions you want a mail application to have to - * a user account. See https://developers.google.com/calendar/api/auth/scopes + * Specifies the level of permissions you want a calendar application to have to + * a user account. See https://developers.google.com/calendar/auth * for more info. */ public void setScopes(List<String> scopes) { @@ -187,7 +186,7 @@ public class GoogleCalendarStreamConfiguration implements Cloneable { public boolean isConsumeFromNow() { return consumeFromNow; } - + /** * Consume events in the selected calendar from now on */ diff --git a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConstants.java b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConstants.java index e590b74..6f61d54 100644 --- a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConstants.java +++ b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamConstants.java @@ -21,12 +21,7 @@ package org.apache.camel.component.google.calendar.stream; */ public final class GoogleCalendarStreamConstants { - public static final String MAIL_TO = "CamelGoogleMailStreamTo"; - public static final String MAIL_FROM = "CamelGoogleMailStreamFrom"; - public static final String MAIL_CC = "CamelGoogleMailStreamCc"; - public static final String MAIL_BCC = "CamelGoogleMailStreamBcc"; - public static final String MAIL_SUBJECT = "CamelGoogleMailStreamSubject"; - public static final String MAIL_ID = "CamelGoogleMailId"; + public static final String EVENT_ID = "CamelGoogleCalendarEventId"; /** * Prevent instantiation. diff --git a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamEndpoint.java b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamEndpoint.java index 70568aa..24e0fbc 100644 --- a/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamEndpoint.java +++ b/components/camel-google-calendar/src/main/java/org/apache/camel/component/google/calendar/stream/GoogleCalendarStreamEndpoint.java @@ -16,11 +16,8 @@ */ package org.apache.camel.component.google.calendar.stream; -import java.io.UnsupportedEncodingException; - import com.google.api.services.calendar.Calendar; import com.google.api.services.calendar.model.Event; - import org.apache.camel.Consumer; import org.apache.camel.Exchange; import org.apache.camel.ExchangePattern; @@ -35,15 +32,15 @@ import org.apache.camel.spi.UriParam; /** * The google-calendar component provides access to Google Calendar in a streaming mod. */ -@UriEndpoint(firstVersion = "2.23.0", - scheme = "google-calendar-stream", - title = "Google Calendar Stream", - syntax = "google-calendar-stream:index", +@UriEndpoint(firstVersion = "2.23.0", + scheme = "google-calendar-stream", + title = "Google Calendar Stream", + syntax = "google-calendar-stream:index", consumerClass = GoogleCalendarStreamConsumer.class, consumerOnly = true, label = "api,cloud") public class GoogleCalendarStreamEndpoint extends ScheduledPollEndpoint { - + @UriParam private GoogleCalendarStreamConfiguration configuration; @@ -85,11 +82,11 @@ public class GoogleCalendarStreamEndpoint extends ScheduledPollEndpoint { return true; } - public Exchange createExchange(ExchangePattern pattern, Event event) throws UnsupportedEncodingException { - - Exchange exchange = super.createExchange(); + public Exchange createExchange(ExchangePattern pattern, Event event) { + Exchange exchange = super.createExchange(pattern); Message message = exchange.getIn(); message.setBody(event); + message.setHeader(GoogleCalendarStreamConstants.EVENT_ID, event.getId()); return exchange; } } diff --git a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/stream/AbstractGoogleCalendarStreamTestSupport.java b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/stream/AbstractGoogleCalendarStreamTestSupport.java index d95a2c6..0f0e5f9 100644 --- a/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/stream/AbstractGoogleCalendarStreamTestSupport.java +++ b/components/camel-google-calendar/src/test/java/org/apache/camel/component/google/calendar/stream/AbstractGoogleCalendarStreamTestSupport.java @@ -26,7 +26,7 @@ import org.apache.camel.test.junit4.CamelTestSupport; import org.apache.camel.support.IntrospectionSupport; /** - * Abstract base class for GoogleMail Integration tests generated by Camel API + * Abstract base class for GoogleCalendar Integration tests generated by Camel API * component maven plugin. */ public class AbstractGoogleCalendarStreamTestSupport extends CamelTestSupport { @@ -40,7 +40,7 @@ public class AbstractGoogleCalendarStreamTestSupport extends CamelTestSupport { final CamelContext context = super.createCamelContext(); - // read GoogleMail component configuration from TEST_OPTIONS_PROPERTIES + // read GoogleCalendar component configuration from TEST_OPTIONS_PROPERTIES final Properties properties = new Properties(); try { properties.load(getClass().getResourceAsStream(TEST_OPTIONS_PROPERTIES)); @@ -56,7 +56,7 @@ public class AbstractGoogleCalendarStreamTestSupport extends CamelTestSupport { final GoogleCalendarStreamConfiguration configuration = new GoogleCalendarStreamConfiguration(); IntrospectionSupport.setProperties(configuration, options); - // add GoogleMailComponent to Camel context + // add GoogleCalendarComponent to Camel context final GoogleCalendarStreamComponent component = new GoogleCalendarStreamComponent(context); component.setConfiguration(configuration); context.addComponent("google-calendar-stream", component); diff --git a/platforms/spring-boot/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/stream/springboot/GoogleCalendarStreamComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/stream/springboot/GoogleCalendarStreamComponentConfiguration.java index 5acded1..d8efcb8 100644 --- a/platforms/spring-boot/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/stream/springboot/GoogleCalendarStreamComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-google-calendar-starter/src/main/java/org/apache/camel/component/google/calendar/stream/springboot/GoogleCalendarStreamComponentConfiguration.java @@ -24,7 +24,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties; /** * The google-calendar component provides access to Google Calendar in a * streaming mod. - * + * * Generated by camel-package-maven-plugin - do not edit this file! */ @Generated("org.apache.camel.maven.packaging.SpringBootAutoConfigurationMojo") @@ -84,11 +84,11 @@ public class GoogleCalendarStreamComponentConfiguration public static class GoogleCalendarStreamConfigurationNestedConfiguration { public static final Class CAMEL_NESTED_CLASS = org.apache.camel.component.google.calendar.stream.GoogleCalendarStreamConfiguration.class; /** - * Client ID of the mail application + * Client ID of the calendar application */ private String clientId; /** - * Client secret of the mail application + * Client secret of the calendar application */ private String clientSecret; /** @@ -108,9 +108,9 @@ public class GoogleCalendarStreamComponentConfiguration */ private String applicationName; /** - * Specifies the level of permissions you want a mail application to + * Specifies the level of permissions you want a calendar application to * have to a user account. See - * https://developers.google.com/calendar/api/auth/scopes for more info. + * https://developers.google.com/calendar/auth for more info. */ private List scopes; /**