class FeedServiceImpl implements IFeedService {

  @Override
  public Response insert(Feed feed) {
    ProjectLogger.log("FeedServiceImpl:insert method called : ", LoggerEnum.INFO.name());
    Map<String, Object> feedData = feed.getData();
    Map<String, Object> dbMap = mapper.convertValue(feed, Map.class);
    String feedId = ProjectUtil.generateUniqueId();
    dbMap.put(JsonKey.ID, feedId);
    dbMap.put(JsonKey.CREATED_ON, new Timestamp(Calendar.getInstance().getTimeInMillis()));
    try {
      if (MapUtils.isNotEmpty(feed.getData())) {
        dbMap.put(JsonKey.FEED_DATA, mapper.writeValueAsString(feed.getData()));
      }
    } catch (Exception ex) {
      ProjectLogger.log("FeedServiceImpl:insert Exception occurred while mapping.", ex);
    }
    Response response = saveFeed(dbMap);
    // save data to ES
    dbMap.put(JsonKey.FEED_DATA, feedData);
    dbMap.put(JsonKey.CREATED_ON, Calendar.getInstance().getTimeInMillis());
    getESInstance().save(ProjectUtil.EsType.userfeed.getTypeName(), feedId, dbMap);
    return response;
  }

}