Search in sources :

Example 1 with CheckAccountExternalIdsResultInfo

use of com.google.gerrit.extensions.api.config.ConsistencyCheckInfo.CheckAccountExternalIdsResultInfo in project gerrit by GerritCodeReview.

the class CheckConsistency method apply.

@Override
public ConsistencyCheckInfo apply(ConfigResource resource, ConsistencyCheckInput input) throws RestApiException, IOException {
    IdentifiedUser user = userProvider.get();
    if (!user.isIdentifiedUser()) {
        throw new AuthException("Authentication required");
    }
    if (!user.getCapabilities().canAccessDatabase()) {
        throw new AuthException("not allowed to run consistency checks");
    }
    if (input == null || input.checkAccountExternalIds == null) {
        throw new BadRequestException("input required");
    }
    ConsistencyCheckInfo consistencyCheckInfo = new ConsistencyCheckInfo();
    if (input.checkAccountExternalIds != null) {
        consistencyCheckInfo.checkAccountExternalIdsResult = new CheckAccountExternalIdsResultInfo(externalIdsConsistencyChecker.check());
    }
    return consistencyCheckInfo;
}
Also used : ConsistencyCheckInfo(com.google.gerrit.extensions.api.config.ConsistencyCheckInfo) AuthException(com.google.gerrit.extensions.restapi.AuthException) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) IdentifiedUser(com.google.gerrit.server.IdentifiedUser) CheckAccountExternalIdsResultInfo(com.google.gerrit.extensions.api.config.ConsistencyCheckInfo.CheckAccountExternalIdsResultInfo)

Example 2 with CheckAccountExternalIdsResultInfo

use of com.google.gerrit.extensions.api.config.ConsistencyCheckInfo.CheckAccountExternalIdsResultInfo in project gerrit by GerritCodeReview.

the class CheckConsistency method apply.

@Override
public Response<ConsistencyCheckInfo> apply(ConfigResource resource, ConsistencyCheckInput input) throws RestApiException, IOException, PermissionBackendException, ConfigInvalidException {
    permissionBackend.currentUser().check(GlobalPermission.ACCESS_DATABASE);
    if (input == null || (input.checkAccounts == null && input.checkAccountExternalIds == null && input.checkGroups == null)) {
        throw new BadRequestException("input required");
    }
    ConsistencyCheckInfo consistencyCheckInfo = new ConsistencyCheckInfo();
    if (input.checkAccounts != null) {
        consistencyCheckInfo.checkAccountsResult = new CheckAccountsResultInfo(accountsConsistencyChecker.check());
    }
    if (input.checkAccountExternalIds != null) {
        consistencyCheckInfo.checkAccountExternalIdsResult = new CheckAccountExternalIdsResultInfo(externalIdsConsistencyChecker.check());
    }
    if (input.checkGroups != null) {
        consistencyCheckInfo.checkGroupsResult = new CheckGroupsResultInfo(groupsConsistencyChecker.check());
    }
    return Response.ok(consistencyCheckInfo);
}
Also used : CheckAccountsResultInfo(com.google.gerrit.extensions.api.config.ConsistencyCheckInfo.CheckAccountsResultInfo) ConsistencyCheckInfo(com.google.gerrit.extensions.api.config.ConsistencyCheckInfo) BadRequestException(com.google.gerrit.extensions.restapi.BadRequestException) CheckGroupsResultInfo(com.google.gerrit.extensions.api.config.ConsistencyCheckInfo.CheckGroupsResultInfo) CheckAccountExternalIdsResultInfo(com.google.gerrit.extensions.api.config.ConsistencyCheckInfo.CheckAccountExternalIdsResultInfo)

Aggregations

ConsistencyCheckInfo (com.google.gerrit.extensions.api.config.ConsistencyCheckInfo)2 CheckAccountExternalIdsResultInfo (com.google.gerrit.extensions.api.config.ConsistencyCheckInfo.CheckAccountExternalIdsResultInfo)2 BadRequestException (com.google.gerrit.extensions.restapi.BadRequestException)2 CheckAccountsResultInfo (com.google.gerrit.extensions.api.config.ConsistencyCheckInfo.CheckAccountsResultInfo)1 CheckGroupsResultInfo (com.google.gerrit.extensions.api.config.ConsistencyCheckInfo.CheckGroupsResultInfo)1 AuthException (com.google.gerrit.extensions.restapi.AuthException)1 IdentifiedUser (com.google.gerrit.server.IdentifiedUser)1