/**
   * @param document
   * @return
   */
  private boolean isDocumentTemplate(Document document) {
    if (document.getContentType().trim().equals(MimeTypesHelper.HTML.getType())
        || document.getContentType().trim().equals(MimeTypesHelper.TXT.getType())) {
      return true;
    }

    return false;
  }
  /**
   * @param document
   * @param addAtTop
   * @return
   */
  private boolean addTemplate(Document document, boolean addAtTop) {
    if (isDocumentTemplate(document)) {
      String tempContent =
          new String(
              DocumentMgmtUtility.getDocumentManagementService()
                  .retrieveDocumentContent(document.getId()));

      tempContent = resolveExpressions(tempContent);

      editor.addContent(
          tempContent,
          addAtTop ? DocumentEditingPolicy.ADD_AT_TOP : DocumentEditingPolicy.ADD_AT_BOTTOM);

      return true;
    } else {
      MessageDialog.addErrorMessage(
          this.getMessages().getString("invalid.template.message")
              + " "
              + document.getContentType());
      return false;
    }
  }