[
https://issues.apache.org/jira/browse/CAMEL-11959?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16226401#comment-16226401
]
ASF GitHub Bot commented on CAMEL-11959:
----------------------------------------
davsclaus commented on a change in pull request #2070: CAMEL-11959: Add new
camel-yql component
URL: https://github.com/apache/camel/pull/2070#discussion_r147912501
##########
File path:
components/camel-yql/src/main/java/org/apache/camel/component/yql/YqlProducer.java
##########
@@ -0,0 +1,55 @@
+/**
+ * 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.yql;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.yql.client.YqlClient;
+import org.apache.camel.component.yql.client.YqlResponse;
+import org.apache.camel.component.yql.configuration.YqlConfiguration;
+import org.apache.camel.impl.DefaultProducer;
+
+/**
+ * A Producer that send messages to YQL
+ */
+public class YqlProducer extends DefaultProducer {
+
+ static final String CAMEL_YQL_HTTP_STATUS = "CamelYqlHttpStatus";
+ static final String CAMEL_YQL_HTTP_REQUEST = "CamelYqlHttpRequest";
+
+ private final YqlEndpoint endpoint;
+ private final YqlClient yahooClient;
+
+ YqlProducer(final YqlEndpoint endpoint) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ this.yahooClient = new YqlClient();
+ }
+
+ @Override
+ public void process(final Exchange exchange) throws Exception {
+ final YqlConfiguration configuration = endpoint.getConfiguration();
+ final YqlResponse yqlResponse = yahooClient.get(
+ configuration.getQuery(),
+ configuration.getFormat(),
+ configuration.isDiagnostics(),
+ configuration.getCallback()
+ );
+ exchange.getIn().setHeader(CAMEL_YQL_HTTP_STATUS,
yqlResponse.getStatus());
+ exchange.getIn().setHeader(CAMEL_YQL_HTTP_REQUEST,
yqlResponse.getHttpRequest());
+ exchange.getIn().setBody(yqlResponse.getBody());
Review comment:
I wonder if there was an error, eg status code is 5xx, 4xx etc if we should
not throw an exception instead by default. And then allow to turn this on|off -
this is how the http components does it. Then its easier for Camel users to
know if something went wrong.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> New component YQL
> -----------------
>
> Key: CAMEL-11959
> URL: https://issues.apache.org/jira/browse/CAMEL-11959
> Project: Camel
> Issue Type: New Feature
> Reporter: Carl-Philipp Harmant
> Priority: Minor
>
> Add a new component, camel-yql that will allow to obtain data from YQL (Yahoo
> Query Language)
> https://developer.yahoo.com/yql/
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)