001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.messageboards.util;
016    
017    import com.liferay.portal.kernel.util.GetterUtil;
018    import com.liferay.portal.kernel.util.HtmlUtil;
019    import com.liferay.portal.kernel.util.ObjectValuePair;
020    import com.liferay.portal.kernel.util.Validator;
021    
022    import java.util.ArrayList;
023    import java.util.List;
024    
025    /**
026     * @author Jorge Ferrer
027     */
028    public class MBMailMessage {
029    
030            public void addFile(String fileName, byte[] bytes) {
031                    _files.add(new ObjectValuePair<String, byte[]>(fileName, bytes));
032            }
033    
034            public List<ObjectValuePair<String, byte[]>> getFiles() {
035                    return _files;
036            }
037    
038            public String getHtmlBody() {
039                    return _htmlBody;
040            }
041    
042            public void setHtmlBody(String htmlBody) {
043                    _htmlBody = htmlBody;
044            }
045    
046            public String getPlainBody() {
047                    return _plainBody;
048            }
049    
050            public void setPlainBody(String plainBody) {
051                    _plainBody = plainBody;
052            }
053    
054            public String getBody() {
055                    if (Validator.isNotNull(_plainBody)) {
056                            return GetterUtil.getString(_plainBody);
057                    }
058                    else if (Validator.isNotNull(_htmlBody)) {
059                            return HtmlUtil.extractText(_htmlBody);
060                    }
061                    else {
062                            return "-";
063                    }
064            }
065    
066            private String _htmlBody;
067            private String _plainBody;
068            private List<ObjectValuePair<String, byte[]>> _files =
069                    new ArrayList<ObjectValuePair<String, byte[]>>();
070    
071    }