Return-Path: X-Original-To: apmail-streams-dev-archive@minotaur.apache.org Delivered-To: apmail-streams-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1476B17780 for ; Tue, 31 Mar 2015 14:38:58 +0000 (UTC) Received: (qmail 2562 invoked by uid 500); 31 Mar 2015 14:32:18 -0000 Delivered-To: apmail-streams-dev-archive@streams.apache.org Received: (qmail 2519 invoked by uid 500); 31 Mar 2015 14:32:18 -0000 Mailing-List: contact dev-help@streams.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@streams.incubator.apache.org Delivered-To: mailing list dev@streams.incubator.apache.org Received: (qmail 2507 invoked by uid 99); 31 Mar 2015 14:32:18 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 31 Mar 2015 14:32:18 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 31 Mar 2015 14:31:56 +0000 Received: (qmail 1197 invoked by uid 99); 31 Mar 2015 14:31:53 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 31 Mar 2015 14:31:53 +0000 Date: Tue, 31 Mar 2015 14:31:53 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: dev@streams.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (STREAMS-273) Support POST endpoints in streams-http MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/STREAMS-273?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14388590#comment-14388590 ] ASF GitHub Bot commented on STREAMS-273: ---------------------------------------- Github user robdouglas commented on a diff in the pull request: https://github.com/apache/incubator-streams/pull/206#discussion_r27483949 --- Diff: streams-components/streams-http/src/main/java/org/apache/streams/components/http/processor/SimpleHTTPPostProcessor.java --- @@ -0,0 +1,278 @@ +/* + * 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 + * + * 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.streams.components.http.processor; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; +import com.google.common.base.Strings; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import org.apache.commons.codec.binary.Base64; +import org.apache.http.HttpEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.utils.URIBuilder; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.util.EntityUtils; +import org.apache.streams.components.http.HttpConfigurator; +import org.apache.streams.components.http.HttpProcessorConfiguration; +import org.apache.streams.config.StreamsConfigurator; +import org.apache.streams.core.StreamsDatum; +import org.apache.streams.core.StreamsProcessor; +import org.apache.streams.jackson.StreamsJacksonMapper; +import org.apache.streams.pojo.extensions.ExtensionUtil; +import org.apache.streams.pojo.json.ActivityObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Map; + +/** + * Processor retrieves contents from an known url and stores the resulting object in an extension field + */ +public class SimpleHTTPPostProcessor implements StreamsProcessor { + + private final static String STREAMS_ID = "SimpleHTTPPostProcessor"; + + private final static Logger LOGGER = LoggerFactory.getLogger(SimpleHTTPPostProcessor.class); + + protected ObjectMapper mapper; + + protected URIBuilder uriBuilder; + + protected CloseableHttpClient httpclient; + + protected HttpProcessorConfiguration configuration; + + protected String authHeader; + + public SimpleHTTPPostProcessor() { + this(HttpConfigurator.detectProcessorConfiguration(StreamsConfigurator.config.getConfig("http"))); + } + + public SimpleHTTPPostProcessor(HttpProcessorConfiguration processorConfiguration) { + LOGGER.info("creating SimpleHTTPPostProcessor"); + LOGGER.info(processorConfiguration.toString()); + this.configuration = processorConfiguration; + } + + + /** + Override this to store a result other than exact json representation of response + */ + protected ObjectNode prepareExtensionFragment(String entityString) { + + try { + return mapper.readValue(entityString, ObjectNode.class); + } catch (IOException e) { + LOGGER.warn(e.getMessage()); --- End diff -- Instead of just the message, can we log out the entire exception so we can get the stack trace as well? > Support POST endpoints in streams-http > -------------------------------------- > > Key: STREAMS-273 > URL: https://issues.apache.org/jira/browse/STREAMS-273 > Project: Streams > Issue Type: Improvement > Reporter: Steve Blackmon > Assignee: Steve Blackmon > > Endpoints with require POST of a document rather than GET using parameters should be supported in streams-http. -- This message was sent by Atlassian JIRA (v6.3.4#6332)