/******************************************************************************* Scriba EBook Maker Copyright (C) 2011 Senato della Repubblica (http://www.senato.it/) Offices: Ufficio Stampa e internet [1] Servizio dell'Informatica [2] Contributors: Roberto Battistoni (2, roberto.battistoni@senato.it): software engineer and developer Carlo Marchetti (2, carlo.marchetti@senato.it): project manager Marco Tagliavini (1, marco.tagliavini@senato.it): project visionary This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see *******************************************************************************/ package it.senato.areatesti.ebook.ebookmaker.plugin.defaultplugin; import it.senato.areatesti.ebook.ebookmaker.Context; import it.senato.areatesti.ebook.ebookmaker.misc.Misc; import it.senato.areatesti.ebook.ebookmaker.packaging.PackageMaker; import it.senato.areatesti.ebook.ebookmaker.plugin.base.AbstractPlugin; import it.senato.areatesti.ebook.ebookmaker.scf.bean.ContentItem; import it.senato.areatesti.ebook.ebookmaker.scf.bean.MetadataItem; import it.senato.areatesti.ebook.ebookmaker.scf.bean.base.IItem; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.nio.charset.CharacterCodingException; import java.util.ArrayList; import java.util.List; /** * Plugin of the Cover internal page * */ public class CoverPlugin extends AbstractPlugin { @Override public List elaborateContent(ContentItem content, ArrayList metadataList) throws IOException { byte[] bContent = PackageMaker.downloadContentStrict(content); if (bContent == null) return null; String text = new String(bContent, Context.DEF_ENCODING); text = text.replace(Context.DC_DATE_PLACEHOLDER, Misc.getNowTimestamp()); text = text.replace(Context.PRETTY_DATE_PLACEHOLDER, Misc.getNowTimestampLong()); // Searches for the title in the metadatas for (IItem item: metadataList) { MetadataItem mi = (MetadataItem) item; if (mi.getElemName().equals("title")) text = text.replace("%titolo%", mi.getElemVal()); } content.setByteContent(text.getBytes(Context.DEF_ENCODING)); List clist = new ArrayList(); clist.add(content); return clist; } @Override public ArrayList makesHtmlFromPdf( ContentItem contentItemOfPdfRef, String fileNamePdf) throws IOException { throw new RuntimeException("Not implemented!"); } @Override public String adjustConvertedHtml(String htmlContent) { throw new RuntimeException("Not implemented!"); } @Override public String convertEncoding(byte[] byteContent, String outputEncoding) throws UnsupportedEncodingException, CharacterCodingException, IOException { throw new RuntimeException("Not implemented!"); } }