Class ProcessUploadedFile

  • All Implemented Interfaces:
    Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig, ConnectionProvider
    Direct Known Subclasses:
    ImportBPSet, ImportProductInDiscount

    public abstract class ProcessUploadedFile
    extends HttpSecureAppServlet
    Generic base class to be extended to implement an import by uploading a file. The actual processing happens in a subclass which needs to override two methods. The resulting (error) messages can be returned as a file to download by the user.
    Author:
    mtaal
    See Also:
    Serialized Form
    • Constructor Detail

      • ProcessUploadedFile

        public ProcessUploadedFile()
    • Method Detail

      • doPost

        public void doPost​(javax.servlet.http.HttpServletRequest request,
                           javax.servlet.http.HttpServletResponse response)
                    throws IOException,
                           javax.servlet.ServletException
        Overrides:
        doPost in class javax.servlet.http.HttpServlet
        Throws:
        IOException
        javax.servlet.ServletException
      • post

        public void post​(VariablesSecureApp vars,
                         javax.servlet.http.HttpServletRequest request,
                         javax.servlet.http.HttpServletResponse response)
      • uploadFile

        protected void uploadFile​(VariablesSecureApp vars,
                                  javax.servlet.http.HttpServletRequest request,
                                  javax.servlet.http.HttpServletResponse response,
                                  org.codehaus.jettison.json.JSONObject paramValues)
                           throws Exception
        Throws:
        Exception
      • readAndReturnResult

        protected void readAndReturnResult​(javax.servlet.http.HttpServletResponse response,
                                           org.codehaus.jettison.json.JSONObject paramValues)
                                    throws Exception
        Throws:
        Exception
      • clearBeforeImport

        protected abstract void clearBeforeImport​(String ownerId,
                                                  org.codehaus.jettison.json.JSONObject paramValues)
        This method is called when the parameter import mode is set to import and replace. In that case the current content should be removed. The ownerId is the id of the parent record.
      • doProcessFile

        protected abstract ProcessUploadedFile.UploadResult doProcessFile​(org.codehaus.jettison.json.JSONObject paramValues,
                                                                          File file)
                                                                   throws Exception
        Is called to process the content of the uploaded file. The results should be returned in the uploadResult object.
        Throws:
        Exception