Search in sources :

Example 31 with RestApiException

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

the class AccountApiImpl method get.

@Override
public com.google.gerrit.extensions.common.AccountInfo get() throws RestApiException {
    AccountLoader accountLoader = accountLoaderFactory.create(true);
    try {
        AccountInfo ai = accountLoader.get(account.getUser().getAccountId());
        accountLoader.fill();
        return ai;
    } catch (Exception e) {
        throw asRestApiException("Cannot parse change", e);
    }
}
Also used : AccountLoader(com.google.gerrit.server.account.AccountLoader) AccountInfo(com.google.gerrit.extensions.common.AccountInfo) ApiUtil.asRestApiException(com.google.gerrit.server.api.ApiUtil.asRestApiException) RestApiException(com.google.gerrit.extensions.restapi.RestApiException)

Example 32 with RestApiException

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

the class AccountApiImpl method unstarChange.

@Override
public void unstarChange(String changeId) throws RestApiException {
    try {
        ChangeResource rsrc = changes.parse(TopLevelResource.INSTANCE, IdString.fromUrl(changeId));
        AccountResource.StarredChange starredChange = new AccountResource.StarredChange(account.getUser(), rsrc);
        starredChangesDelete.apply(starredChange, new StarredChanges.EmptyInput());
    } catch (Exception e) {
        throw asRestApiException("Cannot unstar change", e);
    }
}
Also used : AccountResource(com.google.gerrit.server.account.AccountResource) ChangeResource(com.google.gerrit.server.change.ChangeResource) StarredChanges(com.google.gerrit.server.account.StarredChanges) ApiUtil.asRestApiException(com.google.gerrit.server.api.ApiUtil.asRestApiException) RestApiException(com.google.gerrit.extensions.restapi.RestApiException)

Example 33 with RestApiException

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

the class AccountApiImpl method starChange.

@Override
public void starChange(String changeId) throws RestApiException {
    try {
        ChangeResource rsrc = changes.parse(TopLevelResource.INSTANCE, IdString.fromUrl(changeId));
        starredChangesCreate.setChange(rsrc);
        starredChangesCreate.apply(account, new StarredChanges.EmptyInput());
    } catch (Exception e) {
        throw asRestApiException("Cannot star change", e);
    }
}
Also used : ChangeResource(com.google.gerrit.server.change.ChangeResource) StarredChanges(com.google.gerrit.server.account.StarredChanges) ApiUtil.asRestApiException(com.google.gerrit.server.api.ApiUtil.asRestApiException) RestApiException(com.google.gerrit.extensions.restapi.RestApiException)

Example 34 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);
    } catch (Exception e) {
        throw asRestApiException("Cannot retrieve suggested accounts", e);
    }
}
Also used : QueryAccounts(com.google.gerrit.server.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)

Example 35 with RestApiException

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

the class RevisionApiImpl method getMergeList.

@Override
public MergeListRequest getMergeList() throws RestApiException {
    return new MergeListRequest() {

        @Override
        public List<CommitInfo> get() throws RestApiException {
            try {
                GetMergeList gml = getMergeList.get();
                gml.setUninterestingParent(getUninterestingParent());
                gml.setAddLinks(getAddLinks());
                return gml.apply(revision).value();
            } catch (Exception e) {
                throw asRestApiException("Cannot get merge list", e);
            }
        }
    };
}
Also used : CommitInfo(com.google.gerrit.extensions.common.CommitInfo) ApiUtil.asRestApiException(com.google.gerrit.server.api.ApiUtil.asRestApiException) RestApiException(com.google.gerrit.extensions.restapi.RestApiException) GetMergeList(com.google.gerrit.server.change.GetMergeList)

Aggregations

RestApiException (com.google.gerrit.extensions.restapi.RestApiException)50 ApiUtil.asRestApiException (com.google.gerrit.server.api.ApiUtil.asRestApiException)16 OrmException (com.google.gwtorm.server.OrmException)14 IOException (java.io.IOException)14 BatchUpdate (com.google.gerrit.server.update.BatchUpdate)12 UpdateException (com.google.gerrit.server.update.UpdateException)12 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)10 Change (com.google.gerrit.reviewdb.client.Change)8 AuthException (com.google.gerrit.extensions.restapi.AuthException)7 ResourceConflictException (com.google.gerrit.extensions.restapi.ResourceConflictException)7 ResourceNotFoundException (com.google.gerrit.extensions.restapi.ResourceNotFoundException)7 BatchUpdateOp (com.google.gerrit.server.update.BatchUpdateOp)6 PatchSet (com.google.gerrit.reviewdb.client.PatchSet)5 ArrayList (java.util.ArrayList)5 RevWalk (org.eclipse.jgit.revwalk.RevWalk)5 Test (org.junit.Test)5 AbstractDaemonTest (com.google.gerrit.acceptance.AbstractDaemonTest)4 PermissionBackendException (com.google.gerrit.server.permissions.PermissionBackendException)4 ChangeContext (com.google.gerrit.server.update.ChangeContext)4 Provider (com.google.inject.Provider)4