Search in sources :

Example 56 with RestApiException

use of com.google.gerrit.extensions.restapi.RestApiException in project gerrit by GerritCodeReview.

the class DashboardApiImpl method setDefault.

@Override
public void setDefault() throws RestApiException {
    SetDashboardInput input = new SetDashboardInput();
    input.id = id;
    try {
        set.apply(DashboardResource.projectDefault(project.getProjectState(), project.getUser()), input);
    } catch (Exception e) {
        String msg = String.format("Cannot %s default dashboard", id != null ? "set" : "remove");
        throw asRestApiException(msg, e);
    }
}
Also used : SetDashboardInput(com.google.gerrit.extensions.api.projects.SetDashboardInput) IdString(com.google.gerrit.extensions.restapi.IdString) ApiUtil.asRestApiException(com.google.gerrit.server.api.ApiUtil.asRestApiException) PermissionBackendException(com.google.gerrit.server.permissions.PermissionBackendException) ConfigInvalidException(org.eclipse.jgit.errors.ConfigInvalidException) IOException(java.io.IOException) RestApiException(com.google.gerrit.extensions.restapi.RestApiException)

Example 57 with RestApiException

use of com.google.gerrit.extensions.restapi.RestApiException in project gerrit by GerritCodeReview.

the class ProjectApiImpl method head.

@Override
public void head(String head) throws RestApiException {
    HeadInput input = new HeadInput();
    input.ref = head;
    try {
        setHead.apply(checkExists(), input);
    } catch (Exception e) {
        throw asRestApiException("Cannot set HEAD", e);
    }
}
Also used : HeadInput(com.google.gerrit.extensions.api.projects.HeadInput) ResourceNotFoundException(com.google.gerrit.extensions.restapi.ResourceNotFoundException) ApiUtil.asRestApiException(com.google.gerrit.server.api.ApiUtil.asRestApiException) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) NotImplementedException(com.google.gerrit.extensions.restapi.NotImplementedException) RestApiException(com.google.gerrit.extensions.restapi.RestApiException) ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException)

Example 58 with RestApiException

use of com.google.gerrit.extensions.restapi.RestApiException in project gerrit by GerritCodeReview.

the class ProjectApiImpl method index.

@Override
public void index(boolean indexChildren) throws RestApiException {
    try {
        IndexProjectInput input = new IndexProjectInput();
        input.indexChildren = indexChildren;
        index.apply(checkExists(), input);
    } catch (Exception e) {
        throw asRestApiException("Cannot index project", e);
    }
}
Also used : IndexProjectInput(com.google.gerrit.extensions.api.projects.IndexProjectInput) ResourceNotFoundException(com.google.gerrit.extensions.restapi.ResourceNotFoundException) ApiUtil.asRestApiException(com.google.gerrit.server.api.ApiUtil.asRestApiException) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) NotImplementedException(com.google.gerrit.extensions.restapi.NotImplementedException) RestApiException(com.google.gerrit.extensions.restapi.RestApiException) ResourceConflictException(com.google.gerrit.extensions.restapi.ResourceConflictException)

Example 59 with RestApiException

use of com.google.gerrit.extensions.restapi.RestApiException in project gerrit by GerritCodeReview.

the class LabelApiImpl method create.

@Override
public LabelApi create(LabelDefinitionInput input) throws RestApiException {
    try {
        createLabel.apply(project, IdString.fromDecoded(label), input);
        // recreate project resource because project state was updated by creating the new label and
        // needs to be reloaded
        project = new ProjectResource(projectCache.get(project.getNameKey()).orElseThrow(illegalState(project.getNameKey())), project.getUser());
        return this;
    } catch (Exception e) {
        throw asRestApiException("Cannot create branch", e);
    }
}
Also used : ProjectResource(com.google.gerrit.server.project.ProjectResource) ApiUtil.asRestApiException(com.google.gerrit.server.api.ApiUtil.asRestApiException) PermissionBackendException(com.google.gerrit.server.permissions.PermissionBackendException) RestApiException(com.google.gerrit.extensions.restapi.RestApiException)

Example 60 with RestApiException

use of com.google.gerrit.extensions.restapi.RestApiException in project gerrit by GerritCodeReview.

the class AccountsImpl method suggestAccounts.

private List<AccountInfo> suggestAccounts(SuggestAccountsRequest r) throws RestApiException {
    try {
        QueryAccounts myQueryAccounts = queryAccountsProvider.get();
        myQueryAccounts.setSuggest(true);
        myQueryAccounts.setQuery(r.getQuery());
        myQueryAccounts.setLimit(r.getLimit());
        return myQueryAccounts.apply(TopLevelResource.INSTANCE).value();
    } catch (Exception e) {
        throw asRestApiException("Cannot retrieve suggested accounts", e);
    }
}
Also used : QueryAccounts(com.google.gerrit.server.restapi.account.QueryAccounts) ApiUtil.asRestApiException(com.google.gerrit.server.api.ApiUtil.asRestApiException) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) AuthException(com.google.gerrit.extensions.restapi.AuthException) RestApiException(com.google.gerrit.extensions.restapi.RestApiException)

Aggregations

RestApiException (com.google.gerrit.extensions.restapi.RestApiException)93 ApiUtil.asRestApiException (com.google.gerrit.server.api.ApiUtil.asRestApiException)38 IOException (java.io.IOException)31 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)24 UpdateException (com.google.gerrit.server.update.UpdateException)23 BatchUpdate (com.google.gerrit.server.update.BatchUpdate)22 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)20 PermissionBackendException (com.google.gerrit.server.permissions.PermissionBackendException)19 AuthException (com.google.gerrit.extensions.restapi.AuthException)18 StorageException (com.google.gerrit.exceptions.StorageException)17 List (java.util.List)17 BatchUpdateOp (com.google.gerrit.server.update.BatchUpdateOp)16 Inject (com.google.inject.Inject)15 ArrayList (java.util.ArrayList)15 ResourceNotFoundException (com.google.gerrit.extensions.restapi.ResourceNotFoundException)14 ChangeNotes (com.google.gerrit.server.notedb.ChangeNotes)14 ChangeContext (com.google.gerrit.server.update.ChangeContext)14 ConfigInvalidException (org.eclipse.jgit.errors.ConfigInvalidException)14 Provider (com.google.inject.Provider)12 Change (com.google.gerrit.entities.Change)11