Class ProgramServiceImpl
java.lang.Object
io.meeds.gamification.service.impl.ProgramServiceImpl
- All Implemented Interfaces:
ProgramService
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.exoplatform.social.core.manager.IdentityManagerprotected final org.exoplatform.services.listener.ListenerServiceprotected final ProgramStorageprotected final org.exoplatform.social.core.space.spi.SpaceServiceFields inherited from interface io.meeds.gamification.service.ProgramService
PROGRAM_AUDIENCE_UPDATED_EVENT, PROGRAM_CREATED_LISTENER, PROGRAM_DELETED_LISTENER, PROGRAM_DISABLED_LISTENER, PROGRAM_ENABLED_LISTENER, PROGRAM_UPDATED_LISTENER -
Constructor Summary
ConstructorsConstructorDescriptionProgramServiceImpl(ProgramStorage programStorage, org.exoplatform.services.listener.ListenerService listenerService, org.exoplatform.social.core.manager.IdentityManager identityManager, org.exoplatform.social.core.space.spi.SpaceService spaceService) -
Method Summary
Modifier and TypeMethodDescriptionbooleancanAddProgram(org.exoplatform.services.security.Identity aclIdentity) Check whether user can add programs or notbooleancanUseProgramColor(long programId, String color) Return true if the color isn't used by any other program, else return falsebooleancanViewProgram(long programId, String username) Check whether user can view program details or notintcountMemberPrograms(String username) intcountOwnedPrograms(String username) intcountPrograms(ProgramFilter programFilter) Count all Programs by filterintcountPrograms(ProgramFilter programFilter, String username) Count all Programs by filterintcreateProgram(ProgramDTO program) Creates a new ProgramcreateProgram(ProgramDTO program, org.exoplatform.services.security.Identity aclIdentity) Creates a new ProgramvoiddeleteProgramAvatarById(long programId, org.exoplatform.services.security.Identity aclIdentity) Delete program Avatar identified by program iddeleteProgramById(long programId, org.exoplatform.services.security.Identity aclIdentity) Deletes an existing Program by idvoiddeleteProgramCoverById(long programId, org.exoplatform.services.security.Identity aclIdentity) Delete program Cover identified by program idgetMemberProgramIds(String username, int offset, int limit) getOwnedProgramIds(String username, int offset, int limit) getProgramAvatarStream(long programId) Retrieves the program avatar identified by Program technical identifier.getProgramById(long programId) Retrieves a program identified by its technical identifier.getProgramById(long programId, String username) Retrieves a program identified by its technical identifier accessed by a usergetProgramByTitle(String programTitle) Find a Program by titlegetProgramCoverStream(long programId) Retrieves the program cover identified by Program technical identifier.getProgramIds(ProgramFilter programFilter, int offset, int limit) Gets Program Ids by filter.getProgramIds(ProgramFilter programFilter, String username, int offset, int limit) Gets Program Ids by filter.getPrograms(ProgramFilter programFilter, String username, int offset, int limit) Gets programs by filter.getPublicProgramIds(int offset, int limit) booleanisProgramMember(long programId, String username) Check whether user is member of program or notbooleanisProgramMember(long programId, String username, boolean checkDeleted) Check whether user was program member before deleting it or notbooleanisProgramOwner(long programId, String username) Check whether user can add programs or notbooleanisProgramOwner(long programId, String username, boolean checkDeleted) Check whether user was program owner before deleting it or notupdateProgram(ProgramDTO program) Update an existing ProgramupdateProgram(ProgramDTO program, org.exoplatform.services.security.Identity aclIdentity) Update an existing ProgramvoidupdateProgramDate(long programId)
-
Field Details
-
programStorage
-
listenerService
protected final org.exoplatform.services.listener.ListenerService listenerService -
identityManager
protected final org.exoplatform.social.core.manager.IdentityManager identityManager -
spaceService
protected final org.exoplatform.social.core.space.spi.SpaceService spaceService
-
-
Constructor Details
-
ProgramServiceImpl
public ProgramServiceImpl(ProgramStorage programStorage, org.exoplatform.services.listener.ListenerService listenerService, org.exoplatform.social.core.manager.IdentityManager identityManager, org.exoplatform.social.core.space.spi.SpaceService spaceService)
-
-
Method Details
-
getPrograms
public List<ProgramDTO> getPrograms(ProgramFilter programFilter, String username, int offset, int limit) throws IllegalAccessException Description copied from interface:ProgramServiceGets programs by filter.- Specified by:
getProgramsin interfaceProgramService- Parameters:
programFilter-ProgramFilterused to filter resultsusername- User name accessing programsoffset- index of the searchlimit- limit of results to return- Returns:
- A
<ProgramDTO>object - Throws:
IllegalAccessException- when user is not authorized to get another owner's programs list
-
getProgramIds
public List<Long> getProgramIds(ProgramFilter programFilter, String username, int offset, int limit) throws IllegalAccessException Description copied from interface:ProgramServiceGets Program Ids by filter.- Specified by:
getProgramIdsin interfaceProgramService- Parameters:
programFilter-ProgramFilterused to filter resultsusername- User name accessing Programsoffset- index of the searchlimit- limit of results to return- Returns:
- A
<ProgramDTO>object - Throws:
IllegalAccessException- when user is not authorized to get another owner's Programs list
-
getProgramIds
Description copied from interface:ProgramServiceGets Program Ids by filter.- Specified by:
getProgramIdsin interfaceProgramService- Parameters:
programFilter-ProgramFilterused to filter resultsoffset- index of the searchlimit- limit of results to return- Returns:
- A
<ProgramDTO>object
-
getOwnedProgramIds
- Specified by:
getOwnedProgramIdsin interfaceProgramService- Parameters:
username- user nameoffset- start index for fetchlimit- limit to fetch- Returns:
ListofProgramDTOid of programs where the user is owner
-
getMemberProgramIds
- Specified by:
getMemberProgramIdsin interfaceProgramService- Parameters:
username- user nameoffset- start index for fetchlimit- limit to fetch- Returns:
ListofProgramDTOid of programs where the user is member of
-
getPublicProgramIds
- Specified by:
getPublicProgramIdsin interfaceProgramService- Parameters:
offset- start index for fetchlimit- limit to fetch- Returns:
ListofProgramDTOid of programs publically accessible
-
getProgramByTitle
Description copied from interface:ProgramServiceFind a Program by title- Specified by:
getProgramByTitlein interfaceProgramService- Parameters:
programTitle- : Program title- Returns:
- found
ProgramDTO
-
countPrograms
public int countPrograms(ProgramFilter programFilter, String username) throws IllegalAccessException Description copied from interface:ProgramServiceCount all Programs by filter- Specified by:
countProgramsin interfaceProgramService- Parameters:
programFilter-ProgramFilterused to filter Programsusername- User name accessing Programs- Returns:
- Programs count
- Throws:
IllegalAccessException- when user is not authorized to get another owner's Programs list
-
countPrograms
Description copied from interface:ProgramServiceCount all Programs by filter- Specified by:
countProgramsin interfaceProgramService- Parameters:
programFilter-ProgramFilterused to filter Programs- Returns:
- Programs count
-
countOwnedPrograms
- Specified by:
countOwnedProgramsin interfaceProgramService- Parameters:
username- User name accessing Programs- Returns:
- Owned Programs count for a given user identified by its name
-
countMemberPrograms
- Specified by:
countMemberProgramsin interfaceProgramService- Parameters:
username- User name accessing Programs- Returns:
- Programs as member count for a given user identified by its name
-
countPublicPrograms
public int countPublicPrograms()- Specified by:
countPublicProgramsin interfaceProgramService- Returns:
- Programs publically accessible count
-
createProgram
public ProgramDTO createProgram(ProgramDTO program, org.exoplatform.services.security.Identity aclIdentity) throws IllegalAccessException Description copied from interface:ProgramServiceCreates a new Program- Specified by:
createProgramin interfaceProgramService- Parameters:
program- : an object of type ProgramDTOaclIdentity- Security identity of user attempting to create a program- Returns:
- created
ProgramDTO - Throws:
IllegalAccessException- when user is not authorized to create a Program for the designated owner defined in object
-
createProgram
Description copied from interface:ProgramServiceCreates a new Program- Specified by:
createProgramin interfaceProgramService- Parameters:
program- : an object of type ProgramDTO- Returns:
- created
ProgramDTO
-
updateProgram
public ProgramDTO updateProgram(ProgramDTO program, org.exoplatform.services.security.Identity aclIdentity) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Description copied from interface:ProgramServiceUpdate an existing Program- Specified by:
updateProgramin interfaceProgramService- Parameters:
program- : an instance of type ProgramDTOaclIdentity- Security identity of user attempting to update a program- Returns:
- updated object
ProgramDTO - Throws:
IllegalAccessException- when user is not authorized to create a Program for the designated owner defined in objectorg.exoplatform.commons.exception.ObjectNotFoundException- when the Program identified by its technical identifier is not found
-
updateProgram
public ProgramDTO updateProgram(ProgramDTO program) throws org.exoplatform.commons.exception.ObjectNotFoundException Description copied from interface:ProgramServiceUpdate an existing Program- Specified by:
updateProgramin interfaceProgramService- Parameters:
program- : an instance of type ProgramDTO- Returns:
- updated object
ProgramDTO - Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- when the Program identified by its technical identifier is not found
-
updateProgramDate
public void updateProgramDate(long programId) - Specified by:
updateProgramDatein interfaceProgramService
-
deleteProgramById
public ProgramDTO deleteProgramById(long programId, org.exoplatform.services.security.Identity aclIdentity) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Description copied from interface:ProgramServiceDeletes an existing Program by id- Specified by:
deleteProgramByIdin interfaceProgramService- Parameters:
programId- Program technical identifier to deleteaclIdentity- Security identity of user attempting to delete a program- Returns:
- deleted
ProgramDTO - Throws:
IllegalAccessException- when user is not authorized to delete programorg.exoplatform.commons.exception.ObjectNotFoundException- program not found
-
deleteProgramCoverById
public void deleteProgramCoverById(long programId, org.exoplatform.services.security.Identity aclIdentity) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Description copied from interface:ProgramServiceDelete program Cover identified by program id- Specified by:
deleteProgramCoverByIdin interfaceProgramService- Parameters:
programId-ProgramDTOtechnical identifieraclIdentity- Security identity of user attempting to delete the program cover- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- program not foundIllegalAccessException- when user is not authorized to delete program cover
-
deleteProgramAvatarById
public void deleteProgramAvatarById(long programId, org.exoplatform.services.security.Identity aclIdentity) throws org.exoplatform.commons.exception.ObjectNotFoundException, IllegalAccessException Description copied from interface:ProgramServiceDelete program Avatar identified by program id- Specified by:
deleteProgramAvatarByIdin interfaceProgramService- Parameters:
programId-ProgramDTOtechnical identifieraclIdentity- Security identity of user attempting to delete the program avatar- Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- program not foundIllegalAccessException- when user is not authorized to delete program avatar
-
getProgramById
public ProgramDTO getProgramById(long programId, String username) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException Description copied from interface:ProgramServiceRetrieves a program identified by its technical identifier accessed by a user- Specified by:
getProgramByIdin interfaceProgramService- Parameters:
programId-username-- Returns:
- found
ProgramDTO - Throws:
IllegalAccessException- when user is not authorized to access programorg.exoplatform.commons.exception.ObjectNotFoundException- program not found
-
getProgramById
Description copied from interface:ProgramServiceRetrieves a program identified by its technical identifier.- Specified by:
getProgramByIdin interfaceProgramService- Parameters:
programId- : program id- Returns:
- found
ProgramDTO
-
getProgramCoverStream
public InputStream getProgramCoverStream(long programId) throws org.exoplatform.commons.exception.ObjectNotFoundException Description copied from interface:ProgramServiceRetrieves the program cover identified by Program technical identifier.- Specified by:
getProgramCoverStreamin interfaceProgramService- Parameters:
programId- Program unique identifier- Returns:
- found
InputStream - Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- When program not found or file attachment not found
-
getProgramAvatarStream
public InputStream getProgramAvatarStream(long programId) throws org.exoplatform.commons.exception.ObjectNotFoundException Description copied from interface:ProgramServiceRetrieves the program avatar identified by Program technical identifier.- Specified by:
getProgramAvatarStreamin interfaceProgramService- Parameters:
programId- Program unique identifier- Returns:
- found
InputStream - Throws:
org.exoplatform.commons.exception.ObjectNotFoundException- When program not found or file attachment not found
-
canAddProgram
public boolean canAddProgram(org.exoplatform.services.security.Identity aclIdentity) Description copied from interface:ProgramServiceCheck whether user can add programs or not- Specified by:
canAddProgramin interfaceProgramService- Parameters:
aclIdentity- Security identity of user- Returns:
- true if user has enough privileges to create a program, else false
-
isProgramOwner
Description copied from interface:ProgramServiceCheck whether user can add programs or not- Specified by:
isProgramOwnerin interfaceProgramService- Parameters:
programId- technical identifier of programusername- user name- Returns:
- true if user is a program owner, else false
-
isProgramOwner
Description copied from interface:ProgramServiceCheck whether user was program owner before deleting it or not- Specified by:
isProgramOwnerin interfaceProgramService- Parameters:
programId- technical identifier of programusername- user namecheckDeleted- Whether to consider if the program is deleted or not- Returns:
- true if user is a program owner or was a program owner before deleting the program, else false
-
isProgramMember
Description copied from interface:ProgramServiceCheck whether user is member of program or not- Specified by:
isProgramMemberin interfaceProgramService- Parameters:
programId- technical identifier of programusername- user name- Returns:
- true if user has enough privileges to access the program, else false
-
isProgramMember
Description copied from interface:ProgramServiceCheck whether user was program member before deleting it or not- Specified by:
isProgramMemberin interfaceProgramService- Parameters:
programId- technical identifier of programusername- user namecheckDeleted- Whether to consider if the program is deleted or not- Returns:
- true if user is a program member or was a program member before deleting the program, else false
-
canUseProgramColor
Description copied from interface:ProgramServiceReturn true if the color isn't used by any other program, else return false- Specified by:
canUseProgramColorin interfaceProgramService- Parameters:
programId-color-- Returns:
- true if not used, else false
-
canViewProgram
Description copied from interface:ProgramServiceCheck whether user can view program details or not- Specified by:
canViewProgramin interfaceProgramService- Parameters:
programId- technical identifier of programusername- user name- Returns:
- true if user has enough privileges to see a program, else false
-
getAdministrators
- Specified by:
getAdministratorsin interfaceProgramService- Returns:
Listuser names, member of rewarding administrators
-