@ -1,12 +1,36 @@
/ * *
/ * *
* Copyright ( c ) 2000 - 2013 Liferay , Inc . All rights reserved . The contents of this file are subject to the terms of the
* Copyright ( c ) 2000 - 2013 Liferay , Inc . All rights reserved .
* Liferay Enterprise Subscription License ( "License" ) . You may not use this file except in compliance with the License .
*
* You can obtain a copy of the License by contacting Liferay , Inc . See the License for the specific language governing
* The contents of this file are subject to the terms of the Liferay Enterprise Subscription License
* permissions and limitations under the License , including but not limited to distribution rights of the Software .
* ( "License" ) . You may not use this file except in compliance with the License . You can obtain a
* copy of the License by contacting Liferay , Inc . See the License for the specific language
* governing permissions and limitations under the License , including but not limited to
* distribution rights of the Software .
*
*
*
* /
* /
package it.tref.liferay.portos.mailmanager.service.impl ;
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.EmailBccException ;
import it.tref.liferay.portos.mailmanager.EmailBulkAddressesException ;
import it.tref.liferay.portos.mailmanager.EmailBulkAddressesException ;
import it.tref.liferay.portos.mailmanager.EmailCcException ;
import it.tref.liferay.portos.mailmanager.EmailCcException ;
@ -27,30 +51,18 @@ import java.util.Collections;
import java.util.Date ;
import java.util.Date ;
import java.util.List ;
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 .
* The implementation of the email local service .
*
* < p >
* < p >
* All custom service methods should be put in this class . Whenever methods are added , rerun ServiceBuilder to copy
* All custom service methods should be put in this class . Whenever methods are
* their definitions into the { @link it . noovle . azimut . icf . mailmanager . service . EmailLocalService } interface .
* added , rerun ServiceBuilder to copy their definitions into the
* { @link it . noovle . azimut . icf . mailmanager . service . EmailLocalService } interface .
*
* < p >
* < p >
* This is a local service . Methods of this service will not have security checks based on the propagated JAAS
* This is a local service . Methods of this service will not have security
* credentials because this service can only be accessed from within the same VM .
* checks based on the propagated JAAS credentials because this service can only
* be accessed from within the same VM .
* < / p >
* < / p >
*
*
* @author
* @author
@ -59,67 +71,70 @@ import com.liferay.portlet.documentlibrary.model.DLFolderConstants;
* /
* /
public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
/ *
/ *
* NOTE FOR DEVELOPERS : Never reference this interface directly . Always use { @link
* NOTE FOR DEVELOPERS :
* it . noovle . azimut . icf . mailmanager . service . EmailLocalServiceUtil } to access the email local service .
*
* Never reference this interface directly . Always use { @link
* it . noovle . azimut . icf . mailmanager . service . EmailLocalServiceUtil } to access
* the email local service .
* /
* /
@Override
private final static Log _log = LogFactoryUtil . getLog ( EmailLocalServiceImpl . class ) ;
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 ,
public Email addEmail ( String className , long classPK , String from , String to [ ] , String cc [ ] ,
0 , false , null , null , Collections . < FileAttachment > emptyList ( ) , serviceContext ) ;
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 [ ] ,
public Email addEmail ( String className , long classPK , String from , String to [ ] , String cc [ ] , String bcc [ ] ,
String bcc [ ] , String subject , String body , boolean htmlFormat ,
String subject , String body , boolean htmlFormat , List < FileAttachment > fileAttachments ,
List < FileAttachment > fileAttachments , ServiceContext serviceContext ) throws Exception {
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 ) ;
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 [ ] ,
public Email addEmail ( String className , long classPK , String from , String to [ ] , String cc [ ] , String bcc [ ] ,
String bcc [ ] , String [ ] bulkAddresses , String subject , String body , boolean htmlFormat ,
String [ ] bulkAddresses , String subject , String body , boolean htmlFormat , String [ ] replyTo ,
String [ ] replyTo , String messageId , String inReplyTo , String smtpHost , int smtpPort ,
String messageId , String inReplyTo , String smtpHost , int smtpPort , boolean smtpSecure , String smtpUsername ,
boolean smtpSecure , String smtpUsername , String smtpPassword ,
String smtpPassword , List < FileAttachment > fileAttachments , ServiceContext serviceContext ) throws Exception {
List < FileAttachment > fileAttachments , ServiceContext serviceContext ) throws Exception {
return addEmail ( className , classPK , from , to , cc , bcc , bulkAddresses , subject , body , htmlFormat ,
return addEmail ( className , classPK , from , to , cc , bcc , bulkAddresses , subject , body , htmlFormat , replyTo ,
replyTo , messageId , inReplyTo , smtpHost , smtpPort , smtpSecure , smtpUsername , smtpPassword ,
messageId , inReplyTo , smtpHost , smtpPort , smtpSecure , smtpUsername , smtpPassword , fileAttachments ,
fileAttachments , false , null , serviceContext ) ;
false , null , serviceContext ) ;
}
}
@Override
public Email addEmail ( String className , long classPK , String from , String to [ ] , String cc [ ] ,
public Email addEmail ( String className , long classPK , String from , String to [ ] , String cc [ ] , String bcc [ ] ,
String bcc [ ] , String subject , String body , boolean htmlFormat ,
String subject , String body , boolean htmlFormat , List < FileAttachment > fileAttachments , boolean sendSync ,
List < FileAttachment > fileAttachments , boolean sendSync , ServiceContext serviceContext )
ServiceContext serviceContext ) throws Exception {
throws Exception {
return addEmail ( className , classPK , from , to , cc , bcc , null , subject , body , htmlFormat , null , null ,
return addEmail ( className , classPK , from , to , cc , bcc , null , subject , body , htmlFormat , null , null , null , null ,
null , null , 0 , false , null , null , fileAttachments , sendSync , null , serviceContext ) ;
0 , false , null , null , fileAttachments , sendSync , null , serviceContext ) ;
}
}
@Override
public Email addEmail ( String className , long classPK , String from , String to [ ] , String cc [ ] ,
public Email addEmail ( String className , long classPK , String from , String to [ ] , String cc [ ] , String bcc [ ] ,
String bcc [ ] , String subject , String body , boolean htmlFormat ,
String subject , String body , boolean htmlFormat , List < FileAttachment > fileAttachments , boolean sendSync ,
List < FileAttachment > fileAttachments , boolean sendSync , String templateName ,
String templateName , ServiceContext serviceContext ) throws Exception {
ServiceContext serviceContext ) throws Exception {
return addEmail ( className , classPK , from , to , cc , bcc , null , subject , body , htmlFormat , null , null ,
return addEmail ( className , classPK , from , to , cc , bcc , null , subject , body , htmlFormat , null , null , null , null ,
null , null , 0 , false , null , null , fileAttachments , sendSync , templateName , serviceContext ) ;
0 , false , null , null , fileAttachments , sendSync , templateName , serviceContext ) ;
}
}
@Override
public Email addEmail ( String className , long classPK , String from , String to [ ] , String cc [ ] ,
public Email addEmail ( String className , long classPK , String from , String to [ ] , String cc [ ] , String bcc [ ] ,
String bcc [ ] , String [ ] bulkAddresses , String subject , String body , boolean htmlFormat ,
String [ ] bulkAddresses , String subject , String body , boolean htmlFormat , String [ ] replyTo ,
String [ ] replyTo , String messageId , String inReplyTo , String smtpHost , int smtpPort ,
String messageId , String inReplyTo , String smtpHost , int smtpPort , boolean smtpSecure , String smtpUsername ,
boolean smtpSecure , String smtpUsername , String smtpPassword ,
String smtpPassword , List < FileAttachment > fileAttachments , boolean sendSync , String templateName ,
List < FileAttachment > fileAttachments , boolean sendSync , String templateName ,
ServiceContext serviceContext ) throws Exception {
ServiceContext serviceContext ) throws Exception {
User user = userLocalService . getUser ( serviceContext . getUserId ( ) ) ;
User user = userLocalService . getUser ( serviceContext . getUserId ( ) ) ;
Date now = new Date ( ) ;
Date now = new Date ( ) ;
validate ( from , to , cc , bcc , bulkAddresses , subject , body , replyTo ) ;
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 . setGroupId ( serviceContext . getScopeGroupId ( ) ) ;
email . setCompanyId ( serviceContext . getCompanyId ( ) ) ;
email . setCompanyId ( serviceContext . getCompanyId ( ) ) ;
email . setCreateDate ( serviceContext . getCreateDate ( now ) ) ;
email . setCreateDate ( serviceContext . getCreateDate ( now ) ) ;
@ -128,6 +143,7 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
email . setClassPK ( classPK ) ;
email . setClassPK ( classPK ) ;
email . setUserId ( user . getUserId ( ) ) ;
email . setUserId ( user . getUserId ( ) ) ;
email . setUserName ( user . getFullName ( ) ) ;
email . setUserName ( user . getFullName ( ) ) ;
email . setFrom ( from ) ;
email . setFrom ( from ) ;
email . setTo ( StringUtil . merge ( to , StringPool . COMMA ) ) ;
email . setTo ( StringUtil . merge ( to , StringPool . COMMA ) ) ;
email . setCc ( StringUtil . merge ( cc , StringPool . COMMA ) ) ;
email . setCc ( StringUtil . merge ( cc , StringPool . COMMA ) ) ;
@ -135,10 +151,12 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
email . setBulkAddresses ( StringUtil . merge ( bulkAddresses , StringPool . COMMA ) ) ;
email . setBulkAddresses ( StringUtil . merge ( bulkAddresses , StringPool . COMMA ) ) ;
email . setSubject ( subject ) ;
email . setSubject ( subject ) ;
email . setBody ( body ) ;
email . setBody ( body ) ;
email . setHtmlFormat ( htmlFormat ) ;
email . setHtmlFormat ( htmlFormat ) ;
email . setReplyTo ( StringUtil . merge ( replyTo , StringPool . COMMA ) ) ;
email . setReplyTo ( StringUtil . merge ( replyTo , StringPool . COMMA ) ) ;
email . setMessageId ( messageId ) ;
email . setMessageId ( messageId ) ;
email . setInReplyTo ( inReplyTo ) ;
email . setInReplyTo ( inReplyTo ) ;
email . setSmtpHost ( smtpHost ) ;
email . setSmtpHost ( smtpHost ) ;
email . setSmtpPort ( smtpPort ) ;
email . setSmtpPort ( smtpPort ) ;
email . setSmtpSecure ( smtpSecure ) ;
email . setSmtpSecure ( smtpSecure ) ;
@ -146,37 +164,46 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
email . setSmtpPassword ( smtpPassword ) ;
email . setSmtpPassword ( smtpPassword ) ;
email . setCancel ( false ) ;
email . setCancel ( false ) ;
email . setTemplateName ( templateName ) ;
email . setTemplateName ( templateName ) ;
email = addEmail ( email ) ;
email = addEmail ( email ) ;
// Email Attachments
// Email Attachments
if ( fileAttachments ! = null & & ! fileAttachments . isEmpty ( ) ) {
if ( fileAttachments ! = null & & ! fileAttachments . isEmpty ( ) ) {
Folder folder = addEmailAttachmentsFolder ( serviceContext . getCompanyId ( ) , email . getEmailId ( ) ) ;
Folder folder = addEmailAttachmentsFolder ( serviceContext . getCompanyId ( ) , email . getEmailId ( ) ) ;
for ( FileAttachment fileAttachment : fileAttachments ) {
for ( FileAttachment fileAttachment : fileAttachments ) {
if ( fileAttachment instanceof FileAttachment ) {
if ( fileAttachment instanceof FileAttachment ) {
( ( it . tref . liferay . portos . mailmanager . shared . model . FileAttachment ) fileAttachment ) . generateFile ( ) ;
( ( it . tref . liferay . portos . mailmanager . shared . model . FileAttachment ) fileAttachment )
. generateFile ( ) ;
}
}
emailAttachmentLocalService . addEmailAttachment ( serviceContext . getCompanyId ( ) , email . getEmailId ( ) ,
emailAttachmentLocalService . addEmailAttachment ( serviceContext . getCompanyId ( ) ,
folder . getFolderId ( ) , fileAttachment . getFileName ( ) , fileAttachment . getFile ( ) ) ;
email . getEmailId ( ) , folder . getFolderId ( ) , fileAttachment . getFileName ( ) ,
fileAttachment . getFile ( ) ) ;
FileUtil . delete ( fileAttachment . getFile ( ) ) ;
FileUtil . delete ( fileAttachment . getFile ( ) ) ;
}
}
}
}
// Manifattura Web Group per Regione Siciliana
// Il valore di ritorno viene ignorato da SchedulerInvioDocumenti, le mail impostate per l'invio asincrono si
// Il valore di ritorno viene ignorato da SchedulerInvioDocumenti, le
// perdono nell'abisso dell'oblio. Siccome questo è già un task asincrono, inviamo in maniera sincrona e
// mail impostate per l'invio asincrono si perdono nell'abisso
// festeggiamo.
// dell'oblio. Siccome questo è già un task asincrono, inviamo in
// maniera sincrona e festeggiamo.
sendSync = true ;
sendSync = true ;
if ( sendSync ) {
if ( sendSync ) {
MailSenderUtil . sendMail ( email ) ;
MailSenderUtil . sendMail ( email ) ;
markAsSent ( email . getEmailId ( ) , new Date ( ) , StringPool . BLANK ) ;
markAsSent ( email . getEmailId ( ) , new Date ( ) , StringPool . BLANK ) ;
}
}
return email ;
return email ;
}
}
@Override
public Email updateEmail ( long emailId , String from , String to [ ] , String cc [ ] , String bcc [ ] ,
public Email updateEmail ( long emailId , String from , String to [ ] , String cc [ ] , String bcc [ ] , String subject ,
String subject , String body , ServiceContext serviceContext ) throws Exception {
String body , ServiceContext serviceContext ) throws Exception {
Email email = emailLocalService . getEmail ( emailId ) ;
Email email = getEmail ( emailId ) ;
validate ( from , to , cc , bcc , null , subject , body , null ) ;
validate ( from , to , cc , bcc , null , subject , body , null ) ;
email . setModifiedDate ( new Date ( ) ) ;
email . setModifiedDate ( new Date ( ) ) ;
email . setFrom ( from ) ;
email . setFrom ( from ) ;
email . setTo ( StringUtil . merge ( to , StringPool . COMMA ) ) ;
email . setTo ( StringUtil . merge ( to , StringPool . COMMA ) ) ;
@ -184,54 +211,60 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
email . setBcc ( StringUtil . merge ( bcc , StringPool . COMMA ) ) ;
email . setBcc ( StringUtil . merge ( bcc , StringPool . COMMA ) ) ;
email . setSubject ( subject ) ;
email . setSubject ( subject ) ;
email . setBody ( body ) ;
email . setBody ( body ) ;
return updateEmail ( email ) ;
return updateEmail ( email ) ;
}
}
@Override
public Email markAsSent ( long emailId , Date sentDate , String statusMessage ) throws PortalException ,
public Email markAsSent ( long emailId , Date sentDate , String statusMessage ) throws PortalException , SystemException {
SystemException {
Email email = getEmail ( emailId ) ;
Email email = emailLocalService . getEmail ( emailId ) ;
email . setModifiedDate ( new Date ( ) ) ;
email . setModifiedDate ( new Date ( ) ) ;
email . setSent ( true ) ;
email . setSent ( true ) ;
email . setSentDate ( sentDate ) ;
email . setSentDate ( sentDate ) ;
email . setStatusMessage ( statusMessage ) ;
email . setStatusMessage ( statusMessage ) ;
return updateEmail ( email ) ;
return updateEmail ( email ) ;
}
}
@Override
public Email updateStatusMessage ( long emailId , String statusMessage ) throws PortalException ,
public Email updateStatusMessage ( long emailId , String statusMessage ) throws PortalException , SystemException {
SystemException {
Email email = getEmail ( emailId ) ;
Email email = emailLocalService . getEmail ( emailId ) ;
email . setModifiedDate ( new Date ( ) ) ;
email . setModifiedDate ( new Date ( ) ) ;
email . setStatusMessage ( statusMessage ) ;
email . setStatusMessage ( statusMessage ) ;
return updateEmail ( email ) ;
return updateEmail ( email ) ;
}
}
@Override
public Email resendEmail ( long emailId ) throws PortalException , SystemException {
public Email resendEmail ( long emailId ) throws PortalException , SystemException {
Email email = getEmail ( emailId ) ;
Email email = emailLocalService . getEmail ( emailId ) ;
email . setModifiedDate ( new Date ( ) ) ;
email . setModifiedDate ( new Date ( ) ) ;
email . setStatusMessage ( "" ) ;
email . setStatusMessage ( "" ) ;
email . setSent ( false ) ;
email . setSent ( false ) ;
email . setSentDate ( null ) ;
email . setSentDate ( null ) ;
email . setCancel ( false ) ;
email . setCancel ( false ) ;
return updateEmail ( email ) ;
return updateEmail ( email ) ;
}
}
@Override
public Email cancelEmail ( long emailId ) throws PortalException , SystemException {
public Email cancelEmail ( long emailId ) throws PortalException , SystemException {
Email email = getEmail ( emailId ) ;
Email email = emailLocalService . getEmail ( emailId ) ;
email . setModifiedDate ( new Date ( ) ) ;
email . setModifiedDate ( new Date ( ) ) ;
email . setCancel ( true ) ;
email . setCancel ( true ) ;
return updateEmail ( email ) ;
return updateEmail ( email ) ;
}
}
@Override
@Override
public Email deleteEmail ( long emailId ) throws PortalException , SystemException {
public Email deleteEmail ( long emailId ) throws PortalException , SystemException {
Email email = emailLocalService . getEmail ( emailId ) ;
Email email = getEmail ( emailId ) ;
return deleteEmail ( email ) ;
return deleteEmail ( email ) ;
}
}
@ -239,126 +272,108 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
public Email deleteEmail ( Email email ) throws SystemException {
public Email deleteEmail ( Email email ) throws SystemException {
super . deleteEmail ( email ) ;
super . deleteEmail ( email ) ;
// Email Attachments
// Email Attachments
List < EmailAttachment > emailAttachments = emailAttachmentLocalService . findByEmailId ( email . getEmailId ( ) ) ;
List < EmailAttachment > emailAttachments = emailAttachmentLocalService
. findByEmailId ( email . getEmailId ( ) ) ;
for ( EmailAttachment emailAttachment : emailAttachments ) {
for ( EmailAttachment emailAttachment : emailAttachments ) {
emailAttachmentLocalService . deleteEmailAttachment ( emailAttachment ) ;
emailAttachmentLocalService . deleteEmailAttachment ( emailAttachment ) ;
}
}
return email ;
return email ;
}
}
@Override
public List < Email > findByCompany ( long companyId ) throws SystemException {
public List < Email > findByCompany ( long companyId ) throws SystemException {
return emailPersistence . findByCompany ( companyId ) ;
return emailPersistence . findByCompany ( companyId ) ;
}
}
@Override
public List < Email > findByCompany ( long companyId , int start , int end ) throws SystemException {
public List < Email > findByCompany ( long companyId , int start , int end ) throws SystemException {
return emailPersistence . findByCompany ( companyId , start , end ) ;
return emailPersistence . findByCompany ( companyId , start , end ) ;
}
}
@Override
public List < Email > findByCompany ( long companyId , int start , int end , OrderByComparator orderByComparator )
public List < Email > findByCompany ( long companyId , int start , int end , OrderByComparator orderByComparator )
throws SystemException {
throws SystemException {
return emailPersistence . findByCompany ( companyId , start , end , orderByComparator ) ;
return emailPersistence . findByCompany ( companyId , start , end , orderByComparator ) ;
}
}
@Override
public int countByCompany ( long companyId ) throws SystemException {
public int countByCompany ( long companyId ) throws SystemException {
return emailPersistence . countByCompany ( companyId ) ;
return emailPersistence . countByCompany ( companyId ) ;
}
}
@Override
public List < Email > findByC_G ( long companyId , long groupId ) throws SystemException {
public List < Email > findByC_G ( long companyId , long groupId ) throws SystemException {
return emailPersistence . findByC_G ( companyId , groupId ) ;
return emailPersistence . findByC_G ( companyId , groupId ) ;
}
}
@Override
public List < Email > findByC_G ( long companyId , long groupId , int start , int end ) throws SystemException {
public List < Email > findByC_G ( long companyId , long groupId , int start , int end ) throws SystemException {
return emailPersistence . findByC_G ( companyId , groupId , start , end ) ;
return emailPersistence . findByC_G ( companyId , groupId , start , end ) ;
}
}
@Override
public List < Email > findByC_G ( long companyId , long groupId , int start , int end ,
public List < Email > findByC_G ( long companyId , long groupId , int start , int end , OrderByComparator orderByComparator )
OrderByComparator orderByComparator ) throws SystemException {
throws SystemException {
return emailPersistence . findByC_G ( companyId , groupId , start , end , orderByComparator ) ;
return emailPersistence . findByC_G ( companyId , groupId , start , end , orderByComparator ) ;
}
}
@Override
public int countByC_G ( long companyId , long groupId ) throws SystemException {
public int countByC_G ( long companyId , long groupId ) throws SystemException {
return emailPersistence . countByC_G ( companyId , groupId ) ;
return emailPersistence . countByC_G ( companyId , groupId ) ;
}
}
@Override
public List < Email > findByC_G_T ( long companyId , long groupId , String templateName ) throws SystemException {
public List < Email > findByC_G_T ( long companyId , long groupId , String templateName ) throws SystemException {
return emailPersistence . findByC_G_T ( companyId , groupId , templateName ) ;
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 )
public List < Email > findByC_G_T ( long companyId , long groupId , String templateName , int start , int end )
throws SystemException {
throws SystemException {
return emailPersistence . findByC_G_T ( companyId , groupId , templateName , start , end ) ;
return emailPersistence . findByC_G_T ( companyId , groupId , templateName , start , end ) ;
}
}
@Override
public int countByC_G_T ( long companyId , long groupId , String templateName ) throws SystemException {
public int countByC_G_T ( long companyId , long groupId , String templateName ) throws SystemException {
return emailPersistence . countByC_G_T ( companyId , groupId , templateName ) ;
return emailPersistence . countByC_G_T ( companyId , groupId , templateName ) ;
}
}
@Override
public List < Email > findByC_G_C_C ( long companyId , long groupId , long classNameId , long classPK )
public List < Email > findByC_G_C_C ( long companyId , long groupId , long classNameId , long classPK )
throws SystemException {
throws SystemException {
return emailPersistence . findByC_G_C_C ( companyId , groupId , classNameId , classPK ) ;
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 ,
public List < Email > findByC_G_C_C ( long companyId , long groupId , long classNameId , long classPK , int start , int end )
int end ) throws SystemException {
throws SystemException {
return emailPersistence . findByC_G_C_C ( companyId , groupId , classNameId , classPK , start , end ) ;
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 )
public int countByC_G_C_C ( long companyId , long groupId , long classNameId , long classPK ) throws SystemException {
throws SystemException {
return emailPersistence . countByC_G_C_C ( companyId , groupId , classNameId , classPK ) ;
return emailPersistence . countByC_G_C_C ( companyId , groupId , classNameId , classPK ) ;
}
}
private Folder addEmailAttachmentsFolder ( long companyId , long emailId ) throws PortalException , SystemException {
private Folder addEmailAttachmentsFolder ( long companyId , long emailId ) throws PortalException ,
SystemException {
Company company = companyLocalService . getCompany ( companyId ) ;
Company company = companyLocalService . getCompany ( companyId ) ;
Group companyGroup = company . getGroup ( ) ;
Group companyGroup = company . getGroup ( ) ;
User defaultUser = company . getDefaultUser ( ) ;
User defaultUser = company . getDefaultUser ( ) ;
Folder folder =
dlAppLocalService . getFolder ( companyGroup . getGroupId ( ) , DLFolderConstants . DEFAULT_PARENT_FOLDER_ID ,
Folder folder = dlAppLocalService . getFolder ( companyGroup . getGroupId ( ) ,
EmailConstants . DEFAULT_ATTACHMENTS_FOLDER_NAME ) ;
DLFolderConstants . DEFAULT_PARENT_FOLDER_ID , EmailConstants . DEFAULT_ATTACHMENTS_FOLDER_NAME ) ;
ServiceContext serviceContext = new ServiceContext ( ) ;
ServiceContext serviceContext = new ServiceContext ( ) ;
serviceContext . setGroupPermissions ( new String [ ] { ActionKeys . VIEW } ) ;
serviceContext . setGroupPermissions ( new String [ ] { ActionKeys . VIEW } ) ;
serviceContext . setGuestPermissions ( new String [ ] { ActionKeys . VIEW } ) ;
serviceContext . setGuestPermissions ( new String [ ] { ActionKeys . VIEW } ) ;
return dlAppLocalService . addFolder ( defaultUser . getUserId ( ) , folder . getRepositoryId ( ) , folder . getFolderId ( ) ,
String . valueOf ( emailId ) , StringPool . BLANK , serviceContext ) ;
return dlAppLocalService . addFolder ( defaultUser . getUserId ( ) , folder . getRepositoryId ( ) ,
folder . getFolderId ( ) , String . valueOf ( emailId ) , StringPool . BLANK , serviceContext ) ;
}
}
private void validate ( String from , String to [ ] , String cc [ ] , String bcc [ ] , String [ ] bulkAddresses , String subject ,
private void validate ( String from , String to [ ] , String cc [ ] , String bcc [ ] , String [ ] bulkAddresses ,
String body , String [ ] replyTo ) throws PortalException {
String subject , String body , String [ ] replyTo ) throws PortalException {
if ( Validator . isNull ( from ) ) {
if ( Validator . isNull ( from ) ) {
throw new RequiredEmailFromException ( ) ;
throw new RequiredEmailFromException ( ) ;
} else if ( ! Validator . isEmailAddress ( from ) ) {
} else if ( ! Validator . isEmailAddress ( from ) ) {
throw new EmailFromException ( ) ;
throw new EmailFromException ( ) ;
}
}
if ( to = = null | | ( to ! = null & & to . length = = 0 ) ) {
if ( to = = null | | ( to ! = null & & to . length = = 0 ) ) {
throw new RequiredEmailToException ( ) ;
throw new RequiredEmailToException ( ) ;
} else {
} else {
@ -368,6 +383,7 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
}
}
}
}
}
}
if ( cc ! = null & & cc . length > 0 ) {
if ( cc ! = null & & cc . length > 0 ) {
for ( String emailAddress : cc ) {
for ( String emailAddress : cc ) {
if ( ! Validator . isEmailAddress ( emailAddress ) ) {
if ( ! Validator . isEmailAddress ( emailAddress ) ) {
@ -375,6 +391,7 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
}
}
}
}
}
}
if ( bcc ! = null & & bcc . length > 0 ) {
if ( bcc ! = null & & bcc . length > 0 ) {
for ( String emailAddress : bcc ) {
for ( String emailAddress : bcc ) {
if ( ! Validator . isEmailAddress ( emailAddress ) ) {
if ( ! Validator . isEmailAddress ( emailAddress ) ) {
@ -382,6 +399,7 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
}
}
}
}
}
}
if ( bulkAddresses ! = null & & bulkAddresses . length > 0 ) {
if ( bulkAddresses ! = null & & bulkAddresses . length > 0 ) {
for ( String emailAddress : bulkAddresses ) {
for ( String emailAddress : bulkAddresses ) {
if ( ! Validator . isEmailAddress ( emailAddress ) ) {
if ( ! Validator . isEmailAddress ( emailAddress ) ) {
@ -389,12 +407,15 @@ public class EmailLocalServiceImpl extends EmailLocalServiceBaseImpl {
}
}
}
}
}
}
if ( Validator . isNull ( subject ) ) {
if ( Validator . isNull ( subject ) ) {
throw new RequiredEmailSubjectException ( ) ;
throw new RequiredEmailSubjectException ( ) ;
}
}
if ( Validator . isNull ( body ) ) {
if ( Validator . isNull ( body ) ) {
throw new RequiredEmailBodyException ( ) ;
throw new RequiredEmailBodyException ( ) ;
}
}
if ( replyTo ! = null & & replyTo . length = = 0 ) {
if ( replyTo ! = null & & replyTo . length = = 0 ) {
for ( String emailAddress : replyTo ) {
for ( String emailAddress : replyTo ) {
if ( ! Validator . isEmailAddress ( emailAddress ) ) {
if ( ! Validator . isEmailAddress ( emailAddress ) ) {