Class UserPortalFilePreviewHelper


  • public final class UserPortalFilePreviewHelper
    extends Object
    Helper for preview/download resource parameter handling and stream creation for user portal files.
    • Method Detail

      • encodeDynamicResourceParams

        public static String encodeDynamicResourceParams​(javax.servlet.http.HttpServletRequest request,
                                                         UserPortalFileViewModel model,
                                                         String mimeType,
                                                         String userPortalContentType)
        Encodes the parameters needed to serve the given file. Encrypts the parameters so that we do not, for example, expose the file path.
        Parameters:
        request - the current HTTP request, needed for storing the parameters in the session
        model - the file for which to create the parameters
        mimeType - the MIME type of the file, e.g. "image/png" or "application/pdf".
        userPortalContentType - the user portal content contentType of the file, e.g. "form", "tenantResource" or "tenantTemplate".
        Returns:
        the encoded parameters to serve the file, or null if the parameters could not be created.
      • getFile

        public static org.primefaces.model.StreamedContent getFile​(javax.servlet.http.HttpServletRequest request)
        Serves a file from a project, client resource, client template or portal entity.
        Parameters:
        request - the current HTTP request, needed for retrieving the parameters from the session
        Returns:
        the streamed content for the file, or an empty content if the parameters could not be retrieved or were invalid.
      • createDownloadContent

        public static org.primefaces.model.StreamedContent createDownloadContent​(UserPortalFileViewModel file,
                                                                                 String type,
                                                                                 String userPortalContentType)