001
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
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 }