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 A91DB1078E for ; Mon, 17 Nov 2014 19:09:10 +0000 (UTC) Received: (qmail 54711 invoked by uid 500); 17 Nov 2014 19:09:10 -0000 Delivered-To: apmail-streams-dev-archive@streams.apache.org Received: (qmail 54665 invoked by uid 500); 17 Nov 2014 19:09:10 -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 54654 invoked by uid 99); 17 Nov 2014 19:09:10 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Nov 2014 19:09:10 +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; Mon, 17 Nov 2014 19:09:09 +0000 Received: (qmail 54605 invoked by uid 99); 17 Nov 2014 19:08:48 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Nov 2014 19:08:48 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id B8E5C98DD9E; Mon, 17 Nov 2014 19:08:48 +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 68,218 Content-Type: text/plain Message-Id: <20141117190848.B8E5C98DD9E@tyr.zones.apache.org> Date: Mon, 17 Nov 2014 19:08:48 +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/131#discussion_r20456659 --- Diff: streams-components/streams-converters/src/main/java/org/apache/streams/converter/BaseStringActivityConverter.java --- @@ -0,0 +1,65 @@ +package org.apache.streams.converter; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.collect.Lists; +import org.apache.streams.data.ActivityConverter; +import org.apache.streams.exceptions.ActivitySerializerException; +import org.apache.streams.jackson.StreamsJacksonMapper; +import org.apache.streams.pojo.json.Activity; + +import java.util.List; + +/** + * BaseObjectNodeActivityConverter is included by default in all + * @see {@link org.apache.streams.converter.ActivityConverterProcessor} + * + * Ensures generic String Json representation of an Activity can be converted to Activity + * + */ +public class BaseStringActivityConverter implements ActivityConverter { + + private ObjectMapper mapper = new StreamsJacksonMapper(); + + private static BaseStringActivityConverter instance = new BaseStringActivityConverter(); + + public static BaseStringActivityConverter getInstance() { + return instance; + } + + + @Override + public String serializationFormat() { + return null; + } + + @Override + public String serialize(Activity deserialized) throws ActivitySerializerException { + try { + return mapper.writeValueAsString(deserialized); + } catch (JsonProcessingException e) { + throw new ActivitySerializerException(); + } + } + + @Override + public Activity deserialize(String serialized) throws ActivitySerializerException { + try { + return mapper.readValue(serialized, Activity.class); + } catch (Exception e) { + throw new ActivitySerializerException(); + } + } + + @Override + public List deserializeAll(List serializedList) { --- End diff -- BaseObjectNodeActivityConverter and BaseStringActivityConverter both duplicate this method, could it be abstracted out to another class so that they could both use that implementation? --- 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. ---