Package org.exoplatform.kudos.service
Class KudosService
java.lang.Object
org.exoplatform.kudos.service.KudosService
- All Implemented Interfaces:
org.picocontainer.Startable
A service to manage kudos
-
Constructor Summary
ConstructorsConstructorDescriptionKudosService(KudosStorage kudosStorage, org.exoplatform.commons.api.settings.SettingService settingService, org.exoplatform.social.core.manager.ActivityManager activityManager, org.exoplatform.social.core.space.spi.SpaceService spaceService, org.exoplatform.social.core.manager.IdentityManager identityManager, org.exoplatform.services.listener.ListenerService listenerService, org.exoplatform.container.PortalContainer container, org.exoplatform.container.xml.InitParams params) -
Method Summary
Modifier and TypeMethodDescriptionlongcountKudosByEntity(String entityType, String entityId) longcountKudosByEntityAndSender(String entityType, String entityId, String senderIdentityId) Count kudos sent by an identity using a dedicated entity (activity, comment, profile header, tiptip...)longcountKudosByPeriodAndReceiver(long identityId, long startDateInSeconds, long endDateInSeconds) Count kudos received by an identity in a period of timecountKudosByPeriodAndReceivers(List<Long> identitiesId, long startDateInSeconds, long endDateInSeconds) Count kudos received by a list of identities in a period of timelongcountKudosByPeriodAndSender(long senderIdentityId, long startDateInSeconds, long endDateInSeconds) Count kudos sent by an identity in a period of timecreateKudos(Kudos kudos, String currentUser) Create a new Kudos sent by current uservoiddeleteKudosById(long kudosId) Deletes a sent kudosvoiddeleteKudosById(long kudosId, String username) Deletes a sent kudosgetAccountSettings(String username) getKudosByActivityId(Long activityId) Retrieves kudos by activityIdgetKudosByActivityId(Long activityId, org.exoplatform.services.security.Identity currentUser) Retrieves kudos by activityIdgetKudosByEntity(String entityType, String entityId, int limit) Retrieves a list of kudos sent using a dedicated entity (activity, comment, profile header, tiptip...)getKudosByPeriod(long startDateInSeconds, long endDateInSeconds, int limit) Retrieves the list of kudos sent in a period of time.getKudosByPeriod(long dateInSeconds, KudosPeriodType periodType, int limit) Retrieves the list of kudos sent in a period of time.getKudosByPeriodAndReceiver(long identityId, long startDateInSeconds, long endDateInSeconds, int limit) Retrieves kudos received by an identity in a period of timegetKudosByPeriodAndSender(long senderIdentityId, long startDateInSeconds, long endDateInSeconds, int limit) Retrieves Kudos list by sender identity IdgetKudosByPeriodOfDate(long dateInSeconds, int limit) Retrieves the list of kudos sent in a period of time.getKudosListOfActivity(String activityId) Retrieves the list of kudos for a given parent entity id and with a set of entity typesgetKudosListOfActivity(String activityId, org.exoplatform.services.security.Identity currentUser) Retrieves the list of kudos for a given parent entity id and with a set of entity typesgetKudosPeriodOfTime(long dateInSeconds) getKudosPeriodOfTime(KudosPeriodType periodType, long dateInSeconds) booleanisAuthorizedOnKudosModule(String username) Check if user is authorized to send/receive KudosvoidsaveGlobalSettings(GlobalSettings settings) Stores new parameters of Kudos modulevoidstart()voidstop()updateKudos(Kudos kudos) Updates a kudosvoidupdateKudosGeneratedActivityId(long kudosId, long activityId) Stores generated activity for createdKudos
-
Constructor Details
-
KudosService
public KudosService(KudosStorage kudosStorage, org.exoplatform.commons.api.settings.SettingService settingService, org.exoplatform.social.core.manager.ActivityManager activityManager, org.exoplatform.social.core.space.spi.SpaceService spaceService, org.exoplatform.social.core.manager.IdentityManager identityManager, org.exoplatform.services.listener.ListenerService listenerService, org.exoplatform.container.PortalContainer container, org.exoplatform.container.xml.InitParams params)
-
-
Method Details
-
start
public void start()- Specified by:
startin interfaceorg.picocontainer.Startable
-
stop
public void stop()- Specified by:
stopin interfaceorg.picocontainer.Startable
-
getGlobalSettings
- Returns:
GlobalSettingsof Kudos module
-
saveGlobalSettings
Stores new parameters of Kudos module- Parameters:
settings-GlobalSettings
-
getAccountSettings
- Parameters:
username- username to get its settings- Returns:
- kudos settings of a user
-
createKudos
Create a new Kudos sent by current user -
deleteKudosById
Deletes a sent kudos- Parameters:
kudosId- Kudos technical identifier to deleteusername- User name deleting kudos- Throws:
Exception- when user is not authorized to delete the kudos or when the kudos identified by its technical identifier is not found
-
deleteKudosById
public void deleteKudosById(long kudosId) throws org.exoplatform.commons.exception.ObjectNotFoundException Deletes a sent kudos- Parameters:
kudosId- Kudos technical identifier to delete- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the kudos identified by its technical identifier is not found
-
updateKudosGeneratedActivityId
Stores generated activity for createdKudos -
getKudosByActivityId
public Kudos getKudosByActivityId(Long activityId, org.exoplatform.services.security.Identity currentUser) throws IllegalAccessException Retrieves kudos by activityId- Parameters:
activityId-ExoSocialActivityidentifiercurrentUser-Identity- Returns:
Kudos- Throws:
IllegalAccessException- when user doesn't have access to kudos
-
getKudosByActivityId
Retrieves kudos by activityId- Parameters:
activityId-ExoSocialActivityidentifier- Returns:
Kudos
-
updateKudos
Updates a kudos -
getKudosByPeriod
Retrieves the list of kudos sent in a period of time. -
getKudosByPeriod
Retrieves the list of kudos sent in a period of time.- Parameters:
dateInSeconds- timestamp in secondsperiodType-KudosPeriodTypeused to compute real start and end dates of periodlimit- limit of results size to retrieve- Returns:
ListofKudos
-
getKudosByPeriodOfDate
Retrieves the list of kudos sent in a period of time. Configured Period Type is retrieved fromGlobalSettings -
getKudosByEntity
Retrieves a list of kudos sent using a dedicated entity (activity, comment, profile header, tiptip...)- Parameters:
entityType- entity type of typeKudosEntityTypeentityId- entity technical idlimit- limit of results size to retrieve- Returns:
ListofKudos
-
countKudosByEntity
-
countKudosByEntityAndSender
public long countKudosByEntityAndSender(String entityType, String entityId, String senderIdentityId) Count kudos sent by an identity using a dedicated entity (activity, comment, profile header, tiptip...)- Parameters:
entityType- entity type of typeKudosEntityTypeentityId- entity technical idsenderIdentityId-Identitytechnical id- Returns:
- 0 if identity not found, else kudos count
-
countKudosByPeriodAndSender
public long countKudosByPeriodAndSender(long senderIdentityId, long startDateInSeconds, long endDateInSeconds) Count kudos sent by an identity in a period of time- Parameters:
senderIdentityId-Identitytechnical idstartDateInSeconds- timestamp in secondsendDateInSeconds- timestamp in seconds- Returns:
- 0 if identity not found, else kudos count
-
getKudosByPeriodAndSender
public List<Kudos> getKudosByPeriodAndSender(long senderIdentityId, long startDateInSeconds, long endDateInSeconds, int limit) Retrieves Kudos list by sender identity Id -
countKudosByPeriodAndReceiver
public long countKudosByPeriodAndReceiver(long identityId, long startDateInSeconds, long endDateInSeconds) Count kudos received by an identity in a period of time- Parameters:
identityId-Identitytechnical idstartDateInSeconds- timestamp in secondsendDateInSeconds- timestamp in seconds- Returns:
- 0 if identity not found, else kudos count
-
countKudosByPeriodAndReceivers
public Map<Long,Long> countKudosByPeriodAndReceivers(List<Long> identitiesId, long startDateInSeconds, long endDateInSeconds) Count kudos received by a list of identities in a period of time- Parameters:
identitiesId-IdentityList of technical idstartDateInSeconds- timestamp in secondsendDateInSeconds- timestamp in seconds- Returns:
- Map<identityId,kudoCount> the number of kudos by identity
-
getKudosByPeriodAndReceiver
public List<Kudos> getKudosByPeriodAndReceiver(long identityId, long startDateInSeconds, long endDateInSeconds, int limit) Retrieves kudos received by an identity in a period of time -
getKudosListOfActivity
public List<Kudos> getKudosListOfActivity(String activityId, org.exoplatform.services.security.Identity currentUser) throws IllegalAccessException Retrieves the list of kudos for a given parent entity id and with a set of entity types- Parameters:
activityId-ExoSocialActivityidcurrentUser- user requesting access to kudos list- Returns:
ListofKudos- Throws:
IllegalAccessException- when user doesn't have access to kudos
-
getKudosListOfActivity
Retrieves the list of kudos for a given parent entity id and with a set of entity types -
isAuthorizedOnKudosModule
Check if user is authorized to send/receive Kudos- Parameters:
username- username to check- Returns:
- true if authorised else return false
-
getDefaultKudosPeriodType
-
getCurrentKudosPeriod
-
getKudosPeriodOfTime
-
getKudosPeriodOfTime
-