当前位置: 首页>>代码示例>>Java>>正文


Java NameKey类代码示例

本文整理汇总了Java中com.google.gerrit.reviewdb.client.Project.NameKey的典型用法代码示例。如果您正苦于以下问题:Java NameKey类的具体用法?Java NameKey怎么用?Java NameKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NameKey类属于com.google.gerrit.reviewdb.client.Project包,在下文中一共展示了NameKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getResponseCode

import com.google.gerrit.reviewdb.client.Project.NameKey; //导入依赖的package包/类
private int getResponseCode(String projectName) {
    try {
        ProjectControl projectControl =
            this.projectControlFactory.controlFor(new NameKey(projectName));
        CurrentUser user = projectControl.getCurrentUser();

        // This will be the case if the user is unauthenticated.
        if(user.getRealUser().toString().equals("ANONYMOUS")) {
            return 401;
        }

        // Make sure the user is the owner of the project or an admin.
        if(!(projectControl.isVisible() && (user.getCapabilities().canAdministrateServer() || projectControl
            .isOwner()))) {
            return 403;
        }

        return 200;
    } catch(NoSuchProjectException e) {
        return 404;
    }
}
 
开发者ID:palantir,项目名称:gerrit-ci,代码行数:23,代码来源:JobsServlet.java

示例2: migrateData

import com.google.gerrit.reviewdb.client.Project.NameKey; //导入依赖的package包/类
@Override
protected void migrateData(ReviewDb db, UpdateUI ui) throws OrmException {
  ui.message("Listing all changes ...");
  SetMultimap<Project.NameKey, Change.Id> openByProject = getOpenChangesByProject(db, ui);
  ui.message("done");

  ui.message("Updating groups for open changes ...");
  int i = 0;
  for (Map.Entry<Project.NameKey, Collection<Change.Id>> e : openByProject.asMap().entrySet()) {
    try (Repository repo = repoManager.openRepository(e.getKey());
        RevWalk rw = new RevWalk(repo)) {
      updateProjectGroups(db, repo, rw, (Set<Change.Id>) e.getValue(), ui);
    } catch (IOException | NoSuchChangeException err) {
      throw new OrmException(err);
    }
    if (++i % 100 == 0) {
      ui.message("  done " + i + " projects ...");
    }
  }
  ui.message("done");
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:22,代码来源:Schema_108.java

示例3: defaultSubmitTypeForStarFilter

import com.google.gerrit.reviewdb.client.Project.NameKey; //导入依赖的package包/类
@Test
public void defaultSubmitTypeForStarFilter() {
  configureDefaultSubmitType("*", SubmitType.CHERRY_PICK);
  assertThat(repoCfg.getDefaultSubmitType(new NameKey("someProject")))
      .isEqualTo(SubmitType.CHERRY_PICK);

  configureDefaultSubmitType("*", SubmitType.FAST_FORWARD_ONLY);
  assertThat(repoCfg.getDefaultSubmitType(new NameKey("someProject")))
      .isEqualTo(SubmitType.FAST_FORWARD_ONLY);

  configureDefaultSubmitType("*", SubmitType.REBASE_IF_NECESSARY);
  assertThat(repoCfg.getDefaultSubmitType(new NameKey("someProject")))
      .isEqualTo(SubmitType.REBASE_IF_NECESSARY);

  configureDefaultSubmitType("*", SubmitType.REBASE_ALWAYS);
  assertThat(repoCfg.getDefaultSubmitType(new NameKey("someProject")))
      .isEqualTo(SubmitType.REBASE_ALWAYS);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:19,代码来源:RepositoryConfigTest.java

示例4: ownerGroupsForStartWithFilter

import com.google.gerrit.reviewdb.client.Project.NameKey; //导入依赖的package包/类
@Test
public void ownerGroupsForStartWithFilter() {
  ImmutableList<String> ownerGroups1 = ImmutableList.of("group1");
  ImmutableList<String> ownerGroups2 = ImmutableList.of("group2");
  ImmutableList<String> ownerGroups3 = ImmutableList.of("group3");

  configureOwnerGroups("*", ownerGroups1);
  configureOwnerGroups("somePath/*", ownerGroups2);
  configureOwnerGroups("somePath/somePath/*", ownerGroups3);

  assertThat(repoCfg.getOwnerGroups(new NameKey("someProject")))
      .containsExactlyElementsIn(ownerGroups1);

  assertThat(repoCfg.getOwnerGroups(new NameKey("somePath/someProject")))
      .containsExactlyElementsIn(ownerGroups2);

  assertThat(repoCfg.getOwnerGroups(new NameKey("somePath/somePath/someProject")))
      .containsExactlyElementsIn(ownerGroups3);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:20,代码来源:RepositoryConfigTest.java

示例5: basePathForStartWithFilter

import com.google.gerrit.reviewdb.client.Project.NameKey; //导入依赖的package包/类
@Test
public void basePathForStartWithFilter() {
  String basePath1 = "/someAbsolutePath1/someDirectory";
  String basePath2 = "someRelativeDirectory2";
  String basePath3 = "/someAbsolutePath3/someDirectory";
  String basePath4 = "/someAbsolutePath4/someDirectory";

  configureBasePath("pro*", basePath1);
  configureBasePath("project/project/*", basePath2);
  configureBasePath("project/*", basePath3);
  configureBasePath("*", basePath4);

  assertThat(repoCfg.getBasePath(new NameKey("project1")).toString()).isEqualTo(basePath1);
  assertThat(repoCfg.getBasePath(new NameKey("project/project/someProject")).toString())
      .isEqualTo(basePath2);
  assertThat(repoCfg.getBasePath(new NameKey("project/someProject")).toString())
      .isEqualTo(basePath3);
  assertThat(repoCfg.getBasePath(new NameKey("someProject")).toString()).isEqualTo(basePath4);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:20,代码来源:RepositoryConfigTest.java

示例6: onEvent

import com.google.gerrit.reviewdb.client.Project.NameKey; //导入依赖的package包/类
@Override
public void onEvent(Event event) {
  if (RefEvent.class.isAssignableFrom(event.getClass())
      && event.getType().equals(REF_REPLICATED_EVENT)) {
    RefEvent refEvent = (RefEvent) event;
    NameKey projectNameKey = refEvent.getProjectNameKey();
    JsonObject eventJson = (JsonObject) gson.toJsonTree(event);
    String refKey = eventJson.get("ref").getAsString();

    try {
      statusStore.set(projectNameKey, refKey, eventJson);
    } catch (IOException e) {
      log.error(
          "Unable to update replication status for event "
              + eventJson
              + " on project "
              + projectNameKey,
          e);
    }
  }
}
 
开发者ID:GerritCodeReview,项目名称:plugins_github,代码行数:22,代码来源:ReplicationStatusListener.java

示例7: getPullRequests

import com.google.gerrit.reviewdb.client.Project.NameKey; //导入依赖的package包/类
private Map<String, List<GHPullRequest>> getPullRequests(
    GitHubLogin login, Iterable<NameKey> repos) throws IOException {
  int numPullRequests = 0;
  Map<String, List<GHPullRequest>> allPullRequests = Maps.newHashMap();
  try (ReviewDb db = schema.get()) {
    for (NameKey gerritRepoName : repos) {
      try (Repository gitRepo = repoMgr.openRepository(gerritRepoName)) {
        String ghRepoName = gerritRepoName.get().split("/")[1];
        Optional<GHRepository> githubRepo = getGHRepository(login, gerritRepoName);
        if (githubRepo.isPresent()) {
          numPullRequests =
              collectPullRequestsFromGitHubRepository(
                  numPullRequests, db, allPullRequests, gitRepo, ghRepoName, githubRepo);
        }
      }
    }
    return allPullRequests;
  }
}
 
开发者ID:GerritCodeReview,项目名称:plugins_github,代码行数:20,代码来源:PullRequestListController.java

示例8: canAccess

import com.google.gerrit.reviewdb.client.Project.NameKey; //导入依赖的package包/类
@Override
protected boolean canAccess(final RepositoryModel repository, final AccessRestrictionType ifRestriction, final AccessPermission requirePermission) {
	try {
		ProjectControl control = projectControlFactory.controlFor(new NameKey(StringUtils.stripDotGit(repository.name)), userProvider.get());
		if (control == null) {
			return false;
		}
		switch (ifRestriction) {
		case VIEW:
			return control.isVisible();
		case CLONE:
			return control.canRunUploadPack();
		case PUSH:
			return control.canRunReceivePack();
		default:
			return true;
		}
	} catch (NoSuchProjectException | IOException e) {
		return false;
	}
}
 
开发者ID:tomaswolf,项目名称:gerrit-gitblit-plugin,代码行数:22,代码来源:GerritGitBlitUserModel.java

示例9: matches

import com.google.gerrit.reviewdb.client.Project.NameKey; //导入依赖的package包/类
public boolean matches(NameKey name) {
  if (projectPatterns.isEmpty()) {
    return true;
  }
  String projectName = name.get();

  for (String pattern : projectPatterns) {
    if (matchesPattern(projectName, pattern)) {
      return true;
    }
  }
  return false;
}
 
开发者ID:GerritCodeReview,项目名称:plugins_replication,代码行数:14,代码来源:ReplicationFilter.java

示例10: getOpenChangesByProject

import com.google.gerrit.reviewdb.client.Project.NameKey; //导入依赖的package包/类
private SetMultimap<Project.NameKey, Change.Id> getOpenChangesByProject(ReviewDb db, UpdateUI ui)
    throws OrmException {
  SortedSet<NameKey> projects = repoManager.list();
  SortedSet<NameKey> nonExistentProjects = Sets.newTreeSet();
  SetMultimap<Project.NameKey, Change.Id> openByProject =
      MultimapBuilder.hashKeys().hashSetValues().build();
  for (Change c : db.changes().all()) {
    Status status = c.getStatus();
    if (status != null && status.isClosed()) {
      continue;
    }

    NameKey projectKey = c.getProject();
    if (!projects.contains(projectKey)) {
      nonExistentProjects.add(projectKey);
    } else {
      // The old "submitted" state is not supported anymore
      // (thus status is null) but it was an opened state and needs
      // to be migrated as such
      openByProject.put(projectKey, c.getId());
    }
  }

  if (!nonExistentProjects.isEmpty()) {
    ui.message("Detected open changes referring to the following non-existent projects:");
    ui.message(Joiner.on(", ").join(nonExistentProjects));
    ui.message(
        "It is highly recommended to remove\n"
            + "the obsolete open changes, comments and patch-sets from your DB.\n");
  }
  return openByProject;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:33,代码来源:Schema_108.java

示例11: defaultSubmitTypeForSpecificFilter

import com.google.gerrit.reviewdb.client.Project.NameKey; //导入依赖的package包/类
@Test
public void defaultSubmitTypeForSpecificFilter() {
  configureDefaultSubmitType("someProject", SubmitType.CHERRY_PICK);
  assertThat(repoCfg.getDefaultSubmitType(new NameKey("someOtherProject")))
      .isEqualTo(SubmitType.MERGE_IF_NECESSARY);
  assertThat(repoCfg.getDefaultSubmitType(new NameKey("someProject")))
      .isEqualTo(SubmitType.CHERRY_PICK);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:9,代码来源:RepositoryConfigTest.java

示例12: defaultSubmitTypeForStartWithFilter

import com.google.gerrit.reviewdb.client.Project.NameKey; //导入依赖的package包/类
@Test
public void defaultSubmitTypeForStartWithFilter() {
  configureDefaultSubmitType("somePath/somePath/*", SubmitType.REBASE_IF_NECESSARY);
  configureDefaultSubmitType("somePath/*", SubmitType.CHERRY_PICK);
  configureDefaultSubmitType("*", SubmitType.MERGE_ALWAYS);

  assertThat(repoCfg.getDefaultSubmitType(new NameKey("someProject")))
      .isEqualTo(SubmitType.MERGE_ALWAYS);

  assertThat(repoCfg.getDefaultSubmitType(new NameKey("somePath/someProject")))
      .isEqualTo(SubmitType.CHERRY_PICK);

  assertThat(repoCfg.getDefaultSubmitType(new NameKey("somePath/somePath/someProject")))
      .isEqualTo(SubmitType.REBASE_IF_NECESSARY);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:16,代码来源:RepositoryConfigTest.java

示例13: ownerGroupsForStarFilter

import com.google.gerrit.reviewdb.client.Project.NameKey; //导入依赖的package包/类
@Test
public void ownerGroupsForStarFilter() {
  ImmutableList<String> ownerGroups = ImmutableList.of("group1", "group2");
  configureOwnerGroups("*", ownerGroups);
  assertThat(repoCfg.getOwnerGroups(new NameKey("someProject")))
      .containsExactlyElementsIn(ownerGroups);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:RepositoryConfigTest.java

示例14: ownerGroupsForSpecificFilter

import com.google.gerrit.reviewdb.client.Project.NameKey; //导入依赖的package包/类
@Test
public void ownerGroupsForSpecificFilter() {
  ImmutableList<String> ownerGroups = ImmutableList.of("group1", "group2");
  configureOwnerGroups("someProject", ownerGroups);
  assertThat(repoCfg.getOwnerGroups(new NameKey("someOtherProject"))).isEmpty();
  assertThat(repoCfg.getOwnerGroups(new NameKey("someProject")))
      .containsExactlyElementsIn(ownerGroups);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:9,代码来源:RepositoryConfigTest.java

示例15: basePathForSpecificFilter

import com.google.gerrit.reviewdb.client.Project.NameKey; //导入依赖的package包/类
@Test
public void basePathForSpecificFilter() {
  String basePath = "/someAbsolutePath/someDirectory";
  configureBasePath("someProject", basePath);
  assertThat(repoCfg.getBasePath(new NameKey("someOtherProject"))).isNull();
  assertThat(repoCfg.getBasePath(new NameKey("someProject")).toString()).isEqualTo(basePath);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:RepositoryConfigTest.java


注:本文中的com.google.gerrit.reviewdb.client.Project.NameKey类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。