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 ECF0B17AFD for ; Tue, 17 Feb 2015 19:49:56 +0000 (UTC) Received: (qmail 77730 invoked by uid 500); 17 Feb 2015 19:49:56 -0000 Delivered-To: apmail-streams-dev-archive@streams.apache.org Received: (qmail 77681 invoked by uid 500); 17 Feb 2015 19:49:56 -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 77667 invoked by uid 99); 17 Feb 2015 19:49:56 -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 19:49:56 +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 19:49:34 +0000 Received: (qmail 77307 invoked by uid 99); 17 Feb 2015 19:49:32 -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 19:49:32 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 092B3E03E8; Tue, 17 Feb 2015 19:49:32 +0000 (UTC) From: rbnks 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: <20150217194932.092B3E03E8@git1-us-west.apache.org> Date: Tue, 17 Feb 2015 19:49:32 +0000 (UTC) X-Virus-Checked: Checked by ClamAV on apache.org Github user rbnks commented on a diff in the pull request: https://github.com/apache/incubator-streams/pull/184#discussion_r24847322 --- 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 -- Its a advertised exception that is part of the overriden method. Any code call this method should be forced to handle this exception and choses how to respond to the exception. I believe this is fine here. --- 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. ---