Class FormThemeAPI


  • public class FormThemeAPI
    extends ASubAPI
    API class for common operations on form themes.
    Since:
    8.3.0
    Author:
    XIMA MEDIA GmbH
    • Constructor Detail

      • FormThemeAPI

        public FormThemeAPI()
    • Method Detail

      • findDefaultFormThemeByClient

        public FormThemeReference findDefaultFormThemeByClient​(UserContext userContext,
                                                               Mandant client)
        Gets the default form theme for the given client scope. When no client is given, returns the system's default form theme.
        Parameters:
        userContext - User context of the user who wants to load the file.
        client - The client scope for which to get the default form theme. May be null to get the system default form theme.
        Returns:
        The default form theme for the given client scope, never null.
      • findDefaultFormThemeByProject

        public FormThemeReference findDefaultFormThemeByProject​(UserContext userContext,
                                                                Projekt project)
        Gets the default form theme for the client scope from the given project. When no project is given, returns the system's default form theme.
        Parameters:
        userContext - User context of the user who wants to load the file.
        project - A project owned by the client scope for which to get the default form theme. May be null to get the system default form theme.
        Returns:
        The default form theme for the given client scope, never null.
      • findDefaultFormThemeByProject

        public FormThemeReference findDefaultFormThemeByProject​(UserContext userContext,
                                                                Long projectId)
        Gets the default form theme for the client scope from the given project. When no project is given, returns the system's default form theme.
        Parameters:
        userContext - User context of the user who wants to load the file.
        projectId - ID of a project owned by the client scope for which to get the default form theme. May be null to get the system default form theme.
        Returns:
        The default form theme for the given client scope, never null.
      • handleFormThemeFileRequest

        public ETagResource<ByteArrayFile> handleFormThemeFileRequest​(UserContext uc,
                                                                      Long clientId,
                                                                      FormThemeFileReference fileReference,
                                                                      ETagRequest eTagRequest)
                                                               throws IOException
        Loads the content of the given form the file.
        Parameters:
        uc - User context of the user who wants to load the file.
        clientId - ID of the client to load the file for, usually the client who owns the form. May be null if the form theme is not client-specific (e.g. when provided by a system plugin).
        fileReference - Reference to the file to load.
        eTagRequest - The ETag request to check if the file has changed.
        Returns:
        The content of the file, if modified.
        Throws:
        FileNotFoundException - If the file does not exist.
        IOException - If the file could not be loaded.
      • handleFormThemeFileRequest

        public ETagResource<ByteArrayFile> handleFormThemeFileRequest​(UserContext uc,
                                                                      UUID clientUuid,
                                                                      FormThemeFileReference fileReference,
                                                                      ETagRequest eTagRequest)
                                                               throws IOException
        Loads the content of the given form the file.
        Parameters:
        uc - User context of the user who wants to load the file.
        clientUuid - UUID of the client to load the file for, usually the client who owns the form. May be null if the form theme is not client-specific (e.g. when provided by a system plugin).
        fileReference - Reference to the file to load.
        eTagRequest - The ETag request to check if the file has changed.
        Returns:
        The content of the file, if modified.
        Throws:
        FileNotFoundException - If the file does not exist.
        IOException - If the file could not be loaded.
      • loadFormThemeFile

        public byte[] loadFormThemeFile​(UserContext uc,
                                        UUID clientUuid,
                                        FormThemeFileReference fileReference)
                                 throws IOException
        Loads the content of the given form the file.
        Parameters:
        uc - User context of the user who wants to load the file.
        clientUuid - UUID of the client to load the file for, usually the client who owns the form. May be null if the form theme is not client-specific (e.g. when provided by a system plugin).
        fileReference - Reference to the file to load.
        Returns:
        The content of the file.
        Throws:
        FileNotFoundException - If the file does not exist.
        IOException - If the file could not be loaded.
      • loadFormThemeFile

        public byte[] loadFormThemeFile​(UserContext uc,
                                        Long clientId,
                                        FormThemeFileReference fileReference)
                                 throws IOException
        Loads the content of the given form the file.
        Parameters:
        uc - User context of the user who wants to load the file.
        clientId - ID of the client to load the file for, usually the client who owns the form. May be null if the form theme is not client-specific (e.g. when provided by a system plugin).
        fileReference - Reference to the file to load.
        Returns:
        The content of the file.
        Throws:
        FileNotFoundException - If the file does not exist.
        IOException - If the file could not be loaded.
      • loadFormThemeFile

        public byte[] loadFormThemeFile​(UserContext uc,
                                        Mandant client,
                                        FormThemeFileReference fileReference)
                                 throws IOException
        Loads the content of the given form the file.
        Parameters:
        uc - User context of the user who wants to load the file.
        client - The client to load the file for, usually the client who owns the form. May be null if the form theme is not client-specific (e.g. when provided by a system plugin).
        fileReference - Reference to the file to load.
        Returns:
        The content of the file.
        Throws:
        FileNotFoundException - If the file does not exist.
        IOException - If the file could not be loaded.
      • resolveFormThemeCssClassesHierarchically

        public Set<String> resolveFormThemeCssClassesHierarchically​(UserContext uc,
                                                                    Mandant client,
                                                                    FormThemeReference formThemeReference,
                                                                    boolean useDefaultIfUnresolvable)
        Gets all CSS classes from the given form theme and all its parent themes. CSS classes are returned in no particular order.
        Parameters:
        uc - User context of the user who wants to load the file.
        client - The client to load the file for, usually the client who owns the form. May be null if the form theme is not client-specific (e.g. when provided by a system plugin).
        formThemeReference - The form theme to get the files for.
        useDefaultIfUnresolvable - If true and the given theme cannot be resolved (e.g. when the referenced theme does not exist anymore), uses the default theme instead.
        Returns:
        A set of CSS classes that are defined in the form theme and all its parent themes.
      • resolveFormThemeFilesHierarchically

        public Map<String,​List<FormThemeFileReference>> resolveFormThemeFilesHierarchically​(UserContext uc,
                                                                                                  Mandant client,
                                                                                                  FormThemeReference formThemeReference,
                                                                                                  String resourceContext,
                                                                                                  Set<String> extensions,
                                                                                                  boolean useDefaultIfUnresolvable)
        Gets all files from the given form theme, including files from parent form themes (if any). Files are returned in order of their file name.
        Parameters:
        uc - User context of the user who wants to load the file.
        client - The client to load the file for, usually the client who owns the form. May be null if the form theme is not client-specific (e.g. when provided by a system plugin).
        formThemeReference - The form theme to get the files for.
        resourceContext - The resource context to get the files for. See EFormThemeResourceContext for well-known contexts.
        extensions - The file extensions to get the files for. If empty, all files are returned.
        useDefaultIfUnresolvable - If true and the given theme cannot be resolved (e.g. when the referenced theme does not exist anymore), uses the default theme instead.
        Returns:
        A map of form resource types to a set of form theme file references.