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 5D97D17414 for ; Tue, 17 Feb 2015 17:11:01 +0000 (UTC) Received: (qmail 21053 invoked by uid 500); 17 Feb 2015 17:11:01 -0000 Delivered-To: apmail-streams-dev-archive@streams.apache.org Received: (qmail 21008 invoked by uid 500); 17 Feb 2015 17:11:01 -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 20983 invoked by uid 99); 17 Feb 2015 17:11:00 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Feb 2015 17:11:00 +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, 17 Feb 2015 17:10:33 +0000 Received: (qmail 19794 invoked by uid 99); 17 Feb 2015 17:10:30 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 17 Feb 2015 17:10:30 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 75875E03C8; Tue, 17 Feb 2015 17:10:30 +0000 (UTC) From: robdouglas To: dev@streams.incubator.apache.org Reply-To: dev@streams.incubator.apache.org References: In-Reply-To: Subject: [GitHub] incubator-streams pull request: Streams 279 Content-Type: text/plain Message-Id: <20150217171030.75875E03C8@git1-us-west.apache.org> Date: Tue, 17 Feb 2015 17:10:30 +0000 (UTC) X-Virus-Checked: Checked by ClamAV on apache.org Github user robdouglas commented on a diff in the pull request: https://github.com/apache/incubator-streams/pull/184#discussion_r24832308 --- Diff: streams-contrib/streams-provider-youtube/src/main/java/com/youtube/serializer/YoutubeChannelDeserializer.java --- @@ -0,0 +1,131 @@ +package com.youtube.serializer; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.databind.JsonNode; +import com.google.api.client.util.DateTime; +import com.google.api.services.youtube.model.Channel; +import com.google.api.services.youtube.model.ChannelContentDetails; +import com.google.api.services.youtube.model.ChannelLocalization; +import com.google.api.services.youtube.model.ChannelSnippet; +import com.google.api.services.youtube.model.ChannelStatistics; +import com.google.api.services.youtube.model.ChannelTopicDetails; +import com.google.api.services.youtube.model.Thumbnail; +import com.google.api.services.youtube.model.ThumbnailDetails; +import com.google.common.collect.Lists; + +import java.io.IOException; +import java.util.Iterator; +import java.util.List; + +/** + * + */ +public class YoutubeChannelDeserializer extends JsonDeserializer { + + + @Override + public Channel deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { + JsonNode node = jp.getCodec().readTree(jp); + try { + Channel channel = new Channel(); + if(node.findPath("etag") != null) + channel.setEtag(node.get("etag").asText()); + if(node.findPath("kind") != null) + channel.setKind(node.get("kind").asText()); + channel.setId(node.get("id").asText()); + channel.setTopicDetails(setTopicDetails(node.findValue("topicDetails"))); + channel.setStatistics(setChannelStatistics(node.findValue("statistics"))); + channel.setContentDetails(setContentDetails(node.findValue("contentDetails"))); + channel.setSnippet(setChannelSnippet(node.findValue("snippet"))); + return channel; + } catch (Throwable t) { + throw new IOException(t); + } --- End diff -- In the event that there is a deserialization error, could we log the error message and return a null object? I'm not sure we want to derail the entire operation if one datum has trouble getting deserialized. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---