Search in sources :

Example 61 with RestApiException

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

the class ChangeApiImpl method get.

@Override
public ChangeInfo get(EnumSet<ListChangesOption> options, ImmutableListMultimap<String, String> pluginOptions) throws RestApiException {
    try (DynamicOptions dynamicOptions = new DynamicOptions(injector, dynamicBeans)) {
        GetChange getChange = getChangeProvider.get();
        options.forEach(getChange::addOption);
        dynamicOptionParser.parseDynamicOptions(getChange, pluginOptions, dynamicOptions);
        return getChange.apply(change).value();
    } catch (Exception e) {
        throw asRestApiException("Cannot retrieve change", e);
    }
}
Also used : DynamicOptions(com.google.gerrit.server.DynamicOptions) GetChange(com.google.gerrit.server.restapi.change.GetChange) ApiUtil.asRestApiException(com.google.gerrit.server.api.ApiUtil.asRestApiException) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) IllegalLabelException(com.google.gerrit.server.StarredChangesUtil.IllegalLabelException) RestApiException(com.google.gerrit.extensions.restapi.RestApiException) StorageException(com.google.gerrit.exceptions.StorageException) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 62 with RestApiException

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

the class ChangeApiImpl method metaDiff.

@Override
public ChangeInfoDifference metaDiff(@Nullable String oldMetaRevId, @Nullable String newMetaRevId, EnumSet<ListChangesOption> options, ImmutableListMultimap<String, String> pluginOptions) throws RestApiException {
    try (DynamicOptions dynamicOptions = new DynamicOptions(injector, dynamicBeans)) {
        GetMetaDiff metaDiff = getMetaDiffProvider.get();
        metaDiff.setOldMetaRevId(oldMetaRevId);
        metaDiff.setNewMetaRevId(newMetaRevId);
        options.forEach(metaDiff::addOption);
        dynamicOptionParser.parseDynamicOptions(metaDiff, pluginOptions, dynamicOptions);
        return metaDiff.apply(change).value();
    } catch (Exception e) {
        throw asRestApiException("Cannot retrieve metaDiff", e);
    }
}
Also used : DynamicOptions(com.google.gerrit.server.DynamicOptions) GetMetaDiff(com.google.gerrit.server.restapi.change.GetMetaDiff) ApiUtil.asRestApiException(com.google.gerrit.server.api.ApiUtil.asRestApiException) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) IllegalLabelException(com.google.gerrit.server.StarredChangesUtil.IllegalLabelException) RestApiException(com.google.gerrit.extensions.restapi.RestApiException) StorageException(com.google.gerrit.exceptions.StorageException) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 63 with RestApiException

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

the class ChangeApiImpl method pureRevert.

@Override
public PureRevertInfo pureRevert(@Nullable String claimedOriginal) throws RestApiException {
    try {
        GetPureRevert getPureRevert = getPureRevertProvider.get();
        getPureRevert.setClaimedOriginal(claimedOriginal);
        return getPureRevert.apply(change).value();
    } catch (Exception e) {
        throw asRestApiException("Cannot compute pure revert", e);
    }
}
Also used : GetPureRevert(com.google.gerrit.server.restapi.change.GetPureRevert) ApiUtil.asRestApiException(com.google.gerrit.server.api.ApiUtil.asRestApiException) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) IllegalLabelException(com.google.gerrit.server.StarredChangesUtil.IllegalLabelException) RestApiException(com.google.gerrit.extensions.restapi.RestApiException) StorageException(com.google.gerrit.exceptions.StorageException) CmdLineException(org.kohsuke.args4j.CmdLineException)

Example 64 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.restapi.change.GetMergeList)

Example 65 with RestApiException

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

the class GroupApiImpl method name.

@Override
public void name(String name) throws RestApiException {
    NameInput in = new NameInput();
    in.name = name;
    try {
        putName.apply(rsrc, in);
    } catch (Exception e) {
        throw asRestApiException("Cannot put group name", e);
    }
}
Also used : NameInput(com.google.gerrit.extensions.common.NameInput) ApiUtil.asRestApiException(com.google.gerrit.server.api.ApiUtil.asRestApiException) 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