use of com.google.gerrit.extensions.restapi.RestApiException in project gerrit by GerritCodeReview.
the class ProjectApiImpl method children.
@Override
public List<ProjectInfo> children(boolean recursive) throws RestApiException {
ListChildProjects list = children.list();
list.setRecursive(recursive);
try {
return list.apply(checkExists());
} catch (Exception e) {
throw asRestApiException("Cannot list children", e);
}
}
use of com.google.gerrit.extensions.restapi.RestApiException in project gerrit by GerritCodeReview.
the class SetAccountCommand method setAccount.
private void setAccount() throws OrmException, IOException, UnloggedFailure, ConfigInvalidException, PermissionBackendException {
user = genericUserFactory.create(id);
rsrc = new AccountResource(user);
try {
for (String email : addEmails) {
addEmail(email);
}
for (String email : deleteEmails) {
deleteEmail(email);
}
if (preferredEmail != null) {
putPreferred(preferredEmail);
}
if (fullName != null) {
PutName.Input in = new PutName.Input();
in.name = fullName;
putName.apply(rsrc, in);
}
if (httpPassword != null || clearHttpPassword) {
PutHttpPassword.Input in = new PutHttpPassword.Input();
in.httpPassword = httpPassword;
putHttpPassword.apply(rsrc, in);
}
if (active) {
putActive.apply(rsrc, null);
} else if (inactive) {
try {
deleteActive.apply(rsrc, null);
} catch (ResourceNotFoundException e) {
// user is already inactive
}
}
addSshKeys = readSshKey(addSshKeys);
if (!addSshKeys.isEmpty()) {
addSshKeys(addSshKeys);
}
deleteSshKeys = readSshKey(deleteSshKeys);
if (!deleteSshKeys.isEmpty()) {
deleteSshKeys(deleteSshKeys);
}
} catch (RestApiException e) {
throw die(e.getMessage());
}
}
use of com.google.gerrit.extensions.restapi.RestApiException in project gerrit by GerritCodeReview.
the class CreateAccountCommand method run.
@Override
protected void run() throws OrmException, IOException, ConfigInvalidException, UnloggedFailure {
AccountInput input = new AccountInput();
input.username = username;
input.email = email;
input.name = fullName;
input.sshKey = readSshKey();
input.httpPassword = httpPassword;
input.groups = Lists.transform(groups, AccountGroup.Id::toString);
try {
createAccountFactory.create(username).apply(TopLevelResource.INSTANCE, input);
} catch (RestApiException e) {
throw die(e.getMessage());
}
}
use of com.google.gerrit.extensions.restapi.RestApiException in project gerrit by GerritCodeReview.
the class CreateProjectCommand method run.
@Override
protected void run() throws Failure {
try {
if (!suggestParent) {
if (projectName == null) {
throw die("Project name is required.");
}
ProjectInput input = new ProjectInput();
input.name = projectName;
if (ownerIds != null) {
input.owners = Lists.transform(ownerIds, AccountGroup.UUID::get);
}
if (newParent != null) {
input.parent = newParent.getProject().getName();
}
input.permissionsOnly = permissionsOnly;
input.description = projectDescription;
input.submitType = submitType;
input.useContributorAgreements = contributorAgreements;
input.useSignedOffBy = signedOffBy;
input.useContentMerge = contentMerge;
input.requireChangeId = requireChangeID;
input.createNewChangeForAllNotInTarget = createNewChangeForAllNotInTarget;
input.branches = branch;
input.createEmptyCommit = createEmptyCommit;
input.maxObjectSizeLimit = maxObjectSizeLimit;
if (pluginConfigValues != null) {
input.pluginConfigValues = parsePluginConfigValues(pluginConfigValues);
}
gApi.projects().create(input);
} else {
for (Project.NameKey parent : suggestParentCandidates.getNameKeys()) {
stdout.print(parent.get() + '\n');
}
}
} catch (RestApiException err) {
throw die(err);
} catch (PermissionBackendException err) {
throw new Failure(1, "permissions unavailable", err);
}
}
use of com.google.gerrit.extensions.restapi.RestApiException in project gerrit by GerritCodeReview.
the class RenameGroupCommand method run.
@Override
protected void run() throws Failure {
try {
GroupResource rsrc = groups.parse(TopLevelResource.INSTANCE, IdString.fromDecoded(groupName));
PutName.Input input = new PutName.Input();
input.name = newGroupName;
putName.apply(rsrc, input);
} catch (RestApiException | OrmException | IOException | NoSuchGroupException e) {
throw die(e);
}
}
Aggregations