Class ProgramServiceImpl

java.lang.Object
io.meeds.gamification.service.impl.ProgramServiceImpl
All Implemented Interfaces:
ProgramService

public class ProgramServiceImpl extends Object implements ProgramService
  • Field Details

    • programStorage

      protected final ProgramStorage 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: ProgramService
      Gets programs by filter.
      Specified by:
      getPrograms in interface ProgramService
      Parameters:
      programFilter - ProgramFilter used to filter results
      username - User name accessing programs
      offset - index of the search
      limit - 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: ProgramService
      Gets Program Ids by filter.
      Specified by:
      getProgramIds in interface ProgramService
      Parameters:
      programFilter - ProgramFilter used to filter results
      username - User name accessing Programs
      offset - index of the search
      limit - 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, int offset, int limit)
      Description copied from interface: ProgramService
      Gets Program Ids by filter.
      Specified by:
      getProgramIds in interface ProgramService
      Parameters:
      programFilter - ProgramFilter used to filter results
      offset - index of the search
      limit - limit of results to return
      Returns:
      A <ProgramDTO> object
    • getOwnedProgramIds

      public List<Long> getOwnedProgramIds(String username, int offset, int limit)
      Specified by:
      getOwnedProgramIds in interface ProgramService
      Parameters:
      username - user name
      offset - start index for fetch
      limit - limit to fetch
      Returns:
      List of ProgramDTO id of programs where the user is owner
    • getMemberProgramIds

      public List<Long> getMemberProgramIds(String username, int offset, int limit)
      Specified by:
      getMemberProgramIds in interface ProgramService
      Parameters:
      username - user name
      offset - start index for fetch
      limit - limit to fetch
      Returns:
      List of ProgramDTO id of programs where the user is member of
    • getPublicProgramIds

      public List<Long> getPublicProgramIds(int offset, int limit)
      Specified by:
      getPublicProgramIds in interface ProgramService
      Parameters:
      offset - start index for fetch
      limit - limit to fetch
      Returns:
      List of ProgramDTO id of programs publically accessible
    • getProgramByTitle

      public ProgramDTO getProgramByTitle(String programTitle)
      Description copied from interface: ProgramService
      Find a Program by title
      Specified by:
      getProgramByTitle in interface ProgramService
      Parameters:
      programTitle - : Program title
      Returns:
      found ProgramDTO
    • countPrograms

      public int countPrograms(ProgramFilter programFilter, String username) throws IllegalAccessException
      Description copied from interface: ProgramService
      Count all Programs by filter
      Specified by:
      countPrograms in interface ProgramService
      Parameters:
      programFilter - ProgramFilter used to filter Programs
      username - User name accessing Programs
      Returns:
      Programs count
      Throws:
      IllegalAccessException - when user is not authorized to get another owner's Programs list
    • countPrograms

      public int countPrograms(ProgramFilter programFilter)
      Description copied from interface: ProgramService
      Count all Programs by filter
      Specified by:
      countPrograms in interface ProgramService
      Parameters:
      programFilter - ProgramFilter used to filter Programs
      Returns:
      Programs count
    • countOwnedPrograms

      public int countOwnedPrograms(String username)
      Specified by:
      countOwnedPrograms in interface ProgramService
      Parameters:
      username - User name accessing Programs
      Returns:
      Owned Programs count for a given user identified by its name
    • countMemberPrograms

      public int countMemberPrograms(String username)
      Specified by:
      countMemberPrograms in interface ProgramService
      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:
      countPublicPrograms in interface ProgramService
      Returns:
      Programs publically accessible count
    • createProgram

      public ProgramDTO createProgram(ProgramDTO program, org.exoplatform.services.security.Identity aclIdentity) throws IllegalAccessException
      Description copied from interface: ProgramService
      Creates a new Program
      Specified by:
      createProgram in interface ProgramService
      Parameters:
      program - : an object of type ProgramDTO
      aclIdentity - 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

      public ProgramDTO createProgram(ProgramDTO program)
      Description copied from interface: ProgramService
      Creates a new Program
      Specified by:
      createProgram in interface ProgramService
      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: ProgramService
      Update an existing Program
      Specified by:
      updateProgram in interface ProgramService
      Parameters:
      program - : an instance of type ProgramDTO
      aclIdentity - 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 object
      org.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: ProgramService
      Update an existing Program
      Specified by:
      updateProgram in interface ProgramService
      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:
      updateProgramDate in interface ProgramService
    • deleteProgramById

      public ProgramDTO deleteProgramById(long programId, org.exoplatform.services.security.Identity aclIdentity) throws IllegalAccessException, org.exoplatform.commons.exception.ObjectNotFoundException
      Description copied from interface: ProgramService
      Deletes an existing Program by id
      Specified by:
      deleteProgramById in interface ProgramService
      Parameters:
      programId - Program technical identifier to delete
      aclIdentity - Security identity of user attempting to delete a program
      Returns:
      deleted ProgramDTO
      Throws:
      IllegalAccessException - when user is not authorized to delete program
      org.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: ProgramService
      Delete program Cover identified by program id
      Specified by:
      deleteProgramCoverById in interface ProgramService
      Parameters:
      programId - ProgramDTO technical identifier
      aclIdentity - Security identity of user attempting to delete the program cover
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - program not found
      IllegalAccessException - 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: ProgramService
      Delete program Avatar identified by program id
      Specified by:
      deleteProgramAvatarById in interface ProgramService
      Parameters:
      programId - ProgramDTO technical identifier
      aclIdentity - Security identity of user attempting to delete the program avatar
      Throws:
      org.exoplatform.commons.exception.ObjectNotFoundException - program not found
      IllegalAccessException - 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: ProgramService
      Retrieves a program identified by its technical identifier accessed by a user
      Specified by:
      getProgramById in interface ProgramService
      Parameters:
      programId -
      username -
      Returns:
      found ProgramDTO
      Throws:
      IllegalAccessException - when user is not authorized to access program
      org.exoplatform.commons.exception.ObjectNotFoundException - program not found
    • getProgramById

      public ProgramDTO getProgramById(long programId)
      Description copied from interface: ProgramService
      Retrieves a program identified by its technical identifier.
      Specified by:
      getProgramById in interface ProgramService
      Parameters:
      programId - : program id
      Returns:
      found ProgramDTO
    • getProgramCoverStream

      public InputStream getProgramCoverStream(long programId) throws org.exoplatform.commons.exception.ObjectNotFoundException
      Description copied from interface: ProgramService
      Retrieves the program cover identified by Program technical identifier.
      Specified by:
      getProgramCoverStream in interface ProgramService
      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: ProgramService
      Retrieves the program avatar identified by Program technical identifier.
      Specified by:
      getProgramAvatarStream in interface ProgramService
      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: ProgramService
      Check whether user can add programs or not
      Specified by:
      canAddProgram in interface ProgramService
      Parameters:
      aclIdentity - Security identity of user
      Returns:
      true if user has enough privileges to create a program, else false
    • isProgramOwner

      public boolean isProgramOwner(long programId, String username)
      Description copied from interface: ProgramService
      Check whether user can add programs or not
      Specified by:
      isProgramOwner in interface ProgramService
      Parameters:
      programId - technical identifier of program
      username - user name
      Returns:
      true if user is a program owner, else false
    • isProgramOwner

      public boolean isProgramOwner(long programId, String username, boolean checkDeleted)
      Description copied from interface: ProgramService
      Check whether user was program owner before deleting it or not
      Specified by:
      isProgramOwner in interface ProgramService
      Parameters:
      programId - technical identifier of program
      username - user name
      checkDeleted - 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

      public boolean isProgramMember(long programId, String username)
      Description copied from interface: ProgramService
      Check whether user is member of program or not
      Specified by:
      isProgramMember in interface ProgramService
      Parameters:
      programId - technical identifier of program
      username - user name
      Returns:
      true if user has enough privileges to access the program, else false
    • isProgramMember

      public boolean isProgramMember(long programId, String username, boolean checkDeleted)
      Description copied from interface: ProgramService
      Check whether user was program member before deleting it or not
      Specified by:
      isProgramMember in interface ProgramService
      Parameters:
      programId - technical identifier of program
      username - user name
      checkDeleted - 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

      public boolean canUseProgramColor(long programId, String color)
      Description copied from interface: ProgramService
      Return true if the color isn't used by any other program, else return false
      Specified by:
      canUseProgramColor in interface ProgramService
      Parameters:
      programId -
      color -
      Returns:
      true if not used, else false
    • canViewProgram

      public boolean canViewProgram(long programId, String username)
      Description copied from interface: ProgramService
      Check whether user can view program details or not
      Specified by:
      canViewProgram in interface ProgramService
      Parameters:
      programId - technical identifier of program
      username - user name
      Returns:
      true if user has enough privileges to see a program, else false
    • getAdministrators

      public List<String> getAdministrators()
      Specified by:
      getAdministrators in interface ProgramService
      Returns:
      List user names, member of rewarding administrators