class UpdateFileMetadataAPIController {

    @PreAuthorize("hasPermission(#fileId, 'FILE', 'write|group-write')")
    @RequestMapping(value = "/file/metadata/{fileId}", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
    @ResponseBody
    public EcmFile updateFile(@RequestBody EcmFile file, @PathVariable("fileId") Long fileId, Authentication authentication)
            throws AcmUserActionFailedException, AcmObjectNotFoundException
    {
        if (file == null || file.getFileId() == null || fileId == null || !fileId.equals(file.getFileId()))
        {
            log.error("Invalid incoming file [{}]", file == null ? "unknown" : file.toString());
            throw new AcmUserActionFailedException(EcmFileConstants.USER_ACTION_UPDATE_FILE, EcmFileConstants.OBJECT_FILE_TYPE, null,
                    "Invalid incoming file", null);
        }
        file = getEcmFileService().updateFile(file);
        if (file != null)
        {
            return file;
        }
        throw new AcmUserActionFailedException(EcmFileConstants.USER_ACTION_UPDATE_FILE, EcmFileConstants.OBJECT_FILE_TYPE, fileId,
                "Failed to update file with fileId: " + fileId, null);
    }

}