streams-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rbnks <...@git.apache.org>
Subject [GitHub] incubator-streams pull request: Streams 279
Date Tue, 17 Feb 2015 19:49:32 GMT
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<Channel> {
    +
    +
    +    @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.
---

Mime
View raw message