• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java NoSuchProjectException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getResponseCode

import com.google.gerrit.server.project.NoSuchProjectException; //导入依赖的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: updateProjectConfig

import com.google.gerrit.server.project.NoSuchProjectException; //导入依赖的package包/类
@Override
protected ProjectAccess updateProjectConfig(
    ProjectConfig config, MetaDataUpdate md, boolean parentProjectUpdate)
    throws IOException, NoSuchProjectException, ConfigInvalidException,
        PermissionBackendException {
  RevCommit commit = config.commit(md);

  gitRefUpdated.fire(
      config.getProject().getNameKey(),
      RefNames.REFS_CONFIG,
      base,
      commit.getId(),
      user.asIdentifiedUser().getAccount());

  projectCache.evict(config.getProject());
  createGroupPermissionSyncer.syncIfNeeded();
  return projectAccessFactory.create(projectName).call();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:19,代码来源:ChangeProjectAccess.java


示例3: updateSuperProjects

import com.google.gerrit.server.project.NoSuchProjectException; //导入依赖的package包/类
public void updateSuperProjects() throws SubmoduleException {
  ImmutableSet<Project.NameKey> projects = getProjectsInOrder();
  if (projects == null) {
    return;
  }

  LinkedHashSet<Project.NameKey> superProjects = new LinkedHashSet<>();
  try {
    for (Project.NameKey project : projects) {
      // only need superprojects
      if (branchesByProject.containsKey(project)) {
        superProjects.add(project);
        // get a new BatchUpdate for the super project
        OpenRepo or = orm.getRepo(project);
        for (Branch.NameKey branch : branchesByProject.get(project)) {
          addOp(or.getUpdate(), branch);
        }
      }
    }
    batchUpdateFactory.execute(
        orm.batchUpdates(superProjects), BatchUpdateListener.NONE, orm.getSubmissionId(), false);
  } catch (RestApiException | UpdateException | IOException | NoSuchProjectException e) {
    throw new SubmoduleException("Cannot update gitlinks", e);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:26,代码来源:SubmoduleOp.java


示例4: getRepo

import com.google.gerrit.server.project.NoSuchProjectException; //导入依赖的package包/类
public OpenRepo getRepo(Project.NameKey project) throws NoSuchProjectException, IOException {
  if (openRepos.containsKey(project)) {
    return openRepos.get(project);
  }

  ProjectState projectState = projectCache.get(project);
  if (projectState == null) {
    throw new NoSuchProjectException(project);
  }
  try {
    OpenRepo or = new OpenRepo(repoManager.openRepository(project), projectState);
    openRepos.put(project, or);
    return or;
  } catch (RepositoryNotFoundException e) {
    throw new NoSuchProjectException(project, e);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:18,代码来源:MergeOpRepoManager.java


示例5: wrapAndThrowException

import com.google.gerrit.server.project.NoSuchProjectException; //导入依赖的package包/类
static void wrapAndThrowException(Exception e) throws UpdateException, RestApiException {
  Throwables.throwIfUnchecked(e);

  // Propagate REST API exceptions thrown by operations; they commonly throw exceptions like
  // ResourceConflictException to indicate an atomic update failure.
  Throwables.throwIfInstanceOf(e, UpdateException.class);
  Throwables.throwIfInstanceOf(e, RestApiException.class);

  // Convert other common non-REST exception types with user-visible messages to corresponding
  // REST exception types
  if (e instanceof InvalidChangeOperationException) {
    throw new ResourceConflictException(e.getMessage(), e);
  } else if (e instanceof NoSuchChangeException
      || e instanceof NoSuchRefException
      || e instanceof NoSuchProjectException) {
    throw new ResourceNotFoundException(e.getMessage(), e);
  }

  // Otherwise, wrap in a generic UpdateException, which does not include a user-visible message.
  throw new UpdateException(e);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:22,代码来源:BatchUpdate.java


示例6: getProjectOwners

import com.google.gerrit.server.project.NoSuchProjectException; //导入依赖的package包/类
private Set<Account> getProjectOwners(final Project.NameKey project, Set<AccountGroup.UUID> seen)
    throws NoSuchProjectException, NoSuchGroupException, OrmException, IOException {
  seen.add(SystemGroupBackend.PROJECT_OWNERS);
  if (project == null) {
    return Collections.emptySet();
  }

  ProjectState projectState = projectCache.checkedGet(project);
  if (projectState == null) {
    throw new NoSuchProjectException(project);
  }

  final HashSet<Account> projectOwners = new HashSet<>();
  for (AccountGroup.UUID ownerGroup : projectState.getAllOwners()) {
    if (!seen.contains(ownerGroup)) {
      projectOwners.addAll(listAccounts(ownerGroup, project, seen));
    }
  }
  return projectOwners;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:21,代码来源:GroupMembers.java


示例7: getGroupMembers

import com.google.gerrit.server.project.NoSuchProjectException; //导入依赖的package包/类
private Set<Account> getGroupMembers(
    InternalGroup group, Project.NameKey project, Set<AccountGroup.UUID> seen)
    throws NoSuchGroupException, OrmException, NoSuchProjectException, IOException {
  seen.add(group.getGroupUUID());
  GroupControl groupControl = groupControlFactory.controlFor(new InternalGroupDescription(group));

  Set<Account> directMembers =
      group
          .getMembers()
          .stream()
          .filter(groupControl::canSeeMember)
          .map(accountCache::get)
          .map(AccountState::getAccount)
          .collect(toImmutableSet());

  Set<Account> indirectMembers = new HashSet<>();
  if (groupControl.canSeeGroup()) {
    for (AccountGroup.UUID subgroupUuid : group.getSubgroups()) {
      if (!seen.contains(subgroupUuid)) {
        indirectMembers.addAll(listAccounts(subgroupUuid, project, seen));
      }
    }
  }

  return Sets.union(directMembers, indirectMembers);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:27,代码来源:GroupMembers.java


示例8: format

import com.google.gerrit.server.project.NoSuchProjectException; //导入依赖的package包/类
private ChangeInfo format(
    ChangeData cd, Optional<PatchSet.Id> limitToPsId, boolean fillAccountLoader)
    throws OrmException {
  try {
    if (fillAccountLoader) {
      accountLoader = accountLoaderFactory.create(has(DETAILED_ACCOUNTS));
      ChangeInfo res = toChangeInfo(cd, limitToPsId);
      accountLoader.fill();
      return res;
    }
    return toChangeInfo(cd, limitToPsId);
  } catch (PatchListNotAvailableException
      | GpgException
      | OrmException
      | IOException
      | PermissionBackendException
      | NoSuchProjectException
      | RuntimeException e) {
    if (!has(CHECK)) {
      Throwables.throwIfInstanceOf(e, OrmException.class);
      throw new OrmException(e);
    }
    return checkOnly(cd);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:26,代码来源:ChangeJson.java


示例9: cherryPick

import com.google.gerrit.server.project.NoSuchProjectException; //导入依赖的package包/类
public Change.Id cherryPick(
    BatchUpdate.Factory batchUpdateFactory,
    Change change,
    PatchSet patch,
    CherryPickInput input,
    Branch.NameKey dest)
    throws OrmException, IOException, InvalidChangeOperationException, IntegrationException,
        UpdateException, RestApiException, ConfigInvalidException, NoSuchProjectException {
  return cherryPick(
      batchUpdateFactory,
      change,
      patch.getId(),
      change.getProject(),
      ObjectId.fromString(patch.getRevision().get()),
      input,
      dest);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:18,代码来源:CherryPickChange.java


示例10: applyImpl

import com.google.gerrit.server.project.NoSuchProjectException; //导入依赖的package包/类
@Override
public ChangeInfo applyImpl(
    BatchUpdate.Factory updateFactory, ChangeResource rsrc, RevertInput input)
    throws IOException, OrmException, RestApiException, UpdateException, NoSuchChangeException,
        PermissionBackendException, NoSuchProjectException {
  Change change = rsrc.getChange();
  if (change.getStatus() != Change.Status.MERGED) {
    throw new ResourceConflictException("change is " + ChangeUtil.status(change));
  }

  contributorAgreements.check(rsrc.getProject(), rsrc.getUser());
  permissionBackend.user(rsrc.getUser()).ref(change.getDest()).check(CREATE_CHANGE);

  Change.Id revertId =
      revert(updateFactory, rsrc.getNotes(), rsrc.getUser(), Strings.emptyToNull(input.message));
  return json.noOptions().format(rsrc.getProject(), revertId);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:18,代码来源:Revert.java


示例11: applyImpl

import com.google.gerrit.server.project.NoSuchProjectException; //导入依赖的package包/类
@Override
protected Response<?> applyImpl(
    BatchUpdate.Factory updateFactory, ChangeResource rsrc, PublishChangeEditInput in)
    throws IOException, OrmException, RestApiException, UpdateException, ConfigInvalidException,
        NoSuchProjectException {
  contributorAgreementsChecker.check(rsrc.getProject(), rsrc.getUser());
  Optional<ChangeEdit> edit = editUtil.byChange(rsrc.getNotes(), rsrc.getUser());
  if (!edit.isPresent()) {
    throw new ResourceConflictException(
        String.format("no edit exists for change %s", rsrc.getChange().getChangeId()));
  }
  if (in == null) {
    in = new PublishChangeEditInput();
  }
  editUtil.publish(
      updateFactory,
      rsrc.getNotes(),
      rsrc.getUser(),
      edit.get(),
      in.notify,
      notifyUtil.resolveAccounts(in.notifyDetails));
  return Response.none();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:24,代码来源:PublishChangeEdit.java


示例12: findAccountsInGroup

import com.google.gerrit.server.project.NoSuchProjectException; //导入依赖的package包/类
private Set<Id> findAccountsInGroup(String groupNameOrUUID) {
  AccountGroup group =
      Optional.ofNullable(groupCache.get(new AccountGroup.NameKey(groupNameOrUUID)))
          .orElse(groupCache.get(new AccountGroup.UUID(groupNameOrUUID)));

  if (group == null) {
    log.warn("Group {} was not found", groupNameOrUUID);
  }

  try (ManualRequestContext ctx = oneOffRequestContext.openAs(adminUser.getAccountId())) {

    return groupMembers
        .create(adminUser)
        .listAccounts(group.getGroupUUID(), null)
        .stream()
        .map(Account::getId)
        .collect(Collectors.toSet());
  } catch (NoSuchGroupException | NoSuchProjectException | OrmException | IOException e) {
    log.error("Unable to list accounts in group " + group, e);
    return Collections.emptySet();
  }
}
 
开发者ID:GerritCodeReview,项目名称:plugins_owners,代码行数:23,代码来源:AccountsImpl.java


示例13: canAccess

import com.google.gerrit.server.project.NoSuchProjectException; //导入依赖的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


示例14: checkProjectState

import com.google.gerrit.server.project.NoSuchProjectException; //导入依赖的package包/类
private ProjectState checkProjectState()
    throws NoSuchProjectException, IOException, PermissionBackendException {
  ProjectState state = projectCache.checkedGet(projectName);
  try {
    permissionBackend.user(user).project(projectName).check(ProjectPermission.ACCESS);
  } catch (AuthException e) {
    throw new NoSuchProjectException(projectName);
  }
  return state;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:11,代码来源:ProjectAccessFactory.java


示例15: parseCreate

import com.google.gerrit.server.project.NoSuchProjectException; //导入依赖的package包/类
private void parseCreate(ReceiveCommand cmd)
    throws PermissionBackendException, NoSuchProjectException, IOException {
  RevObject obj;
  try {
    obj = rp.getRevWalk().parseAny(cmd.getNewId());
  } catch (IOException err) {
    logError(
        "Invalid object " + cmd.getNewId().name() + " for " + cmd.getRefName() + " creation",
        err);
    reject(cmd, "invalid object");
    return;
  }
  logDebug("Creating {}", cmd);

  if (isHead(cmd) && !isCommit(cmd)) {
    return;
  }

  Branch.NameKey branch = new Branch.NameKey(project.getName(), cmd.getRefName());
  try {
    // Must pass explicit user instead of injecting a provider into CreateRefControl, since
    // Provider<CurrentUser> within ReceiveCommits will always return anonymous.
    createRefControl.checkCreateRef(Providers.of(user), rp.getRepository(), branch, obj);
  } catch (AuthException denied) {
    reject(cmd, "prohibited by Gerrit: " + denied.getMessage());
    return;
  }

  if (!validRefOperation(cmd)) {
    // validRefOperation sets messages, so no need to provide more feedback.
    return;
  }

  validateNewCommits(new Branch.NameKey(project.getNameKey(), cmd.getRefName()), cmd);
  actualCommands.add(cmd);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:37,代码来源:ReceiveCommits.java


示例16: superProjectSubscriptionsForSubmoduleBranch

import com.google.gerrit.server.project.NoSuchProjectException; //导入依赖的package包/类
public Collection<SubmoduleSubscription> superProjectSubscriptionsForSubmoduleBranch(
    Branch.NameKey srcBranch) throws IOException {
  logDebug("Calculating possible superprojects for " + srcBranch);
  Collection<SubmoduleSubscription> ret = new ArrayList<>();
  Project.NameKey srcProject = srcBranch.getParentKey();
  ProjectConfig cfg = projectCache.get(srcProject).getConfig();
  for (SubscribeSection s : projectStateFactory.create(cfg).getSubscribeSections(srcBranch)) {
    logDebug("Checking subscribe section " + s);
    Collection<Branch.NameKey> branches = getDestinationBranches(srcBranch, s);
    for (Branch.NameKey targetBranch : branches) {
      Project.NameKey targetProject = targetBranch.getParentKey();
      try {
        OpenRepo or = orm.getRepo(targetProject);
        ObjectId id = or.repo.resolve(targetBranch.get());
        if (id == null) {
          logDebug("The branch " + targetBranch + " doesn't exist.");
          continue;
        }
      } catch (NoSuchProjectException e) {
        logDebug("The project " + targetProject + " doesn't exist");
        continue;
      }

      GitModules m = branchGitModules.get(targetBranch);
      if (m == null) {
        m = gitmodulesFactory.create(targetBranch, orm);
        branchGitModules.put(targetBranch, m);
      }
      ret.addAll(m.subscribedTo(srcBranch));
    }
  }
  logDebug("Calculated superprojects for " + srcBranch + " are " + ret);
  return ret;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:35,代码来源:SubmoduleOp.java


示例17: batchUpdates

import com.google.gerrit.server.project.NoSuchProjectException; //导入依赖的package包/类
public List<BatchUpdate> batchUpdates(Collection<Project.NameKey> projects)
    throws NoSuchProjectException, IOException {
  List<BatchUpdate> updates = new ArrayList<>(projects.size());
  for (Project.NameKey project : projects) {
    updates.add(getRepo(project).getUpdate().setRefLogMessage("merged"));
  }
  return updates;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:9,代码来源:MergeOpRepoManager.java


示例18: getRepo

import com.google.gerrit.server.project.NoSuchProjectException; //导入依赖的package包/类
private OpenRepo getRepo(MergeOpRepoManager orm, Project.NameKey project) throws IOException {
  try {
    OpenRepo or = orm.getRepo(project);
    checkState(or.rw.hasRevSort(RevSort.TOPO));
    return or;
  } catch (NoSuchProjectException e) {
    throw new IOException(e);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:10,代码来源:LocalMergeSuperSetComputation.java


示例19: run

import com.google.gerrit.server.project.NoSuchProjectException; //导入依赖的package包/类
public boolean run(
    SubmitType submitType,
    Repository repo,
    CodeReviewRevWalk rw,
    Branch.NameKey destBranch,
    ObjectId tip,
    ObjectId toMerge,
    Set<RevCommit> alreadyAccepted)
    throws IntegrationException, NoSuchProjectException, IOException {
  CodeReviewCommit tipCommit = rw.parseCommit(tip);
  CodeReviewCommit toMergeCommit = rw.parseCommit(toMerge);
  RevFlag canMerge = rw.newFlag("CAN_MERGE");
  toMergeCommit.add(canMerge);
  Arguments args =
      new Arguments(
          repo,
          rw,
          mergeUtilFactory.create(getProject(destBranch)),
          new MergeSorter(rw, alreadyAccepted, canMerge, ImmutableSet.of(toMergeCommit)));

  switch (submitType) {
    case CHERRY_PICK:
      return CherryPick.dryRun(args, tipCommit, toMergeCommit);
    case FAST_FORWARD_ONLY:
      return FastForwardOnly.dryRun(args, tipCommit, toMergeCommit);
    case MERGE_ALWAYS:
      return MergeAlways.dryRun(args, tipCommit, toMergeCommit);
    case MERGE_IF_NECESSARY:
      return MergeIfNecessary.dryRun(args, tipCommit, toMergeCommit);
    case REBASE_IF_NECESSARY:
      return RebaseIfNecessary.dryRun(args, repo, tipCommit, toMergeCommit);
    case REBASE_ALWAYS:
      return RebaseAlways.dryRun(args, repo, tipCommit, toMergeCommit);
    default:
      String errorMsg = "No submit strategy for: " + submitType;
      log.error(errorMsg);
      throw new IntegrationException(errorMsg);
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:40,代码来源:SubmitDryRun.java


示例20: getProject

import com.google.gerrit.server.project.NoSuchProjectException; //导入依赖的package包/类
private ProjectState getProject(Branch.NameKey branch) throws NoSuchProjectException {
  ProjectState p = projectCache.get(branch.getParentKey());
  if (p == null) {
    throw new NoSuchProjectException(branch.getParentKey());
  }
  return p;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:8,代码来源:SubmitDryRun.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RenewDelegationTokenOp类代码示例发布时间:2022-05-22
下一篇:
Java DCIdentifier类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap