/*
   * Gets the Author Tag for a specific topic
   */
  public RESTTagV1 getAuthorForTopic(final int topicId, final Integer rev) {
    if (rev == null) {
      final List<RESTTagV1> tags = this.getTagsByTopicId(topicId);

      if (tags != null) {
        for (RESTTagV1 tag : tags) {
          if (ComponentTagV1.containedInCategory(tag, CSConstants.WRITER_CATEGORY_ID)) return tag;
        }
      }
    } else {
      final RESTTopicV1 topic = this.getTopicById(topicId, rev);
      if (topic != null) {
        for (RESTTopicV1 topicRevision : topic.getRevisions().getItems()) {
          if (topicRevision.getRevision().equals(rev)) {
            List<RESTTagV1> writerTags =
                ComponentBaseTopicV1.returnTagsInCategoriesByID(
                    topicRevision, CollectionUtilities.toArrayList(CSConstants.WRITER_CATEGORY_ID));
            if (writerTags.size() == 1) return writerTags.get(0);
            break;
          }
        }
      }
    }
    return null;
  }
  /*
   * Gets a ContentSpec tuple for a specified id.
   */
  public RESTTopicV1 getContentSpecById(
      final int id, final Integer rev, final boolean expandTranslations) {
    final RESTTopicV1 cs = getTopicById(id, rev, expandTranslations);
    if (cs == null) return null;

    final List<RESTTagV1> topicTypes =
        ComponentBaseTopicV1.returnTagsInCategoriesByID(
            cs, CollectionUtilities.toArrayList(CSConstants.TYPE_CATEGORY_ID));
    for (final RESTTagV1 type : topicTypes) {
      if (type.getId().equals(CSConstants.CONTENT_SPEC_TAG_ID)) {
        return cs;
      }
    }
    return null;
  }
  /*
   * Gets a ContentSpec tuple for a specified id.
   */
  public RESTTranslatedTopicV1 getTranslatedContentSpecById(
      final int id, final Integer rev, final String locale) {
    if (locale == null) return null;
    final RESTTopicV1 cs = getTopicById(id, rev, true);
    if (cs == null) return null;

    final List<RESTTagV1> topicTypes =
        ComponentBaseTopicV1.returnTagsInCategoriesByID(
            cs, CollectionUtilities.toArrayList(CSConstants.TYPE_CATEGORY_ID));
    if (cs.getTranslatedTopics_OTM() != null && cs.getTranslatedTopics_OTM().getItems() != null) {
      for (final RESTTagV1 type : topicTypes) {
        if (type.getId().equals(CSConstants.CONTENT_SPEC_TAG_ID)) {
          for (final RESTTranslatedTopicV1 topic : cs.getTranslatedTopics_OTM().getItems()) {
            if (topic.getLocale().equals(locale)) return topic;
          }
        }
      }
    }
    return null;
  }