AccountService: Remove unused changeDiffPreferences method

Also remove ListenableAccountDiffPreference which is no longer used.

Change-Id: I5cd58df3e3b37c41b52ff346f975a9953553756f
This commit is contained in:
David Pursehouse
2016-05-02 15:15:57 +09:00
parent 221415d298
commit 4c9c8e012c
3 changed files with 1 additions and 94 deletions

View File

@@ -16,7 +16,6 @@ package com.google.gerrit.common.data;
import com.google.gerrit.common.audit.Audit;
import com.google.gerrit.common.auth.SignInRequired;
import com.google.gerrit.extensions.client.DiffPreferencesInfo;
import com.google.gerrit.reviewdb.client.AccountProjectWatch;
import com.google.gwtjsonrpc.common.AsyncCallback;
import com.google.gwtjsonrpc.common.RemoteJsonService;
@@ -29,11 +28,6 @@ import java.util.Set;
@RpcImpl(version = Version.V2_0)
public interface AccountService extends RemoteJsonService {
@Audit
@SignInRequired
void changeDiffPreferences(DiffPreferencesInfo diffPref,
AsyncCallback<VoidResult> callback);
@SignInRequired
void myProjectWatch(AsyncCallback<List<AccountProjectWatchInfo>> callback);

View File

@@ -1,55 +0,0 @@
// Copyright (C) 2010 The Android Open Source Project
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.gerrit.client.ui;
import com.google.gerrit.client.Gerrit;
import com.google.gerrit.client.account.Util;
import com.google.gerrit.client.rpc.GerritCallback;
import com.google.gerrit.extensions.client.DiffPreferencesInfo;
import com.google.gwtjsonrpc.common.VoidResult;
public class ListenableAccountDiffPreference
extends ListenableOldValue<DiffPreferencesInfo> {
public ListenableAccountDiffPreference() {
reset();
}
public void save(final GerritCallback<VoidResult> cb) {
if (Gerrit.isSignedIn()) {
Util.ACCOUNT_SVC.changeDiffPreferences(get(),
new GerritCallback<VoidResult>() {
@Override
public void onSuccess(VoidResult result) {
Gerrit.setDiffPreferences(get());
cb.onSuccess(result);
}
@Override
public void onFailure(Throwable caught) {
cb.onFailure(caught);
}
});
}
}
public void reset() {
if (Gerrit.isSignedIn() && Gerrit.getDiffPreferences() != null) {
set(Gerrit.getDiffPreferences());
} else {
set(DiffPreferencesInfo.defaults());
}
}
}

View File

@@ -19,17 +19,12 @@ import com.google.gerrit.common.data.AccountService;
import com.google.gerrit.common.data.AgreementInfo;
import com.google.gerrit.common.errors.InvalidQueryException;
import com.google.gerrit.common.errors.NoSuchEntityException;
import com.google.gerrit.extensions.client.DiffPreferencesInfo;
import com.google.gerrit.extensions.restapi.AuthException;
import com.google.gerrit.extensions.restapi.BadRequestException;
import com.google.gerrit.httpd.rpc.BaseServiceImplementation;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.AccountProjectWatch;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.AccountResource;
import com.google.gerrit.server.account.SetDiffPreferences;
import com.google.gerrit.server.project.NoSuchProjectException;
import com.google.gerrit.server.project.ProjectControl;
import com.google.gerrit.server.query.QueryParseException;
@@ -41,9 +36,6 @@ import com.google.gwtorm.server.OrmException;
import com.google.inject.Inject;
import com.google.inject.Provider;
import org.eclipse.jgit.errors.ConfigInvalidException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -55,41 +47,17 @@ class AccountServiceImpl extends BaseServiceImplementation implements
private final ProjectControl.Factory projectControlFactory;
private final AgreementInfoFactory.Factory agreementInfoFactory;
private final Provider<ChangeQueryBuilder> queryBuilder;
private final SetDiffPreferences setDiff;
@Inject
AccountServiceImpl(final Provider<ReviewDb> schema,
final Provider<IdentifiedUser> identifiedUser,
final ProjectControl.Factory projectControlFactory,
final AgreementInfoFactory.Factory agreementInfoFactory,
final Provider<ChangeQueryBuilder> queryBuilder,
SetDiffPreferences setDiff) {
final Provider<ChangeQueryBuilder> queryBuilder) {
super(schema, identifiedUser);
this.projectControlFactory = projectControlFactory;
this.agreementInfoFactory = agreementInfoFactory;
this.queryBuilder = queryBuilder;
this.setDiff = setDiff;
}
@Override
public void changeDiffPreferences(final DiffPreferencesInfo diffPref,
AsyncCallback<VoidResult> callback) {
run(callback, new Action<VoidResult>() {
@Override
public VoidResult run(ReviewDb db) throws OrmException {
if (!getUser().isIdentifiedUser()) {
throw new IllegalArgumentException("Not authenticated");
}
IdentifiedUser me = getUser().asIdentifiedUser();
try {
setDiff.apply(new AccountResource(me), diffPref);
} catch (AuthException | BadRequestException | ConfigInvalidException
| IOException e) {
throw new OrmException("Cannot save diff preferences", e);
}
return VoidResult.INSTANCE;
}
});
}
@Override