public function process()
 {
     $parameters = $this->getParametersAsArray();
     if (!empty($parameters[0])) {
         $repository_id = (int) $parameters[0];
     } else {
         $this->error('Missing argument repository id');
         return false;
     }
     if (!empty($parameters[1])) {
         $remote_server_id = (int) $parameters[1];
     } else {
         $this->error('Missing argument remote server id');
         return false;
     }
     $repository = $this->repository_factory->getRepositoryById($repository_id);
     if (!$repository) {
         $this->error('Failed to find repository ' . $repository_id);
         return false;
     }
     $server = $this->server_factory->getServerById($remote_server_id);
     if (!$server) {
         $this->error('Failed to find server ' . $remote_server_id);
         return false;
     }
     $project = $repository->getProject();
     if (!$project) {
         $this->error('Failed to find project ' . $repository->getProject());
         return false;
     }
     return $this->makeGerritProjectReadOnly($repository, $server, $project);
 }
 private function getServer()
 {
     try {
         return $this->gerrit_server_factory->getServerById($this->getServerId());
     } catch (Git_RemoteServer_NotFoundException $e) {
         return new Git_RemoteServer_GerritServer($this->getServerId(), '', '', '', '', '', '', false, '', '');
     }
 }
Ejemplo n.º 3
0
 private function gerritProjectAlreadyExists($remote_server_id, GitRepository $repo)
 {
     $gerrit_server = $this->gerrit_server_factory->getServerById($remote_server_id);
     $driver = $this->driver_factory->getDriver($gerrit_server);
     $gerrit_project_name = $driver->getGerritProjectName($repo);
     return $driver->doesTheProjectExist($gerrit_server, $gerrit_project_name);
 }
 private function verbalizeRemoteServerId($remote_server_id, $with_link)
 {
     $txt = '#' . $remote_server_id;
     if ($with_link) {
         try {
             $server = $this->server_factory->getServerById($remote_server_id);
             $txt = $server->getHost();
         } catch (Git_RemoteServer_NotFoundException $exception) {
             $txt .= " GERRIT SERVER DELETED";
         }
     }
     return $txt;
 }
Ejemplo n.º 5
0
 public function disconnectFromGerrit(GitRepository $repository)
 {
     $repository->getBackend()->disconnectFromGerrit($repository);
     $this->git_system_event_manager->queueRepositoryUpdate($repository);
     $server = $this->gerrit_server_factory->getServerById($repository->getRemoteServerId());
     $driver = $this->driver_factory->getDriver($server);
     $disconnect_option = $this->request->get(GitViews_RepoManagement_Pane_Gerrit::OPTION_DISCONNECT_GERRIT_PROJECT);
     if ($disconnect_option == GitViews_RepoManagement_Pane_Gerrit::OPTION_DELETE_GERRIT_PROJECT) {
         $this->git_system_event_manager->queueRemoteProjectDeletion($repository, $driver);
         $this->history_dao->groupAddHistory("git_disconnect_gerrit_delete", $repository->getName(), $repository->getProjectId());
     }
     if ($disconnect_option == GitViews_RepoManagement_Pane_Gerrit::OPTION_READONLY_GERRIT_PROJECT) {
         $this->git_system_event_manager->queueRemoteProjectReadOnly($repository, $driver);
         $this->history_dao->groupAddHistory("git_disconnect_gerrit_read_only", $repository->getName(), $repository->getProjectId());
     }
 }