class UpdateFileTypeAPIController {

    @PreAuthorize("hasPermission(#fileId, 'FILE', 'write|group-write')")
    @RequestMapping(value = "/file/{fileId}/type/{fileType}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    public EcmFile updateFileType(@PathVariable("fileId") Long fileId, @PathVariable("fileType") String fileType,
            Authentication authentication, HttpSession session) throws AcmObjectNotFoundException
    {

        log.debug("Updating file type to '{}'", fileType);

        EcmFile file = updateFileType(fileId, fileType);

        if (file == null)
        {
            throw new AcmObjectNotFoundException("EcmFile", fileId, "Cannot update file type.");
        }

        return file;
    }

}