Class MultipartItemResolver

java.lang.Object
fr.paris.lutece.portal.util.mvc.binding.AbstractParameterResolver
fr.paris.lutece.portal.util.mvc.binding.MultipartItemResolver
All Implemented Interfaces:
ParameterResolver

@ApplicationScoped public class MultipartItemResolver extends AbstractParameterResolver
Resolver for parameters of type MultipartItem, MultipartItem[], or List<MultipartItem>.

This class is responsible for resolving multipart file uploads in the context of an MVC request. It supports single file resolution, arrays of files, and lists of files, using the MultipartHttpServletRequest.

The resolver checks for the presence of the RequestParam annotation to determine the parameter name and whether the parameter is required. If the required parameter is missing, a ResolverResult.failed(T, java.util.List<fr.paris.lutece.portal.util.mvc.binding.BindingError>) is returned with an appropriate error message.

This class is annotated with ApplicationScoped, meaning it is managed by the CDI container and shared across the application.

See Also:
  • Constructor Details

    • MultipartItemResolver

      public MultipartItemResolver()
  • Method Details

    • supports

      public boolean supports(Parameter parameter)
      Determines whether this resolver supports the given parameter.

      This method checks if the parameter type is MultipartItem, MultipartItem[], or List<MultipartItem>.

      Parameters:
      parameter - The method parameter to check.
      Returns:
      true if the parameter type is supported, false otherwise.
    • resolve

      public ResolverResult<?> resolve(jakarta.servlet.http.HttpServletRequest request, Parameter parameter)
      Resolves the value of the given parameter from the HttpServletRequest.

      This method retrieves the parameter name from the RequestParam annotation if present, and resolves the value based on the parameter type. Supported types include:

      • MultipartItem - Single file upload.
      • MultipartItem[] - Array of file uploads.
      • List<MultipartItem> - List of file uploads.

      Parameters:
      request - The HTTP request containing the multipart data.
      parameter - The method parameter to resolve.
      Returns:
      A ResolverResult containing the resolved value or an error if resolution fails.