protected function processActionPublish()
 {
     $onlineSession = $this->getOnlineEditSessionForFile();
     if ($onlineSession) {
         $forkSession = $onlineSession;
         if ($onlineSession->getOwnerId() != $this->getUser()->getId()) {
             $forkSession = $this->forkEditSessionForCurrentUser($onlineSession);
         }
         $this->sendJsonSuccessResponse(array('editSessionId' => $forkSession->getId(), 'id' => $onlineSession->getServiceFileId(), 'link' => $onlineSession->getServiceFileLink()));
     }
     $src = $this->getFileSrcToPublish();
     if (!$src) {
         $this->errorCollection->add(array(new Error(Loc::getMessage('DISK_DOC_CONTROLLER_ERROR_COULD_NOT_GET_FILE'), self::ERROR_COULD_NOT_GET_FILE)));
         $this->sendJsonErrorResponse();
     }
     $fileData = new FileData();
     $fileData->setName($this->file->getName());
     $fileData->setMimeType(TypeFile::getMimeTypeByFilename($this->file->getName()));
     $fileData->setSrc($src);
     $fileData = $this->documentHandler->createFile($fileData);
     if (!$fileData) {
         if ($this->documentHandler->isRequiredAuthorization()) {
             $this->sendNeedAuth();
         }
         $this->errorCollection->add($this->documentHandler->getErrors());
         $this->sendJsonErrorResponse();
     }
     //if somebody publish to google similar document
     $onlineSession = $this->getOnlineEditSessionForFile();
     if ($onlineSession) {
         $this->documentHandler->deleteFile($fileData);
         $forkSession = $onlineSession;
         if ($onlineSession->getOwnerId() != $this->getUser()->getId()) {
             $forkSession = $this->forkEditSessionForCurrentUser($onlineSession);
         }
         $this->sendJsonSuccessResponse(array('editSessionId' => $forkSession->getId(), 'id' => $onlineSession->getServiceFileId(), 'link' => $onlineSession->getServiceFileLink()));
     }
     $session = $this->addFileEditSessionByCurrentUser($fileData);
     $this->sendJsonSuccessResponse(array('editSessionId' => $session->getId(), 'id' => $fileData->getId(), 'link' => $fileData->getLinkInService()));
 }