Package com.jalios.jcms.application
Class ApplicationManager
- java.lang.Object
-
- com.jalios.jcms.application.ApplicationManager
-
- All Implemented Interfaces:
JPropertiesListener
public final class ApplicationManager extends java.lang.Object implements JPropertiesListener
Manager for Application- Since:
- jcms-10.0.3
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
ApplicationManager.InstalledApplications
A POJO class representing installed applications with utility methods
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ACL_CAN_USE_APPLICATION_LAUNCHER
static java.lang.String
ACL_CAN_USE_APPLICATION_LAUNCHER_CATALOG_ADMINISTRATION
static java.lang.String
ADMIN_ALERT_DOMAIN
static java.lang.String
ALERT_DOMAIN
static java.lang.String
DEPLOY_ALERT_NAME
static java.lang.String
INSTALL_RECOMPUTE_ALARM
static java.lang.String
INSTALL_RECOMPUTE_DEFAULT_SCHEDULE
static java.lang.String
INSTALL_RECOMPUTE_SCHEDULE_PROP
protected static java.lang.Thread
lastAddApplicationThread
static java.lang.String
MBR_PREF
static java.lang.String
SHORTCUT_TYPE_CATEGORY_VID
-
Fields inherited from interface com.jalios.util.JPropertiesListener
REVISION
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
addApplication(Member mbr, int tabIndex, java.lang.String shortcutId)
Deprecated.useaddApplication(Member, String, Shortcut, boolean, boolean)
since it returns a ControllerStatusControllerStatus
addApplication(Member mbr, java.lang.String tabName, generated.Shortcut application, boolean checkAlreadyInstalled, boolean sendAlert)
Returns a ControllerStatus as a result of the action which adds the given application to the member's shortcut in given tabControllerStatus
addApplication(Member mbr, java.util.Collection<Group> groups, java.util.Collection<Member> members, java.lang.String tabName, generated.Shortcut application)
Returns a controller status as a result of the action that will : - Launch a new thread to retrieve all members from provided groups - Install the app in a new thread for each member - Create a tab if there's no matching tab in case tab name has been provided - Will send an alert telling the user an app has been installed - At the end of all threads, the author of the action will receive an alertboolean
canAdministrateApplications(Member mbr)
boolean
canRecomputeInstallCountCache(Member mbr)
boolean
canUseApplicationLauncher(Member mbr)
Returns true if the given member can use the Application launcher.boolean
canUseApplicationLauncherCatalogAdministration(Member mbr)
Returns true if the given member can use the Application launcher catalog administration.ApplicationManager.InstalledApplications
getAlreadyInstalledTabsMap(Member mbr)
ApplicationLauncher
getApplicationLauncher(Member mbr)
Returns the application launcher for given member by searching for his saved launcher, or by searching in its department default launcher, or the global default launcherjava.lang.String
getApplicationLauncherAsJson(ApplicationLauncher launcher)
Transforms an application launcher into jsonjava.lang.String
getApplicationLauncherAsJson(Member mbr)
int
getAverageInstallCount()
java.lang.String
getCleanedApplicationLauncherAsJson(ApplicationLauncher launcher)
Transforms an application launcher into json to save in the databaseApplicationLauncher
getDefaultApplicationLauncher()
ApplicationLauncher
getDefaultApplicationLauncher(Group department)
java.lang.String
getDefaultApplicationLauncherAsJson()
Group
getDefaultApplicationLauncherGroup(Group department)
java.util.Set<java.lang.String>
getDepartmentShortcutIds(Group department)
ApplicationLauncher
getEmptyApplicationLauncher()
int
getInstallCount(Application application)
java.util.List<Application>
getInstalledApplications(Member mbr)
int
getInstallOrganizationGroupCount(Application application, Member mbr)
static ApplicationManager
getInstance()
ApplicationLauncherTab
getOrAddTab(Member mbr, ApplicationLauncher applicationLauncher, java.lang.String tabName)
Returns a tab by either finding it in the given launcher by its name, or by creating a new one if not foundApplicationLauncherTab
getTabByName(ApplicationLauncher applicationLauncher, java.lang.String tabName)
Returns a tab by searching by its name in given application launcherjava.util.List<ApplicationLauncherTab>
getTabs(Member mbr)
int
getTotalInstallCount()
Category
getTypeRoot()
boolean
hasCustomApplicationLauncher(Group department)
Check if a department has a custom launcherboolean
hasDefaultApplicationLauncher(Group department)
Returns true if given department has a default launcherboolean
isApplicationAlreadyInTab(Member mbr, int tabIndex, java.lang.String shortcutId)
Checks if application is already installed in given tab indexboolean
isApplicationInstalled(AbstractShortcut shortcut, Member mbr)
boolean
isDepartmentEnabled()
boolean
isDeployApplicationToLauncherRunning()
boolean
isInstallCountInitialized()
boolean
isResetApplicationLauncherRunning()
void
propertiesChange(JProperties properties)
Invoked after properties have been modified in JCMS and save on disk.void
recomputeInstallCountCache()
Recomputes the install count cache asynchronouslyboolean
removeApplication(Member mbr, int tabIndex, java.lang.String shortcutId)
Removes an application (shortcutId) in given tab for given memberboolean
removeApplicationOnAllTabs(Member mbr, java.lang.String shortcutId)
Remove an application (shortcutId) on all member tabsvoid
resetApplicationLauncher(java.util.Collection<Member> members, java.util.Collection<Group> groups)
Deletes saved launcher for given member and groupsvoid
resetDefaultApplicationLauncher(Group department)
boolean
saveDefaultApplicationLauncher(Group department, java.lang.String data)
Saves json data as default json launcher for the given departmentstatic void
waitForAddingAllApplications()
A convenient method for unit test to wait for the ending of the add application thread.
-
-
-
Field Detail
-
SHORTCUT_TYPE_CATEGORY_VID
public static final java.lang.String SHORTCUT_TYPE_CATEGORY_VID
- See Also:
- Constant Field Values
-
MBR_PREF
public static final java.lang.String MBR_PREF
- See Also:
- Constant Field Values
-
INSTALL_RECOMPUTE_SCHEDULE_PROP
public static final java.lang.String INSTALL_RECOMPUTE_SCHEDULE_PROP
- See Also:
- Constant Field Values
-
INSTALL_RECOMPUTE_DEFAULT_SCHEDULE
public static final java.lang.String INSTALL_RECOMPUTE_DEFAULT_SCHEDULE
- See Also:
- Constant Field Values
-
INSTALL_RECOMPUTE_ALARM
public static final java.lang.String INSTALL_RECOMPUTE_ALARM
- See Also:
- Constant Field Values
-
DEPLOY_ALERT_NAME
public static final java.lang.String DEPLOY_ALERT_NAME
- See Also:
- Constant Field Values
-
ALERT_DOMAIN
public static final java.lang.String ALERT_DOMAIN
- See Also:
- Constant Field Values
-
ADMIN_ALERT_DOMAIN
public static final java.lang.String ADMIN_ALERT_DOMAIN
- See Also:
- Constant Field Values
-
ACL_CAN_USE_APPLICATION_LAUNCHER
public static final java.lang.String ACL_CAN_USE_APPLICATION_LAUNCHER
- See Also:
- Constant Field Values
-
ACL_CAN_USE_APPLICATION_LAUNCHER_CATALOG_ADMINISTRATION
public static final java.lang.String ACL_CAN_USE_APPLICATION_LAUNCHER_CATALOG_ADMINISTRATION
- See Also:
- Constant Field Values
-
lastAddApplicationThread
protected static java.lang.Thread lastAddApplicationThread
-
-
Method Detail
-
getInstance
public static ApplicationManager getInstance()
-
propertiesChange
public void propertiesChange(JProperties properties)
Description copied from interface:JPropertiesListener
Invoked after properties have been modified in JCMS and save on disk.You cannot alter the value received in parameters.
Note that properties parameter may be null, a limited set of site properties, or all site properties.
To check that a property has been modified, reload the "current" property instead using
channel.getProperties
orchannel.getProperty
.- Specified by:
propertiesChange
in interfaceJPropertiesListener
- Parameters:
properties
- the properties which have been submitted to change
-
isResetApplicationLauncherRunning
public boolean isResetApplicationLauncherRunning()
-
isDeployApplicationToLauncherRunning
public boolean isDeployApplicationToLauncherRunning()
-
isDepartmentEnabled
public boolean isDepartmentEnabled()
-
canUseApplicationLauncher
public boolean canUseApplicationLauncher(Member mbr)
Returns true if the given member can use the Application launcher.- Parameters:
mbr
- the member- Returns:
- true if the given member can use the application launcher.
- Since:
- jcms-10.0.3
-
canUseApplicationLauncherCatalogAdministration
public boolean canUseApplicationLauncherCatalogAdministration(Member mbr)
Returns true if the given member can use the Application launcher catalog administration.- Parameters:
mbr
- the member- Returns:
- true if the given member can use the Application launcher catalog administration.
- Since:
- jcms-10.0.4
-
isApplicationInstalled
public boolean isApplicationInstalled(AbstractShortcut shortcut, Member mbr)
- Parameters:
shortcut
- theAbstractShortcut
mbr
- theMember
- Returns:
- true if application is installed for given member
- Since:
- jcms-10.0.3
-
canRecomputeInstallCountCache
public boolean canRecomputeInstallCountCache(Member mbr)
- Parameters:
mbr
- theMember
- Returns:
- true if given member can recompute the install count cache
- Since:
- jcms-10.0.3
-
canAdministrateApplications
public boolean canAdministrateApplications(Member mbr)
- Parameters:
mbr
- theMember
- Returns:
- true if given member can administrate applications (Launcher / Reset / Recompute)
- Since:
- jcms-10.0.6
-
getTypeRoot
public Category getTypeRoot()
- Returns:
- the type root of Applications
- Since:
- jcms-10.0.3
-
recomputeInstallCountCache
public void recomputeInstallCountCache()
Recomputes the install count cache asynchronously- Since:
- jcms-10.0.3
-
isInstallCountInitialized
public boolean isInstallCountInitialized()
- Returns:
- true if install count is initialized
- Since:
- jcms-10.0.3
-
getAverageInstallCount
public int getAverageInstallCount()
- Returns:
- the average install count per user
- Since:
- jcms-10.0.3
-
getInstallCount
public int getInstallCount(Application application)
- Parameters:
application
- theApplication
- Returns:
- the install count for given application
- Since:
- jcms-10.0.3
-
getTotalInstallCount
public int getTotalInstallCount()
- Returns:
- the total count of installed applications
- Since:
- jcms-10.0.3
-
getDepartmentShortcutIds
public java.util.Set<java.lang.String> getDepartmentShortcutIds(Group department)
- Parameters:
department
- the organization department- Returns:
- the set of
AbstractShortcut
of given department - Since:
- jcms-10.0.3
-
getInstallOrganizationGroupCount
public int getInstallOrganizationGroupCount(Application application, Member mbr)
- Parameters:
application
- theApplication
mbr
- theMember
- Returns:
- the install count for given application in given Member department
-
getDefaultApplicationLauncher
public ApplicationLauncher getDefaultApplicationLauncher()
- Returns:
- the default
ApplicationLauncher
- Since:
- jcms-10.0.3
-
saveDefaultApplicationLauncher
public boolean saveDefaultApplicationLauncher(Group department, java.lang.String data)
Saves json data as default json launcher for the given department- Parameters:
department
- theGroup
representing a departmentdata
- the json data- Returns:
- true if save has succeed
- Since:
- jcms-10.0.3
-
hasCustomApplicationLauncher
public boolean hasCustomApplicationLauncher(Group department)
Check if a department has a custom launcher- Parameters:
department
-- Returns:
- true if the department has a custom Launcher
-
getDefaultApplicationLauncher
public ApplicationLauncher getDefaultApplicationLauncher(Group department)
- Parameters:
department
- theGroup
representing department- Returns:
- the default
ApplicationLauncher
for given department - Since:
- jcms-10.0.3
-
getDefaultApplicationLauncherGroup
public Group getDefaultApplicationLauncherGroup(Group department)
-
hasDefaultApplicationLauncher
public boolean hasDefaultApplicationLauncher(Group department)
Returns true if given department has a default launcher- Parameters:
department
- theGroup
- Returns:
- true if given department has a default launcher
- Since:
- jcms-10.0.3
-
getDefaultApplicationLauncherAsJson
public java.lang.String getDefaultApplicationLauncherAsJson()
- Returns:
- the default application launcher as Json
- Since:
- jcms-10.0.3
-
getEmptyApplicationLauncher
public ApplicationLauncher getEmptyApplicationLauncher()
- Returns:
- an empty ApplicationLauncher with a tab
- Since:
- jcms-10.0.3
-
getApplicationLauncher
public ApplicationLauncher getApplicationLauncher(Member mbr)
Returns the application launcher for given member by searching for his saved launcher, or by searching in its department default launcher, or the global default launcher- Parameters:
mbr
- theMember
- Returns:
- an
ApplicationLauncher
- Since:
- jcms-10.0.3
-
getApplicationLauncherAsJson
public java.lang.String getApplicationLauncherAsJson(ApplicationLauncher launcher)
Transforms an application launcher into json- Parameters:
launcher
- theApplicationLauncher
- Returns:
- a json representing the
ApplicationLauncher
- Since:
- jcms-10.0.3
-
getCleanedApplicationLauncherAsJson
public java.lang.String getCleanedApplicationLauncherAsJson(ApplicationLauncher launcher)
Transforms an application launcher into json to save in the database- Parameters:
launcher
- theApplicationLauncher
- Returns:
- a json representing the
ApplicationLauncher
to be saved in the database - Since:
- jcms-10.0.6
-
getApplicationLauncherAsJson
public java.lang.String getApplicationLauncherAsJson(Member mbr)
- Parameters:
mbr
- theMember
- Returns:
- the application launcher for given Member as json
- Since:
- jcms-10.0.3
-
getTabs
public java.util.List<ApplicationLauncherTab> getTabs(Member mbr)
- Parameters:
mbr
- theMember
- Returns:
- the List of
ApplicationLauncherTab
for given member - Since:
- jcms-10.0.3
-
addApplication
@Deprecated public boolean addApplication(Member mbr, int tabIndex, java.lang.String shortcutId)
Deprecated.useaddApplication(Member, String, Shortcut, boolean, boolean)
since it returns a ControllerStatusAdds an application (shortcutId) in given tab for given member- Parameters:
mbr
- theMember
tabIndex
- the tab indexshortcutId
- theAbstractShortcut
id- Returns:
- true if adding the application has succeed
- Since:
- jcms-10.0.3
-
getOrAddTab
public ApplicationLauncherTab getOrAddTab(Member mbr, ApplicationLauncher applicationLauncher, java.lang.String tabName)
Returns a tab by either finding it in the given launcher by its name, or by creating a new one if not found- Parameters:
mbr
- theMember
to update the launcherapplicationLauncher
- theApplicationLauncher
tabName
- the name of the tab- Returns:
- an
ApplicationLauncherTab
- Since:
- 10.0.6
-
addApplication
public ControllerStatus addApplication(Member mbr, java.util.Collection<Group> groups, java.util.Collection<Member> members, java.lang.String tabName, generated.Shortcut application)
Returns a controller status as a result of the action that will : - Launch a new thread to retrieve all members from provided groups - Install the app in a new thread for each member - Create a tab if there's no matching tab in case tab name has been provided - Will send an alert telling the user an app has been installed - At the end of all threads, the author of the action will receive an alert- Parameters:
mbr
- theMember
which performs the actiongroups
- a collection ofGroup
members
- a colletion ofMember
tabName
- the tab name where the application will be installed (If empty, first tab will be used). If user doesn't have any tab by this name, a new one will be created.application
- theShortcut
to install- Returns:
- a ControllerStatus as a result of adding the app to multiple users
- Since:
- 10.0.6
-
waitForAddingAllApplications
public static void waitForAddingAllApplications()
A convenient method for unit test to wait for the ending of the add application thread. This method is not thread safe (it only wait for the last sending thread).- Since:
- jcms-10.0.6
-
addApplication
public ControllerStatus addApplication(Member mbr, java.lang.String tabName, generated.Shortcut application, boolean checkAlreadyInstalled, boolean sendAlert)
Returns a ControllerStatus as a result of the action which adds the given application to the member's shortcut in given tab- Parameters:
mbr
- theMember
to search for a matching launchertabName
- the tab name where the application will be added (If not available, a new tab will be created)application
- aShortcut
checkAlreadyInstalled
- to prevent action to be performed if app is already installedsendAlert
- to send an alert informing the user an app has been installed- Returns:
- a
ControllerStatus
as a result of the operation - Since:
- 10.0.6
-
getTabByName
public ApplicationLauncherTab getTabByName(ApplicationLauncher applicationLauncher, java.lang.String tabName)
Returns a tab by searching by its name in given application launcher- Parameters:
applicationLauncher
- theApplicationLauncher
tabName
- the name of the tab- Returns:
- an
ApplicationLauncherTab
- Since:
- 10.0.6
-
removeApplication
public boolean removeApplication(Member mbr, int tabIndex, java.lang.String shortcutId)
Removes an application (shortcutId) in given tab for given member- Parameters:
mbr
- theMember
tabIndex
- the tab indexshortcutId
- theAbstractShortcut
id- Returns:
- true if removing the application has succeed
- Since:
- jcms-10.0.3
-
removeApplicationOnAllTabs
public boolean removeApplicationOnAllTabs(Member mbr, java.lang.String shortcutId)
Remove an application (shortcutId) on all member tabs- Parameters:
mbr
-Member
shortcutId
- theAbstractShortcut
id- Returns:
- true if the app was remove on all tabs
-
isApplicationAlreadyInTab
public boolean isApplicationAlreadyInTab(Member mbr, int tabIndex, java.lang.String shortcutId)
Checks if application is already installed in given tab index- Parameters:
mbr
- theMember
tabIndex
- the tab indexshortcutId
- theAbstractShortcut
id- Returns:
- true if application is already installed in tab
- Since:
- jcms-10.0.3
-
getInstalledApplications
public java.util.List<Application> getInstalledApplications(Member mbr)
- Parameters:
mbr
- theMember
- Returns:
ApplicationManager.InstalledApplications
for givenMember
- Since:
- jcms-10.0.3
-
getAlreadyInstalledTabsMap
public ApplicationManager.InstalledApplications getAlreadyInstalledTabsMap(Member mbr)
-
resetApplicationLauncher
public void resetApplicationLauncher(java.util.Collection<Member> members, java.util.Collection<Group> groups)
Deletes saved launcher for given member and groups
-
resetDefaultApplicationLauncher
public void resetDefaultApplicationLauncher(Group department)
-
-