/**
   * Strip long params in publication object to prevent SQL errors on columns
   *
   * @param p publication to check
   */
  protected void stripLongParams(Publication p) {

    if (p.getTitle() != null && p.getTitle().length() > 1024) {
      p.setTitle(p.getTitle().substring(0, 1024));
    }
    if (p.getMain() != null && p.getMain().length() > 4000) {
      p.setMain(p.getMain().substring(0, 4000));
    }
    if (p.getIsbn() != null && p.getIsbn().length() > 32) {
      p.setIsbn(p.getIsbn().substring(0, 32));
    }
    if (p.getDoi() != null && p.getDoi().length() > 256) {
      p.setDoi(p.getDoi().substring(0, 256));
    }
  }
 public boolean publicationExists(Publication p) {
   if (p.getId() != null && p.getId() != 0) {
     return publicationDao.findPublicationById(p.getId()) != null;
   }
   if (p.getExternalId() != null
       && p.getExternalId() != 0
       && p.getPublicationSystemId() != null
       && p.getPublicationSystemId() != 0) {
     Publication filter = new Publication();
     filter.setExternalId(p.getExternalId());
     filter.setPublicationSystemId(p.getPublicationSystemId());
     return publicationDao.findPublicationsByFilter(filter).size() >= 1;
   }
   if (p.getIsbn() != null && p.getIsbn() != "") {
     Publication filter = new Publication();
     filter.setIsbn(p.getIsbn());
     return publicationDao.findPublicationsByFilter(filter).size() >= 1;
   }
   return false;
 }