Class EditorProfileService
java.lang.Object
fr.paris.lutece.portal.service.editor.EditorProfileService
Chooses the profile of the back office rich text editor. Only the profiles of the editor of the back office are candidates. A profile targets plugins,
and optionally roles and workgroups: it matches the templates of one of its plugins, for a user holding one of its roles (any user when it has none) and
belonging to one of its workgroups (any user when it has none). The first matching profile, in the order of priority, applies; the default profile of
the editor applies when none matches.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name standing for the templates of the core -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateMissingDefaultProfiles(List<String> listEditorNames, String strName) Creates the default profile of each editor that has none, so that every editor keeps onestatic EditorProfilefindProfile(List<EditorProfile> listProfiles, String strEditorName, String strPlugin, Collection<String> listRoles, Collection<String> listWorkgroups) Finds the profile of an editor applying to a plugin and to the roles and workgroups of a userstatic StringChooses the plugin of a page from its rendered template and its request.static StringgetPluginFromRequestUri(String strRequestUri) Guesses the plugin of a request from its URI: ...static StringgetPluginFromTemplateName(String strTemplateName) Guesses the plugin of a template from its path: admin/plugins/[plugin]/... for a plugin, admin/... for the coregetProfile(String strEditorName, String strPlugin, AdminUser user) Gives the profile of an editor for the templates of a plugin and a userstatic booleanisValidConfig(String strConfig) Checks the configuration of a profilevoidmove(EditorProfile profile, boolean bUp) Moves a profile one step before or after in the order of priority of its editor.
-
Field Details
-
PLUGIN_CORE
The name standing for the templates of the core- See Also:
-
-
Constructor Details
-
EditorProfileService
public EditorProfileService()
-
-
Method Details
-
getProfile
Gives the profile of an editor for the templates of a plugin and a user- Parameters:
strEditorName- the name of the editorstrPlugin- the name of the plugin, core for the templates of the coreuser- the user, null when unknown: only the profiles without role nor workgroup match- Returns:
- the matching profile, or the default profile of the editor, null when the editor has no profile
-
findProfile
public static EditorProfile findProfile(List<EditorProfile> listProfiles, String strEditorName, String strPlugin, Collection<String> listRoles, Collection<String> listWorkgroups) Finds the profile of an editor applying to a plugin and to the roles and workgroups of a user- Parameters:
listProfiles- the profiles, by prioritystrEditorName- the name of the editorstrPlugin- the name of the pluginlistRoles- the keys of the roles of the userlistWorkgroups- the keys of the workgroups of the user- Returns:
- the first matching profile of the editor, or its default profile, null when the editor has no profile
-
getPluginFromTemplateName
Guesses the plugin of a template from its path: admin/plugins/[plugin]/... for a plugin, admin/... for the core- Parameters:
strTemplateName- the path of the template- Returns:
- the name of the plugin, core, or null when the path tells nothing
-
getPluginFromRequestUri
Guesses the plugin of a request from its URI: .../jsp/admin/plugins/[plugin]/... for a plugin, the core otherwise- Parameters:
strRequestUri- the URI of the request- Returns:
- the name of the plugin, or core
-
getPlugin
Chooses the plugin of a page from its rendered template and its request. A template of a plugin names it. A template of the core may render the form of a plugin (the portlet forms of the plugins are included in admin/portlet/create_portlet.html): a JSP of a plugin then names it. Otherwise the page belongs to the core.- Parameters:
strTemplateName- the path of the rendered template, may be nullstrRequestUri- the URI of the request, may be null- Returns:
- the name of the plugin, or core
-
isValidConfig
Checks the configuration of a profile- Parameters:
strConfig- the configuration- Returns:
- true when it is empty or a JSON object
-
createMissingDefaultProfiles
Creates the default profile of each editor that has none, so that every editor keeps one- Parameters:
listEditorNames- the names of the editors of the back officestrName- the name given to a created default profile
-
move
Moves a profile one step before or after in the order of priority of its editor. The default profile stays last.- Parameters:
profile- the profilebUp- true to move it before the previous one, false after the next one
-