Class UIProjectReferenceFileService


  • @Component
    public class UIProjectReferenceFileService
    extends java.lang.Object
    A utility class for formatting responses for the project reference files page UI.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<UIReferenceFile> addReferenceFileToProject​(java.lang.Long projectId, java.util.List<org.springframework.web.multipart.MultipartFile> files, java.util.Locale locale)
      Add a new reference file to a project.
      java.lang.String deleteReferenceFile​(java.lang.Long fileId, java.lang.Long projectId, java.util.Locale locale)
      Delete a reference file.
      void downloadReferenceFile​(java.lang.Long fileId, javax.servlet.http.HttpServletResponse response)
      Download a reference file based on the id passed.
      java.util.List<UIReferenceFile> getReferenceFilesForProject​(java.lang.Long projectId, java.util.Locale locale)
      Get the reference files for a project
      • Methods inherited from class java.lang.Object

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

      • UIProjectReferenceFileService

        @Autowired
        public UIProjectReferenceFileService​(ProjectService projectService,
                                             ReferenceFileService referenceFileService,
                                             org.springframework.context.MessageSource messageSource)
    • Method Detail

      • addReferenceFileToProject

        public java.util.List<UIReferenceFile> addReferenceFileToProject​(java.lang.Long projectId,
                                                                         java.util.List<org.springframework.web.multipart.MultipartFile> files,
                                                                         java.util.Locale locale)
                                                                  throws UnsupportedReferenceFileContentError,
                                                                         java.io.IOException
        Add a new reference file to a project.
        Parameters:
        projectId - The id of the project to add the file to.
        files - List of MultipartFile file being uploaded.
        locale - locale of the logged in user
        Returns:
        Return success message or error if file was successfully uploaded or not
        Throws:
        UnsupportedReferenceFileContentError - if content is invalid
        java.io.IOException - if there is an I/O error
      • deleteReferenceFile

        public java.lang.String deleteReferenceFile​(java.lang.Long fileId,
                                                    java.lang.Long projectId,
                                                    java.util.Locale locale)
                                             throws EntityNotFoundException
        Delete a reference file. This will remove it from the project.
        Parameters:
        fileId - The id of the file to remove.
        projectId - the project to delete the reference file for.
        locale - the locale specified by the browser.
        Returns:
        Success or error based on the result of deleting the file.
        Throws:
        EntityNotFoundException - if project or reference file cannot be read
      • downloadReferenceFile

        public void downloadReferenceFile​(java.lang.Long fileId,
                                          javax.servlet.http.HttpServletResponse response)
                                   throws java.io.IOException
        Download a reference file based on the id passed.
        Parameters:
        fileId - The id of the file to download
        response - HttpServletResponse to write to file to
        Throws:
        java.io.IOException - if we fail to read the file from disk.
      • getReferenceFilesForProject

        public java.util.List<UIReferenceFile> getReferenceFilesForProject​(java.lang.Long projectId,
                                                                           java.util.Locale locale)
        Get the reference files for a project
        Parameters:
        projectId - the ID of the project
        locale - locale of the logged in user
        Returns:
        information about the reference files in the project