|
|
|
@ -7,6 +7,24 @@
|
|
|
|
|
|
|
|
|
|
package it.tref.liferay.portos.mailmanager.service.impl; |
|
|
|
|
|
|
|
|
|
import com.liferay.mail.model.FileAttachment; |
|
|
|
|
import com.liferay.portal.kernel.exception.PortalException; |
|
|
|
|
import com.liferay.portal.kernel.exception.SystemException; |
|
|
|
|
import com.liferay.portal.kernel.log.Log; |
|
|
|
|
import com.liferay.portal.kernel.log.LogFactoryUtil; |
|
|
|
|
import com.liferay.portal.kernel.repository.model.Folder; |
|
|
|
|
import com.liferay.portal.kernel.util.FileUtil; |
|
|
|
|
import com.liferay.portal.kernel.util.OrderByComparator; |
|
|
|
|
import com.liferay.portal.kernel.util.StringPool; |
|
|
|
|
import com.liferay.portal.kernel.util.StringUtil; |
|
|
|
|
import com.liferay.portal.kernel.util.Validator; |
|
|
|
|
import com.liferay.portal.model.Company; |
|
|
|
|
import com.liferay.portal.model.Group; |
|
|
|
|
import com.liferay.portal.model.User; |
|
|
|
|
import com.liferay.portal.security.permission.ActionKeys; |
|
|
|
|
import com.liferay.portal.service.ServiceContext; |
|
|
|
|
import com.liferay.portlet.documentlibrary.model.DLFolderConstants; |
|
|
|
|
|
|
|
|
|
import it.tref.liferay.portos.mailmanager.EmailBccException; |
|
|
|
|
import it.tref.liferay.portos.mailmanager.EmailBulkAddressesException; |
|
|
|
|
import it.tref.liferay.portos.mailmanager.EmailCcException; |
|
|
|
@ -27,24 +45,9 @@ import java.util.Collections;
|
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
import com.liferay.mail.model.FileAttachment; |
|
|
|
|
import com.liferay.portal.kernel.exception.PortalException; |
|
|
|
|
import com.liferay.portal.kernel.exception.SystemException; |
|
|
|
|
import com.liferay.portal.kernel.repository.model.Folder; |
|
|
|
|
import com.liferay.portal.kernel.util.FileUtil; |
|
|
|
|
import com.liferay.portal.kernel.util.OrderByComparator; |
|
|
|
|
import com.liferay.portal.kernel.util.StringPool; |
|
|
|
|
import com.liferay.portal.kernel.util.StringUtil; |
|
|
|
|
import com.liferay.portal.kernel.util.Validator; |
|
|
|
|
import com.liferay.portal.model.Company; |
|
|
|
|
import com.liferay.portal.model.Group; |
|
|
|
|
import com.liferay.portal.model.User; |
|
|
|
|
import com.liferay.portal.security.permission.ActionKeys; |
|
|
|
|
import com.liferay.portal.service.ServiceContext; |
|
|
|
|
import com.liferay.portlet.documentlibrary.model.DLFolderConstants; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* The implementation of the email local service. |
|
|
|
|
* |
|
|
|
|
* <p> |
|
|
|
|
* All custom service methods should be put in this class. Whenever methods are added, rerun ServiceBuilder to copy |
|
|
|
|
* their definitions into the {@link it.noovle.azimut.icf.mailmanager.service.EmailLocalService} interface. |
|
|
|
@ -63,63 +66,61 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
|
|
|
|
|
* it.noovle.azimut.icf.mailmanager.service.EmailLocalServiceUtil} to access the email local service. |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Email addEmail(String className, long classPK, String from, String to[], String cc[], String bcc[], |
|
|
|
|
String subject, String body, boolean htmlFormat, ServiceContext serviceContext) throws Exception { |
|
|
|
|
private final static Log _log = LogFactoryUtil.getLog(EmailLocalServiceImpl.class); |
|
|
|
|
|
|
|
|
|
return addEmail(className, classPK, from, to, cc, bcc, null, subject, body, htmlFormat, null, null, null, null, |
|
|
|
|
0, false, null, null, Collections.<FileAttachment> emptyList(), serviceContext); |
|
|
|
|
public Email addEmail(String className, long classPK, String from, String to[], String cc[], |
|
|
|
|
String bcc[], String subject, String body, boolean htmlFormat, ServiceContext serviceContext) |
|
|
|
|
throws Exception { |
|
|
|
|
return addEmail(className, classPK, from, to, cc, bcc, null, subject, body, htmlFormat, null, null, |
|
|
|
|
null, null, 0, false, null, null, Collections.<FileAttachment> emptyList(), serviceContext); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Email addEmail(String className, long classPK, String from, String to[], String cc[], String bcc[], |
|
|
|
|
String subject, String body, boolean htmlFormat, List<FileAttachment> fileAttachments, |
|
|
|
|
ServiceContext serviceContext) throws Exception { |
|
|
|
|
|
|
|
|
|
return addEmail(className, classPK, from, to, cc, bcc, null, subject, body, htmlFormat, null, null, null, null, |
|
|
|
|
0, false, null, null, fileAttachments, false, null, serviceContext); |
|
|
|
|
public Email addEmail(String className, long classPK, String from, String to[], String cc[], |
|
|
|
|
String bcc[], String subject, String body, boolean htmlFormat, |
|
|
|
|
List<FileAttachment> fileAttachments, ServiceContext serviceContext) throws Exception { |
|
|
|
|
return addEmail(className, classPK, from, to, cc, bcc, null, subject, body, htmlFormat, null, null, |
|
|
|
|
null, null, 0, false, null, null, fileAttachments, false, null, serviceContext); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Email addEmail(String className, long classPK, String from, String to[], String cc[], String bcc[], |
|
|
|
|
String[] bulkAddresses, String subject, String body, boolean htmlFormat, String[] replyTo, |
|
|
|
|
String messageId, String inReplyTo, String smtpHost, int smtpPort, boolean smtpSecure, String smtpUsername, |
|
|
|
|
String smtpPassword, List<FileAttachment> fileAttachments, ServiceContext serviceContext) throws Exception { |
|
|
|
|
|
|
|
|
|
return addEmail(className, classPK, from, to, cc, bcc, bulkAddresses, subject, body, htmlFormat, replyTo, |
|
|
|
|
messageId, inReplyTo, smtpHost, smtpPort, smtpSecure, smtpUsername, smtpPassword, fileAttachments, |
|
|
|
|
false, null, serviceContext); |
|
|
|
|
public Email addEmail(String className, long classPK, String from, String to[], String cc[], |
|
|
|
|
String bcc[], String[] bulkAddresses, String subject, String body, boolean htmlFormat, |
|
|
|
|
String[] replyTo, String messageId, String inReplyTo, String smtpHost, int smtpPort, |
|
|
|
|
boolean smtpSecure, String smtpUsername, String smtpPassword, |
|
|
|
|
List<FileAttachment> fileAttachments, ServiceContext serviceContext) throws Exception { |
|
|
|
|
return addEmail(className, classPK, from, to, cc, bcc, bulkAddresses, subject, body, htmlFormat, |
|
|
|
|
replyTo, messageId, inReplyTo, smtpHost, smtpPort, smtpSecure, smtpUsername, smtpPassword, |
|
|
|
|
fileAttachments, false, null, serviceContext); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Email addEmail(String className, long classPK, String from, String to[], String cc[], String bcc[], |
|
|
|
|
String subject, String body, boolean htmlFormat, List<FileAttachment> fileAttachments, boolean sendSync, |
|
|
|
|
ServiceContext serviceContext) throws Exception { |
|
|
|
|
|
|
|
|
|
return addEmail(className, classPK, from, to, cc, bcc, null, subject, body, htmlFormat, null, null, null, null, |
|
|
|
|
0, false, null, null, fileAttachments, sendSync, null, serviceContext); |
|
|
|
|
public Email addEmail(String className, long classPK, String from, String to[], String cc[], |
|
|
|
|
String bcc[], String subject, String body, boolean htmlFormat, |
|
|
|
|
List<FileAttachment> fileAttachments, boolean sendSync, ServiceContext serviceContext) |
|
|
|
|
throws Exception { |
|
|
|
|
return addEmail(className, classPK, from, to, cc, bcc, null, subject, body, htmlFormat, null, null, |
|
|
|
|
null, null, 0, false, null, null, fileAttachments, sendSync, null, serviceContext); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Email addEmail(String className, long classPK, String from, String to[], String cc[], String bcc[], |
|
|
|
|
String subject, String body, boolean htmlFormat, List<FileAttachment> fileAttachments, boolean sendSync, |
|
|
|
|
String templateName, ServiceContext serviceContext) throws Exception { |
|
|
|
|
|
|
|
|
|
return addEmail(className, classPK, from, to, cc, bcc, null, subject, body, htmlFormat, null, null, null, null, |
|
|
|
|
0, false, null, null, fileAttachments, sendSync, templateName, serviceContext); |
|
|
|
|
public Email addEmail(String className, long classPK, String from, String to[], String cc[], |
|
|
|
|
String bcc[], String subject, String body, boolean htmlFormat, |
|
|
|
|
List<FileAttachment> fileAttachments, boolean sendSync, String templateName, |
|
|
|
|
ServiceContext serviceContext) throws Exception { |
|
|
|
|
return addEmail(className, classPK, from, to, cc, bcc, null, subject, body, htmlFormat, null, null, |
|
|
|
|
null, null, 0, false, null, null, fileAttachments, sendSync, templateName, serviceContext); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Email addEmail(String className, long classPK, String from, String to[], String cc[], String bcc[], |
|
|
|
|
String[] bulkAddresses, String subject, String body, boolean htmlFormat, String[] replyTo, |
|
|
|
|
String messageId, String inReplyTo, String smtpHost, int smtpPort, boolean smtpSecure, String smtpUsername, |
|
|
|
|
String smtpPassword, List<FileAttachment> fileAttachments, boolean sendSync, String templateName, |
|
|
|
|
public Email addEmail(String className, long classPK, String from, String to[], String cc[], |
|
|
|
|
String bcc[], String[] bulkAddresses, String subject, String body, boolean htmlFormat, |
|
|
|
|
String[] replyTo, String messageId, String inReplyTo, String smtpHost, int smtpPort, |
|
|
|
|
boolean smtpSecure, String smtpUsername, String smtpPassword, |
|
|
|
|
List<FileAttachment> fileAttachments, boolean sendSync, String templateName, |
|
|
|
|
ServiceContext serviceContext) throws Exception { |
|
|
|
|
|
|
|
|
|
User user = userLocalService.getUser(serviceContext.getUserId()); |
|
|
|
|
Date now = new Date(); |
|
|
|
|
validate(from, to, cc, bcc, bulkAddresses, subject, body, replyTo); |
|
|
|
|
Email email = createEmail(counterLocalService.increment(Email.class.getName())); |
|
|
|
|
|
|
|
|
|
Email email = emailLocalService.createEmail(counterLocalService.increment(Email.class.getName())); |
|
|
|
|
|
|
|
|
|
email.setGroupId(serviceContext.getScopeGroupId()); |
|
|
|
|
email.setCompanyId(serviceContext.getCompanyId()); |
|
|
|
|
email.setCreateDate(serviceContext.getCreateDate(now)); |
|
|
|
@ -171,11 +172,11 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
|
|
|
|
|
return email; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Email updateEmail(long emailId, String from, String to[], String cc[], String bcc[], String subject, |
|
|
|
|
String body, ServiceContext serviceContext) throws Exception { |
|
|
|
|
public Email updateEmail(long emailId, String from, String to[], String cc[], String bcc[], |
|
|
|
|
String subject, String body, ServiceContext serviceContext) throws Exception { |
|
|
|
|
|
|
|
|
|
Email email = emailLocalService.getEmail(emailId); |
|
|
|
|
|
|
|
|
|
Email email = getEmail(emailId); |
|
|
|
|
validate(from, to, cc, bcc, null, subject, body, null); |
|
|
|
|
email.setModifiedDate(new Date()); |
|
|
|
|
email.setFrom(from); |
|
|
|
@ -187,10 +188,10 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
|
|
|
|
|
return updateEmail(email); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Email markAsSent(long emailId, Date sentDate, String statusMessage) throws PortalException, SystemException { |
|
|
|
|
public Email markAsSent(long emailId, Date sentDate, String statusMessage) throws PortalException, |
|
|
|
|
SystemException { |
|
|
|
|
|
|
|
|
|
Email email = getEmail(emailId); |
|
|
|
|
Email email = emailLocalService.getEmail(emailId); |
|
|
|
|
email.setModifiedDate(new Date()); |
|
|
|
|
email.setSent(true); |
|
|
|
|
email.setSentDate(sentDate); |
|
|
|
@ -198,19 +199,18 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
|
|
|
|
|
return updateEmail(email); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Email updateStatusMessage(long emailId, String statusMessage) throws PortalException, SystemException { |
|
|
|
|
public Email updateStatusMessage(long emailId, String statusMessage) throws PortalException, |
|
|
|
|
SystemException { |
|
|
|
|
|
|
|
|
|
Email email = getEmail(emailId); |
|
|
|
|
Email email = emailLocalService.getEmail(emailId); |
|
|
|
|
email.setModifiedDate(new Date()); |
|
|
|
|
email.setStatusMessage(statusMessage); |
|
|
|
|
return updateEmail(email); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Email resendEmail(long emailId) throws PortalException, SystemException { |
|
|
|
|
|
|
|
|
|
Email email = getEmail(emailId); |
|
|
|
|
Email email = emailLocalService.getEmail(emailId); |
|
|
|
|
email.setModifiedDate(new Date()); |
|
|
|
|
email.setStatusMessage(""); |
|
|
|
|
email.setSent(false); |
|
|
|
@ -219,10 +219,9 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
|
|
|
|
|
return updateEmail(email); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Email cancelEmail(long emailId) throws PortalException, SystemException { |
|
|
|
|
|
|
|
|
|
Email email = getEmail(emailId); |
|
|
|
|
Email email = emailLocalService.getEmail(emailId); |
|
|
|
|
email.setModifiedDate(new Date()); |
|
|
|
|
email.setCancel(true); |
|
|
|
|
return updateEmail(email); |
|
|
|
@ -230,8 +229,7 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Email deleteEmail(long emailId) throws PortalException, SystemException { |
|
|
|
|
|
|
|
|
|
Email email = getEmail(emailId); |
|
|
|
|
Email email = emailLocalService.getEmail(emailId); |
|
|
|
|
return deleteEmail(email); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -247,92 +245,76 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
|
|
|
|
|
return email; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<Email> findByCompany(long companyId) throws SystemException { |
|
|
|
|
|
|
|
|
|
return emailPersistence.findByCompany(companyId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<Email> findByCompany(long companyId, int start, int end) throws SystemException { |
|
|
|
|
|
|
|
|
|
return emailPersistence.findByCompany(companyId, start, end); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<Email> findByCompany(long companyId, int start, int end, OrderByComparator orderByComparator) |
|
|
|
|
throws SystemException { |
|
|
|
|
|
|
|
|
|
return emailPersistence.findByCompany(companyId, start, end, orderByComparator); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public int countByCompany(long companyId) throws SystemException { |
|
|
|
|
|
|
|
|
|
return emailPersistence.countByCompany(companyId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<Email> findByC_G(long companyId, long groupId) throws SystemException { |
|
|
|
|
|
|
|
|
|
return emailPersistence.findByC_G(companyId, groupId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<Email> findByC_G(long companyId, long groupId, int start, int end) throws SystemException { |
|
|
|
|
|
|
|
|
|
return emailPersistence.findByC_G(companyId, groupId, start, end); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<Email> findByC_G(long companyId, long groupId, int start, int end, OrderByComparator orderByComparator) |
|
|
|
|
throws SystemException { |
|
|
|
|
|
|
|
|
|
public List<Email> findByC_G(long companyId, long groupId, int start, int end, |
|
|
|
|
OrderByComparator orderByComparator) throws SystemException { |
|
|
|
|
return emailPersistence.findByC_G(companyId, groupId, start, end, orderByComparator); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public int countByC_G(long companyId, long groupId) throws SystemException { |
|
|
|
|
|
|
|
|
|
return emailPersistence.countByC_G(companyId, groupId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<Email> findByC_G_T(long companyId, long groupId, String templateName) throws SystemException { |
|
|
|
|
|
|
|
|
|
return emailPersistence.findByC_G_T(companyId, groupId, templateName); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<Email> findByC_G_T(long companyId, long groupId, String templateName, int start, int end) |
|
|
|
|
throws SystemException { |
|
|
|
|
|
|
|
|
|
return emailPersistence.findByC_G_T(companyId, groupId, templateName, start, end); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public int countByC_G_T(long companyId, long groupId, String templateName) throws SystemException { |
|
|
|
|
|
|
|
|
|
return emailPersistence.countByC_G_T(companyId, groupId, templateName); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<Email> findByC_G_C_C(long companyId, long groupId, long classNameId, long classPK) |
|
|
|
|
throws SystemException { |
|
|
|
|
|
|
|
|
|
return emailPersistence.findByC_G_C_C(companyId, groupId, classNameId, classPK); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<Email> findByC_G_C_C(long companyId, long groupId, long classNameId, long classPK, int start, int end) |
|
|
|
|
throws SystemException { |
|
|
|
|
|
|
|
|
|
public List<Email> findByC_G_C_C(long companyId, long groupId, long classNameId, long classPK, int start, |
|
|
|
|
int end) throws SystemException { |
|
|
|
|
return emailPersistence.findByC_G_C_C(companyId, groupId, classNameId, classPK, start, end); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public int countByC_G_C_C(long companyId, long groupId, long classNameId, long classPK) throws SystemException { |
|
|
|
|
|
|
|
|
|
public int countByC_G_C_C(long companyId, long groupId, long classNameId, long classPK) |
|
|
|
|
throws SystemException { |
|
|
|
|
return emailPersistence.countByC_G_C_C(companyId, groupId, classNameId, classPK); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|