franta-hg@72: /*
franta-hg@72:  *   SONEWS News Server
franta-hg@72:  *   see AUTHORS for the list of contributors
franta-hg@72:  *
franta-hg@72:  *   This program is free software: you can redistribute it and/or modify
franta-hg@72:  *   it under the terms of the GNU General Public License as published by
franta-hg@72:  *   the Free Software Foundation, either version 3 of the License, or
franta-hg@72:  *   (at your option) any later version.
franta-hg@72:  *
franta-hg@72:  *   This program is distributed in the hope that it will be useful,
franta-hg@72:  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
franta-hg@72:  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
franta-hg@72:  *   GNU General Public License for more details.
franta-hg@72:  *
franta-hg@72:  *   You should have received a copy of the GNU General Public License
franta-hg@72:  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
franta-hg@72:  */
franta-hg@72: package org.sonews.storage;
franta-hg@72: 
franta-hg@72: import java.io.IOException;
franta-hg@72: import java.util.Enumeration;
franta-hg@72: import javax.mail.Header;
franta-hg@72: import javax.mail.MessagingException;
franta-hg@72: import javax.mail.internet.InternetHeaders;
franta-hg@72: 
franta-hg@72: /**
franta-hg@72:  *
franta-hg@72:  * @author František Kučera (frantovo.cz)
franta-hg@72:  */
franta-hg@72: public class DrupalArticle extends Article {
franta-hg@72: 
franta-hg@72: 	public DrupalArticle(DrupalMessage msg) throws MessagingException, IOException {
franta-hg@72: 		headers = new InternetHeaders();
franta-hg@72: 
franta-hg@72: 		/** In order to have all headers (like MIME type) */
franta-hg@72: 		msg.saveChanges();
franta-hg@72: 
franta-hg@72: 		for (Enumeration e = msg.getAllHeaders(); e.hasMoreElements();) {
franta-hg@72: 			final Header header = (Header) e.nextElement();
franta-hg@72: 			this.headers.addHeader(header.getName(), header.getValue());
franta-hg@72: 		}
franta-hg@72: 
franta-hg@72: 		setBody(msg.getBody());
franta-hg@72: 		validateHeaders();
franta-hg@72: 	}
franta-hg@72: }