Use REST call instead of AccountService.changePreferences(...)
AccountService.changePreferences(...) is not used anymore and can be removed. Change-Id: Ie67eb430d7409f2ae9b355f1b06792c153c9b353 Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
@@ -18,7 +18,6 @@ import com.google.gerrit.common.audit.Audit;
|
|||||||
import com.google.gerrit.common.auth.SignInRequired;
|
import com.google.gerrit.common.auth.SignInRequired;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.AccountDiffPreference;
|
import com.google.gerrit.reviewdb.client.AccountDiffPreference;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
|
||||||
import com.google.gerrit.reviewdb.client.AccountProjectWatch;
|
import com.google.gerrit.reviewdb.client.AccountProjectWatch;
|
||||||
import com.google.gwtjsonrpc.common.AsyncCallback;
|
import com.google.gwtjsonrpc.common.AsyncCallback;
|
||||||
import com.google.gwtjsonrpc.common.RemoteJsonService;
|
import com.google.gwtjsonrpc.common.RemoteJsonService;
|
||||||
@@ -34,11 +33,6 @@ public interface AccountService extends RemoteJsonService {
|
|||||||
@SignInRequired
|
@SignInRequired
|
||||||
void myAccount(AsyncCallback<Account> callback);
|
void myAccount(AsyncCallback<Account> callback);
|
||||||
|
|
||||||
@Audit
|
|
||||||
@SignInRequired
|
|
||||||
void changePreferences(AccountGeneralPreferences pref,
|
|
||||||
AsyncCallback<VoidResult> gerritCallback);
|
|
||||||
|
|
||||||
@Audit
|
@Audit
|
||||||
@SignInRequired
|
@SignInRequired
|
||||||
void changeDiffPreferences(AccountDiffPreference diffPref,
|
void changeDiffPreferences(AccountDiffPreference diffPref,
|
||||||
|
@@ -15,16 +15,18 @@
|
|||||||
package com.google.gerrit.client.download;
|
package com.google.gerrit.client.download;
|
||||||
|
|
||||||
import com.google.gerrit.client.Gerrit;
|
import com.google.gerrit.client.Gerrit;
|
||||||
|
import com.google.gerrit.client.account.AccountApi;
|
||||||
import com.google.gerrit.client.config.DownloadInfo.DownloadSchemeInfo;
|
import com.google.gerrit.client.config.DownloadInfo.DownloadSchemeInfo;
|
||||||
|
import com.google.gerrit.client.info.AccountPreferencesInfo;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadScheme;
|
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences.DownloadScheme;
|
||||||
import com.google.gwt.aria.client.Roles;
|
import com.google.gwt.aria.client.Roles;
|
||||||
|
import com.google.gwt.core.client.JavaScriptObject;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.gwt.user.client.ui.Anchor;
|
import com.google.gwt.user.client.ui.Anchor;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
import com.google.gwtjsonrpc.common.AsyncCallback;
|
|
||||||
import com.google.gwtjsonrpc.common.VoidResult;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -115,14 +117,16 @@ public class DownloadUrlLink extends Anchor implements ClickHandler {
|
|||||||
// If the user is signed-in, remember this choice for future panels.
|
// If the user is signed-in, remember this choice for future panels.
|
||||||
//
|
//
|
||||||
pref.setDownloadUrl(scheme);
|
pref.setDownloadUrl(scheme);
|
||||||
com.google.gerrit.client.account.Util.ACCOUNT_SVC.changePreferences(pref,
|
AccountPreferencesInfo in = AccountPreferencesInfo.create();
|
||||||
new AsyncCallback<VoidResult>() {
|
in.downloadScheme(scheme);
|
||||||
|
AccountApi.self().view("preferences")
|
||||||
|
.put(in, new AsyncCallback<JavaScriptObject>() {
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onSuccess(JavaScriptObject result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(VoidResult result) {
|
public void onFailure(Throwable caught) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -22,12 +22,10 @@ import com.google.gerrit.common.errors.NoSuchEntityException;
|
|||||||
import com.google.gerrit.httpd.rpc.BaseServiceImplementation;
|
import com.google.gerrit.httpd.rpc.BaseServiceImplementation;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.reviewdb.client.AccountDiffPreference;
|
import com.google.gerrit.reviewdb.client.AccountDiffPreference;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGeneralPreferences;
|
|
||||||
import com.google.gerrit.reviewdb.client.AccountProjectWatch;
|
import com.google.gerrit.reviewdb.client.AccountProjectWatch;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
import com.google.gerrit.server.IdentifiedUser;
|
import com.google.gerrit.server.IdentifiedUser;
|
||||||
import com.google.gerrit.server.account.AccountCache;
|
|
||||||
import com.google.gerrit.server.project.NoSuchProjectException;
|
import com.google.gerrit.server.project.NoSuchProjectException;
|
||||||
import com.google.gerrit.server.project.ProjectControl;
|
import com.google.gerrit.server.project.ProjectControl;
|
||||||
import com.google.gerrit.server.query.QueryParseException;
|
import com.google.gerrit.server.query.QueryParseException;
|
||||||
@@ -48,7 +46,6 @@ import java.util.Set;
|
|||||||
class AccountServiceImpl extends BaseServiceImplementation implements
|
class AccountServiceImpl extends BaseServiceImplementation implements
|
||||||
AccountService {
|
AccountService {
|
||||||
private final Provider<IdentifiedUser> currentUser;
|
private final Provider<IdentifiedUser> currentUser;
|
||||||
private final AccountCache accountCache;
|
|
||||||
private final ProjectControl.Factory projectControlFactory;
|
private final ProjectControl.Factory projectControlFactory;
|
||||||
private final AgreementInfoFactory.Factory agreementInfoFactory;
|
private final AgreementInfoFactory.Factory agreementInfoFactory;
|
||||||
private final ChangeQueryBuilder queryBuilder;
|
private final ChangeQueryBuilder queryBuilder;
|
||||||
@@ -56,13 +53,11 @@ class AccountServiceImpl extends BaseServiceImplementation implements
|
|||||||
@Inject
|
@Inject
|
||||||
AccountServiceImpl(final Provider<ReviewDb> schema,
|
AccountServiceImpl(final Provider<ReviewDb> schema,
|
||||||
final Provider<IdentifiedUser> identifiedUser,
|
final Provider<IdentifiedUser> identifiedUser,
|
||||||
final AccountCache accountCache,
|
|
||||||
final ProjectControl.Factory projectControlFactory,
|
final ProjectControl.Factory projectControlFactory,
|
||||||
final AgreementInfoFactory.Factory agreementInfoFactory,
|
final AgreementInfoFactory.Factory agreementInfoFactory,
|
||||||
final ChangeQueryBuilder queryBuilder) {
|
final ChangeQueryBuilder queryBuilder) {
|
||||||
super(schema, identifiedUser);
|
super(schema, identifiedUser);
|
||||||
this.currentUser = identifiedUser;
|
this.currentUser = identifiedUser;
|
||||||
this.accountCache = accountCache;
|
|
||||||
this.projectControlFactory = projectControlFactory;
|
this.projectControlFactory = projectControlFactory;
|
||||||
this.agreementInfoFactory = agreementInfoFactory;
|
this.agreementInfoFactory = agreementInfoFactory;
|
||||||
this.queryBuilder = queryBuilder;
|
this.queryBuilder = queryBuilder;
|
||||||
@@ -78,24 +73,6 @@ class AccountServiceImpl extends BaseServiceImplementation implements
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void changePreferences(final AccountGeneralPreferences pref,
|
|
||||||
final AsyncCallback<VoidResult> callback) {
|
|
||||||
run(callback, new Action<VoidResult>() {
|
|
||||||
@Override
|
|
||||||
public VoidResult run(final ReviewDb db) throws OrmException, Failure {
|
|
||||||
final Account a = db.accounts().get(getAccountId());
|
|
||||||
if (a == null) {
|
|
||||||
throw new Failure(new NoSuchEntityException());
|
|
||||||
}
|
|
||||||
a.setGeneralPreferences(pref);
|
|
||||||
db.accounts().update(Collections.singleton(a));
|
|
||||||
accountCache.evict(a.getId());
|
|
||||||
return VoidResult.INSTANCE;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changeDiffPreferences(final AccountDiffPreference diffPref,
|
public void changeDiffPreferences(final AccountDiffPreference diffPref,
|
||||||
AsyncCallback<VoidResult> callback) {
|
AsyncCallback<VoidResult> callback) {
|
||||||
|
Reference in New Issue
Block a user