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 2013/06/26 20:27:29 UTC
[1/2] CAMEL-6493 - first cut of camel-yammer,
component to interact with yammer social network
Updated Branches:
refs/heads/master 568f008b4 -> a18e7e98b
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 3b5e6d9..69dbecb 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -327,6 +327,7 @@
<scala-version>2.10.1</scala-version>
<scala-maven-plugin-version>3.1.2</scala-maven-plugin-version>
<scalatest-version>2.0.M5b</scalatest-version>
+ <scribe-version>1.3.5</scribe-version>
<scriptengines-version>1.1</scriptengines-version>
<serp-bundle-version>1.14.1_1</serp-bundle-version>
<servicemix-specs-version>2.2.0</servicemix-specs-version>
[2/2] git commit: CAMEL-6493 - first cut of camel-yammer,
component to interact with yammer social network
Posted by ja...@apache.org.
CAMEL-6493 - first cut of camel-yammer, component to interact with yammer social network
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a18e7e98
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a18e7e98
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a18e7e98
Branch: refs/heads/master
Commit: a18e7e98bf1cc65191415e3d699c4a2859426d35
Parents: 568f008
Author: Jonathan Anstey <ja...@gmail.com>
Authored: Wed Jun 26 15:55:19 2013 -0230
Committer: Jonathan Anstey <ja...@gmail.com>
Committed: Wed Jun 26 15:55:19 2013 -0230
----------------------------------------------------------------------
components/camel-yammer/pom.xml | 74 ++++
.../camel/component/yammer/ApiRequestor.java | 24 ++
.../component/yammer/ScribeApiRequestor.java | 64 +++
.../camel/component/yammer/YammerComponent.java | 83 ++++
.../component/yammer/YammerConfiguration.java | 115 ++++++
.../camel/component/yammer/YammerConstants.java | 25 ++
.../camel/component/yammer/YammerEndpoint.java | 71 ++++
.../component/yammer/YammerFunctionType.java | 30 ++
.../yammer/YammerMessagePollingConsumer.java | 71 ++++
.../component/yammer/model/Attachment.java | 393 +++++++++++++++++++
.../camel/component/yammer/model/Body.java | 57 +++
.../yammer/model/FollowedReference.java | 48 +++
.../camel/component/yammer/model/Image.java | 59 +++
.../camel/component/yammer/model/LikedBy.java | 50 +++
.../camel/component/yammer/model/Message.java | 240 +++++++++++
.../camel/component/yammer/model/Messages.java | 70 ++++
.../camel/component/yammer/model/Meta.java | 133 +++++++
.../camel/component/yammer/model/Name.java | 60 +++
.../camel/component/yammer/model/Realtime.java | 60 +++
.../camel/component/yammer/model/Reference.java | 96 +++++
.../yammer/model/ThreadedExtended.java | 24 ++
.../yammer/scribe/JsonTokenExtractor.java | 49 +++
.../component/yammer/scribe/YammerApi.java | 41 ++
.../yammer/utils/YammerAccessCodeGenerator.java | 74 ++++
.../services/org/apache/camel/component/yammer | 1 +
.../component/yammer/TestApiRequestor.java | 33 ++
.../component/yammer/YammerComponentTest.java | 66 ++++
.../src/test/resources/log4j.properties | 30 ++
.../src/test/resources/messages.json | 72 ++++
parent/pom.xml | 1 +
30 files changed, 2214 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-yammer/pom.xml b/components/camel-yammer/pom.xml
new file mode 100644
index 0000000..a2d52d6
--- /dev/null
+++ b/components/camel-yammer/pom.xml
@@ -0,0 +1,74 @@
+<?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/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>components</artifactId>
+ <version>2.12-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-yammer</artifactId>
+ <packaging>bundle</packaging>
+ <name>Camel :: Yammer</name>
+ <description>Camel Yammer Component</description>
+
+ <properties>
+ <camel.osgi.export.pkg>org.apache.camel.component.yammer.*</camel.osgi.export.pkg>
+ <camel.osgi.export.service>org.apache.camel.spi.ComponentResolver;component=yammer</camel.osgi.export.service>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ <version>${jackson-version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.scribe</groupId>
+ <artifactId>scribe</artifactId>
+ <version>${scribe-version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/ApiRequestor.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/ApiRequestor.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/ApiRequestor.java
new file mode 100644
index 0000000..0deed1c
--- /dev/null
+++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/ApiRequestor.java
@@ -0,0 +1,24 @@
+/**
+ * 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.component.yammer;
+
+
+public interface ApiRequestor {
+
+ String send() throws Exception;
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/ScribeApiRequestor.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/ScribeApiRequestor.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/ScribeApiRequestor.java
new file mode 100644
index 0000000..b18ef91
--- /dev/null
+++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/ScribeApiRequestor.java
@@ -0,0 +1,64 @@
+/**
+ * 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.component.yammer;
+
+import org.scribe.model.OAuthConstants;
+import org.scribe.model.OAuthRequest;
+import org.scribe.model.Response;
+import org.scribe.model.Verb;
+
+public class ScribeApiRequestor implements ApiRequestor {
+
+ String apiUrl;
+ String apiAccessToken;
+
+ public ScribeApiRequestor(String apiUrl, String apiAccessToken) {
+ this.apiUrl = apiUrl;
+ this.apiAccessToken = apiAccessToken;
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.camel.component.yammer.ApiRequestor#send()
+ */
+ @Override
+ public String send() throws Exception {
+ OAuthRequest request = new OAuthRequest(Verb.GET, apiUrl);
+ request.addQuerystringParameter(OAuthConstants.ACCESS_TOKEN, apiAccessToken);
+ Response response = request.send();
+ if (response.isSuccessful()) {
+ return response.getBody();
+ } else {
+ throw new Exception(String.format("Failed to poll %s. Got response code %s and body: %s", getApiUrl(), response.getCode(), response.getBody()));
+ }
+ }
+
+ public String getApiUrl() {
+ return apiUrl;
+ }
+
+ public void setApiUrl(String apiUrl) {
+ this.apiUrl = apiUrl;
+ }
+
+ public String getApiAccessToken() {
+ return apiAccessToken;
+ }
+
+ public void setApiAccessToken(String apiAccessToken) {
+ this.apiAccessToken = apiAccessToken;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerComponent.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerComponent.java
new file mode 100644
index 0000000..1f5433d
--- /dev/null
+++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerComponent.java
@@ -0,0 +1,83 @@
+/**
+ * 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.component.yammer;
+
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultComponent;
+
+/**
+ * Represents the component that manages {@link YammerEndpoint}.
+ */
+public class YammerComponent extends DefaultComponent {
+
+ private String consumerKey;
+ private String consumerSecret;
+ private String accessToken;
+ private YammerConfiguration config;
+
+ protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+ // set options from component
+ getConfig().setConsumerKey(consumerKey);
+ getConfig().setConsumerSecret(consumerSecret);
+ getConfig().setAccessToken(accessToken);
+ getConfig().setFunction(remaining);
+
+ // and then override from parameters
+ setProperties(getConfig(), parameters);
+
+ Endpoint endpoint = new YammerEndpoint(uri, this, getConfig());
+ setProperties(endpoint, parameters);
+ return endpoint;
+ }
+
+ public String getConsumerKey() {
+ return consumerKey;
+ }
+
+ public void setConsumerKey(String consumerKey) {
+ this.consumerKey = consumerKey;
+ }
+
+ public String getConsumerSecret() {
+ return consumerSecret;
+ }
+
+ public void setConsumerSecret(String consumerSecret) {
+ this.consumerSecret = consumerSecret;
+ }
+
+ public String getAccessToken() {
+ return accessToken;
+ }
+
+ public void setAccessToken(String accessToken) {
+ this.accessToken = accessToken;
+ }
+
+ public YammerConfiguration getConfig() {
+ if (config == null) {
+ config = new YammerConfiguration();
+ }
+ return config;
+ }
+
+ public void setConfig(YammerConfiguration config) {
+ this.config = config;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerConfiguration.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerConfiguration.java
new file mode 100644
index 0000000..3ab6f81b
--- /dev/null
+++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerConfiguration.java
@@ -0,0 +1,115 @@
+/**
+ * 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.component.yammer;
+
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
+
+@UriParams
+public class YammerConfiguration {
+
+ @UriParam
+ private String consumerKey;
+ @UriParam
+ private String consumerSecret;
+ @UriParam
+ private String accessToken;
+
+ private String function;
+
+ @UriParam
+ private boolean useJson;
+
+ @UriParam
+ private long delay = 3000 + 2000; // 3 sec per poll is enforced by yammer; add 2 sec for safety
+ private ApiRequestor requestor;
+
+ public String getConsumerKey() {
+ return consumerKey;
+ }
+
+ public void setConsumerKey(String consumerKey) {
+ this.consumerKey = consumerKey;
+ }
+
+ public String getConsumerSecret() {
+ return consumerSecret;
+ }
+
+ public void setConsumerSecret(String consumerSecret) {
+ this.consumerSecret = consumerSecret;
+ }
+
+ public long getDelay() {
+ return delay;
+ }
+
+ public void setDelay(long delay) {
+ this.delay = delay;
+ }
+
+ public String getAccessToken() {
+ return accessToken;
+ }
+
+ public void setAccessToken(String accessToken) {
+ this.accessToken = accessToken;
+ }
+
+ public String getFunction() {
+ return function;
+ }
+
+ public void setFunction(String function) {
+ this.function = function;
+ }
+
+ public String getApiUrl() throws Exception {
+ switch (YammerFunctionType.fromUri(function)) {
+ case MESSAGES:
+ return String.format("%s%s.json", YammerConstants.YAMMER_BASE_API_URL, function);
+ case ALGO:
+ case FOLLOWING:
+ case MY_FEED:
+ case PRIVATE:
+ case SENT:
+ return String.format("%smessages/%s.json", YammerConstants.YAMMER_BASE_API_URL, function);
+ default:
+ throw new Exception(String.format("%s is not a valid Yammer function type.", function));
+ }
+ }
+
+ public boolean isUseJson() {
+ return useJson;
+ }
+
+ public void setUseJson(boolean useJson) {
+ this.useJson = useJson;
+ }
+
+ public ApiRequestor getRequestor() throws Exception {
+ if (requestor == null) {
+ requestor = new ScribeApiRequestor(getApiUrl(), getAccessToken());
+ }
+ return requestor;
+ }
+
+ public void setRequestor(ApiRequestor requestor) {
+ this.requestor = requestor;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerConstants.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerConstants.java
new file mode 100644
index 0000000..a3202a9
--- /dev/null
+++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerConstants.java
@@ -0,0 +1,25 @@
+/**
+ * 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.component.yammer;
+
+public final class YammerConstants {
+
+ public static final String YAMMER_BASE_API_URL = "https://www.yammer.com/api/v1/";
+
+ private YammerConstants() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerEndpoint.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerEndpoint.java
new file mode 100644
index 0000000..5e5fbb0
--- /dev/null
+++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerEndpoint.java
@@ -0,0 +1,71 @@
+/**
+ * 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.component.yammer;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.ScheduledPollEndpoint;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+
+/**
+ * Represents a Yammer endpoint.
+ */
+@UriEndpoint(scheme = "yammer", consumerClass = YammerMessagePollingConsumer.class)
+public class YammerEndpoint extends ScheduledPollEndpoint {
+
+ @UriParam
+ private YammerConfiguration config;
+
+ public YammerEndpoint() {
+ }
+
+ public YammerEndpoint(String uri, YammerComponent component) {
+ super(uri, component);
+ }
+
+ public YammerEndpoint(String uri, YammerComponent yammerComponent, YammerConfiguration config) {
+ this.setConfig(config);
+ }
+
+ public Producer createProducer() throws Exception {
+ throw new UnsupportedOperationException("YammerProducer is not implemented");
+ }
+
+ public Consumer createConsumer(Processor processor) throws Exception {
+ return new YammerMessagePollingConsumer(this, processor);
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+
+ public YammerConfiguration getConfig() {
+ return config;
+ }
+
+ public void setConfig(YammerConfiguration config) {
+ this.config = config;
+ }
+
+ @Override
+ protected String createEndpointUri() {
+ return String.format("yammer://%s?consumerKey=%s&consumerSecret=%s&accessToken=%s", config.getFunction(), config.getConsumerKey(), config.getConsumerSecret(), config.getAccessToken());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerFunctionType.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerFunctionType.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerFunctionType.java
new file mode 100644
index 0000000..14bed8f
--- /dev/null
+++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerFunctionType.java
@@ -0,0 +1,30 @@
+/**
+ * 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.component.yammer;
+
+public enum YammerFunctionType {
+ MESSAGES, MY_FEED, ALGO, FOLLOWING, SENT, PRIVATE;
+
+ public static YammerFunctionType fromUri(String uri) {
+ for (YammerFunctionType endpointType : YammerFunctionType.values()) {
+ if (endpointType.name().equalsIgnoreCase(uri)) {
+ return endpointType;
+ }
+ }
+ return YammerFunctionType.MESSAGES;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerMessagePollingConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerMessagePollingConsumer.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerMessagePollingConsumer.java
new file mode 100644
index 0000000..5a44ddd
--- /dev/null
+++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/YammerMessagePollingConsumer.java
@@ -0,0 +1,71 @@
+/**
+ * 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.component.yammer;
+
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.yammer.model.Messages;
+import org.apache.camel.impl.ScheduledPollConsumer;
+import org.codehaus.jackson.map.ObjectMapper;
+
+/**
+ * A Yammer consumer that periodically polls messages from Yammer's message API.
+ */
+public class YammerMessagePollingConsumer extends ScheduledPollConsumer {
+ private final YammerEndpoint endpoint;
+
+
+ public YammerMessagePollingConsumer(YammerEndpoint endpoint, Processor processor) throws Exception {
+ super(endpoint, processor);
+ this.endpoint = endpoint;
+
+ long delay = endpoint.getConfig().getDelay();
+ setDelay(delay);
+ setTimeUnit(TimeUnit.MILLISECONDS);
+ }
+
+ @Override
+ protected int poll() throws Exception {
+ Exchange exchange = endpoint.createExchange();
+
+ try {
+ String jsonBody = endpoint.getConfig().getRequestor().send();
+
+ if (!endpoint.getConfig().isUseJson()) {
+ ObjectMapper jsonMapper = new ObjectMapper();
+ Messages messages = jsonMapper.readValue(jsonBody, Messages.class);
+ exchange.getIn().setBody(messages);
+ } else {
+ exchange.getIn().setBody(jsonBody);
+ }
+
+ // send message to next processor in the route
+ getProcessor().process(exchange);
+
+ return 1; // number of messages polled
+ } finally {
+ // log exception if an exception occurred and was not handled
+ if (exchange.getException() != null) {
+ getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException());
+ }
+ }
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Attachment.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Attachment.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Attachment.java
new file mode 100644
index 0000000..7fae49e
--- /dev/null
+++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Attachment.java
@@ -0,0 +1,393 @@
+/**
+ * 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.component.yammer.model;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Attachment {
+
+ @JsonProperty("last_uploaded_at")
+ private String lastUploadedAt;
+ private String description;
+ @JsonProperty("thumbnail_url")
+ private String thumbnailUrl;
+ @JsonProperty("large_preview_url")
+ private String largePreviewUrl;
+ private String url;
+ @JsonProperty("streaming_url")
+ private Object streamingUrl;
+ @JsonProperty("group_id")
+ private Object groupId;
+ private Long id;
+ @JsonProperty("last_uploaded_by_id")
+ private Long lastUploadedById;
+ private Long size;
+ @JsonProperty("owner_type")
+ private String ownerType;
+ @JsonProperty("content_type")
+ private String contentType;
+ @JsonProperty("small_icon_url")
+ private String smallIconUrl;
+ @JsonProperty("original_name")
+ private String originalName;
+ private String type;
+ private Boolean official;
+ private Long height;
+ private Object transcoded;
+ private String path;
+ @JsonProperty("preview_url")
+ private String previewUrl;
+ private String name;
+ @JsonProperty("y_id")
+ private Long yId;
+ @JsonProperty("download_url")
+ private String downloadUrl;
+ @JsonProperty("created_at")
+ private String createdAt;
+ @JsonProperty("owner_id")
+ private Long ownerId;
+ @JsonProperty("content_class")
+ private String contentClass;
+ private String privacy;
+ @JsonProperty("full_name")
+ private String fullName;
+ @JsonProperty("last_uploaded_by_type")
+ private String lastUploadedByType;
+ @JsonProperty("overlay_url")
+ private String overlayUrl;
+ @JsonProperty("real_type")
+ private String realType;
+ @JsonProperty("large_icon_url")
+ private String largeIconUrl;
+ @JsonProperty("scaled_url")
+ private String scaledUrl;
+ private Long width;
+ private Image image;
+ @JsonProperty("web_url")
+ private String webUrl;
+ private Object uuid;
+
+ public String getLastUploadedAt() {
+ return lastUploadedAt;
+ }
+
+ public void setLastUploadedAt(String lastUploadedAt) {
+ this.lastUploadedAt = lastUploadedAt;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getThumbnailUrl() {
+ return thumbnailUrl;
+ }
+
+ public void setThumbnailUrl(String thumbnailUrl) {
+ this.thumbnailUrl = thumbnailUrl;
+ }
+
+ public String getLargePreviewUrl() {
+ return largePreviewUrl;
+ }
+
+ public void setLargePreviewUrl(String largePreviewUrl) {
+ this.largePreviewUrl = largePreviewUrl;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public Object getStreamingUrl() {
+ return streamingUrl;
+ }
+
+ public void setStreamingUrl(Object streamingUrl) {
+ this.streamingUrl = streamingUrl;
+ }
+
+ public Object getGroupId() {
+ return groupId;
+ }
+
+ public void setGroupId(Object groupId) {
+ this.groupId = groupId;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Long getLastUploadedById() {
+ return lastUploadedById;
+ }
+
+ public void setLastUploadedById(Long lastUploadedById) {
+ this.lastUploadedById = lastUploadedById;
+ }
+
+ public Long getSize() {
+ return size;
+ }
+
+ public void setSize(Long size) {
+ this.size = size;
+ }
+
+ public String getOwnerType() {
+ return ownerType;
+ }
+
+ public void setOwnerType(String ownerType) {
+ this.ownerType = ownerType;
+ }
+
+ public String getContentType() {
+ return contentType;
+ }
+
+ public void setContentType(String contentType) {
+ this.contentType = contentType;
+ }
+
+ public String getSmallIconUrl() {
+ return smallIconUrl;
+ }
+
+ public void setSmallIconUrl(String smallIconUrl) {
+ this.smallIconUrl = smallIconUrl;
+ }
+
+ public String getOriginalName() {
+ return originalName;
+ }
+
+ public void setOriginalName(String originalName) {
+ this.originalName = originalName;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public Boolean getOfficial() {
+ return official;
+ }
+
+ public void setOfficial(Boolean official) {
+ this.official = official;
+ }
+
+ public Long getHeight() {
+ return height;
+ }
+
+ public void setHeight(Long height) {
+ this.height = height;
+ }
+
+ public Object getTranscoded() {
+ return transcoded;
+ }
+
+ public void setTranscoded(Object transcoded) {
+ this.transcoded = transcoded;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public String getPreviewUrl() {
+ return previewUrl;
+ }
+
+ public void setPreviewUrl(String previewUrl) {
+ this.previewUrl = previewUrl;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Long getYId() {
+ return yId;
+ }
+
+ public void setYId(Long yId) {
+ this.yId = yId;
+ }
+
+ public String getDownloadUrl() {
+ return downloadUrl;
+ }
+
+ public void setDownloadUrl(String downloadUrl) {
+ this.downloadUrl = downloadUrl;
+ }
+
+ public String getCreatedAt() {
+ return createdAt;
+ }
+
+ public void setCreatedAt(String createdAt) {
+ this.createdAt = createdAt;
+ }
+
+ public Long getOwnerId() {
+ return ownerId;
+ }
+
+ public void setOwnerId(Long ownerId) {
+ this.ownerId = ownerId;
+ }
+
+ public String getContentClass() {
+ return contentClass;
+ }
+
+ public void setContentClass(String contentClass) {
+ this.contentClass = contentClass;
+ }
+
+ public String getPrivacy() {
+ return privacy;
+ }
+
+ public void setPrivacy(String privacy) {
+ this.privacy = privacy;
+ }
+
+ public String getFullName() {
+ return fullName;
+ }
+
+ public void setFullName(String fullName) {
+ this.fullName = fullName;
+ }
+
+ public String getLastUploadedByType() {
+ return lastUploadedByType;
+ }
+
+ public void setLastUploadedByType(String lastUploadedByType) {
+ this.lastUploadedByType = lastUploadedByType;
+ }
+
+ public String getOverlayUrl() {
+ return overlayUrl;
+ }
+
+ public void setOverlayUrl(String overlayUrl) {
+ this.overlayUrl = overlayUrl;
+ }
+
+ public String getRealType() {
+ return realType;
+ }
+
+ public void setRealType(String realType) {
+ this.realType = realType;
+ }
+
+ public String getLargeIconUrl() {
+ return largeIconUrl;
+ }
+
+ public void setLargeIconUrl(String largeIconUrl) {
+ this.largeIconUrl = largeIconUrl;
+ }
+
+ public String getScaledUrl() {
+ return scaledUrl;
+ }
+
+ public void setScaledUrl(String scaledUrl) {
+ this.scaledUrl = scaledUrl;
+ }
+
+ public Long getWidth() {
+ return width;
+ }
+
+ public void setWidth(Long width) {
+ this.width = width;
+ }
+
+ public Image getImage() {
+ return image;
+ }
+
+ public void setImage(Image image) {
+ this.image = image;
+ }
+
+ public String getWebUrl() {
+ return webUrl;
+ }
+
+ public void setWebUrl(String webUrl) {
+ this.webUrl = webUrl;
+ }
+
+ public Object getUuid() {
+ return uuid;
+ }
+
+ public void setUuid(Object uuid) {
+ this.uuid = uuid;
+ }
+
+ @Override
+ public String toString() {
+ return "Attachment [lastUploadedAt=" + lastUploadedAt + ", description=" + description + ", thumbnailUrl=" + thumbnailUrl + ", largePreviewUrl=" + largePreviewUrl + ", url=" + url
+ + ", streamingUrl=" + streamingUrl + ", groupId=" + groupId + ", id=" + id + ", lastUploadedById=" + lastUploadedById + ", size=" + size + ", ownerType=" + ownerType
+ + ", contentType=" + contentType + ", smallIconUrl=" + smallIconUrl + ", originalName=" + originalName + ", type=" + type + ", official=" + official + ", height=" + height
+ + ", transcoded=" + transcoded + ", path=" + path + ", previewUrl=" + previewUrl + ", name=" + name + ", yId=" + yId + ", downloadUrl=" + downloadUrl + ", createdAt=" + createdAt
+ + ", ownerId=" + ownerId + ", contentClass=" + contentClass + ", privacy=" + privacy + ", fullName=" + fullName + ", lastUploadedByType=" + lastUploadedByType + ", overlayUrl="
+ + overlayUrl + ", realType=" + realType + ", largeIconUrl=" + largeIconUrl + ", scaledUrl=" + scaledUrl + ", width=" + width + ", image=" + image + ", webUrl=" + webUrl + ", uuid="
+ + uuid + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Body.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Body.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Body.java
new file mode 100644
index 0000000..a63775e
--- /dev/null
+++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Body.java
@@ -0,0 +1,57 @@
+/**
+ * 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.component.yammer.model;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Body {
+
+ private String parsed;
+ private String plain;
+ private String rich;
+
+ public String getParsed() {
+ return parsed;
+ }
+
+ public void setParsed(String parsed) {
+ this.parsed = parsed;
+ }
+
+ public String getPlain() {
+ return plain;
+ }
+
+ public void setPlain(String plain) {
+ this.plain = plain;
+ }
+
+ public String getRich() {
+ return rich;
+ }
+
+ public void setRich(String rich) {
+ this.rich = rich;
+ }
+
+ @Override
+ public String toString() {
+ return "Body [parsed=" + parsed + ", plain=" + plain + ", rich=" + rich + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/FollowedReference.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/FollowedReference.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/FollowedReference.java
new file mode 100644
index 0000000..0462557
--- /dev/null
+++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/FollowedReference.java
@@ -0,0 +1,48 @@
+/**
+ * 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.component.yammer.model;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class FollowedReference {
+
+ private Long id;
+ private String type;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ @Override
+ public String toString() {
+ return "FollowedReference [id=" + id + ", type=" + type + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Image.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Image.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Image.java
new file mode 100644
index 0000000..f6abc8a
--- /dev/null
+++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Image.java
@@ -0,0 +1,59 @@
+/**
+ * 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.component.yammer.model;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Image {
+
+ private String url;
+ @JsonProperty("thumbnail_url")
+ private String thumbnailUrl;
+ private Long size;
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public String getThumbnailUrl() {
+ return thumbnailUrl;
+ }
+
+ public void setThumbnailUrl(String thumbnailUrl) {
+ this.thumbnailUrl = thumbnailUrl;
+ }
+
+ public Long getSize() {
+ return size;
+ }
+
+ public void setSize(Long size) {
+ this.size = size;
+ }
+
+ @Override
+ public String toString() {
+ return "Image [url=" + url + ", thumbnailUrl=" + thumbnailUrl + ", size=" + size + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/LikedBy.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/LikedBy.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/LikedBy.java
new file mode 100644
index 0000000..b25e9f0
--- /dev/null
+++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/LikedBy.java
@@ -0,0 +1,50 @@
+/**
+ * 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.component.yammer.model;
+
+import java.util.List;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class LikedBy {
+
+ private Long count;
+ private List<Name> names;
+
+ public Long getCount() {
+ return count;
+ }
+
+ public void setCount(Long count) {
+ this.count = count;
+ }
+
+ public List<Name> getNames() {
+ return names;
+ }
+
+ public void setNames(List<Name> names) {
+ this.names = names;
+ }
+
+ @Override
+ public String toString() {
+ return "LikedBy [count=" + count + ", names=" + names + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Message.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Message.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Message.java
new file mode 100644
index 0000000..c2ccbf3
--- /dev/null
+++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Message.java
@@ -0,0 +1,240 @@
+/**
+ * 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.component.yammer.model;
+
+import java.util.List;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Message {
+
+ @JsonProperty("replied_to_id")
+ private Object repliedToId;
+ @JsonProperty("network_id")
+ private Long networkId;
+ private String url;
+ @JsonProperty("thread_id")
+ private Long threadId;
+ private Long id;
+ @JsonProperty("message_type")
+ private String messageType;
+ @JsonProperty("chat_client_sequence")
+ private Object chatClientSequence;
+ private Body body;
+ @JsonProperty("client_url")
+ private String clientUrl;
+ @JsonProperty("content_excerpt")
+ private String contentExcerpt;
+ @JsonProperty("created_at")
+ private String createdAt;
+ @JsonProperty("client_type")
+ private String clientType;
+ private String privacy;
+ @JsonProperty("sender_type")
+ private String senderType;
+ @JsonProperty("liked_by")
+ private LikedBy likedBy;
+ @JsonProperty("sender_id")
+ private Long senderId;
+ private Object language;
+ @JsonProperty("system_message")
+ private Boolean systemMessage;
+ private List<Attachment> attachments;
+ @JsonProperty("direct_message")
+ private Boolean directMessage;
+ @JsonProperty("web_url")
+ private String webUrl;
+
+ public Object getRepliedToId() {
+ return repliedToId;
+ }
+
+ public void setRepliedToId(Object repliedToId) {
+ this.repliedToId = repliedToId;
+ }
+
+ public Long getNetworkId() {
+ return networkId;
+ }
+
+ public void setNetworkId(Long networkId) {
+ this.networkId = networkId;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public Long getThreadId() {
+ return threadId;
+ }
+
+ public void setThreadId(Long threadId) {
+ this.threadId = threadId;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getMessageType() {
+ return messageType;
+ }
+
+ public void setMessageType(String messageType) {
+ this.messageType = messageType;
+ }
+
+ public Object getChatClientSequence() {
+ return chatClientSequence;
+ }
+
+ public void setChatClientSequence(Object chatClientSequence) {
+ this.chatClientSequence = chatClientSequence;
+ }
+
+ public Body getBody() {
+ return body;
+ }
+
+ public void setBody(Body body) {
+ this.body = body;
+ }
+
+ public String getClientUrl() {
+ return clientUrl;
+ }
+
+ public void setClientUrl(String clientUrl) {
+ this.clientUrl = clientUrl;
+ }
+
+ public String getContentExcerpt() {
+ return contentExcerpt;
+ }
+
+ public void setContentExcerpt(String contentExcerpt) {
+ this.contentExcerpt = contentExcerpt;
+ }
+
+ public String getCreatedAt() {
+ return createdAt;
+ }
+
+ public void setCreatedAt(String createdAt) {
+ this.createdAt = createdAt;
+ }
+
+ public String getClientType() {
+ return clientType;
+ }
+
+ public void setClientType(String clientType) {
+ this.clientType = clientType;
+ }
+
+ public String getPrivacy() {
+ return privacy;
+ }
+
+ public void setPrivacy(String privacy) {
+ this.privacy = privacy;
+ }
+
+ public String getSenderType() {
+ return senderType;
+ }
+
+ public void setSenderType(String senderType) {
+ this.senderType = senderType;
+ }
+
+ public LikedBy getLikedBy() {
+ return likedBy;
+ }
+
+ public void setLikedBy(LikedBy likedBy) {
+ this.likedBy = likedBy;
+ }
+
+ public Long getSenderId() {
+ return senderId;
+ }
+
+ public void setSenderId(Long senderId) {
+ this.senderId = senderId;
+ }
+
+ public Object getLanguage() {
+ return language;
+ }
+
+ public void setLanguage(Object language) {
+ this.language = language;
+ }
+
+ public Boolean getSystemMessage() {
+ return systemMessage;
+ }
+
+ public void setSystemMessage(Boolean systemMessage) {
+ this.systemMessage = systemMessage;
+ }
+
+ public List<Attachment> getAttachments() {
+ return attachments;
+ }
+
+ public void setAttachments(List<Attachment> attachments) {
+ this.attachments = attachments;
+ }
+
+ public Boolean getDirectMessage() {
+ return directMessage;
+ }
+
+ public void setDirectMessage(Boolean directMessage) {
+ this.directMessage = directMessage;
+ }
+
+ public String getWebUrl() {
+ return webUrl;
+ }
+
+ public void setWebUrl(String webUrl) {
+ this.webUrl = webUrl;
+ }
+
+ @Override
+ public String toString() {
+ return "Message [repliedToId=" + repliedToId + ", networkId=" + networkId + ", url=" + url + ", threadId=" + threadId + ", id=" + id + ", messageType=" + messageType + ", chatClientSequence="
+ + chatClientSequence + ", body=" + body + ", clientUrl=" + clientUrl + ", contentExcerpt=" + contentExcerpt + ", createdAt=" + createdAt + ", clientType=" + clientType + ", privacy="
+ + privacy + ", senderType=" + senderType + ", likedBy=" + likedBy + ", senderId=" + senderId + ", language=" + language + ", systemMessage=" + systemMessage + ", attachments="
+ + attachments + ", directMessage=" + directMessage + ", webUrl=" + webUrl + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Messages.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Messages.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Messages.java
new file mode 100644
index 0000000..a8b6193
--- /dev/null
+++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Messages.java
@@ -0,0 +1,70 @@
+/**
+ * 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.component.yammer.model;
+
+import java.util.List;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Messages {
+
+ @JsonProperty("threaded_extended")
+ private ThreadedExtended threadedExtended;
+ private List<Message> messages;
+ private List<Reference> references;
+ private Meta meta;
+
+ public ThreadedExtended getThreadedExtended() {
+ return threadedExtended;
+ }
+
+ public void setThreadedExtended(ThreadedExtended threadedExtended) {
+ this.threadedExtended = threadedExtended;
+ }
+
+ public List<Message> getMessages() {
+ return messages;
+ }
+
+ public void setMessages(List<Message> messages) {
+ this.messages = messages;
+ }
+
+ public List<Reference> getReferences() {
+ return references;
+ }
+
+ public void setReferences(List<Reference> references) {
+ this.references = references;
+ }
+
+ public Meta getMeta() {
+ return meta;
+ }
+
+ public void setMeta(Meta meta) {
+ this.meta = meta;
+ }
+
+ @Override
+ public String toString() {
+ return "Messages [threadedExtended=" + threadedExtended + ", messages=" + messages + ", references=" + references + ", meta=" + meta + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Meta.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Meta.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Meta.java
new file mode 100644
index 0000000..17d1264
--- /dev/null
+++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Meta.java
@@ -0,0 +1,133 @@
+/**
+ * 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.component.yammer.model;
+
+import java.util.List;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Meta {
+
+ @JsonProperty("feed_desc")
+ private String feedDesc;
+ @JsonProperty("current_user_id")
+ private Long currentUserId;
+ @JsonProperty("requested_poll_interval")
+ private Long requestedPollInterval;
+ @JsonProperty("older_available")
+ private Boolean olderAvailable;
+ @JsonProperty("followed_references")
+ private List<FollowedReference> followedReferences;
+ private List<Object> ymodules;
+ @JsonProperty("liked_message_ids")
+ private List<Long> likedMessageIds;
+ @JsonProperty("feed_name")
+ private String feedName;
+ private Realtime realtime;
+ @JsonProperty("direct_from_body")
+ private Boolean directFromBody;
+
+ public String getFeedDesc() {
+ return feedDesc;
+ }
+
+ public void setFeedDesc(String feedDesc) {
+ this.feedDesc = feedDesc;
+ }
+
+ public Long getCurrentUserId() {
+ return currentUserId;
+ }
+
+ public void setCurrentUserId(Long currentUserId) {
+ this.currentUserId = currentUserId;
+ }
+
+ public Long getRequestedPollInterval() {
+ return requestedPollInterval;
+ }
+
+ public void setRequestedPollInterval(Long requestedPollInterval) {
+ this.requestedPollInterval = requestedPollInterval;
+ }
+
+ public Boolean getOlderAvailable() {
+ return olderAvailable;
+ }
+
+ public void setOlderAvailable(Boolean olderAvailable) {
+ this.olderAvailable = olderAvailable;
+ }
+
+ public List<FollowedReference> getFollowedReferences() {
+ return followedReferences;
+ }
+
+ public void setFollowedReferences(List<FollowedReference> followedReferences) {
+ this.followedReferences = followedReferences;
+ }
+
+ public List<Object> getYmodules() {
+ return ymodules;
+ }
+
+ public void setYmodules(List<Object> ymodules) {
+ this.ymodules = ymodules;
+ }
+
+ public List<Long> getLikedMessageIds() {
+ return likedMessageIds;
+ }
+
+ public void setLikedMessageIds(List<Long> likedMessageIds) {
+ this.likedMessageIds = likedMessageIds;
+ }
+
+ public String getFeedName() {
+ return feedName;
+ }
+
+ public void setFeedName(String feedName) {
+ this.feedName = feedName;
+ }
+
+ public Realtime getRealtime() {
+ return realtime;
+ }
+
+ public void setRealtime(Realtime realtime) {
+ this.realtime = realtime;
+ }
+
+ public Boolean getDirectFromBody() {
+ return directFromBody;
+ }
+
+ public void setDirectFromBody(Boolean directFromBody) {
+ this.directFromBody = directFromBody;
+ }
+
+ @Override
+ public String toString() {
+ return "Meta [feedDesc=" + feedDesc + ", currentUserId=" + currentUserId + ", requestedPollInterval=" + requestedPollInterval + ", olderAvailable=" + olderAvailable + ", followedReferences="
+ + followedReferences + ", ymodules=" + ymodules + ", likedMessageIds=" + likedMessageIds + ", feedName=" + feedName + ", realtime=" + realtime + ", directFromBody=" + directFromBody
+ + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Name.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Name.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Name.java
new file mode 100644
index 0000000..7c207e7
--- /dev/null
+++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Name.java
@@ -0,0 +1,60 @@
+/**
+ * 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.component.yammer.model;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Name {
+
+ private String permalink;
+ @JsonProperty("full_name")
+ private String fullName;
+ @JsonProperty("user_id")
+ private Long userId;
+
+ public String getPermalink() {
+ return permalink;
+ }
+
+ public void setPermalink(String permalink) {
+ this.permalink = permalink;
+ }
+
+ public String getFullName() {
+ return fullName;
+ }
+
+ public void setFullName(String fullName) {
+ this.fullName = fullName;
+ }
+
+ public Long getUserId() {
+ return userId;
+ }
+
+ public void setUserId(Long userId) {
+ this.userId = userId;
+ }
+
+ @Override
+ public String toString() {
+ return "Name [permalink=" + permalink + ", fullName=" + fullName + ", userId=" + userId + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Realtime.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Realtime.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Realtime.java
new file mode 100644
index 0000000..6ac0e74
--- /dev/null
+++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Realtime.java
@@ -0,0 +1,60 @@
+/**
+ * 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.component.yammer.model;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Realtime {
+
+ private String uri;
+ @JsonProperty("channel_id")
+ private String channelId;
+ @JsonProperty("authentication_token")
+ private String authenticationToken;
+
+ public String getUri() {
+ return uri;
+ }
+
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+
+ public String getChannelId() {
+ return channelId;
+ }
+
+ public void setChannelId(String channelId) {
+ this.channelId = channelId;
+ }
+
+ public String getAuthenticationToken() {
+ return authenticationToken;
+ }
+
+ public void setAuthenticationToken(String authenticationToken) {
+ this.authenticationToken = authenticationToken;
+ }
+
+ @Override
+ public String toString() {
+ return "Realtime [uri=" + uri + ", channelId=" + channelId + ", authenticationToken=" + authenticationToken + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Reference.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Reference.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Reference.java
new file mode 100644
index 0000000..42a1349
--- /dev/null
+++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/Reference.java
@@ -0,0 +1,96 @@
+/**
+ * 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.component.yammer.model;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.annotate.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Reference {
+
+ private String url;
+ private String permalink;
+ @JsonProperty("normalized_name")
+ private String normalizedName;
+ private Long id;
+ private String type;
+ private String name;
+ @JsonProperty("web_url")
+ private String webUrl;
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public String getPermalink() {
+ return permalink;
+ }
+
+ public void setPermalink(String permalink) {
+ this.permalink = permalink;
+ }
+
+ public String getNormalizedName() {
+ return normalizedName;
+ }
+
+ public void setNormalizedName(String normalizedName) {
+ this.normalizedName = normalizedName;
+ }
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getWebUrl() {
+ return webUrl;
+ }
+
+ public void setWebUrl(String webUrl) {
+ this.webUrl = webUrl;
+ }
+
+ @Override
+ public String toString() {
+ return "Reference [url=" + url + ", permalink=" + permalink + ", normalizedName=" + normalizedName + ", id=" + id + ", type=" + type + ", name=" + name + ", webUrl=" + webUrl + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/ThreadedExtended.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/ThreadedExtended.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/ThreadedExtended.java
new file mode 100644
index 0000000..a090227
--- /dev/null
+++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/model/ThreadedExtended.java
@@ -0,0 +1,24 @@
+/**
+ * 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.component.yammer.model;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ThreadedExtended {
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/scribe/JsonTokenExtractor.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/scribe/JsonTokenExtractor.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/scribe/JsonTokenExtractor.java
new file mode 100644
index 0000000..a9aca8b
--- /dev/null
+++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/scribe/JsonTokenExtractor.java
@@ -0,0 +1,49 @@
+/**
+ * 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.component.yammer.scribe;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.scribe.exceptions.OAuthException;
+import org.scribe.extractors.AccessTokenExtractor;
+import org.scribe.model.Token;
+import org.scribe.utils.Preconditions;
+
+
+public class JsonTokenExtractor implements AccessTokenExtractor {
+ private Pattern accessTokenPattern;
+
+ public JsonTokenExtractor() {
+ accessTokenPattern = Pattern.compile("\"access_token\":\\s*\"(\\S*?)\"");
+ }
+
+ public JsonTokenExtractor(String tokenRegex) {
+ accessTokenPattern = Pattern.compile(tokenRegex);
+ }
+
+ public Token extract(String response) {
+ Preconditions.checkEmptyString(response, "Cannot extract a token from a null or empty String");
+ Matcher matcher = accessTokenPattern.matcher(response);
+ if (matcher.find()) {
+ return new Token(matcher.group(1), "", response);
+ } else {
+ throw new OAuthException("Cannot extract an acces token. Response was: " + response);
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/scribe/YammerApi.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/scribe/YammerApi.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/scribe/YammerApi.java
new file mode 100644
index 0000000..bbebd13
--- /dev/null
+++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/scribe/YammerApi.java
@@ -0,0 +1,41 @@
+/**
+ * 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.component.yammer.scribe;
+
+import org.scribe.builder.api.DefaultApi20;
+import org.scribe.extractors.AccessTokenExtractor;
+import org.scribe.model.OAuthConfig;
+import org.scribe.utils.OAuthEncoder;
+
+public class YammerApi extends DefaultApi20 {
+ private static final String AUTHORIZE_URL = "https://www.yammer.com/dialog/oauth?client_id=%s&redirect_uri=%s";
+
+ @Override
+ public AccessTokenExtractor getAccessTokenExtractor() {
+ return new JsonTokenExtractor("\"token\":\\s*\"(\\S*?)\"");
+ }
+
+ @Override
+ public String getAccessTokenEndpoint() {
+ return "https://www.yammer.com/oauth2/access_token.json";
+ }
+
+ @Override
+ public String getAuthorizationUrl(OAuthConfig config) {
+ return String.format(AUTHORIZE_URL, config.getApiKey(), OAuthEncoder.encode(config.getCallback()));
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/utils/YammerAccessCodeGenerator.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/utils/YammerAccessCodeGenerator.java b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/utils/YammerAccessCodeGenerator.java
new file mode 100644
index 0000000..a83364fa
--- /dev/null
+++ b/components/camel-yammer/src/main/java/org/apache/camel/component/yammer/utils/YammerAccessCodeGenerator.java
@@ -0,0 +1,74 @@
+/**
+ * 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.component.yammer.utils;
+
+import java.util.Scanner;
+
+import org.apache.camel.component.yammer.scribe.YammerApi;
+import org.scribe.builder.ServiceBuilder;
+import org.scribe.model.Token;
+import org.scribe.model.Verifier;
+import org.scribe.oauth.OAuthService;
+
+
+/**
+ * Use this to get an access token from yammer. You will need the
+ * consumer key and secret key for your app registered with yammer to do this.
+ *
+ */
+public final class YammerAccessCodeGenerator {
+
+ private static final Token EMPTY_TOKEN = null;
+
+ private YammerAccessCodeGenerator() {
+ }
+
+ public static void main(String[] args) {
+ Scanner in = new Scanner(System.in);
+
+ System.out.println("Paste the consumerKey here");
+ System.out.print(">>");
+ String apiKey = in.nextLine();
+
+ System.out.println("Paste the consumerSecret here");
+ System.out.print(">>");
+ String apiSecret = in.nextLine();
+
+ OAuthService service = new ServiceBuilder()
+ .provider(YammerApi.class)
+ .apiKey(apiKey)
+ .apiSecret(apiSecret)
+ .build();
+
+ String authorizationUrl = service.getAuthorizationUrl(EMPTY_TOKEN);
+ System.out
+ .println("Go and authorize your app here (eg. in a web browser):");
+ System.out.println(authorizationUrl);
+ System.out.println("... and paste the authorization code here");
+ System.out.print(">>");
+ Verifier verifier = new Verifier(in.nextLine());
+
+ System.out.println();
+
+ Token accessToken = service.getAccessToken(EMPTY_TOKEN, verifier);
+ System.out.println("Your Access Token is: " + accessToken);
+ System.out.println();
+
+ in.close();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/main/resources/META-INF/services/org/apache/camel/component/yammer
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/main/resources/META-INF/services/org/apache/camel/component/yammer b/components/camel-yammer/src/main/resources/META-INF/services/org/apache/camel/component/yammer
new file mode 100644
index 0000000..6165599
--- /dev/null
+++ b/components/camel-yammer/src/main/resources/META-INF/services/org/apache/camel/component/yammer
@@ -0,0 +1 @@
+class=org.apache.camel.component.yammer.YammerComponent
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/test/java/org/apache/camel/component/yammer/TestApiRequestor.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/test/java/org/apache/camel/component/yammer/TestApiRequestor.java b/components/camel-yammer/src/test/java/org/apache/camel/component/yammer/TestApiRequestor.java
new file mode 100644
index 0000000..8b11eb3
--- /dev/null
+++ b/components/camel-yammer/src/test/java/org/apache/camel/component/yammer/TestApiRequestor.java
@@ -0,0 +1,33 @@
+/**
+ * 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.component.yammer;
+
+
+public class TestApiRequestor implements ApiRequestor {
+
+ String body;
+
+ public TestApiRequestor(String body) {
+ this.body = body;
+ }
+
+ @Override
+ public String send() {
+ return body;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/test/java/org/apache/camel/component/yammer/YammerComponentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/test/java/org/apache/camel/component/yammer/YammerComponentTest.java b/components/camel-yammer/src/test/java/org/apache/camel/component/yammer/YammerComponentTest.java
new file mode 100644
index 0000000..a900728
--- /dev/null
+++ b/components/camel-yammer/src/test/java/org/apache/camel/component/yammer/YammerComponentTest.java
@@ -0,0 +1,66 @@
+/**
+ * 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.component.yammer;
+
+import java.io.InputStream;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.component.yammer.model.Message;
+import org.apache.camel.component.yammer.model.Messages;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Before;
+import org.junit.Test;
+
+public class YammerComponentTest extends CamelTestSupport {
+
+ @Override
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+
+ YammerComponent yc = context.getComponent("yammer", YammerComponent.class);
+ YammerConfiguration config = yc.getConfig();
+ InputStream is = getClass().getResourceAsStream("/messages.json");
+ String messages = context.getTypeConverter().convertTo(String.class, is);
+ config.setRequestor(new TestApiRequestor(messages));
+ }
+
+ @Test
+ public void testConsumeAllMessages() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMinimumMessageCount(1);
+ assertMockEndpointsSatisfied();
+
+ Exchange exchange = mock.getExchanges().get(0);
+ Messages messages = exchange.getIn().getBody(Messages.class);
+
+ assertEquals(2, messages.getMessages().size());
+ assertEquals("Testing yammer API...", messages.getMessages().get(0).getBody().getPlain());
+ assertEquals("(Principal Software Engineer) has #joined the redhat.com network. Take a moment to welcome Jonathan.", messages.getMessages().get(1).getBody().getPlain());
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ public void configure() {
+ from("yammer:messages?consumerKey=aConsumerKey&consumerSecret=aConsumerSecretKey&accessToken=aAccessToken").to("mock:result");
+ }
+ };
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/test/resources/log4j.properties b/components/camel-yammer/src/test/resources/log4j.properties
new file mode 100644
index 0000000..9887f12
--- /dev/null
+++ b/components/camel-yammer/src/test/resources/log4j.properties
@@ -0,0 +1,30 @@
+#-------------------------------------------------------------------------------
+# 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.
+#-------------------------------------------------------------------------------
+#
+# The logging properties used
+#
+log4j.rootLogger=INFO, out
+
+# uncomment the following line to turn on Camel debugging
+#log4j.logger.org.apache.camel=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
http://git-wip-us.apache.org/repos/asf/camel/blob/a18e7e98/components/camel-yammer/src/test/resources/messages.json
----------------------------------------------------------------------
diff --git a/components/camel-yammer/src/test/resources/messages.json b/components/camel-yammer/src/test/resources/messages.json
new file mode 100644
index 0000000..4bd80d8
--- /dev/null
+++ b/components/camel-yammer/src/test/resources/messages.json
@@ -0,0 +1,72 @@
+{
+ "messages":[
+ {
+ "replied_to_id":null,
+ "network_id":7654,
+ "url":"https://www.yammer.com/api/v1/messages/305298242",
+ "thread_id":305298242,
+ "id":305298242,
+ "message_type":"update",
+ "chat_client_sequence":null,
+ "body":{
+ "parsed":"Testing yammer API...",
+ "plain":"Testing yammer API...",
+ "rich":"Testing yammer API..."
+ },
+ "client_url":"https://www.yammer.com/",
+ "content_excerpt":"Testing yammer API...",
+ "created_at":"2013/06/25 18:14:45 +0000",
+ "client_type":"Web",
+ "privacy":"public",
+ "sender_type":"user",
+ "liked_by":{
+ "count":1,
+ "names":[
+ {
+ "permalink":"janstey",
+ "full_name":"Jonathan Anstey",
+ "user_id":1499642294
+ }
+
+ ]
+
+ },
+ "sender_id":1499642294,
+ "language":null,
+ "system_message":false,
+ "attachments":[
+
+ ],
+ "direct_message":false,
+ "web_url":"https://www.yammer.com/redhat.com/messages/305298242"
+ },
+ {
+ "replied_to_id":null,
+ "network_id":7654,
+ "url":"https://www.yammer.com/api/v1/messages/294326302",
+ "thread_id":294326302,
+ "id":294326302,
+ "message_type":"system",
+ "chat_client_sequence":null,
+ "body":{
+ "parsed":"(Principal Software Engineer) has [[tag:14658]] the redhat.com network. Take a moment to welcome Jonathan.",
+ "plain":"(Principal Software Engineer) has #joined the redhat.com network. Take a moment to welcome Jonathan.",
+ "rich":"(Principal Software Engineer) has \u003Cspan class='yammer-object' data-yammer-object='tag:14658' data-resource-id='14658' data-resource-model='tag'\u003E#\u003Ca href='https://www.yammer.com/redhat.com/topics/25209'\u003Ejoined\u003C/a\u003E\u003C/span\u003E the redhat.com network. Take a moment to welcome Jonathan."
+ },
+ "client_url":"https://www.yammer.com/",
+ "content_excerpt":"(Principal Software Engineer) has #joined the redhat.com network. Take a moment to welcome Jonathan.",
+ "created_at":"2013/05/10 19:08:29 +0000",
+ "client_type":"Web",
+ "sender_type":"user",
+ "privacy":"public",
+ "liked_by":{
+ "count":0,
+ "names":[
+
+ ]
+
+ }
+ }
+ ]
+
+ }