Class AdminUploadServlet

java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
sk.iway.iwcm.admin.upload.AdminUploadServlet
All Implemented Interfaces:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable

@WebServlet("/admin/upload/chunk") public class AdminUploadServlet extends jakarta.servlet.http.HttpServlet
Receives administrative uploads in chunks, validates their destination, and assembles them. Completed uploads are either written directly to an approved folder or retained temporarily for a subsequent conflict-resolution request.
See Also:
  • Field Summary

    Fields inherited from class jakarta.servlet.http.HttpServlet

    LEGACY_DO_HEAD
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    Deletes a temporary upload that is no longer needed.
    protected void
    doPost(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
    Validates and stores one upload chunk, assembling and processing the file after the final chunk.
    static String
    Returns the original name of a temporary upload.
    static String
    Returns the physical path of a temporary upload for validation by downstream consumers.
    static String
    moveAndReplaceFile(String fileKey, String destinationFolder, String fileNameParam)
    Moves a temporary upload to its final destination, replacing an existing file if necessary.

    Methods inherited from class jakarta.servlet.http.HttpServlet

    doDelete, doGet, doHead, doOptions, doPatch, doPut, doTrace, getLastModified, init, isSensitiveHeader, service, service

    Methods inherited from class jakarta.servlet.GenericServlet

    destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AdminUploadServlet

      public AdminUploadServlet()
  • Method Details

    • doPost

      protected void doPost(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException, IOException
      Validates and stores one upload chunk, assembling and processing the file after the final chunk. File archive requests also preserve their validated bulk metadata across all chunks.
      Overrides:
      doPost in class jakarta.servlet.http.HttpServlet
      Parameters:
      request - multipart upload request
      response - response receiving the JSON upload status
      Throws:
      jakarta.servlet.ServletException - when the servlet container cannot process the multipart request
      IOException - when request data cannot be read or the response cannot be written
    • moveAndReplaceFile

      public static String moveAndReplaceFile(String fileKey, String destinationFolder, String fileNameParam) throws IOException
      Moves a temporary upload to its final destination, replacing an existing file if necessary.
      Parameters:
      fileKey - unique key of the temporary upload
      destinationFolder - virtual path of the destination folder, for example /images/gallery/
      fileNameParam - requested destination file name
      Returns:
      the final file name, or null when the temporary file was not moved
      Throws:
      IOException - when the file cannot be moved
    • deleteTempFile

      public static boolean deleteTempFile(String fileKey)
      Deletes a temporary upload that is no longer needed.
      Parameters:
      fileKey - unique key of the temporary upload
      Returns:
      true when the temporary file existed and was deleted
    • getTempFilePath

      public static String getTempFilePath(String fileKey)
      Returns the physical path of a temporary upload for validation by downstream consumers.
      Parameters:
      fileKey - unique key of the temporary upload
      Returns:
      temporary file path, or null when the key is unknown
    • getOriginalFileName

      public static String getOriginalFileName(String fileKey)
      Returns the original name of a temporary upload.
      Parameters:
      fileKey - unique key of the temporary upload
      Returns:
      original file name, or null when the key is unknown