/**
   * Updates the book in the database or adds it if it does not yet exist. Also notifies the
   * appropriate model listeners.
   *
   * @param book the book
   * @param merge whether to merge the book with the current session. See {@link
   *     com.liferay.portal.service.persistence.BatchSession#update(com.liferay.portal.kernel.dao.orm.Session,
   *     com.liferay.portal.model.BaseModel, boolean)} for an explanation.
   * @return the book that was updated
   * @throws SystemException if a system exception occurred
   */
  public Book updateBook(Book book, boolean merge) throws SystemException {
    book.setNew(false);

    book = bookPersistence.update(book, merge);

    Indexer indexer = IndexerRegistryUtil.getIndexer(getModelClassName());

    if (indexer != null) {
      try {
        indexer.reindex(book);
      } catch (SearchException se) {
        if (_log.isWarnEnabled()) {
          _log.warn(se, se);
        }
      }
    }

    return book;
  }