public function permission()
 {
     $permission = $this->getRequestParam('permission', NULL);
     $password = $this->getRequestParam('password', '');
     $file_alias = $this->getRequestParam('file_alias', NULL);
     $file_id = $this->getRequestParam('file_id', NULL);
     $response = new AjaxResponse();
     try {
         if ($permission == NULL || !FilePermissions::tryParse($permission)) {
             throw new Exception();
         }
         if ($file_alias != NULL) {
             $file = File::find('alias', $file_alias);
         } else {
             if ($file_id != NULL) {
                 $file = File::find('_id', $file_id);
             } else {
                 throw new Exception();
             }
         }
         $file->permission = $permission;
         $file->password = $password;
         $file->save();
         $response->success = true;
     } catch (InvalidArgumentException $e) {
         $response->success = false;
         $response->message = System::getLanguage()->_('ErrorInvalidParameter');
     } catch (InvalidPasswordException $e) {
         $response->success = false;
         $response->message = System::getLanguage()->_('ErrorInvalidPassword');
     } catch (NotAuthorisedException $e) {
         $response->success = false;
         $response->message = System::getLanguage()->_('PermissionDenied');
     } catch (Exception $e) {
         $response->success = false;
         $response->message = System::getLanguage()->_('ErrorInvalidParameter');
     }
     $response->send();
 }