Class EditorProfileService

java.lang.Object
fr.paris.lutece.portal.service.editor.EditorProfileService

@ApplicationScoped public class EditorProfileService extends Object
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 Details

  • Constructor Details

    • EditorProfileService

      public EditorProfileService()
  • Method Details

    • getProfile

      public EditorProfile getProfile(String strEditorName, String strPlugin, AdminUser user)
      Gives the profile of an editor for the templates of a plugin and a user
      Parameters:
      strEditorName - the name of the editor
      strPlugin - the name of the plugin, core for the templates of the core
      user - 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 priority
      strEditorName - the name of the editor
      strPlugin - the name of the plugin
      listRoles - the keys of the roles of the user
      listWorkgroups - 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

      public static String getPluginFromTemplateName(String strTemplateName)
      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

      public static String getPluginFromRequestUri(String strRequestUri)
      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

      public static String getPlugin(String strTemplateName, String strRequestUri)
      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 null
      strRequestUri - the URI of the request, may be null
      Returns:
      the name of the plugin, or core
    • isValidConfig

      public static boolean isValidConfig(String strConfig)
      Checks the configuration of a profile
      Parameters:
      strConfig - the configuration
      Returns:
      true when it is empty or a JSON object
    • createMissingDefaultProfiles

      public void createMissingDefaultProfiles(List<String> listEditorNames, String strName)
      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 office
      strName - the name given to a created default profile
    • move

      public void move(EditorProfile profile, boolean bUp)
      Moves a profile one step before or after in the order of priority of its editor. The default profile stays last.
      Parameters:
      profile - the profile
      bUp - true to move it before the previous one, false after the next one