private function makeGerritProjectReadOnly(GitRepository $repository, Git_RemoteServer_GerritServer $server, Project $project)
 {
     try {
         $this->driver_factory->getDriver($server)->makeGerritProjectReadOnly($server, $project->getUnixName() . '/' . $repository->getName());
     } catch (Exception $e) {
         $this->error($e->getMessage() . $e->getTraceAsString());
         return false;
     }
     $this->done();
     return true;
 }
示例#2
0
 private function getRemoteRepositoryInfoDone()
 {
     /** @var $gerrit_server Git_RemoteServer_GerritServer */
     $gerrit_server = $this->gerrit_servers[$this->repository->getRemoteServerId()];
     $driver = $this->driver_factory->getDriver($gerrit_server);
     $gerrit_project = $driver->getGerritProjectName($this->repository);
     $link = $gerrit_server->getProjectUrl($gerrit_project);
     $html = '';
     $html .= '<div class="alert alert-info gerrit_url">';
     $html .= $GLOBALS['Language']->getText('plugin_git', 'delegated_to_gerrit');
     $html .= ' <a href="' . $link . '">' . $gerrit_project . '</a>';
     $html .= '</div>';
     return $html;
 }
示例#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 deleteGerritProject(GitRepository $repository, Git_RemoteServer_GerritServer $server, Project $project, $backend)
 {
     try {
         $this->driver_factory->getDriver($server)->deleteProject($server, $project->getUnixName() . '/' . $repository->getName());
         $backend->setGerritProjectAsDeleted($repository);
     } catch (Exception $e) {
         $this->error($e->getMessage() . $e->getTraceAsString());
         return false;
     }
     $this->done();
     return true;
 }
 /**
  *
  * @param Git_RemoteServer_GerritServer $remote_server
  * @param array $keys
  * @param Git_Driver_Gerrit_User $gerrit_user
  *
  * @return string[] List of errors
  */
 private function removeKeys(Git_RemoteServer_GerritServer $remote_server, array $keys, Git_Driver_Gerrit_User $gerrit_user)
 {
     $errors = array();
     foreach ($keys as $key) {
         try {
             $this->gerrit_driver_factory->getDriver($remote_server)->removeSSHKeyFromAccount($remote_server, $gerrit_user, $key);
         } catch (Git_Driver_Gerrit_Exception $exception) {
             $errors[] = $exception->getMessage();
         }
     }
     return $errors;
 }
示例#6
0
 private function getAccessURLs()
 {
     $urls = $this->repository->getAccessURL();
     if ($this->repository->isMigratedToGerrit()) {
         $gerrit_user = $this->gerrit_usermanager->getGerritUser($this->current_user);
         $gerrit_server = $this->gerrit_servers[$this->repository->getRemoteServerId()];
         $driver = $this->driver_factory->getDriver($gerrit_server);
         $gerrit_project = $driver->getGerritProjectName($this->repository);
         $clone_url = $gerrit_server->getEndUserCloneUrl($gerrit_project, $gerrit_user);
         $this->prependGerritCloneURL($urls, $clone_url);
     }
     return $urls;
 }
 /**
  * @param array $gerrit_servers
  * @param Project $project
  */
 private function createProjectOnServers(array $gerrit_servers, Project $project)
 {
     $ugroups = $this->ugroup_manager->getUGroups($project);
     $admin_ugroup = $this->getAdminUGroup($ugroups);
     $project_name = $project->getUnixName();
     foreach ($gerrit_servers as $gerrit_server) {
         $this->membership_manager->createArrayOfGroupsForServer($gerrit_server, $ugroups);
         $driver = $this->driver_factory->getDriver($gerrit_server);
         if (!$driver->doesTheParentProjectExist($gerrit_server, $project_name)) {
             $admin_group_name = $project_name . '/' . $admin_ugroup->getNormalizedName();
             $project_name = $driver->createProjectWithPermissionsOnly($gerrit_server, $project, $admin_group_name);
         }
     }
 }
示例#8
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());
     }
 }
 /**
  *
  * @param Git_RemoteServer_GerritServer $gerrit_server
  * @param string $gerrit_project_url
  * @return string file contents
  *
  * @throw Git_Driver_Gerrit_RemoteSSHCommandFailure
  */
 public function getGerritConfig(Git_RemoteServer_GerritServer $gerrit_server, $gerrit_project_url)
 {
     $this->driver_factory->getDriver($gerrit_server)->ping($gerrit_server);
     $this->cloneGerritProjectConfig($gerrit_server, $gerrit_project_url);
     return file_get_contents($this->dir . '/project.config');
 }
示例#10
0
 /**
  * @param PFUser user
  */
 public function ldap_daily_synchro_update_user(PFUser $user)
 {
     if ($user->getStatus() == PFUser::STATUS_SUSPENDED) {
         $factory = $this->getGerritServerFactory();
         $gerrit_servers = $factory->getServers();
         $gerritDriverFactory = new Git_Driver_Gerrit_GerritDriverFactory($this->getLogger());
         foreach ($gerrit_servers as $server) {
             $gerritDriver = $gerritDriverFactory->getDriver($server);
             $gerritDriver->setUserAccountInactive($server, $user);
         }
     }
 }
示例#11
0
 /**
  * @param PFUser user
  */
 public function ldap_daily_synchro_update_user(PFUser $user)
 {
     //get gerrit servers
     $factory = $this->getGerritServerFactory();
     $gerrit_servers = $factory->getServers();
     $gerritDriverFactory = new Git_Driver_Gerrit_GerritDriverFactory($this->getLogger());
     foreach ($gerrit_servers as $server) {
         $gerritDriver = $gerritDriverFactory->getDriver($server);
         $gerritDriver->setUserAccountInactive($server, $user);
     }
 }
 protected function getDriver(Git_RemoteServer_GerritServer $server)
 {
     return $this->driver_factory->getDriver($server);
 }
示例#13
0
 private function getGerritDriverForRepository(GitRepository $repository)
 {
     $server = $this->getGerritServerForRepository($repository);
     return $this->driver_factory->getDriver($server);
 }
 /**
  *
  * @param Git_RemoteServer_GerritServer $remote_server
  * @param array $keys
  * @param Git_Driver_Gerrit_User $gerrit_user
  * @throws Git_Driver_Gerrit_Exception
  */
 private function removeKeys(Git_RemoteServer_GerritServer $remote_server, array $keys, Git_Driver_Gerrit_User $gerrit_user)
 {
     foreach ($keys as $key) {
         $this->gerrit_driver_factory->getDriver($remote_server)->removeSSHKeyFromAccount($remote_server, $gerrit_user, $key);
     }
 }