com.dotmarketing.portlets.mailinglists.factories
Class MailingListFactory

java.lang.Object
  extended by com.dotmarketing.portlets.mailinglists.factories.MailingListFactory

public class MailingListFactory
extends java.lang.Object

Author:
will

Constructor Summary
MailingListFactory()
           
 
Method Summary
static boolean addMailingSubscriber(MailingList ml, UserProxy up, boolean force)
          Add a subscriber to the passed mailing
static void deleteAllBouncesFromMailingList(MailingList ml)
          Removes all the associated bounce from the given list
static void deleteAllSubscribersFromMailingList(MailingList ml)
          Removes all the associated subscriber from the given list
static void deleteAllUnsubscribersFromMailingList(MailingList ml)
          Removes all the associated unsubscriber from the given list
static boolean deleteBounceFromMailingList(MailingList ml, UserProxy up)
          Delete subscriber of the subscriber to the given mailing
static boolean deleteSubscriberFromMailingList(MailingList ml, UserProxy up)
          Delete subscriber of the subscriber to the given mailing
static boolean deleteUnsubscriberFromMailingList(MailingList ml, UserProxy up)
          Delete subscriber of the subscriber to the given mailing
static boolean deleteUserFromMailingList(MailingList ml, UserProxy up)
          Delete a user from the given mailing regardless if it's a subscriber, unsubscriber or bounce
static java.util.List<MailingList> getAllMailingLists()
          Retrieves all the mailing lists
static java.util.List<MailingList> getAllMailingLists(java.lang.String orderby)
          Retrieves all the mailing lists sort by specified field
static java.util.List<MailingList> getAllMailingLists(java.lang.String orderby, java.lang.String direction)
          Retrieves all the mailing lists sort by specified field
static java.util.List getAllMailingListsCondition(java.lang.String condition)
          Retrieves all the mailing lists that match condition.
static java.util.List<MailingList> getAllPublicLists()
          Retrieves the list of all public mailing list
static java.util.List<UserProxy> getMailingListBounces(MailingList ml)
          Return the list of bounces or errors from a mailing list
static java.util.List<UserProxy> getMailingListBounces(java.lang.String mlInode, java.lang.String userId, int start, int limit, java.lang.String orderBy)
          Return the list of bounces or errors from a mailing list for pagination and filter by only the subscribers the user can see, if userId is null it will pull all results
static int getMailingListBouncesCount(java.lang.String mlInode)
          Returns the count of bounces/errors of a mailing list
static int getMailingListBouncesCount(java.lang.String mlInode, java.lang.String userId)
          Return the count of bounces/errors in a mailing list filter by what the user can see if a userId is supplied
static MailingList getMailingListsByInode(java.lang.String inode)
          Returns the mailing list specified
static java.util.List<MailingList> getMailingListsBySubscriber(com.liferay.portal.model.User u)
          return a list of all the mailing list (private and public) where the user is susbcribed
static java.util.List<MailingList> getMailingListsByUser(com.liferay.portal.model.User u)
          Returns a list of mailing lists that belongs to the given user
static java.util.List<MailingList> getMailingListsByUser(com.liferay.portal.model.User u, java.lang.String orderby)
          Returns a list of mailing lists that belongs to the given user
static java.util.List<MailingList> getMailingListsByUser(com.liferay.portal.model.User u, java.lang.String orderby, java.lang.String direction)
          Returns a list of mailing lists that belongs to the given user
static java.util.List getMailingListsByUserCondition(com.liferay.portal.model.User user, java.lang.String condition)
          Retrieves mailing lists that belong a user and match condition.
static java.util.List<UserProxy> getMailingListSubscribers(MailingList ml)
          Return the list of subscriber of a mailing list
static java.util.List<UserProxy> getMailingListSubscribers(java.lang.String mlInode, java.lang.String userId, int start, int limit, java.lang.String orderBy)
          Return the list of subscriber of a mailing list for pagination and filter by only the subscribers the user can see, if userId is null it will pull all results
static int getMailingListSubscribersCount(java.lang.String mlInode)
          Returns the count of subscribers of a mailing list
static int getMailingListSubscribersCount(java.lang.String mlInode, java.lang.String userId)
          Return the count of subscribers in a mailing list filter by what the user can see if a userId is supplied
static java.util.List<UserProxy> getMailingListUnsubscribers(MailingList ml)
          Return the list of user who unsubscribed from a mailing list
static java.util.List<UserProxy> getMailingListUnsubscribers(java.lang.String mlInode, java.lang.String userId, int start, int limit, java.lang.String orderBy)
          Return the list of user who unsubscribed from a mailing list for pagination and filter by only the subscribers the user can see, if userId is null it will pull all results
static int getMailingListUnsubscribersCount(java.lang.String mlInode)
          Return the count of people how unsubscribe from a mailing list
static int getMailingListUnsubscribersCount(java.lang.String mlInode, java.lang.String userId)
          Return the count of people how unsubscribe from a mailing list filter by what the passed user can see if a userId is supplied
static MailingList getUnsubscribersMailingList()
          get the Unsubscribers Mailing List, if it doesn't exists, it's created an returned
static boolean isMailingListAdmin(com.liferay.portal.model.User user)
          Returns true if the user belongs to the MAILINGLISTS_ADMIN_ROLE
static boolean isMailingListEditor(com.liferay.portal.model.User user)
          Returns true if the user belongs to the MAILINGLISTS_EDITOR_ROLE
static boolean isMailingListManager(com.liferay.portal.model.User user)
          Returns true if the user belongs to the MAILINGLISTS_ADMIN_ROLE or to the USER_MANAGER_ADMIN_ROLE
static boolean isSubscribed(MailingList ml, UserProxy up)
          Checks if a user is subscribed to a mailing list
static boolean markAsBounceFromMailingList(MailingList ml, UserProxy up)
          Change a user to the bounce list from the passed mailing
static MailingList newInstance()
           
static boolean unsubcribeFromMailingList(MailingList ml, UserProxy up, boolean force)
          Unsubscribe a subscriber from the passed mailing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MailingListFactory

public MailingListFactory()
Method Detail

isMailingListAdmin

public static boolean isMailingListAdmin(com.liferay.portal.model.User user)
                                  throws com.liferay.portal.PortalException,
                                         com.liferay.portal.SystemException
Returns true if the user belongs to the MAILINGLISTS_ADMIN_ROLE

Parameters:
user -
Returns:
Throws:
com.liferay.portal.PortalException
com.liferay.portal.SystemException

isMailingListEditor

public static boolean isMailingListEditor(com.liferay.portal.model.User user)
                                   throws com.liferay.portal.PortalException,
                                          com.liferay.portal.SystemException
Returns true if the user belongs to the MAILINGLISTS_EDITOR_ROLE

Parameters:
user -
Returns:
Throws:
com.liferay.portal.PortalException
com.liferay.portal.SystemException

isMailingListManager

public static boolean isMailingListManager(com.liferay.portal.model.User user)
                                    throws com.liferay.portal.PortalException,
                                           com.liferay.portal.SystemException
Returns true if the user belongs to the MAILINGLISTS_ADMIN_ROLE or to the USER_MANAGER_ADMIN_ROLE

Parameters:
user -
Returns:
Throws:
com.liferay.portal.PortalException
com.liferay.portal.SystemException

getMailingListsByInode

public static MailingList getMailingListsByInode(java.lang.String inode)
Returns the mailing list specified

Parameters:
inode -
Returns:
MailingList
Throws:
com.liferay.portal.PortalException
com.liferay.portal.SystemException

getMailingListsByUser

public static java.util.List<MailingList> getMailingListsByUser(com.liferay.portal.model.User u)
Returns a list of mailing lists that belongs to the given user

Parameters:
user -
Returns:
Throws:
com.liferay.portal.PortalException
com.liferay.portal.SystemException

getMailingListsByUser

public static java.util.List<MailingList> getMailingListsByUser(com.liferay.portal.model.User u,
                                                                java.lang.String orderby)
Returns a list of mailing lists that belongs to the given user

Parameters:
u -
orderby - Order field to use
Returns:

getMailingListsByUser

public static java.util.List<MailingList> getMailingListsByUser(com.liferay.portal.model.User u,
                                                                java.lang.String orderby,
                                                                java.lang.String direction)
Returns a list of mailing lists that belongs to the given user

Parameters:
u -
orderby - Order field to use
direction - sort direction (desc or asc)
Returns:

getAllMailingLists

public static java.util.List<MailingList> getAllMailingLists()
Retrieves all the mailing lists

Returns:

getAllMailingLists

public static java.util.List<MailingList> getAllMailingLists(java.lang.String orderby)
Retrieves all the mailing lists sort by specified field

Parameters:
orderby -
Returns:

getAllMailingLists

public static java.util.List<MailingList> getAllMailingLists(java.lang.String orderby,
                                                             java.lang.String direction)
Retrieves all the mailing lists sort by specified field

Parameters:
orderby -
direction -
Returns:

getAllPublicLists

public static java.util.List<MailingList> getAllPublicLists()
Retrieves the list of all public mailing list

Returns:

newInstance

public static MailingList newInstance()

getUnsubscribersMailingList

public static MailingList getUnsubscribersMailingList()
get the Unsubscribers Mailing List, if it doesn't exists, it's created an returned

Returns:
the Unsubscribers Mailing List

getMailingListSubscribers

public static java.util.List<UserProxy> getMailingListSubscribers(MailingList ml)
                                                           throws java.lang.Exception
Return the list of subscriber of a mailing list

Throws:
java.lang.Exception

getMailingListSubscribers

public static java.util.List<UserProxy> getMailingListSubscribers(java.lang.String mlInode,
                                                                  java.lang.String userId,
                                                                  int start,
                                                                  int limit,
                                                                  java.lang.String orderBy)
                                                           throws java.lang.Exception
Return the list of subscriber of a mailing list for pagination and filter by only the subscribers the user can see, if userId is null it will pull all results

Throws:
DotSecurityException
DotDataException
NoSuchUserException
java.lang.Exception

getMailingListSubscribersCount

public static int getMailingListSubscribersCount(java.lang.String mlInode)
                                          throws java.lang.Exception
Returns the count of subscribers of a mailing list

Parameters:
mlInode -
Returns:
Throws:
java.lang.Exception

getMailingListSubscribersCount

public static int getMailingListSubscribersCount(java.lang.String mlInode,
                                                 java.lang.String userId)
                                          throws java.lang.Exception
Return the count of subscribers in a mailing list filter by what the user can see if a userId is supplied

Parameters:
mlInode - Mailing list inode
userId - User id to filter the count
Returns:
Throws:
java.lang.Exception

getMailingListUnsubscribers

public static java.util.List<UserProxy> getMailingListUnsubscribers(MailingList ml)
                                                             throws java.lang.Exception
Return the list of user who unsubscribed from a mailing list

Throws:
java.lang.Exception

getMailingListUnsubscribers

public static java.util.List<UserProxy> getMailingListUnsubscribers(java.lang.String mlInode,
                                                                    java.lang.String userId,
                                                                    int start,
                                                                    int limit,
                                                                    java.lang.String orderBy)
                                                             throws java.lang.Exception
Return the list of user who unsubscribed from a mailing list for pagination and filter by only the subscribers the user can see, if userId is null it will pull all results

Throws:
java.lang.Exception

getMailingListUnsubscribersCount

public static int getMailingListUnsubscribersCount(java.lang.String mlInode)
                                            throws java.lang.Exception
Return the count of people how unsubscribe from a mailing list

Parameters:
mlInode -
Returns:
Throws:
java.lang.Exception

getMailingListUnsubscribersCount

public static int getMailingListUnsubscribersCount(java.lang.String mlInode,
                                                   java.lang.String userId)
                                            throws java.lang.Exception
Return the count of people how unsubscribe from a mailing list filter by what the passed user can see if a userId is supplied

Parameters:
mlInode - Mailing list inode
userId - User id to filter the count
Returns:
Throws:
java.lang.Exception

getMailingListBounces

public static java.util.List<UserProxy> getMailingListBounces(MailingList ml)
                                                       throws java.lang.Exception
Return the list of bounces or errors from a mailing list

Throws:
java.lang.Exception

getMailingListBounces

public static java.util.List<UserProxy> getMailingListBounces(java.lang.String mlInode,
                                                              java.lang.String userId,
                                                              int start,
                                                              int limit,
                                                              java.lang.String orderBy)
                                                       throws java.lang.Exception
Return the list of bounces or errors from a mailing list for pagination and filter by only the subscribers the user can see, if userId is null it will pull all results

Throws:
java.lang.Exception

getMailingListBouncesCount

public static int getMailingListBouncesCount(java.lang.String mlInode)
                                      throws java.lang.Exception
Returns the count of bounces/errors of a mailing list

Parameters:
mlInode -
Returns:
Throws:
java.lang.Exception

getMailingListBouncesCount

public static int getMailingListBouncesCount(java.lang.String mlInode,
                                             java.lang.String userId)
                                      throws java.lang.Exception
Return the count of bounces/errors in a mailing list filter by what the user can see if a userId is supplied

Parameters:
mlInode - Mailing list inode
userId - User id to filter the count
Returns:
Throws:
java.lang.Exception

addMailingSubscriber

public static boolean addMailingSubscriber(MailingList ml,
                                           UserProxy up,
                                           boolean force)
                                    throws DotHibernateException
Add a subscriber to the passed mailing

Parameters:
ml - The mailing list to add it
up - The user to add
force - Forces the subscription even if the user was unsubscribed or belongs to the bounces
Returns:
true if the user was successfully added to the list, false - if the user could be added because belongs to the unsubscribers
Throws:
DotHibernateException

getMailingListsBySubscriber

public static java.util.List<MailingList> getMailingListsBySubscriber(com.liferay.portal.model.User u)
return a list of all the mailing list (private and public) where the user is susbcribed

Parameters:
u - user whom mailing lists are obtained
Returns:
list of all the mailing list (private and public) where the user is susbcribed

unsubcribeFromMailingList

public static boolean unsubcribeFromMailingList(MailingList ml,
                                                UserProxy up,
                                                boolean force)
                                         throws DotHibernateException
Unsubscribe a subscriber from the passed mailing

Parameters:
ml - The mailing list
up - The user to unsubscribed
force - Forces the unsubscription even if the user was never in the list
Returns:
true if the user was successfully unsubscribed from the list, false - if the user could not be unsubscribed because never belonged to the list
Throws:
DotHibernateException

deleteUserFromMailingList

public static boolean deleteUserFromMailingList(MailingList ml,
                                                UserProxy up)
Delete a user from the given mailing regardless if it's a subscriber, unsubscriber or bounce

Parameters:
ml - The mailing list
up - The user to remove
Returns:
true if the user was successfully removed from the list, false - if the user could not be removed because never belonged to the list

deleteSubscriberFromMailingList

public static boolean deleteSubscriberFromMailingList(MailingList ml,
                                                      UserProxy up)
Delete subscriber of the subscriber to the given mailing

Parameters:
ml - The mailing list
up - The user to remove
Returns:
true if the user was successfully removed from the list, false - if the user could not be removed because never belonged to the list

deleteUnsubscriberFromMailingList

public static boolean deleteUnsubscriberFromMailingList(MailingList ml,
                                                        UserProxy up)
Delete subscriber of the subscriber to the given mailing

Parameters:
ml - The mailing list
up - The user to remove
Returns:
true if the user was successfully removed from the list, false - if the user could not be removed because never belonged to the list

deleteBounceFromMailingList

public static boolean deleteBounceFromMailingList(MailingList ml,
                                                  UserProxy up)
Delete subscriber of the subscriber to the given mailing

Parameters:
ml - The mailing list
up - The user to remove
Returns:
true if the user was successfully removed from the list, false - if the user could not be removed because never belonged to the list

markAsBounceFromMailingList

public static boolean markAsBounceFromMailingList(MailingList ml,
                                                  UserProxy up)
                                           throws DotHibernateException
Change a user to the bounce list from the passed mailing

Parameters:
ml - The mailing list
up - The user to change his status to bounced
Returns:
true if the user was successfully added to the bounce list, false - if the user could not be added to the bounces list because never belonged to the list
Throws:
DotHibernateException

deleteAllSubscribersFromMailingList

public static void deleteAllSubscribersFromMailingList(MailingList ml)
Removes all the associated subscriber from the given list

Parameters:
ml -

deleteAllUnsubscribersFromMailingList

public static void deleteAllUnsubscribersFromMailingList(MailingList ml)
Removes all the associated unsubscriber from the given list

Parameters:
ml -

deleteAllBouncesFromMailingList

public static void deleteAllBouncesFromMailingList(MailingList ml)
Removes all the associated bounce from the given list

Parameters:
ml -

isSubscribed

public static boolean isSubscribed(MailingList ml,
                                   UserProxy up)
Checks if a user is subscribed to a mailing list

Parameters:
ml -
up -
Returns:
true if the user is a subscriber of the given list

getAllMailingListsCondition

public static java.util.List getAllMailingListsCondition(java.lang.String condition)
Retrieves all the mailing lists that match condition.

Parameters:
condition -
Returns:
Mailing lists that match the search condition.

getMailingListsByUserCondition

public static java.util.List getMailingListsByUserCondition(com.liferay.portal.model.User user,
                                                            java.lang.String condition)
Retrieves mailing lists that belong a user and match condition.

Parameters:
user -
condition -
Returns:
Mailing lists for user that match the search condition.


Copyright © 2013 dotCMS Inc. All Rights Reserved.