Class ApplicationCenterService

  • All Implemented Interfaces:
    org.picocontainer.Startable

    public class ApplicationCenterService
    extends Object
    implements org.picocontainer.Startable
    A Service to access and store applications
    • Constructor Detail

      • ApplicationCenterService

        public ApplicationCenterService​(org.exoplatform.container.configuration.ConfigurationManager configurationManager,
                                        ApplicationCenterStorage appCenterStorage,
                                        org.exoplatform.commons.api.settings.SettingService settingService,
                                        org.exoplatform.services.security.IdentityRegistry identityRegistry,
                                        org.exoplatform.services.security.Authenticator authenticator,
                                        org.exoplatform.container.PortalContainer container,
                                        org.exoplatform.container.xml.InitParams params)
    • Method Detail

      • start

        public void start()
        A method that will be invoked when the server starts ( PortalContainer starts ) to inject default application and to delete injected default applications
        Specified by:
        start in interface org.picocontainer.Startable
      • stop

        public void stop()
        Specified by:
        stop in interface org.picocontainer.Startable
      • createApplication

        public Application createApplication​(Application application)
                                      throws Exception
        Create new Application that will be available for all users. If the application already exits an ApplicationAlreadyExistsException will be thrown.
        Parameters:
        application - application to create
        Returns:
        stored Application in datasource
        Throws:
        Exception - when application already exists or an error occurs while creating application or its attached image
      • deleteApplication

        public void deleteApplication​(Long applicationId,
                                      String username)
                               throws ApplicationNotFoundException,
                                      IllegalAccessException,
                                      org.exoplatform.commons.file.services.FileStorageException
        Delete application identified by its id and check if username has permission to delete it.
        Parameters:
        applicationId - technical identifier of application
        username - user currently deleting application
        Throws:
        ApplicationNotFoundException - if application wasn't found
        IllegalAccessException - if user is not allowed to delete application
        org.exoplatform.commons.file.services.FileStorageException
      • addFavoriteApplication

        public void addFavoriteApplication​(long applicationId,
                                           String username)
                                    throws ApplicationNotFoundException,
                                           IllegalAccessException,
                                           org.exoplatform.commons.file.services.FileStorageException
        Add an application, identified by its technical id, as favorite of a user
        Parameters:
        applicationId - technical application id
        username - user login
        Throws:
        ApplicationNotFoundException - when application is not found
        IllegalAccessException - if user hasn't access permission to the application
        org.exoplatform.commons.file.services.FileStorageException
      • deleteFavoriteApplication

        public void deleteFavoriteApplication​(Long applicationId,
                                              String username)
        Deletes an application identified by its id from favorite applications of user
        Parameters:
        applicationId - application technical identifier
        username - login of user currently deleting application
      • setMaxFavoriteApps

        public void setMaxFavoriteApps​(long maxFavoriteApplications)
        Change general setting for maximum allowed favorites that a user can have
        Parameters:
        maxFavoriteApplications - max favorite applications count
      • getMaxFavoriteApps

        public long getMaxFavoriteApps()
        Returns:
        the maximum favorite applications that a user can have as favorite
      • setDefaultAppImage

        public ApplicationImage setDefaultAppImage​(ApplicationImage defaultAppImage)
                                            throws Exception
        Stores default image for applications not having an attached illustration
        Parameters:
        defaultAppImage - image content and name
        Returns:
        stored image
        Throws:
        Exception - if an exception occurs while storing image into database
      • getAppGeneralSettings

        public GeneralSettings getAppGeneralSettings()
                                              throws Exception
        Returns:
        GeneralSettings of application including default image and maximum favorite applications count
        Throws:
        Exception - if an exception occurs while retrieving image data from store
      • getApplicationsList

        public ApplicationList getApplicationsList​(int offset,
                                                   int limit,
                                                   String keyword)
                                            throws org.exoplatform.commons.file.services.FileStorageException
        Retrieves the list of applications with offset, limit and a keyword that can be empty
        Parameters:
        offset - offset of the query
        limit - limit of the query that can be less or equal to 0, which mean, getting all available applications
        keyword - used to search in title and url
        Returns:
        ApplicationList that contains the list of applications
        Throws:
        org.exoplatform.commons.file.services.FileStorageException
      • getAuthorizedApplicationsList

        public ApplicationList getAuthorizedApplicationsList​(int offset,
                                                             int limit,
                                                             String keyword,
                                                             String username)
                                                      throws org.exoplatform.commons.file.services.FileStorageException
        Retrieves the list of applications switch offset and limit of the query, a keyword to filter on title and url of Application and the username to filter on authorized applications
        Parameters:
        offset - offset of the query
        limit - limit of the query that can be less or equal to 0, which mean, getting all available applications
        keyword - used to search in title and url
        username - login of user to use to filter on authorized applications
        Returns:
        ApplicationList that contains the List of authorized UserApplication
        Throws:
        org.exoplatform.commons.file.services.FileStorageException
      • getMandatoryAndFavoriteApplicationsList

        public ApplicationList getMandatoryAndFavoriteApplicationsList​(String username)
        Retrieves all the list of applications for a user
        Parameters:
        username - login of user
        Returns:
        ApplicationList that contains List of UserApplication
      • updateFavoriteApplicationOrder

        public void updateFavoriteApplicationOrder​(ApplicationOrder applicationOrder,
                                                   String userName)
                                            throws ApplicationNotFoundException,
                                                   org.exoplatform.commons.file.services.FileStorageException
        Update favorite applications order for a user
        Parameters:
        applicationOrder -
        userName -
        Throws:
        ApplicationNotFoundException
        org.exoplatform.commons.file.services.FileStorageException
      • getApplicationImageLastUpdated

        public Long getApplicationImageLastUpdated​(long applicationId,
                                                   String username)
                                            throws ApplicationNotFoundException,
                                                   IllegalAccessException,
                                                   org.exoplatform.commons.file.services.FileStorageException
        Return the Application illustration last modifed timestamp (in ms), if not found, the default image last modifed timestamp will be retrieved
        Parameters:
        applicationId - technical id of application
        username - login of user accessing application
        Returns:
        timestamp in milliseconds of last modified date of illustration
        Throws:
        ApplicationNotFoundException - if application wasn't found
        IllegalAccessException - if user doesn't have access permission to application
        org.exoplatform.commons.file.services.FileStorageException - if an error occurs while accessing file from store
      • addApplicationPlugin

        public void addApplicationPlugin​(ApplicationPlugin applicationPlugin)
        Inject a default application using IOC ComponentPlugin using configuration
        Parameters:
        applicationPlugin - plugin containing application to inject
      • removeApplicationPlugin

        public void removeApplicationPlugin​(String pluginName)
        Delete an injected plugin identified by its name
        Parameters:
        pluginName - plugin name to delete
      • isDefaultSystemApplication

        public boolean isDefaultSystemApplication​(Application application)
        Checks whether the application is a system application injected by configuration or not
        Parameters:
        application - application to check its state
        Returns:
        true if the configuration of the application exists with same title and URL, else false.