@Override
  public String replaceImportContentReferences(
      PortletDataContext portletDataContext, StagedModel stagedModel, String content)
      throws Exception {

    JournalFeed feed = (JournalFeed) stagedModel;

    Group group = _groupLocalService.getGroup(portletDataContext.getScopeGroupId());

    String newGroupFriendlyURL = group.getFriendlyURL();

    newGroupFriendlyURL = newGroupFriendlyURL.substring(1);

    String[] friendlyURLParts = StringUtil.split(feed.getTargetLayoutFriendlyUrl(), '/');

    String oldGroupFriendlyURL = friendlyURLParts[2];

    if (oldGroupFriendlyURL.equals(DATA_HANDLER_GROUP_FRIENDLY_URL)) {
      feed.setTargetLayoutFriendlyUrl(
          StringUtil.replace(
              feed.getTargetLayoutFriendlyUrl(),
              DATA_HANDLER_GROUP_FRIENDLY_URL,
              newGroupFriendlyURL));
    }

    return content;
  }
  @Override
  public String replaceExportContentReferences(
      PortletDataContext portletDataContext,
      StagedModel stagedModel,
      String content,
      boolean exportReferencedContent,
      boolean escapeContent)
      throws Exception {

    JournalFeed feed = (JournalFeed) stagedModel;

    Group group = _groupLocalService.getGroup(portletDataContext.getScopeGroupId());

    String newGroupFriendlyURL = group.getFriendlyURL();

    newGroupFriendlyURL = newGroupFriendlyURL.substring(1);

    String[] friendlyURLParts =
        StringUtil.split(feed.getTargetLayoutFriendlyUrl(), StringPool.FORWARD_SLASH);

    String oldGroupFriendlyURL = friendlyURLParts[2];

    if (newGroupFriendlyURL.equals(oldGroupFriendlyURL)) {
      String targetLayoutFriendlyUrl =
          StringUtil.replaceFirst(
              feed.getTargetLayoutFriendlyUrl(),
              StringPool.SLASH + newGroupFriendlyURL + StringPool.SLASH,
              StringPool.SLASH + DATA_HANDLER_GROUP_FRIENDLY_URL + StringPool.SLASH);

      feed.setTargetLayoutFriendlyUrl(targetLayoutFriendlyUrl);
    }

    Group targetLayoutGroup =
        _groupLocalService.fetchFriendlyURLGroup(
            portletDataContext.getCompanyId(), StringPool.SLASH + oldGroupFriendlyURL);

    boolean privateLayout = false;

    if (!PropsValues.LAYOUT_FRIENDLY_URL_PUBLIC_SERVLET_MAPPING.equals(
        StringPool.SLASH + friendlyURLParts[1])) {

      privateLayout = true;
    }

    String targetLayoutFriendlyURL = StringPool.SLASH + friendlyURLParts[3];

    Layout targetLayout =
        _layoutLocalService.fetchLayoutByFriendlyURL(
            targetLayoutGroup.getGroupId(), privateLayout, targetLayoutFriendlyURL);

    Element feedElement = portletDataContext.getExportDataElement(feed);

    portletDataContext.addReferenceElement(
        feed, feedElement, targetLayout, PortletDataContext.REFERENCE_TYPE_DEPENDENCY, true);

    return content;
  }
  @Override
  public boolean equals(Object obj) {
    if (this == obj) {
      return true;
    }

    if (!(obj instanceof JournalFeed)) {
      return false;
    }

    JournalFeed journalFeed = (JournalFeed) obj;

    long primaryKey = journalFeed.getPrimaryKey();

    if (getPrimaryKey() == primaryKey) {
      return true;
    } else {
      return false;
    }
  }
  @Override
  public int compareTo(JournalFeed journalFeed) {
    int value = 0;

    value = getFeedId().compareTo(journalFeed.getFeedId());

    if (value != 0) {
      return value;
    }

    return 0;
  }
  /**
   * Converts the soap model instance into a normal model instance.
   *
   * @param soapModel the soap model instance to convert
   * @return the normal model instance
   */
  public static JournalFeed toModel(JournalFeedSoap soapModel) {
    if (soapModel == null) {
      return null;
    }

    JournalFeed model = new JournalFeedImpl();

    model.setUuid(soapModel.getUuid());
    model.setId(soapModel.getId());
    model.setGroupId(soapModel.getGroupId());
    model.setCompanyId(soapModel.getCompanyId());
    model.setUserId(soapModel.getUserId());
    model.setUserName(soapModel.getUserName());
    model.setCreateDate(soapModel.getCreateDate());
    model.setModifiedDate(soapModel.getModifiedDate());
    model.setFeedId(soapModel.getFeedId());
    model.setName(soapModel.getName());
    model.setDescription(soapModel.getDescription());
    model.setDDMStructureKey(soapModel.getDDMStructureKey());
    model.setDDMTemplateKey(soapModel.getDDMTemplateKey());
    model.setDDMRendererTemplateKey(soapModel.getDDMRendererTemplateKey());
    model.setDelta(soapModel.getDelta());
    model.setOrderByCol(soapModel.getOrderByCol());
    model.setOrderByType(soapModel.getOrderByType());
    model.setTargetLayoutFriendlyUrl(soapModel.getTargetLayoutFriendlyUrl());
    model.setTargetPortletId(soapModel.getTargetPortletId());
    model.setContentField(soapModel.getContentField());
    model.setFeedFormat(soapModel.getFeedFormat());
    model.setFeedVersion(soapModel.getFeedVersion());
    model.setLastPublishDate(soapModel.getLastPublishDate());

    return model;
  }