本文整理汇总了Java中com.google.gerrit.server.project.NoSuchProjectException类的典型用法代码示例。如果您正苦于以下问题:Java NoSuchProjectException类的具体用法?Java NoSuchProjectException怎么用?Java NoSuchProjectException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NoSuchProjectException类属于com.google.gerrit.server.project包,在下文中一共展示了NoSuchProjectException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例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();
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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();
}
示例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();
}
}
示例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;
}
}
示例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;
}
示例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);
}