Class FileControllerServiceImpl

java.lang.Object
org.kuali.rice.krad.web.service.impl.FileControllerServiceImpl
All Implemented Interfaces:
FileControllerService

public class FileControllerServiceImpl extends Object implements FileControllerService
Default implementation of the file controller service.
Author:
Kuali Rice Team (rice.collab@kuali.org)
  • Field Details

  • Constructor Details

    • FileControllerServiceImpl

      public FileControllerServiceImpl()
  • Method Details

    • addFileUploadLine

      public org.springframework.web.servlet.ModelAndView addFileUploadLine(UifFormBase form)
      Invoked by the multiFile upload element to add a file object to the collection it controls.
      Specified by:
      addFileUploadLine in interface FileControllerService
      Parameters:
      form - form instance containing the file data
      Returns:
      ModelAndView instance for rendering the view
    • deleteFileUploadLine

      public org.springframework.web.servlet.ModelAndView deleteFileUploadLine(UifFormBase form)
      Invoked by the multiFile upload widget to delete a file; Inform the model of file to delete.
      Specified by:
      deleteFileUploadLine in interface FileControllerService
      Parameters:
      form - form instance containing the file data
      Returns:
      ModelAndView instance for rendering the view
    • getFileFromLine

      public void getFileFromLine(UifFormBase form, javax.servlet.http.HttpServletResponse response)
      Invoked by the multiFile upload widget to get the file contents for a file upload line.
      Specified by:
      getFileFromLine in interface FileControllerService
      Parameters:
      form - form instance containing the file request data
      response - Http response for streaming back the file contents
    • sendFileFromLineResponse

      protected void sendFileFromLineResponse(UifFormBase form, javax.servlet.http.HttpServletResponse response, List<FileMeta> collection, FileMeta fileLine)
      Hook controller method to send a response back by using response.flushBuffer() using request/collection/fileLine information provided.

      A sample implementation may look like:

      
       if (fileLine instanceof FileMetaBlob) {
       InputStream is = ((FileMetaBlob) fileLine).getBlob().getBinaryStream();
       response.setContentType("application/force-download");
       response.setHeader("Content-Disposition", "attachment; filename=" + fileLine.getName());
      
       // copy it to response's OutputStream
       FileCopyUtils.copy(is, response.getOutputStream());
      
       response.flushBuffer();
       }
       
      Parameters:
      form - form instance containing the file request data
      response - Http response object for streaming back the file contents
      collection - collection the file object belongs to
      fileLine - the particular file line instance the contents should be sent back for
    • getCollectionControllerService

      protected CollectionControllerService getCollectionControllerService()
    • setCollectionControllerService

      public void setCollectionControllerService(CollectionControllerService collectionControllerService)
    • getModelAndViewService

      protected ModelAndViewService getModelAndViewService()
    • setModelAndViewService

      public void setModelAndViewService(ModelAndViewService modelAndViewService)