private void publishRtf(Resource resource,BigDecimal version) throws PublicationException {
  if (isLocked(resource.getShortname())) {
    throw new PublicationException(PublicationException.TYPE.LOCKED,"Resource " + resource.getShortname() + " is currently locked by another process");
  }
  Document doc=new Document();
  File rtfFile=dataDir.resourceRtfFile(resource.getShortname(),version);
  OutputStream out=null;
  try {
    out=new FileOutputStream(rtfFile);
    RtfWriter2.getInstance(doc,out);
    eml2Rtf.writeEmlIntoRtf(doc,resource);
  }
 catch (  FileNotFoundException e) {
    throw new PublicationException(PublicationException.TYPE.RTF,"Can't find rtf file to write metadata to: " + rtfFile.getAbsolutePath(),e);
  }
catch (  DocumentException e) {
    throw new PublicationException(PublicationException.TYPE.RTF,"RTF DocumentException while writing to file: " + rtfFile.getAbsolutePath(),e);
  }
catch (  Exception e) {
    throw new PublicationException(PublicationException.TYPE.RTF,"An unexpected error occurred while writing RTF file: " + e.getMessage(),e);
  }
 finally {
    if (out != null) {
      try {
        out.close();
      }
 catch (      IOException e) {
        log.warn("FileOutputStream to RTF file could not be closed");
      }
    }
  }
}

private void publishRtf ( Resource resource , BigDecimal version ) throws PublicationException { if ( isLocked ( resource . getShortname ( ) ) ) { throw new PublicationException ( PublicationException . TYPE . LOCKED , "Resource " + resource . getShortname ( ) + " is currently locked by another process" ) ; } Document doc = new Document ( ) ; File rtfFile = dataDir . resourceRtfFile ( resource . getShortname ( ) , version ) ; OutputStream out = null ; try { out = new FileOutputStream ( rtfFile ) ; RtfWriter2 . getInstance ( doc , out ) ; eml2Rtf . writeEmlIntoRtf ( doc , resource ) ; } catch ( FileNotFoundException e ) { throw new PublicationException ( PublicationException . TYPE . RTF , "Can't find rtf file to write metadata to: " + rtfFile . getAbsolutePath ( ) , e ) ; } catch ( DocumentException e ) { throw new PublicationException ( PublicationException . TYPE . RTF , "RTF DocumentException while writing to file: " + rtfFile . getAbsolutePath ( ) , e ) ; } catch ( Exception e ) { throw new PublicationException ( PublicationException . TYPE . RTF , "An unexpected error occurred while writing RTF file: " + e . getMessage ( ) , e ) ; } finally { if ( out != null ) { try { out . close ( ) ; } catch ( IOException e ) { log . warn ( "FileOutputStream to RTF file could not be closed" ) ; } } } }
publishes a new version of the rtf file for the given resource .
