Class FileResource

java.lang.Object
org.powertac.visualizer.web.rest.FileResource

@RestController
@RequestMapping("/api")
public class FileResource
extends Object
REST controller for managing File.
  • Constructor Summary

    Constructors 
    Constructor Description
    FileResource​(FileService fileService, GameService gameService, UserRepository userRepository)  
  • Method Summary

    Modifier and Type Method Description
    org.springframework.http.ResponseEntity<File> createFile​(@Valid File file)
    POST /files : Create a new file.
    org.springframework.http.ResponseEntity<Void> deleteFile​(Long id)
    DELETE /files/:id : delete the "id" file.
    org.springframework.http.ResponseEntity<List<File>> getAllFiles​(org.springframework.data.domain.Pageable pageable)
    GET /files : get all the files.
    org.springframework.http.ResponseEntity<File> getFile​(Long id)
    GET /files/:id : get the "id" file.
    void getMyFile​(@Valid @NotNull String type, @Valid @NotNull Long id, javax.servlet.http.HttpServletResponse response)
    Download a file.
    org.springframework.http.ResponseEntity<List<File>> getMyFiles​(@Valid @NotNull String type)
    Get all files owned by logged in user, plus all shared files.
    org.springframework.http.ResponseEntity<File> postFile​(@Valid @NotNull String type, Boolean shared, Boolean overwrite, @Valid @NotNull org.springframework.web.multipart.MultipartFile part)
    Upload a file.
    org.springframework.http.ResponseEntity<File> updateFile​(@Valid File file)
    PUT /files : Updates an existing file.

    Methods inherited from class java.lang.Object

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

  • Method Details

    • createFile

      @PostMapping("/files") @Timed public org.springframework.http.ResponseEntity<File> createFile​(@Valid @RequestBody @Valid File file) throws URISyntaxException
      POST /files : Create a new file.
      Parameters:
      file - the file to create
      Returns:
      the ResponseEntity with status 201 (Created) and with body the new file, or with status 400 (Bad Request) if the file has already an ID
      Throws:
      URISyntaxException - if the Location URI syntax is incorrect
    • updateFile

      @PutMapping("/files") @Timed public org.springframework.http.ResponseEntity<File> updateFile​(@Valid @RequestBody @Valid File file) throws URISyntaxException
      PUT /files : Updates an existing file.
      Parameters:
      file - the file to update
      Returns:
      the ResponseEntity with status 200 (OK) and with body the updated file, or with status 400 (Bad Request) if the file is not valid, or with status 500 (Internal Server Error) if the file couldnt be updated
      Throws:
      URISyntaxException - if the Location URI syntax is incorrect
    • getAllFiles

      @GetMapping("/files") @Timed public org.springframework.http.ResponseEntity<List<File>> getAllFiles​(org.springframework.data.domain.Pageable pageable) throws URISyntaxException
      GET /files : get all the files.
      Parameters:
      pageable - the pagination information
      Returns:
      the ResponseEntity with status 200 (OK) and the list of files in body
      Throws:
      URISyntaxException - if there is an error to generate the pagination HTTP headers
    • getFile

      @GetMapping("/files/{id}") @Timed public org.springframework.http.ResponseEntity<File> getFile​(@PathVariable Long id)
      GET /files/:id : get the "id" file.
      Parameters:
      id - the id of the file to retrieve
      Returns:
      the ResponseEntity with status 200 (OK) and with body the file, or with status 404 (Not Found)
    • deleteFile

      @DeleteMapping("/files/{id}") @Timed public org.springframework.http.ResponseEntity<Void> deleteFile​(@PathVariable Long id)
      DELETE /files/:id : delete the "id" file.
      Parameters:
      id - the id of the file to delete
      Returns:
      the ResponseEntity with status 200 (OK)
    • getMyFiles

      @GetMapping("/myfiles/{type}/") @Timed public org.springframework.http.ResponseEntity<List<File>> getMyFiles​(@Valid @NotNull @PathVariable @Valid @NotNull String type) throws URISyntaxException
      Get all files owned by logged in user, plus all shared files.
      Throws:
      URISyntaxException
    • getMyFile

      @GetMapping("/myfiles/{type}/{id}") @Timed public void getMyFile​(@Valid @NotNull @PathVariable @Valid @NotNull String type, @Valid @NotNull @PathVariable @Valid @NotNull Long id, javax.servlet.http.HttpServletResponse response) throws IOException
      Download a file. TODO document.
      Parameters:
      type -
      id -
      response -
      Throws:
      IOException
    • postFile

      @PostMapping("/myfiles/{type}/") @Timed public org.springframework.http.ResponseEntity<File> postFile​(@Valid @NotNull @PathVariable @Valid @NotNull String type, @RequestParam("shared") Boolean shared, @RequestParam("overwrite") Boolean overwrite, @Valid @NotNull @RequestParam("file") @Valid @NotNull org.springframework.web.multipart.MultipartFile part) throws IOException, URISyntaxException
      Upload a file. TODO document.
      Parameters:
      part -
      type -
      shared -
      Throws:
      org.apache.commons.io.FileExistsException
      IOException
      URISyntaxException