You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2020/03/19 10:12:31 UTC
[camel-quarkus] branch master updated: Add Google Calendar extension
This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push:
new fcda864 Add Google Calendar extension
fcda864 is described below
commit fcda864c160a579c3366fbb5852d26be4da3f888
Author: James Netherton <ja...@gmail.com>
AuthorDate: Thu Mar 19 08:23:39 2020 +0000
Add Google Calendar extension
Fixes #805
---
.../pages/list-of-camel-quarkus-extensions.adoc | 10 +-
extensions/google-calendar/deployment/pom.xml | 79 ++++++++++
.../deployment/GoogleCalendarProcessor.java | 67 +++++++++
extensions/google-calendar/pom.xml | 39 +++++
extensions/google-calendar/runtime/pom.xml | 87 +++++++++++
.../main/resources/META-INF/quarkus-extension.yaml | 31 ++++
extensions/pom.xml | 1 +
integration-tests/google/pom.xml | 6 +-
.../google/it/GoogleCalendarResource.java | 161 +++++++++++++++++++++
.../src/main/resources/application.properties | 6 +
.../component/google/it/GoogleComponentsTest.java | 79 ++++++++++
poms/bom-deployment/pom.xml | 5 +
poms/bom/pom.xml | 10 ++
13 files changed, 579 insertions(+), 2 deletions(-)
diff --git a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
index 495fb83..f738b20 100644
--- a/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
+++ b/docs/modules/ROOT/pages/list-of-camel-quarkus-extensions.adoc
@@ -18,7 +18,7 @@ In case you are missing some Camel feature in the list:
== Camel Components
// components: START
-Number of Camel components: 83 in 72 JAR artifacts (0 deprecated)
+Number of Camel components: 85 in 73 JAR artifacts (0 deprecated)
[width="100%",cols="4,1,1,5",options="header"]
|===
@@ -173,6 +173,14 @@ Level | Since | Description
`ftps:host:port/directoryName` | Native +
Stable | 1.0.0-M1 | The ftps (FTP secure SSL/TLS) component is used for uploading or downloading files from FTP servers.
+| link:https://camel.apache.org/components/latest/google-calendar-component.html[Google Calendar] (camel-quarkus-google-calendar) +
+`google-calendar:apiName/methodName` | Native +
+ Stable | 1.0.0-M6 | The google-calendar component provides access to Google Calendar.
+
+| link:https://camel.apache.org/components/latest/google-calendar-stream-component.html[Google Calendar Stream] (camel-quarkus-google-calendar) +
+`google-calendar-stream:index` | Native +
+ Stable | 1.0.0-M6 | The google-calendar-stream component provides access to Google Calendar in a streaming mode.
+
| link:https://camel.apache.org/components/latest/google-drive-component.html[Google Drive] (camel-quarkus-google-drive) +
`google-drive:apiName/methodName` | Native +
Stable | 1.0.0-M6 | The google-drive component provides access to Google Drive file storage service.
diff --git a/extensions/google-calendar/deployment/pom.xml b/extensions/google-calendar/deployment/pom.xml
new file mode 100644
index 0000000..cf6f3af
--- /dev/null
+++ b/extensions/google-calendar/deployment/pom.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-google-calendar-parent</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-google-calendar-deployment</artifactId>
+ <name>Camel Quarkus :: Google Calendar :: Deployment</name>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bom-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-support-google-http-client-deployment</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-google-calendar</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/extensions/google-calendar/deployment/src/main/java/org/apache/camel/quarkus/component/google/calendar/deployment/GoogleCalendarProcessor.java b/extensions/google-calendar/deployment/src/main/java/org/apache/camel/quarkus/component/google/calendar/deployment/GoogleCalendarProcessor.java
new file mode 100644
index 0000000..54a5c3c
--- /dev/null
+++ b/extensions/google-calendar/deployment/src/main/java/org/apache/camel/quarkus/component/google/calendar/deployment/GoogleCalendarProcessor.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.google.calendar.deployment;
+
+import java.util.Collection;
+
+import io.quarkus.deployment.annotations.BuildProducer;
+import io.quarkus.deployment.annotations.BuildStep;
+import io.quarkus.deployment.builditem.AdditionalApplicationArchiveMarkerBuildItem;
+import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
+import io.quarkus.deployment.builditem.FeatureBuildItem;
+import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import org.apache.camel.quarkus.core.deployment.UnbannedReflectiveBuildItem;
+import org.jboss.jandex.AnnotationInstance;
+import org.jboss.jandex.AnnotationTarget;
+import org.jboss.jandex.DotName;
+import org.jboss.jandex.IndexView;
+
+class GoogleCalendarProcessor {
+
+ private static final String FEATURE = "camel-google-calendar";
+
+ @BuildStep
+ FeatureBuildItem feature() {
+ return new FeatureBuildItem(FEATURE);
+ }
+
+ @BuildStep
+ void applicationArchiveMarkers(BuildProducer<AdditionalApplicationArchiveMarkerBuildItem> applicationArchiveMarker) {
+ applicationArchiveMarker.produce(new AdditionalApplicationArchiveMarkerBuildItem("com/google/api/services/calendar"));
+ }
+
+ @BuildStep
+ void registerForReflection(BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
+ BuildProducer<UnbannedReflectiveBuildItem> unbannedClass, CombinedIndexBuildItem combinedIndex) {
+ IndexView index = combinedIndex.getIndex();
+
+ // Google calendar component configuration class reflection
+ Collection<AnnotationInstance> uriParams = index
+ .getAnnotations(DotName.createSimple("org.apache.camel.spi.UriParams"));
+
+ String[] googleDriveConfigClasses = uriParams.stream()
+ .map(annotation -> annotation.target())
+ .filter(annotationTarget -> annotationTarget.kind().equals(AnnotationTarget.Kind.CLASS))
+ .map(annotationTarget -> annotationTarget.asClass().name().toString())
+ .filter(className -> className.startsWith("org.apache.camel.component.google.calendar"))
+ .toArray(String[]::new);
+
+ reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, googleDriveConfigClasses));
+ unbannedClass.produce(new UnbannedReflectiveBuildItem(googleDriveConfigClasses));
+ }
+
+}
diff --git a/extensions/google-calendar/pom.xml b/extensions/google-calendar/pom.xml
new file mode 100644
index 0000000..021dcdf
--- /dev/null
+++ b/extensions/google-calendar/pom.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-build-parent</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>../../poms/build-parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-google-calendar-parent</artifactId>
+ <name>Camel Quarkus :: Google Calendar</name>
+ <packaging>pom</packaging>
+
+ <modules>
+ <module>deployment</module>
+ <module>runtime</module>
+ </modules>
+</project>
diff --git a/extensions/google-calendar/runtime/pom.xml b/extensions/google-calendar/runtime/pom.xml
new file mode 100644
index 0000000..deba0e7
--- /dev/null
+++ b/extensions/google-calendar/runtime/pom.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-google-calendar-parent</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>camel-quarkus-google-calendar</artifactId>
+ <name>Camel Quarkus :: Google Calendar :: Runtime</name>
+ <description>The google-calendar component provides access to Google Calendar.</description>
+
+ <properties>
+ <firstVersion>1.0.0-M6</firstVersion>
+ </properties>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-bom</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-support-google-http-client</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-google-calendar</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-bootstrap-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <annotationProcessorPaths>
+ <path>
+ <groupId>io.quarkus</groupId>
+ <artifactId>quarkus-extension-processor</artifactId>
+ <version>${quarkus.version}</version>
+ </path>
+ </annotationProcessorPaths>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/extensions/google-calendar/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/google-calendar/runtime/src/main/resources/META-INF/quarkus-extension.yaml
new file mode 100644
index 0000000..d4aba8b
--- /dev/null
+++ b/extensions/google-calendar/runtime/src/main/resources/META-INF/quarkus-extension.yaml
@@ -0,0 +1,31 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+---
+name: "Google Calendar"
+description: "The google-calendar component provides access to Google Calendar."
+metadata:
+ keywords:
+ - "api"
+ - "camel"
+ - "calendar"
+ - "cloud"
+ - "google"
+ guide: "https://quarkus.io/guides/camel"
+ categories:
+ - "integration"
+ status: "stable"
diff --git a/extensions/pom.xml b/extensions/pom.xml
index a1c6078..9a5a16b 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -67,6 +67,7 @@
<module>file</module>
<module>file-watch</module>
<module>ftp</module>
+ <module>google-calendar</module>
<module>google-drive</module>
<module>google-mail</module>
<module>graphql</module>
diff --git a/integration-tests/google/pom.xml b/integration-tests/google/pom.xml
index 9c79ec9..3ccc3dd 100644
--- a/integration-tests/google/pom.xml
+++ b/integration-tests/google/pom.xml
@@ -38,12 +38,16 @@
<!-- explicit dependencies of this module in the Maven sense, although they are required by the Quarkus Maven plugin. -->
<!-- Please update rule whenever you change the dependencies of this module by running -->
<!-- mvn process-resources -Pformat from the root directory -->
- <mvnd.builder.rule>camel-quarkus-google-drive-deployment,camel-quarkus-google-mail-deployment,camel-quarkus-support-policy-deployment</mvnd.builder.rule>
+ <mvnd.builder.rule>camel-quarkus-google-calendar-deployment,camel-quarkus-google-drive-deployment,camel-quarkus-google-mail-deployment,camel-quarkus-support-policy-deployment</mvnd.builder.rule>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-google-calendar</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-google-drive</artifactId>
</dependency>
<dependency>
diff --git a/integration-tests/google/src/main/java/org/apache/camel/quarkus/component/google/it/GoogleCalendarResource.java b/integration-tests/google/src/main/java/org/apache/camel/quarkus/component/google/it/GoogleCalendarResource.java
new file mode 100644
index 0000000..f9ae956
--- /dev/null
+++ b/integration-tests/google/src/main/java/org/apache/camel/quarkus/component/google/it/GoogleCalendarResource.java
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.google.it;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.inject.Inject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.PATCH;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import com.google.api.client.googleapis.json.GoogleJsonResponseException;
+import com.google.api.services.calendar.model.Calendar;
+import com.google.api.services.calendar.model.Event;
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.ProducerTemplate;
+
+@Path("/google-calendar")
+public class GoogleCalendarResource {
+
+ @Inject
+ ProducerTemplate producerTemplate;
+
+ @Path("/create")
+ @POST
+ @Consumes(MediaType.TEXT_PLAIN)
+ @Produces(MediaType.TEXT_PLAIN)
+ public Response createCalendar(String summary) throws Exception {
+ Calendar calendar = new Calendar();
+ calendar.setSummary(summary);
+ calendar.setTimeZone("Europe/London");
+ Calendar response = producerTemplate.requestBody("google-calendar://calendars/insert?inBody=content", calendar,
+ Calendar.class);
+ return Response
+ .created(new URI("https://camel.apache.org/"))
+ .entity(response.getId())
+ .build();
+ }
+
+ @Path("/create/event")
+ @POST
+ @Consumes(MediaType.TEXT_PLAIN)
+ @Produces(MediaType.TEXT_PLAIN)
+ public Response createCalendarEvent(@QueryParam("calendarId") String calendarId, String eventText) throws Exception {
+ Map<String, Object> headers = new HashMap<>();
+ headers.put("CamelGoogleCalendar.calendarId", calendarId);
+ headers.put("CamelGoogleCalendar.text", eventText);
+ Event response = producerTemplate.requestBodyAndHeaders("google-calendar://events/quickAdd", null, headers,
+ Event.class);
+ return Response
+ .created(new URI("https://camel.apache.org/"))
+ .entity(response.getId())
+ .build();
+ }
+
+ @Path("/read")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public Response readCalendar(@QueryParam("calendarId") String calendarId) {
+ try {
+ Calendar response = producerTemplate.requestBody("google-calendar://calendars/get?inBody=calendarId", calendarId,
+ Calendar.class);
+ if (response != null) {
+ return Response.ok(response.getSummary()).build();
+ } else {
+ return Response.status(Response.Status.NOT_FOUND).build();
+ }
+ } catch (CamelExecutionException e) {
+ Exception exchangeException = e.getExchange().getException();
+ if (exchangeException != null && exchangeException.getCause() instanceof GoogleJsonResponseException) {
+ GoogleJsonResponseException originalException = (GoogleJsonResponseException) exchangeException.getCause();
+ return Response.status(originalException.getStatusCode()).build();
+ }
+ throw e;
+ }
+ }
+
+ @Path("/read/event")
+ @GET
+ @Produces(MediaType.TEXT_PLAIN)
+ public Response readCalendarEvent(@QueryParam("calendarId") String calendarId, @QueryParam("eventId") String eventId) {
+ Map<String, Object> headers = new HashMap<>();
+ headers.put("CamelGoogleCalendar.calendarId", calendarId);
+ headers.put("CamelGoogleCalendar.eventId", eventId);
+ try {
+ Event response = producerTemplate.requestBodyAndHeaders("google-calendar://events/get", null, headers, Event.class);
+ if (response != null) {
+ return Response.ok(response.getSummary()).build();
+ } else {
+ return Response.status(Response.Status.NOT_FOUND).build();
+ }
+ } catch (CamelExecutionException e) {
+ Exception exchangeException = e.getExchange().getException();
+ if (exchangeException != null && exchangeException.getCause() instanceof GoogleJsonResponseException) {
+ GoogleJsonResponseException originalException = (GoogleJsonResponseException) exchangeException.getCause();
+ return Response.status(originalException.getStatusCode()).build();
+ }
+ throw e;
+ }
+ }
+
+ @Path("/update/event")
+ @PATCH
+ public Response updateCalendarEvent(@QueryParam("calendarId") String calendarId, @QueryParam("eventId") String eventId) {
+ Map<String, Object> headers = new HashMap<>();
+ headers.put("CamelGoogleCalendar.calendarId", calendarId);
+ headers.put("CamelGoogleCalendar.eventId", eventId);
+ try {
+ Event response = producerTemplate.requestBodyAndHeaders("google-calendar://events/get", null, headers,
+ Event.class);
+ if (response == null) {
+ return Response.status(Response.Status.NOT_FOUND).build();
+ }
+ response.setSummary(response.getSummary() + " Updated");
+
+ headers = new HashMap<>();
+ headers.put("CamelGoogleCalendar.calendarId", calendarId);
+ headers.put("CamelGoogleCalendar.eventId", eventId);
+ headers.put("CamelGoogleCalendar.content", response);
+ producerTemplate.requestBodyAndHeaders("google-calendar://events/update", null, headers);
+ return Response.ok().build();
+ } catch (CamelExecutionException e) {
+ Exception exchangeException = e.getExchange().getException();
+ if (exchangeException != null && exchangeException.getCause() instanceof GoogleJsonResponseException) {
+ GoogleJsonResponseException originalException = (GoogleJsonResponseException) exchangeException.getCause();
+ return Response.status(originalException.getStatusCode()).build();
+ }
+ throw e;
+ }
+ }
+
+ @Path("/delete")
+ @DELETE
+ public Response deleteCalendar(@QueryParam("calendarId") String calendarId) {
+ producerTemplate.requestBody("google-calendar://calendars/delete?inBody=calendarId", calendarId);
+ return Response.status(Response.Status.NO_CONTENT).build();
+ }
+}
diff --git a/integration-tests/google/src/main/resources/application.properties b/integration-tests/google/src/main/resources/application.properties
index 9a53a4d..c54d3a0 100644
--- a/integration-tests/google/src/main/resources/application.properties
+++ b/integration-tests/google/src/main/resources/application.properties
@@ -15,6 +15,12 @@
## limitations under the License.
## ---------------------------------------------------------------------------
+# Camel Google Calendar
+camel.component.google-calendar.configuration.application-name={{env:GOOGLE_API_APPLICATION_NAME}}
+camel.component.google-calendar.configuration.client-id={{env:GOOGLE_API_CLIENT_ID}}
+camel.component.google-calendar.configuration.client-secret={{env:GOOGLE_API_CLIENT_SECRET}}
+camel.component.google-calendar.configuration.refresh-token={{env:GOOGLE_API_REFRESH_TOKEN}}
+
# Camel Google Mail
camel.component.google-mail.configuration.application-name={{env:GOOGLE_API_APPLICATION_NAME}}
camel.component.google-mail.configuration.client-id={{env:GOOGLE_API_CLIENT_ID}}
diff --git a/integration-tests/google/src/test/java/org/apache/camel/quarkus/component/google/it/GoogleComponentsTest.java b/integration-tests/google/src/test/java/org/apache/camel/quarkus/component/google/it/GoogleComponentsTest.java
index 54875e7..b609a91 100644
--- a/integration-tests/google/src/test/java/org/apache/camel/quarkus/component/google/it/GoogleComponentsTest.java
+++ b/integration-tests/google/src/test/java/org/apache/camel/quarkus/component/google/it/GoogleComponentsTest.java
@@ -34,6 +34,85 @@ import static org.hamcrest.Matchers.is;
class GoogleComponentsTest {
@Test
+ public void testGoogleCalendarComponent() throws InterruptedException {
+ String summary = "Camel Quarkus Google Calendar";
+ String eventText = summary += " Event";
+
+ // Create calendar
+ String calendarId = RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .body(summary)
+ .post("/google-calendar/create")
+ .then()
+ .statusCode(201)
+ .extract()
+ .body()
+ .asString();
+
+ // Read calendar
+ RestAssured.given()
+ .queryParam("calendarId", calendarId)
+ .get("/google-calendar/read")
+ .then()
+ .statusCode(200)
+ .body(is(summary));
+
+ // Create event
+ String eventId = RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .queryParam("calendarId", calendarId)
+ .body(eventText)
+ .post("/google-calendar/create/event")
+ .then()
+ .statusCode(201)
+ .extract()
+ .body()
+ .asString();
+
+ // Read event
+ RestAssured.given()
+ .queryParam("calendarId", calendarId)
+ .queryParam("eventId", eventId)
+ .get("/google-calendar/read/event")
+ .then()
+ .statusCode(200)
+ .body(is(eventText));
+
+ // Update event
+ RestAssured.given()
+ .contentType(ContentType.TEXT)
+ .queryParam("calendarId", calendarId)
+ .queryParam("eventId", eventId)
+ .patch("/google-calendar/update/event")
+ .then()
+ .statusCode(200);
+
+ RestAssured.given()
+ .queryParam("calendarId", calendarId)
+ .queryParam("eventId", eventId)
+ .get("/google-calendar/read/event")
+ .then()
+ .statusCode(200)
+ .body(is(eventText + " Updated"));
+
+ // Delete calendar
+ RestAssured.given()
+ .queryParam("calendarId", calendarId)
+ .delete("/google-calendar/delete")
+ .then()
+ .statusCode(204);
+
+ // Wait for calendar deletion to occur
+ Thread.sleep(500);
+
+ RestAssured.given()
+ .queryParam("calendarId", calendarId)
+ .get("/google-calendar/read")
+ .then()
+ .statusCode(404);
+ }
+
+ @Test
public void testGoogleDriveComponent() {
String title = UUID.randomUUID().toString();
diff --git a/poms/bom-deployment/pom.xml b/poms/bom-deployment/pom.xml
index 8fa0fcf..29078aa 100644
--- a/poms/bom-deployment/pom.xml
+++ b/poms/bom-deployment/pom.xml
@@ -271,6 +271,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-google-calendar-deployment</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-google-drive-deployment</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>
diff --git a/poms/bom/pom.xml b/poms/bom/pom.xml
index b105e7c..62ebed9 100644
--- a/poms/bom/pom.xml
+++ b/poms/bom/pom.xml
@@ -314,6 +314,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-google-calendar</artifactId>
+ <version>${camel.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-google-drive</artifactId>
<version>${camel.version}</version>
</dependency>
@@ -957,6 +962,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-google-calendar</artifactId>
+ <version>${camel-quarkus.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-google-drive</artifactId>
<version>${camel-quarkus.version}</version>
</dependency>