Package org.cyclos.impl.messaging
Class NotificationSettingsServiceImpl
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractNetworkedServerComponent
-
- org.cyclos.impl.BaseServiceImpl
-
- org.cyclos.impl.messaging.NotificationSettingsServiceImpl
-
- All Implemented Interfaces:
NotificationSettingsServiceLocal,NotificationSettingsService,Service
@Service public class NotificationSettingsServiceImpl extends BaseServiceImpl implements NotificationSettingsServiceLocal
implementation forNotificationSettingsService
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classNotificationSettingsServiceImpl.EmailUnsubscribeFields
-
Field Summary
-
Fields inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
authHandler, conversionHandler, customFieldValueHandler, entityManagerHandler, groupsHandler, productsHandler, restBeanPropertyMapping, userLocatorHandler
-
Fields inherited from class org.cyclos.impl.AbstractServerComponent
accountHandler, configurationHandler, dataTranslationHandler, notificationHandler, profileFieldHandler, transactionHandler, translationHandler
-
-
Constructor Summary
Constructors Constructor Description NotificationSettingsServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanallowMailing(User user, BulkActionNature nature)Returns whether the given mailing type is allowed for the uservoidappendAccountSettingsValidations(BasicUser owner, Property property)Appends validations of account settings according to the given ownervoidemailUnsubscribe(String key)Unsubscribes from emails with a key that was sent by emailNotificationSettingsDatagetData(UserLocatorVO locator)Returns the notification preferences for the given user / admin.EmailUnsubscribeDatagetEmailUnsubscribeData(String key)Returns data for unsubscribing from emails with a key that was sent by emailNotificationTypeSettingsDTOgetNotificationTypeSettings(Notification notification)Returns the notifications settings for an already generated notification.
This method never return null, if the user hasn't saved his preferences it creates a default one.AdminNotificationTypegetTypeBasedOnSetting(AdminNotificationType type)Returns the notification type which the given type is based on.
This method must be used when the given type does not have a corresponding setting, but uses settings from another type.
E.g:AdminNotificationType.USER_IMPORT_REGISTRATIONis based onAdminNotificationType.USER_REGISTRATIONbooleanisAllowedNotificationType(AdminNotificationType type, User user, Object option)It checks if the user has thePermission.MY_NOTIFICATIONS_ENABLEpermission and is allowed to be notified by the specified type and the selected option.booleanisEnabled(UserNotificationType type, BasicUser user, SimpleEntity entity)It returns true if the notification type is enabled by permission and if the user had selected being notified by that type.booleanisPaymentAmountInRange(BasicUser user, UserAccountType accountType, BigDecimal amount)Returns whether the given amount is included in the payment amount range the given user has set for payments from / to the given account typeStringkeyForEmailUnsubscribe(BasicUser user, EmailUnsubscribeType type)Returns a key for unsubscribing from a particular e-mail.protected voidregisterNetworkMappings(NetworkPathRegistry networkPathRegistry)Needs to be overridden by subclasses to register the path up to the networkvoidsave(NotificationSettingsDTO dto)Saves the notification settings for a given user / admincom.mysema.commons.lang.CloseableIterator<BasicUser>usersToForwardMessageIterator(IncomingMessage message)It returns an iterator over all users allowed to forward the corresponding incoming message.-
Methods inherited from class org.cyclos.impl.BaseServiceImpl
initializeNetworkMappings
-
Methods inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
canManage, checkManagesUser, checkPermission, checkRelatesToUser, checkValue, clearAlreadyValidated, getBaseEntityManagerHandler, getConfiguration, getLoggedBasicUser, getLoggedUser, getProducts, getTranslatedName, getTranslatedValue, hasPermission, hasValue, inSameNetwork, inSameNetworkOrGlobal, isAdmin, isAlreadyValidated, isBroker, isGlobalAdmin, isGlobalAdminInNetwork, isGuest, isLoggedIn, isMember, isMemberOnly, isNetworkAdmin, isOperator, isRelatedToUser, isSystem, isUserManager, isUserManagerOf, message, message, permission, permission, permissionOptionalValue, permissionOptionalValue, setAlreadyValidated, toDate, toDateTime, validate
-
Methods inherited from class org.cyclos.impl.AbstractServerComponent
dataTranslationProxy, dataTranslationProxy, delete, detach, doDataTranslationProxy, find, flush, from, getApplicationContext, getFormatter, getFormatter, getFormatter, getLogger, getRemoteAddress, getSessionData, mailContentBuilder, message, message, persist, processBatch, processBatch, refresh, remove, selectFrom, subQuery, update
-
-
-
-
Method Detail
-
allowMailing
public boolean allowMailing(User user, BulkActionNature nature)
Description copied from interface:NotificationSettingsServiceLocalReturns whether the given mailing type is allowed for the user- Specified by:
allowMailingin interfaceNotificationSettingsServiceLocal
-
appendAccountSettingsValidations
public void appendAccountSettingsValidations(BasicUser owner, Property property)
Description copied from interface:NotificationSettingsServiceLocalAppends validations of account settings according to the given owner- Specified by:
appendAccountSettingsValidationsin interfaceNotificationSettingsServiceLocal
-
emailUnsubscribe
public void emailUnsubscribe(String key) throws FrameworkException
Description copied from interface:NotificationSettingsServiceUnsubscribes from emails with a key that was sent by email- Specified by:
emailUnsubscribein interfaceNotificationSettingsService- Throws:
FrameworkException
-
getData
public NotificationSettingsData getData(UserLocatorVO locator) throws FrameworkException
Description copied from interface:NotificationSettingsServiceReturns the notification preferences for the given user / admin. When null, returns the logged user's settings.- Specified by:
getDatain interfaceNotificationSettingsService- Throws:
FrameworkException
-
getEmailUnsubscribeData
public EmailUnsubscribeData getEmailUnsubscribeData(String key) throws FrameworkException
Description copied from interface:NotificationSettingsServiceReturns data for unsubscribing from emails with a key that was sent by email- Specified by:
getEmailUnsubscribeDatain interfaceNotificationSettingsService- Throws:
FrameworkException
-
getNotificationTypeSettings
public NotificationTypeSettingsDTO getNotificationTypeSettings(Notification notification)
Description copied from interface:NotificationSettingsServiceLocalReturns the notifications settings for an already generated notification.
This method never return null, if the user hasn't saved his preferences it creates a default one.- Specified by:
getNotificationTypeSettingsin interfaceNotificationSettingsServiceLocal
-
getTypeBasedOnSetting
public AdminNotificationType getTypeBasedOnSetting(AdminNotificationType type)
Description copied from interface:NotificationSettingsServiceLocalReturns the notification type which the given type is based on.
This method must be used when the given type does not have a corresponding setting, but uses settings from another type.
E.g:AdminNotificationType.USER_IMPORT_REGISTRATIONis based onAdminNotificationType.USER_REGISTRATION- Specified by:
getTypeBasedOnSettingin interfaceNotificationSettingsServiceLocal
-
isAllowedNotificationType
public boolean isAllowedNotificationType(AdminNotificationType type, User user, Object option)
Description copied from interface:NotificationSettingsServiceLocalIt checks if the user has thePermission.MY_NOTIFICATIONS_ENABLEpermission and is allowed to be notified by the specified type and the selected option. It assumes the user has selected being notified by the specified type
For example: if type isAdminNotificationType.PAYMENT_PERFORMED(option must be aTransferTypeVO) then this method will return true if that TT is contained in the available TT list.- Specified by:
isAllowedNotificationTypein interfaceNotificationSettingsServiceLocal- Parameters:
type- the notification type to be checkeduser- the user to check if he/she is allowed to be notifiedoption- (optional) the selected option to be notified by (chosen by the user). If it's null this method only checks if there are any available options.- Returns:
- true if the user can be notified.
-
isEnabled
public boolean isEnabled(UserNotificationType type, BasicUser user, SimpleEntity entity)
Description copied from interface:NotificationSettingsServiceLocalIt returns true if the notification type is enabled by permission and if the user had selected being notified by that type. The given entity is the one that triggered the notification, such as the performed payment, or the assigned broker.- Specified by:
isEnabledin interfaceNotificationSettingsServiceLocal
-
isPaymentAmountInRange
public boolean isPaymentAmountInRange(BasicUser user, UserAccountType accountType, BigDecimal amount)
Description copied from interface:NotificationSettingsServiceLocalReturns whether the given amount is included in the payment amount range the given user has set for payments from / to the given account type- Specified by:
isPaymentAmountInRangein interfaceNotificationSettingsServiceLocal
-
keyForEmailUnsubscribe
public String keyForEmailUnsubscribe(BasicUser user, EmailUnsubscribeType type)
Description copied from interface:NotificationSettingsServiceLocalReturns a key for unsubscribing from a particular e-mail.- Specified by:
keyForEmailUnsubscribein interfaceNotificationSettingsServiceLocal
-
save
public void save(NotificationSettingsDTO dto)
Description copied from interface:NotificationSettingsServiceSaves the notification settings for a given user / admin- Specified by:
savein interfaceNotificationSettingsService
-
usersToForwardMessageIterator
public com.mysema.commons.lang.CloseableIterator<BasicUser> usersToForwardMessageIterator(IncomingMessage message)
Description copied from interface:NotificationSettingsServiceLocalIt returns an iterator over all users allowed to forward the corresponding incoming message.- Specified by:
usersToForwardMessageIteratorin interfaceNotificationSettingsServiceLocal
-
registerNetworkMappings
protected void registerNetworkMappings(NetworkPathRegistry networkPathRegistry)
Description copied from class:BaseServiceImplNeeds to be overridden by subclasses to register the path up to the network- Specified by:
registerNetworkMappingsin classBaseServiceImpl
-
-