Class ApplicationCenterService
- java.lang.Object
-
- org.exoplatform.appcenter.service.ApplicationCenterService
-
- All Implemented Interfaces:
org.picocontainer.Startable
public class ApplicationCenterService extends Object implements org.picocontainer.Startable
A Service to access and store applications
-
-
Field Summary
Fields Modifier and Type Field Description static StringANY_PERMISSIONstatic StringDEFAULT_ADMINISTRATORS_GROUPstatic StringDEFAULT_ADMINISTRATORS_PERMISSIONstatic StringDEFAULT_APP_IMAGE_BODYstatic StringDEFAULT_APP_IMAGE_IDstatic StringDEFAULT_APP_IMAGE_NAMEstatic intDEFAULT_LIMITstatic StringDEFAULT_USERS_GROUPstatic StringDEFAULT_USERS_PERMISSIONstatic StringLOG_ADD_FAVORITEstatic StringLOG_CLICK_ALL_APPLICATIONSstatic StringLOG_OPEN_APPLICATIONstatic StringLOG_OPEN_FAVORITE_DRAWERstatic StringLOG_REMOVE_FAVORITEstatic StringLOG_REORGANIZE_FAVORITESstatic StringLOG_SERVICE_NAMEstatic StringMAX_FAVORITE_APPSstatic StringMERGE_MODE
-
Constructor Summary
Constructors Constructor Description 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 Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddApplicationPlugin(ApplicationPlugin applicationPlugin)Inject a default application using IOCComponentPluginusing configurationvoidaddFavoriteApplication(long applicationId, String username)Add an application, identified by its technical id, as favorite of a userApplicationcreateApplication(Application application)Create new Application that will be available for all users.voiddeleteApplication(Long applicationId, String username)Delete application identified by its id and check if username has permission to delete it.voiddeleteFavoriteApplication(Long applicationId, String username)Deletes an application identified by its id from favorite applications of userApplicationfindApplication(long applicationId)Get an application by idGeneralSettingsgetAppGeneralSettings()InputStreamgetApplicationImageInputStream(long applicationId, String username)Return theApplicationillustrationInputStream, if not found, the default imageInputStreamwill be retrievedLonggetApplicationImageLastUpdated(long applicationId, String username)Return theApplicationillustration last modifed timestamp (in ms), if not found, the default image last modifed timestamp will be retrievedApplicationListgetApplicationsList(int offset, int limit, String keyword)Retrieves the list of applications with offset, limit and a keyword that can be emptyApplicationListgetAuthorizedApplicationsList(int offset, int limit, String keyword, String username)Retrieves the list of applications switch offset and limit of the query, a keyword to filter on title and url ofApplicationand the username to filter on authorized applicationsApplicationListgetMandatoryAndFavoriteApplicationsList(String username)Retrieves all the list of applications for a userlonggetMaxFavoriteApps()booleanisDefaultSystemApplication(Application application)Checks whether the application is a system application injected by configuration or notvoidremoveApplicationPlugin(String pluginName)Delete an injected plugin identified by its nameApplicationImagesetDefaultAppImage(ApplicationImage defaultAppImage)Stores default image for applications not having an attached illustrationvoidsetMaxFavoriteApps(long maxFavoriteApplications)Change general setting for maximum allowed favorites that a user can havevoidstart()A method that will be invoked when the server starts (PortalContainerstarts ) to inject default application and to delete injected default applicationsvoidstop()ApplicationupdateApplication(Application application, String username)Update an existing application on datasource.voidupdateFavoriteApplicationOrder(ApplicationOrder applicationOrder, String userName)Update favorite applications order for a user
-
-
-
Field Detail
-
DEFAULT_ADMINISTRATORS_GROUP
public static final String DEFAULT_ADMINISTRATORS_GROUP
- See Also:
- Constant Field Values
-
DEFAULT_ADMINISTRATORS_PERMISSION
public static final String DEFAULT_ADMINISTRATORS_PERMISSION
- See Also:
- Constant Field Values
-
ANY_PERMISSION
public static final String ANY_PERMISSION
- See Also:
- Constant Field Values
-
DEFAULT_USERS_GROUP
public static final String DEFAULT_USERS_GROUP
- See Also:
- Constant Field Values
-
DEFAULT_USERS_PERMISSION
public static final String DEFAULT_USERS_PERMISSION
- See Also:
- Constant Field Values
-
MAX_FAVORITE_APPS
public static final String MAX_FAVORITE_APPS
- See Also:
- Constant Field Values
-
DEFAULT_APP_IMAGE_ID
public static final String DEFAULT_APP_IMAGE_ID
- See Also:
- Constant Field Values
-
DEFAULT_APP_IMAGE_NAME
public static final String DEFAULT_APP_IMAGE_NAME
- See Also:
- Constant Field Values
-
DEFAULT_APP_IMAGE_BODY
public static final String DEFAULT_APP_IMAGE_BODY
- See Also:
- Constant Field Values
-
DEFAULT_LIMIT
public static final int DEFAULT_LIMIT
- See Also:
- Constant Field Values
-
LOG_SERVICE_NAME
public static String LOG_SERVICE_NAME
-
LOG_OPEN_FAVORITE_DRAWER
public static String LOG_OPEN_FAVORITE_DRAWER
-
LOG_CLICK_ALL_APPLICATIONS
public static String LOG_CLICK_ALL_APPLICATIONS
-
LOG_OPEN_APPLICATION
public static final String LOG_OPEN_APPLICATION
- See Also:
- Constant Field Values
-
LOG_REORGANIZE_FAVORITES
public static final String LOG_REORGANIZE_FAVORITES
- See Also:
- Constant Field Values
-
LOG_ADD_FAVORITE
public static final String LOG_ADD_FAVORITE
- See Also:
- Constant Field Values
-
LOG_REMOVE_FAVORITE
public static final String LOG_REMOVE_FAVORITE
- See Also:
- Constant Field Values
-
MERGE_MODE
public static final String MERGE_MODE
- See Also:
- Constant Field Values
-
-
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 (PortalContainerstarts ) to inject default application and to delete injected default applications- Specified by:
startin interfaceorg.picocontainer.Startable
-
stop
public void stop()
- Specified by:
stopin interfaceorg.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 anApplicationAlreadyExistsExceptionwill be thrown.- Parameters:
application- application to create- Returns:
- stored
Applicationin datasource - Throws:
Exception- when application already exists or an error occurs while creating application or its attached image
-
findApplication
public Application findApplication(long applicationId) throws Exception
Get an application by id- Parameters:
applicationId- application to find- Returns:
- stored
Applicationin datasource - Throws:
Exception- whenApplicationNotFoundExceptionis thrown or an error occurs while saving application
-
updateApplication
public Application updateApplication(Application application, String username) throws Exception
Update an existing application on datasource. If the application doesn't exit anApplicationNotFoundExceptionwill be thrown.- Parameters:
application- dto to update on storeusername- username storing application- Returns:
- stored
Applicationin datasource - Throws:
Exception- whenApplicationNotFoundExceptionis thrown or an error occurs while saving application
-
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 applicationusername- user currently deleting application- Throws:
ApplicationNotFoundException- if application wasn't foundIllegalAccessException- if user is not allowed to delete applicationorg.exoplatform.commons.file.services.FileStorageException
-
addFavoriteApplication
public void addFavoriteApplication(long applicationId, String username) throws ApplicationNotFoundException, IllegalAccessException, org.exoplatform.commons.file.services.FileStorageExceptionAdd an application, identified by its technical id, as favorite of a user- Parameters:
applicationId- technical application idusername- user login- Throws:
ApplicationNotFoundException- when application is not foundIllegalAccessException- if user hasn't access permission to the applicationorg.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 identifierusername- 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:
GeneralSettingsof 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 querylimit- limit of the query that can be less or equal to 0, which mean, getting all available applicationskeyword- used to search in title and url- Returns:
ApplicationListthat 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 ofApplicationand the username to filter on authorized applications- Parameters:
offset- offset of the querylimit- limit of the query that can be less or equal to 0, which mean, getting all available applicationskeyword- used to search in title and urlusername- login of user to use to filter on authorized applications- Returns:
ApplicationListthat contains theListof authorizedUserApplication- 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:
ApplicationListthat containsListofUserApplication
-
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:
ApplicationNotFoundExceptionorg.exoplatform.commons.file.services.FileStorageException
-
getApplicationImageLastUpdated
public Long getApplicationImageLastUpdated(long applicationId, String username) throws ApplicationNotFoundException, IllegalAccessException, org.exoplatform.commons.file.services.FileStorageException
Return theApplicationillustration last modifed timestamp (in ms), if not found, the default image last modifed timestamp will be retrieved- Parameters:
applicationId- technical id of applicationusername- login of user accessing application- Returns:
- timestamp in milliseconds of last modified date of illustration
- Throws:
ApplicationNotFoundException- if application wasn't foundIllegalAccessException- if user doesn't have access permission to applicationorg.exoplatform.commons.file.services.FileStorageException- if an error occurs while accessing file from store
-
getApplicationImageInputStream
public InputStream getApplicationImageInputStream(long applicationId, String username) throws ApplicationNotFoundException, IllegalAccessException, org.exoplatform.commons.file.services.FileStorageException, IOException
Return theApplicationillustrationInputStream, if not found, the default imageInputStreamwill be retrieved- Parameters:
applicationId- technical id of applicationusername- login of user accessing application- Returns:
InputStreamof application illustration- Throws:
ApplicationNotFoundException- if application wasn't foundIllegalAccessException- if user doesn't have access permission to applicationorg.exoplatform.commons.file.services.FileStorageException- if an error occurs while accessing file from storeIOException- if an error occurs while buildingInputStream
-
addApplicationPlugin
public void addApplicationPlugin(ApplicationPlugin applicationPlugin)
Inject a default application using IOCComponentPluginusing 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.
-
-