Merge "Move more endpoints to singleton scope and remove providers"
This commit is contained in:
commit
7af3ec348e
@ -51,6 +51,7 @@ import com.google.gwtorm.server.OrmConcurrencyException;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
||||||
import org.eclipse.jgit.errors.MissingObjectException;
|
import org.eclipse.jgit.errors.MissingObjectException;
|
||||||
@ -79,6 +80,7 @@ import java.util.Date;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
public class ChangeUtil {
|
public class ChangeUtil {
|
||||||
/**
|
/**
|
||||||
* Epoch for sort key calculations, Tue Sep 30 2008 17:00:00.
|
* Epoch for sort key calculations, Tue Sep 30 2008 17:00:00.
|
||||||
|
@ -21,6 +21,7 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -29,6 +30,7 @@ import java.util.Set;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
public class AccountResolver {
|
public class AccountResolver {
|
||||||
private final Realm realm;
|
private final Realm realm;
|
||||||
private final AccountByEmailCache byEmail;
|
private final AccountByEmailCache byEmail;
|
||||||
|
@ -59,7 +59,7 @@ public class CreateEmail implements RestModifyView<AccountResource, Input> {
|
|||||||
private final AuthConfig authConfig;
|
private final AuthConfig authConfig;
|
||||||
private final AccountManager accountManager;
|
private final AccountManager accountManager;
|
||||||
private final RegisterNewEmailSender.Factory registerNewEmailFactory;
|
private final RegisterNewEmailSender.Factory registerNewEmailFactory;
|
||||||
private final Provider<PutPreferred> putPreferredProvider;
|
private final PutPreferred putPreferred;
|
||||||
private final String email;
|
private final String email;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ -68,14 +68,14 @@ public class CreateEmail implements RestModifyView<AccountResource, Input> {
|
|||||||
AuthConfig authConfig,
|
AuthConfig authConfig,
|
||||||
AccountManager accountManager,
|
AccountManager accountManager,
|
||||||
RegisterNewEmailSender.Factory registerNewEmailFactory,
|
RegisterNewEmailSender.Factory registerNewEmailFactory,
|
||||||
Provider<PutPreferred> putPreferredProvider,
|
PutPreferred putPreferred,
|
||||||
@Assisted String email) {
|
@Assisted String email) {
|
||||||
this.self = self;
|
this.self = self;
|
||||||
this.realm = realm;
|
this.realm = realm;
|
||||||
this.authConfig = authConfig;
|
this.authConfig = authConfig;
|
||||||
this.accountManager = accountManager;
|
this.accountManager = accountManager;
|
||||||
this.registerNewEmailFactory = registerNewEmailFactory;
|
this.registerNewEmailFactory = registerNewEmailFactory;
|
||||||
this.putPreferredProvider = putPreferredProvider;
|
this.putPreferred = putPreferred;
|
||||||
this.email = email;
|
this.email = email;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ public class CreateEmail implements RestModifyView<AccountResource, Input> {
|
|||||||
throw new ResourceConflictException(e.getMessage());
|
throw new ResourceConflictException(e.getMessage());
|
||||||
}
|
}
|
||||||
if (input.preferred) {
|
if (input.preferred) {
|
||||||
putPreferredProvider.get().apply(
|
putPreferred.apply(
|
||||||
new AccountResource.Email(user, email),
|
new AccountResource.Email(user, email),
|
||||||
null);
|
null);
|
||||||
info.preferred = true;
|
info.preferred = true;
|
||||||
|
@ -20,9 +20,11 @@ import com.google.gerrit.reviewdb.client.AuthType;
|
|||||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||||
import com.google.gerrit.server.config.AuthConfig;
|
import com.google.gerrit.server.config.AuthConfig;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
public class DefaultRealm implements Realm {
|
public class DefaultRealm implements Realm {
|
||||||
private final EmailExpander emailExpander;
|
private final EmailExpander emailExpander;
|
||||||
private final AccountByEmailCache byEmail;
|
private final AccountByEmailCache byEmail;
|
||||||
|
@ -32,13 +32,13 @@ public class Emails implements
|
|||||||
ChildCollection<AccountResource, AccountResource.Email>,
|
ChildCollection<AccountResource, AccountResource.Email>,
|
||||||
AcceptsCreate<AccountResource> {
|
AcceptsCreate<AccountResource> {
|
||||||
private final DynamicMap<RestView<AccountResource.Email>> views;
|
private final DynamicMap<RestView<AccountResource.Email>> views;
|
||||||
private final Provider<GetEmails> list;
|
private final GetEmails list;
|
||||||
private final Provider<CurrentUser> self;
|
private final Provider<CurrentUser> self;
|
||||||
private final CreateEmail.Factory createEmailFactory;
|
private final CreateEmail.Factory createEmailFactory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
Emails(DynamicMap<RestView<AccountResource.Email>> views,
|
Emails(DynamicMap<RestView<AccountResource.Email>> views,
|
||||||
Provider<GetEmails> list,
|
GetEmails list,
|
||||||
Provider<CurrentUser> self,
|
Provider<CurrentUser> self,
|
||||||
CreateEmail.Factory createEmailFactory) {
|
CreateEmail.Factory createEmailFactory) {
|
||||||
this.views = views;
|
this.views = views;
|
||||||
@ -49,7 +49,7 @@ public class Emails implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RestView<AccountResource> list() {
|
public RestView<AccountResource> list() {
|
||||||
return list.get();
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,11 +21,13 @@ import com.google.gerrit.server.CurrentUser;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
public class GetEmails implements RestReadView<AccountResource> {
|
public class GetEmails implements RestReadView<AccountResource> {
|
||||||
private final Provider<CurrentUser> self;
|
private final Provider<CurrentUser> self;
|
||||||
|
|
||||||
|
@ -25,9 +25,11 @@ import com.google.gerrit.server.IdentifiedUser;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
public class GetSshKeys implements RestReadView<AccountResource> {
|
public class GetSshKeys implements RestReadView<AccountResource> {
|
||||||
|
|
||||||
private final Provider<CurrentUser> self;
|
private final Provider<CurrentUser> self;
|
||||||
|
@ -32,13 +32,13 @@ import com.google.inject.Singleton;
|
|||||||
public class SshKeys implements
|
public class SshKeys implements
|
||||||
ChildCollection<AccountResource, AccountResource.SshKey> {
|
ChildCollection<AccountResource, AccountResource.SshKey> {
|
||||||
private final DynamicMap<RestView<AccountResource.SshKey>> views;
|
private final DynamicMap<RestView<AccountResource.SshKey>> views;
|
||||||
private final Provider<GetSshKeys> list;
|
private final GetSshKeys list;
|
||||||
private final Provider<CurrentUser> self;
|
private final Provider<CurrentUser> self;
|
||||||
private final Provider<ReviewDb> dbProvider;
|
private final Provider<ReviewDb> dbProvider;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
SshKeys(DynamicMap<RestView<AccountResource.SshKey>> views,
|
SshKeys(DynamicMap<RestView<AccountResource.SshKey>> views,
|
||||||
Provider<GetSshKeys> list, Provider<CurrentUser> self,
|
GetSshKeys list, Provider<CurrentUser> self,
|
||||||
Provider<ReviewDb> dbProvider) {
|
Provider<ReviewDb> dbProvider) {
|
||||||
this.views = views;
|
this.views = views;
|
||||||
this.list = list;
|
this.list = list;
|
||||||
@ -48,7 +48,7 @@ public class SshKeys implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RestView<AccountResource> list() {
|
public RestView<AccountResource> list() {
|
||||||
return list.get();
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -14,24 +14,23 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.api;
|
package com.google.gerrit.server.api;
|
||||||
|
|
||||||
import com.google.gerrit.extensions.api.accounts.Accounts;
|
|
||||||
import com.google.gerrit.extensions.api.GerritApi;
|
import com.google.gerrit.extensions.api.GerritApi;
|
||||||
|
import com.google.gerrit.extensions.api.accounts.Accounts;
|
||||||
import com.google.gerrit.extensions.api.changes.Changes;
|
import com.google.gerrit.extensions.api.changes.Changes;
|
||||||
import com.google.gerrit.extensions.api.projects.Projects;
|
import com.google.gerrit.extensions.api.projects.Projects;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class GerritApiImpl extends GerritApi.NotImplemented implements GerritApi {
|
class GerritApiImpl extends GerritApi.NotImplemented implements GerritApi {
|
||||||
private final Provider<Accounts> accounts;
|
private final Accounts accounts;
|
||||||
private final Provider<Changes> changes;
|
private final Changes changes;
|
||||||
private final Provider<Projects> projects;
|
private final Projects projects;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
GerritApiImpl(Provider<Accounts> accounts,
|
GerritApiImpl(Accounts accounts,
|
||||||
Provider<Changes> changes,
|
Changes changes,
|
||||||
Provider<Projects> projects) {
|
Projects projects) {
|
||||||
this.accounts = accounts;
|
this.accounts = accounts;
|
||||||
this.changes = changes;
|
this.changes = changes;
|
||||||
this.projects = projects;
|
this.projects = projects;
|
||||||
@ -39,16 +38,16 @@ class GerritApiImpl extends GerritApi.NotImplemented implements GerritApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Accounts accounts() {
|
public Accounts accounts() {
|
||||||
return accounts.get();
|
return accounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Changes changes() {
|
public Changes changes() {
|
||||||
return changes.get();
|
return changes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Projects projects() {
|
public Projects projects() {
|
||||||
return projects.get();
|
return projects;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,21 +50,21 @@ class ChangeApiImpl extends ChangeApi.NotImplemented implements ChangeApi {
|
|||||||
private final Revisions revisions;
|
private final Revisions revisions;
|
||||||
private final RevisionApiImpl.Factory revisionApi;
|
private final RevisionApiImpl.Factory revisionApi;
|
||||||
private final ChangeResource change;
|
private final ChangeResource change;
|
||||||
private final Provider<Abandon> abandon;
|
private final Abandon abandon;
|
||||||
private final Provider<Revert> revert;
|
private final Revert revert;
|
||||||
private final Provider<Restore> restore;
|
private final Restore restore;
|
||||||
private final Provider<PostReviewers> postReviewers;
|
private final Provider<PostReviewers> postReviewers;
|
||||||
private final ChangeJson changeJson;
|
private final Provider<ChangeJson> changeJson;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ChangeApiImpl(Changes changeApi,
|
ChangeApiImpl(Changes changeApi,
|
||||||
Revisions revisions,
|
Revisions revisions,
|
||||||
RevisionApiImpl.Factory revisionApi,
|
RevisionApiImpl.Factory revisionApi,
|
||||||
Provider<Abandon> abandon,
|
Abandon abandon,
|
||||||
Provider<Revert> revert,
|
Revert revert,
|
||||||
Provider<Restore> restore,
|
Restore restore,
|
||||||
Provider<PostReviewers> postReviewers,
|
Provider<PostReviewers> postReviewers,
|
||||||
ChangeJson changeJson,
|
Provider<ChangeJson> changeJson,
|
||||||
@Assisted ChangeResource change) {
|
@Assisted ChangeResource change) {
|
||||||
this.changeApi = changeApi;
|
this.changeApi = changeApi;
|
||||||
this.revert = revert;
|
this.revert = revert;
|
||||||
@ -110,7 +110,7 @@ class ChangeApiImpl extends ChangeApi.NotImplemented implements ChangeApi {
|
|||||||
@Override
|
@Override
|
||||||
public void abandon(AbandonInput in) throws RestApiException {
|
public void abandon(AbandonInput in) throws RestApiException {
|
||||||
try {
|
try {
|
||||||
abandon.get().apply(change, in);
|
abandon.apply(change, in);
|
||||||
} catch (OrmException | IOException e) {
|
} catch (OrmException | IOException e) {
|
||||||
throw new RestApiException("Cannot abandon change", e);
|
throw new RestApiException("Cannot abandon change", e);
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ class ChangeApiImpl extends ChangeApi.NotImplemented implements ChangeApi {
|
|||||||
@Override
|
@Override
|
||||||
public void restore(RestoreInput in) throws RestApiException {
|
public void restore(RestoreInput in) throws RestApiException {
|
||||||
try {
|
try {
|
||||||
restore.get().apply(change, in);
|
restore.apply(change, in);
|
||||||
} catch (OrmException | IOException e) {
|
} catch (OrmException | IOException e) {
|
||||||
throw new RestApiException("Cannot restore change", e);
|
throw new RestApiException("Cannot restore change", e);
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ class ChangeApiImpl extends ChangeApi.NotImplemented implements ChangeApi {
|
|||||||
@Override
|
@Override
|
||||||
public ChangeApi revert(RevertInput in) throws RestApiException {
|
public ChangeApi revert(RevertInput in) throws RestApiException {
|
||||||
try {
|
try {
|
||||||
return changeApi.id(revert.get().apply(change, in)._number);
|
return changeApi.id(revert.apply(change, in)._number);
|
||||||
} catch (OrmException | EmailException | IOException e) {
|
} catch (OrmException | EmailException | IOException e) {
|
||||||
throw new RestApiException("Cannot revert change", e);
|
throw new RestApiException("Cannot revert change", e);
|
||||||
}
|
}
|
||||||
@ -165,7 +165,7 @@ class ChangeApiImpl extends ChangeApi.NotImplemented implements ChangeApi {
|
|||||||
throws RestApiException {
|
throws RestApiException {
|
||||||
try {
|
try {
|
||||||
return ChangeInfoMapper.INSTANCE.apply(
|
return ChangeInfoMapper.INSTANCE.apply(
|
||||||
changeJson.addOptions(s).format(change));
|
changeJson.get().addOptions(s).format(change));
|
||||||
} catch (OrmException e) {
|
} catch (OrmException e) {
|
||||||
throw new RestApiException("Cannot retrieve change", e);
|
throw new RestApiException("Cannot retrieve change", e);
|
||||||
}
|
}
|
||||||
|
@ -43,24 +43,24 @@ class RevisionApiImpl extends RevisionApi.NotImplemented implements RevisionApi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final Changes changes;
|
private final Changes changes;
|
||||||
private final Provider<CherryPick> cherryPick;
|
private final CherryPick cherryPick;
|
||||||
private final Provider<DeleteDraftPatchSet> deleteDraft;
|
private final DeleteDraftPatchSet deleteDraft;
|
||||||
private final Provider<Rebase> rebase;
|
private final Rebase rebase;
|
||||||
private final Provider<RebaseChange> rebaseChange;
|
private final RebaseChange rebaseChange;
|
||||||
private final Provider<PostReview> review;
|
private final Submit submit;
|
||||||
private final Provider<Submit> submit;
|
private final Publish publish;
|
||||||
private final Provider<Publish> publish;
|
|
||||||
private final RevisionResource revision;
|
private final RevisionResource revision;
|
||||||
|
private final Provider<PostReview> review;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
RevisionApiImpl(Changes changes,
|
RevisionApiImpl(Changes changes,
|
||||||
Provider<CherryPick> cherryPick,
|
CherryPick cherryPick,
|
||||||
Provider<DeleteDraftPatchSet> deleteDraft,
|
DeleteDraftPatchSet deleteDraft,
|
||||||
Provider<Rebase> rebase,
|
Rebase rebase,
|
||||||
Provider<RebaseChange> rebaseChange,
|
RebaseChange rebaseChange,
|
||||||
|
Submit submit,
|
||||||
|
Publish publish,
|
||||||
Provider<PostReview> review,
|
Provider<PostReview> review,
|
||||||
Provider<Submit> submit,
|
|
||||||
Provider<Publish> publish,
|
|
||||||
@Assisted RevisionResource r) {
|
@Assisted RevisionResource r) {
|
||||||
this.changes = changes;
|
this.changes = changes;
|
||||||
this.cherryPick = cherryPick;
|
this.cherryPick = cherryPick;
|
||||||
@ -92,7 +92,7 @@ class RevisionApiImpl extends RevisionApi.NotImplemented implements RevisionApi
|
|||||||
@Override
|
@Override
|
||||||
public void submit(SubmitInput in) throws RestApiException {
|
public void submit(SubmitInput in) throws RestApiException {
|
||||||
try {
|
try {
|
||||||
submit.get().apply(revision, in);
|
submit.apply(revision, in);
|
||||||
} catch (OrmException | IOException e) {
|
} catch (OrmException | IOException e) {
|
||||||
throw new RestApiException("Cannot submit change", e);
|
throw new RestApiException("Cannot submit change", e);
|
||||||
}
|
}
|
||||||
@ -101,7 +101,7 @@ class RevisionApiImpl extends RevisionApi.NotImplemented implements RevisionApi
|
|||||||
@Override
|
@Override
|
||||||
public void publish() throws RestApiException {
|
public void publish() throws RestApiException {
|
||||||
try {
|
try {
|
||||||
publish.get().apply(revision, new Publish.Input());
|
publish.apply(revision, new Publish.Input());
|
||||||
} catch (OrmException | IOException e) {
|
} catch (OrmException | IOException e) {
|
||||||
throw new RestApiException("Cannot publish draft patch set", e);
|
throw new RestApiException("Cannot publish draft patch set", e);
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ class RevisionApiImpl extends RevisionApi.NotImplemented implements RevisionApi
|
|||||||
@Override
|
@Override
|
||||||
public void delete() throws RestApiException {
|
public void delete() throws RestApiException {
|
||||||
try {
|
try {
|
||||||
deleteDraft.get().apply(revision, null);
|
deleteDraft.apply(revision, null);
|
||||||
} catch (OrmException | IOException e) {
|
} catch (OrmException | IOException e) {
|
||||||
throw new RestApiException("Cannot delete draft ps", e);
|
throw new RestApiException("Cannot delete draft ps", e);
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ class RevisionApiImpl extends RevisionApi.NotImplemented implements RevisionApi
|
|||||||
@Override
|
@Override
|
||||||
public ChangeApi rebase() throws RestApiException {
|
public ChangeApi rebase() throws RestApiException {
|
||||||
try {
|
try {
|
||||||
return changes.id(rebase.get().apply(revision, null)._number);
|
return changes.id(rebase.apply(revision, null)._number);
|
||||||
} catch (OrmException | EmailException e) {
|
} catch (OrmException | EmailException e) {
|
||||||
throw new RestApiException("Cannot rebase ps", e);
|
throw new RestApiException("Cannot rebase ps", e);
|
||||||
}
|
}
|
||||||
@ -127,13 +127,13 @@ class RevisionApiImpl extends RevisionApi.NotImplemented implements RevisionApi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canRebase() {
|
public boolean canRebase() {
|
||||||
return rebaseChange.get().canRebase(revision);
|
return rebaseChange.canRebase(revision);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChangeApi cherryPick(CherryPickInput in) throws RestApiException {
|
public ChangeApi cherryPick(CherryPickInput in) throws RestApiException {
|
||||||
try {
|
try {
|
||||||
return changes.id(cherryPick.get().apply(revision, in)._number);
|
return changes.id(cherryPick.apply(revision, in)._number);
|
||||||
} catch (OrmException | EmailException | IOException e) {
|
} catch (OrmException | EmailException | IOException e) {
|
||||||
throw new RestApiException("Cannot cherry pick", e);
|
throw new RestApiException("Cannot cherry pick", e);
|
||||||
}
|
}
|
||||||
|
@ -42,12 +42,12 @@ import java.io.IOException;
|
|||||||
public class CherryPick implements RestModifyView<RevisionResource, CherryPickInput>,
|
public class CherryPick implements RestModifyView<RevisionResource, CherryPickInput>,
|
||||||
UiAction<RevisionResource> {
|
UiAction<RevisionResource> {
|
||||||
private final Provider<ReviewDb> dbProvider;
|
private final Provider<ReviewDb> dbProvider;
|
||||||
private final Provider<CherryPickChange> cherryPickChange;
|
private final CherryPickChange cherryPickChange;
|
||||||
private final ChangeJson json;
|
private final ChangeJson json;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
CherryPick(Provider<ReviewDb> dbProvider,
|
CherryPick(Provider<ReviewDb> dbProvider,
|
||||||
Provider<CherryPickChange> cherryPickChange,
|
CherryPickChange cherryPickChange,
|
||||||
ChangeJson json) {
|
ChangeJson json) {
|
||||||
this.dbProvider = dbProvider;
|
this.dbProvider = dbProvider;
|
||||||
this.cherryPickChange = cherryPickChange;
|
this.cherryPickChange = cherryPickChange;
|
||||||
@ -85,7 +85,7 @@ public class CherryPick implements RestModifyView<RevisionResource, CherryPickIn
|
|||||||
|
|
||||||
final PatchSet.Id patchSetId = revision.getPatchSet().getId();
|
final PatchSet.Id patchSetId = revision.getPatchSet().getId();
|
||||||
try {
|
try {
|
||||||
Change.Id cherryPickedChangeId = cherryPickChange.get().cherryPick(
|
Change.Id cherryPickedChangeId = cherryPickChange.cherryPick(
|
||||||
patchSetId, input.message,
|
patchSetId, input.message,
|
||||||
input.destination, refControl);
|
input.destination, refControl);
|
||||||
return json.format(cherryPickedChangeId);
|
return json.format(cherryPickedChangeId);
|
||||||
|
@ -29,12 +29,12 @@ import com.google.inject.Singleton;
|
|||||||
@Singleton
|
@Singleton
|
||||||
class Comments implements ChildCollection<RevisionResource, CommentResource> {
|
class Comments implements ChildCollection<RevisionResource, CommentResource> {
|
||||||
private final DynamicMap<RestView<CommentResource>> views;
|
private final DynamicMap<RestView<CommentResource>> views;
|
||||||
private final Provider<ListComments> list;
|
private final ListComments list;
|
||||||
private final Provider<ReviewDb> dbProvider;
|
private final Provider<ReviewDb> dbProvider;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
Comments(DynamicMap<RestView<CommentResource>> views,
|
Comments(DynamicMap<RestView<CommentResource>> views,
|
||||||
Provider<ListComments> list,
|
ListComments list,
|
||||||
Provider<ReviewDb> dbProvider) {
|
Provider<ReviewDb> dbProvider) {
|
||||||
this.views = views;
|
this.views = views;
|
||||||
this.list = list;
|
this.list = list;
|
||||||
@ -48,7 +48,7 @@ class Comments implements ChildCollection<RevisionResource, CommentResource> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RestView<RevisionResource> list() {
|
public RestView<RevisionResource> list() {
|
||||||
return list.get();
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -76,7 +76,7 @@ public class CreateChange implements
|
|||||||
private final GitRepositoryManager gitManager;
|
private final GitRepositoryManager gitManager;
|
||||||
private final TimeZone serverTimeZone;
|
private final TimeZone serverTimeZone;
|
||||||
private final Provider<CurrentUser> userProvider;
|
private final Provider<CurrentUser> userProvider;
|
||||||
private final Provider<ProjectsCollection> projectsCollection;
|
private final ProjectsCollection projectsCollection;
|
||||||
private final CommitValidators.Factory commitValidatorsFactory;
|
private final CommitValidators.Factory commitValidatorsFactory;
|
||||||
private final ChangeInserter.Factory changeInserterFactory;
|
private final ChangeInserter.Factory changeInserterFactory;
|
||||||
private final ChangeJson json;
|
private final ChangeJson json;
|
||||||
@ -86,7 +86,7 @@ public class CreateChange implements
|
|||||||
GitRepositoryManager gitManager,
|
GitRepositoryManager gitManager,
|
||||||
@GerritPersonIdent PersonIdent myIdent,
|
@GerritPersonIdent PersonIdent myIdent,
|
||||||
Provider<CurrentUser> userProvider,
|
Provider<CurrentUser> userProvider,
|
||||||
Provider<ProjectsCollection> projectsCollection,
|
ProjectsCollection projectsCollection,
|
||||||
CommitValidators.Factory commitValidatorsFactory,
|
CommitValidators.Factory commitValidatorsFactory,
|
||||||
ChangeInserter.Factory changeInserterFactory,
|
ChangeInserter.Factory changeInserterFactory,
|
||||||
ChangeJson json) {
|
ChangeJson json) {
|
||||||
@ -130,7 +130,7 @@ public class CreateChange implements
|
|||||||
refName = Constants.R_HEADS + input.branch;
|
refName = Constants.R_HEADS + input.branch;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectResource rsrc = projectsCollection.get().parse(input.project);
|
ProjectResource rsrc = projectsCollection.parse(input.project);
|
||||||
|
|
||||||
Capable r = rsrc.getControl().canPushToAtLeastOneRef();
|
Capable r = rsrc.getControl().canPushToAtLeastOneRef();
|
||||||
if (r != Capable.OK) {
|
if (r != Capable.OK) {
|
||||||
|
@ -32,13 +32,13 @@ import com.google.inject.Singleton;
|
|||||||
class Drafts implements ChildCollection<RevisionResource, DraftResource> {
|
class Drafts implements ChildCollection<RevisionResource, DraftResource> {
|
||||||
private final DynamicMap<RestView<DraftResource>> views;
|
private final DynamicMap<RestView<DraftResource>> views;
|
||||||
private final Provider<CurrentUser> user;
|
private final Provider<CurrentUser> user;
|
||||||
private final Provider<ListDrafts> list;
|
private final ListDrafts list;
|
||||||
private final Provider<ReviewDb> dbProvider;
|
private final Provider<ReviewDb> dbProvider;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
Drafts(DynamicMap<RestView<DraftResource>> views,
|
Drafts(DynamicMap<RestView<DraftResource>> views,
|
||||||
Provider<CurrentUser> user,
|
Provider<CurrentUser> user,
|
||||||
Provider<ListDrafts> list,
|
ListDrafts list,
|
||||||
Provider<ReviewDb> dbProvider) {
|
Provider<ReviewDb> dbProvider) {
|
||||||
this.views = views;
|
this.views = views;
|
||||||
this.user = user;
|
this.user = user;
|
||||||
@ -54,7 +54,7 @@ class Drafts implements ChildCollection<RevisionResource, DraftResource> {
|
|||||||
@Override
|
@Override
|
||||||
public RestView<RevisionResource> list() throws AuthException {
|
public RestView<RevisionResource> list() throws AuthException {
|
||||||
checkIdentifiedUser();
|
checkIdentifiedUser();
|
||||||
return list.get();
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,11 +27,13 @@ import com.google.gerrit.server.patch.PatchListEntry;
|
|||||||
import com.google.gerrit.server.patch.PatchListKey;
|
import com.google.gerrit.server.patch.PatchListKey;
|
||||||
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import org.eclipse.jgit.lib.ObjectId;
|
import org.eclipse.jgit.lib.ObjectId;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
public class FileInfoJson {
|
public class FileInfoJson {
|
||||||
private final PatchListCache patchListCache;
|
private final PatchListCache patchListCache;
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ class Files implements ChildCollection<RevisionResource, FileResource> {
|
|||||||
private final Provider<ReviewDb> db;
|
private final Provider<ReviewDb> db;
|
||||||
private final Provider<CurrentUser> self;
|
private final Provider<CurrentUser> self;
|
||||||
private final FileInfoJson fileInfoJson;
|
private final FileInfoJson fileInfoJson;
|
||||||
private final Provider<Revisions> revisions;
|
private final Revisions revisions;
|
||||||
private final GitRepositoryManager gitManager;
|
private final GitRepositoryManager gitManager;
|
||||||
private final PatchListCache patchListCache;
|
private final PatchListCache patchListCache;
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ class Files implements ChildCollection<RevisionResource, FileResource> {
|
|||||||
ListFiles(Provider<ReviewDb> db,
|
ListFiles(Provider<ReviewDb> db,
|
||||||
Provider<CurrentUser> self,
|
Provider<CurrentUser> self,
|
||||||
FileInfoJson fileInfoJson,
|
FileInfoJson fileInfoJson,
|
||||||
Provider<Revisions> revisions,
|
Revisions revisions,
|
||||||
GitRepositoryManager gitManager,
|
GitRepositoryManager gitManager,
|
||||||
PatchListCache patchListCache) {
|
PatchListCache patchListCache) {
|
||||||
this.db = db;
|
this.db = db;
|
||||||
@ -127,7 +127,7 @@ class Files implements ChildCollection<RevisionResource, FileResource> {
|
|||||||
|
|
||||||
PatchSet basePatchSet = null;
|
PatchSet basePatchSet = null;
|
||||||
if (base != null) {
|
if (base != null) {
|
||||||
RevisionResource baseResource = revisions.get().parse(
|
RevisionResource baseResource = revisions.parse(
|
||||||
resource.getChangeResource(), IdString.fromDecoded(base));
|
resource.getChangeResource(), IdString.fromDecoded(base));
|
||||||
basePatchSet = baseResource.getPatchSet();
|
basePatchSet = baseResource.getPatchSet();
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,6 @@ import com.google.gerrit.server.project.ProjectCache;
|
|||||||
import com.google.gerrit.server.project.ProjectState;
|
import com.google.gerrit.server.project.ProjectState;
|
||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
|
||||||
|
|
||||||
import org.eclipse.jgit.diff.Edit;
|
import org.eclipse.jgit.diff.Edit;
|
||||||
import org.eclipse.jgit.diff.ReplaceEdit;
|
import org.eclipse.jgit.diff.ReplaceEdit;
|
||||||
@ -60,7 +59,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
public class GetDiff implements RestReadView<FileResource> {
|
public class GetDiff implements RestReadView<FileResource> {
|
||||||
private final ProjectCache projectCache;
|
private final ProjectCache projectCache;
|
||||||
private final PatchScriptFactory.Factory patchScriptFactoryFactory;
|
private final PatchScriptFactory.Factory patchScriptFactoryFactory;
|
||||||
private final Provider<Revisions> revisions;
|
private final Revisions revisions;
|
||||||
|
|
||||||
@Option(name = "--base", metaVar = "REVISION")
|
@Option(name = "--base", metaVar = "REVISION")
|
||||||
String base;
|
String base;
|
||||||
@ -77,7 +76,7 @@ public class GetDiff implements RestReadView<FileResource> {
|
|||||||
@Inject
|
@Inject
|
||||||
GetDiff(ProjectCache projectCache,
|
GetDiff(ProjectCache projectCache,
|
||||||
PatchScriptFactory.Factory patchScriptFactoryFactory,
|
PatchScriptFactory.Factory patchScriptFactoryFactory,
|
||||||
Provider<Revisions> revisions) {
|
Revisions revisions) {
|
||||||
this.projectCache = projectCache;
|
this.projectCache = projectCache;
|
||||||
this.patchScriptFactoryFactory = patchScriptFactoryFactory;
|
this.patchScriptFactoryFactory = patchScriptFactoryFactory;
|
||||||
this.revisions = revisions;
|
this.revisions = revisions;
|
||||||
@ -88,7 +87,7 @@ public class GetDiff implements RestReadView<FileResource> {
|
|||||||
throws ResourceConflictException, ResourceNotFoundException, OrmException {
|
throws ResourceConflictException, ResourceNotFoundException, OrmException {
|
||||||
PatchSet.Id basePatchSet = null;
|
PatchSet.Id basePatchSet = null;
|
||||||
if (base != null) {
|
if (base != null) {
|
||||||
RevisionResource baseResource = revisions.get().parse(
|
RevisionResource baseResource = revisions.parse(
|
||||||
resource.getRevision().getChangeResource(), IdString.fromDecoded(base));
|
resource.getRevision().getChangeResource(), IdString.fromDecoded(base));
|
||||||
basePatchSet = baseResource.getPatchSet().getId();
|
basePatchSet = baseResource.getPatchSet().getId();
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import com.google.gerrit.server.project.ChangeControl;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
||||||
import org.eclipse.jgit.errors.MissingObjectException;
|
import org.eclipse.jgit.errors.MissingObjectException;
|
||||||
@ -36,6 +37,7 @@ import org.eclipse.jgit.revwalk.RevWalk;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
class IncludedIn implements RestReadView<ChangeResource> {
|
class IncludedIn implements RestReadView<ChangeResource> {
|
||||||
|
|
||||||
private final Provider<ReviewDb> db;
|
private final Provider<ReviewDb> db;
|
||||||
|
@ -20,7 +20,9 @@ import com.google.gerrit.server.account.AccountInfo;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
class ListComments extends ListDrafts {
|
class ListComments extends ListDrafts {
|
||||||
@Inject
|
@Inject
|
||||||
ListComments(Provider<ReviewDb> db, AccountInfo.Loader.Factory alf) {
|
ListComments(Provider<ReviewDb> db, AccountInfo.Loader.Factory alf) {
|
||||||
|
@ -26,12 +26,14 @@ import com.google.gerrit.server.account.AccountInfo;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
class ListDrafts implements RestReadView<RevisionResource> {
|
class ListDrafts implements RestReadView<RevisionResource> {
|
||||||
protected final Provider<ReviewDb> db;
|
protected final Provider<ReviewDb> db;
|
||||||
private final AccountInfo.Loader.Factory accountLoaderFactory;
|
private final AccountInfo.Loader.Factory accountLoaderFactory;
|
||||||
|
@ -23,10 +23,12 @@ import com.google.gerrit.server.change.ReviewerJson.ReviewerInfo;
|
|||||||
import com.google.gwtorm.server.OrmException;
|
import com.google.gwtorm.server.OrmException;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
class ListReviewers implements RestReadView<ChangeResource> {
|
class ListReviewers implements RestReadView<ChangeResource> {
|
||||||
private final Provider<ReviewDb> dbProvider;
|
private final Provider<ReviewDb> dbProvider;
|
||||||
private final ApprovalsUtil approvalsUtil;
|
private final ApprovalsUtil approvalsUtil;
|
||||||
|
@ -79,7 +79,7 @@ public class PostReviewers implements RestModifyView<ChangeResource, AddReviewer
|
|||||||
private final ReviewerResource.Factory reviewerFactory;
|
private final ReviewerResource.Factory reviewerFactory;
|
||||||
private final ApprovalsUtil approvalsUtil;
|
private final ApprovalsUtil approvalsUtil;
|
||||||
private final AddReviewerSender.Factory addReviewerSenderFactory;
|
private final AddReviewerSender.Factory addReviewerSenderFactory;
|
||||||
private final Provider<GroupsCollection> groupsCollection;
|
private final GroupsCollection groupsCollection;
|
||||||
private final GroupMembers.Factory groupMembersFactory;
|
private final GroupMembers.Factory groupMembersFactory;
|
||||||
private final AccountInfo.Loader.Factory accountLoaderFactory;
|
private final AccountInfo.Loader.Factory accountLoaderFactory;
|
||||||
private final Provider<ReviewDb> dbProvider;
|
private final Provider<ReviewDb> dbProvider;
|
||||||
@ -97,7 +97,7 @@ public class PostReviewers implements RestModifyView<ChangeResource, AddReviewer
|
|||||||
ReviewerResource.Factory reviewerFactory,
|
ReviewerResource.Factory reviewerFactory,
|
||||||
ApprovalsUtil approvalsUtil,
|
ApprovalsUtil approvalsUtil,
|
||||||
AddReviewerSender.Factory addReviewerSenderFactory,
|
AddReviewerSender.Factory addReviewerSenderFactory,
|
||||||
Provider<GroupsCollection> groupsCollection,
|
GroupsCollection groupsCollection,
|
||||||
GroupMembers.Factory groupMembersFactory,
|
GroupMembers.Factory groupMembersFactory,
|
||||||
AccountInfo.Loader.Factory accountLoaderFactory,
|
AccountInfo.Loader.Factory accountLoaderFactory,
|
||||||
Provider<ReviewDb> db,
|
Provider<ReviewDb> db,
|
||||||
@ -162,7 +162,7 @@ public class PostReviewers implements RestModifyView<ChangeResource, AddReviewer
|
|||||||
private PostResult putGroup(ChangeResource rsrc, AddReviewerInput input)
|
private PostResult putGroup(ChangeResource rsrc, AddReviewerInput input)
|
||||||
throws BadRequestException,
|
throws BadRequestException,
|
||||||
UnprocessableEntityException, OrmException, EmailException, IOException {
|
UnprocessableEntityException, OrmException, EmailException, IOException {
|
||||||
GroupDescription.Basic group = groupsCollection.get().parseInternal(input.reviewer);
|
GroupDescription.Basic group = groupsCollection.parseInternal(input.reviewer);
|
||||||
PostResult result = new PostResult();
|
PostResult result = new PostResult();
|
||||||
if (!isLegalReviewerGroup(group.getGroupUUID())) {
|
if (!isLegalReviewerGroup(group.getGroupUUID())) {
|
||||||
result.error = MessageFormat.format(
|
result.error = MessageFormat.format(
|
||||||
|
@ -40,7 +40,7 @@ public class Reviewers implements
|
|||||||
private final ApprovalsUtil approvalsUtil;
|
private final ApprovalsUtil approvalsUtil;
|
||||||
private final AccountsCollection accounts;
|
private final AccountsCollection accounts;
|
||||||
private final ReviewerResource.Factory resourceFactory;
|
private final ReviewerResource.Factory resourceFactory;
|
||||||
private final Provider<ListReviewers> list;
|
private final ListReviewers list;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
Reviewers(Provider<ReviewDb> dbProvider,
|
Reviewers(Provider<ReviewDb> dbProvider,
|
||||||
@ -48,7 +48,7 @@ public class Reviewers implements
|
|||||||
AccountsCollection accounts,
|
AccountsCollection accounts,
|
||||||
ReviewerResource.Factory resourceFactory,
|
ReviewerResource.Factory resourceFactory,
|
||||||
DynamicMap<RestView<ReviewerResource>> views,
|
DynamicMap<RestView<ReviewerResource>> views,
|
||||||
Provider<ListReviewers> list) {
|
ListReviewers list) {
|
||||||
this.dbProvider = dbProvider;
|
this.dbProvider = dbProvider;
|
||||||
this.approvalsUtil = approvalsUtil;
|
this.approvalsUtil = approvalsUtil;
|
||||||
this.accounts = accounts;
|
this.accounts = accounts;
|
||||||
@ -64,7 +64,7 @@ public class Reviewers implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RestView<ChangeResource> list() {
|
public RestView<ChangeResource> list() {
|
||||||
return list.get();
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -35,13 +35,13 @@ public class CachesCollection implements
|
|||||||
ChildCollection<ConfigResource, CacheResource> {
|
ChildCollection<ConfigResource, CacheResource> {
|
||||||
|
|
||||||
private final DynamicMap<RestView<CacheResource>> views;
|
private final DynamicMap<RestView<CacheResource>> views;
|
||||||
private final Provider<ListCaches> list;
|
private final ListCaches list;
|
||||||
private final Provider<CurrentUser> self;
|
private final Provider<CurrentUser> self;
|
||||||
private final DynamicMap<Cache<?, ?>> cacheMap;
|
private final DynamicMap<Cache<?, ?>> cacheMap;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
CachesCollection(DynamicMap<RestView<CacheResource>> views,
|
CachesCollection(DynamicMap<RestView<CacheResource>> views,
|
||||||
Provider<ListCaches> list, Provider<CurrentUser> self,
|
ListCaches list, Provider<CurrentUser> self,
|
||||||
DynamicMap<Cache<?, ?>> cacheMap) {
|
DynamicMap<Cache<?, ?>> cacheMap) {
|
||||||
this.views = views;
|
this.views = views;
|
||||||
this.list = list;
|
this.list = list;
|
||||||
@ -51,7 +51,7 @@ public class CachesCollection implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RestView<ConfigResource> list() {
|
public RestView<ConfigResource> list() {
|
||||||
return list.get();
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,25 +20,24 @@ import com.google.gerrit.extensions.restapi.IdString;
|
|||||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||||
import com.google.gerrit.extensions.restapi.RestView;
|
import com.google.gerrit.extensions.restapi.RestView;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class CapabilitiesCollection implements
|
public class CapabilitiesCollection implements
|
||||||
ChildCollection<ConfigResource, CapabilityResource> {
|
ChildCollection<ConfigResource, CapabilityResource> {
|
||||||
private final DynamicMap<RestView<CapabilityResource>> views;
|
private final DynamicMap<RestView<CapabilityResource>> views;
|
||||||
private final Provider<ListCapabilities> list;
|
private final ListCapabilities list;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
CapabilitiesCollection(DynamicMap<RestView<CapabilityResource>> views,
|
CapabilitiesCollection(DynamicMap<RestView<CapabilityResource>> views,
|
||||||
Provider<ListCapabilities> list) {
|
ListCapabilities list) {
|
||||||
this.views = views;
|
this.views = views;
|
||||||
this.list = list;
|
this.list = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RestView<ConfigResource> list() throws ResourceNotFoundException {
|
public RestView<ConfigResource> list() throws ResourceNotFoundException {
|
||||||
return list.get();
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,7 +21,9 @@ import com.google.gerrit.extensions.restapi.RestCollection;
|
|||||||
import com.google.gerrit.extensions.restapi.RestView;
|
import com.google.gerrit.extensions.restapi.RestView;
|
||||||
import com.google.gerrit.extensions.restapi.TopLevelResource;
|
import com.google.gerrit.extensions.restapi.TopLevelResource;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
public class ConfigCollection implements
|
public class ConfigCollection implements
|
||||||
RestCollection<TopLevelResource, ConfigResource> {
|
RestCollection<TopLevelResource, ConfigResource> {
|
||||||
private final DynamicMap<RestView<ConfigResource>> views;
|
private final DynamicMap<RestView<ConfigResource>> views;
|
||||||
|
@ -22,6 +22,7 @@ import com.google.gerrit.extensions.registration.DynamicMap;
|
|||||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -29,6 +30,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/** List capabilities visible to the calling user. */
|
/** List capabilities visible to the calling user. */
|
||||||
|
@Singleton
|
||||||
public class ListCapabilities implements RestReadView<ConfigResource> {
|
public class ListCapabilities implements RestReadView<ConfigResource> {
|
||||||
private static final Logger log = LoggerFactory.getLogger(ListCapabilities.class);
|
private static final Logger log = LoggerFactory.getLogger(ListCapabilities.class);
|
||||||
private final DynamicMap<CapabilityDefinition> pluginCapabilities;
|
private final DynamicMap<CapabilityDefinition> pluginCapabilities;
|
||||||
|
@ -19,9 +19,11 @@ import com.google.gerrit.extensions.registration.DynamicSet;
|
|||||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||||
import com.google.gerrit.extensions.webui.TopMenu;
|
import com.google.gerrit.extensions.webui.TopMenu;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
class ListTopMenus implements RestReadView<ConfigResource> {
|
class ListTopMenus implements RestReadView<ConfigResource> {
|
||||||
private final DynamicSet<TopMenu> extensions;
|
private final DynamicSet<TopMenu> extensions;
|
||||||
|
|
||||||
|
@ -20,25 +20,24 @@ import com.google.gerrit.extensions.restapi.IdString;
|
|||||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||||
import com.google.gerrit.extensions.restapi.RestView;
|
import com.google.gerrit.extensions.restapi.RestView;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class TopMenuCollection implements
|
class TopMenuCollection implements
|
||||||
ChildCollection<ConfigResource, TopMenuResource> {
|
ChildCollection<ConfigResource, TopMenuResource> {
|
||||||
private final DynamicMap<RestView<TopMenuResource>> views;
|
private final DynamicMap<RestView<TopMenuResource>> views;
|
||||||
private final Provider<ListTopMenus> list;
|
private final ListTopMenus list;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
TopMenuCollection(DynamicMap<RestView<TopMenuResource>> views,
|
TopMenuCollection(DynamicMap<RestView<TopMenuResource>> views,
|
||||||
Provider<ListTopMenus> list) {
|
ListTopMenus list) {
|
||||||
this.views = views;
|
this.views = views;
|
||||||
this.list = list;
|
this.list = list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RestView<ConfigResource> list() throws ResourceNotFoundException {
|
public RestView<ConfigResource> list() throws ResourceNotFoundException {
|
||||||
return list.get();
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -31,6 +31,7 @@ import com.google.gerrit.server.project.NoSuchProjectException;
|
|||||||
import com.google.gerrit.server.project.ProjectCache;
|
import com.google.gerrit.server.project.ProjectCache;
|
||||||
import com.google.gerrit.server.project.ProjectState;
|
import com.google.gerrit.server.project.ProjectState;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import org.eclipse.jgit.lib.ObjectInserter;
|
import org.eclipse.jgit.lib.ObjectInserter;
|
||||||
import org.eclipse.jgit.lib.PersonIdent;
|
import org.eclipse.jgit.lib.PersonIdent;
|
||||||
@ -44,6 +45,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/** Factory to create a {@link SubmitStrategy} for a {@link SubmitType}. */
|
/** Factory to create a {@link SubmitStrategy} for a {@link SubmitType}. */
|
||||||
|
@Singleton
|
||||||
public class SubmitStrategyFactory {
|
public class SubmitStrategyFactory {
|
||||||
private static final Logger log = LoggerFactory
|
private static final Logger log = LoggerFactory
|
||||||
.getLogger(SubmitStrategyFactory.class);
|
.getLogger(SubmitStrategyFactory.class);
|
||||||
|
@ -71,13 +71,13 @@ public class AddIncludedGroups implements RestModifyView<GroupResource, Input> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Provider<GroupsCollection> groupsCollection;
|
private final GroupsCollection groupsCollection;
|
||||||
private final GroupIncludeCache groupIncludeCache;
|
private final GroupIncludeCache groupIncludeCache;
|
||||||
private final Provider<ReviewDb> db;
|
private final Provider<ReviewDb> db;
|
||||||
private final GroupJson json;
|
private final GroupJson json;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public AddIncludedGroups(Provider<GroupsCollection> groupsCollection,
|
public AddIncludedGroups(GroupsCollection groupsCollection,
|
||||||
GroupIncludeCache groupIncludeCache,
|
GroupIncludeCache groupIncludeCache,
|
||||||
Provider<ReviewDb> db, GroupJson json) {
|
Provider<ReviewDb> db, GroupJson json) {
|
||||||
this.groupsCollection = groupsCollection;
|
this.groupsCollection = groupsCollection;
|
||||||
@ -103,7 +103,7 @@ public class AddIncludedGroups implements RestModifyView<GroupResource, Input> {
|
|||||||
Account.Id me = ((IdentifiedUser) control.getCurrentUser()).getAccountId();
|
Account.Id me = ((IdentifiedUser) control.getCurrentUser()).getAccountId();
|
||||||
|
|
||||||
for (String includedGroup : input.groups) {
|
for (String includedGroup : input.groups) {
|
||||||
GroupDescription.Basic d = groupsCollection.get().parse(includedGroup);
|
GroupDescription.Basic d = groupsCollection.parse(includedGroup);
|
||||||
if (!control.canAddGroup(d.getGroupUUID())) {
|
if (!control.canAddGroup(d.getGroupUUID())) {
|
||||||
throw new AuthException(String.format("Cannot add group: %s",
|
throw new AuthException(String.format("Cannot add group: %s",
|
||||||
d.getName()));
|
d.getName()));
|
||||||
@ -140,10 +140,10 @@ public class AddIncludedGroups implements RestModifyView<GroupResource, Input> {
|
|||||||
static class Input {
|
static class Input {
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Provider<AddIncludedGroups> put;
|
private final AddIncludedGroups put;
|
||||||
private final String id;
|
private final String id;
|
||||||
|
|
||||||
PutIncludedGroup(Provider<AddIncludedGroups> put, String id) {
|
PutIncludedGroup(AddIncludedGroups put, String id) {
|
||||||
this.put = put;
|
this.put = put;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
@ -154,7 +154,7 @@ public class AddIncludedGroups implements RestModifyView<GroupResource, Input> {
|
|||||||
UnprocessableEntityException, OrmException {
|
UnprocessableEntityException, OrmException {
|
||||||
AddIncludedGroups.Input in = new AddIncludedGroups.Input();
|
AddIncludedGroups.Input in = new AddIncludedGroups.Input();
|
||||||
in.groups = ImmutableList.of(id);
|
in.groups = ImmutableList.of(id);
|
||||||
List<GroupInfo> list = put.get().apply(resource, in);
|
List<GroupInfo> list = put.apply(resource, in);
|
||||||
if (list.size() == 1) {
|
if (list.size() == 1) {
|
||||||
return list.get(0);
|
return list.get(0);
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
|
|||||||
|
|
||||||
private final AccountManager accountManager;
|
private final AccountManager accountManager;
|
||||||
private final AuthType authType;
|
private final AuthType authType;
|
||||||
private final Provider<AccountsCollection> accounts;
|
private final AccountsCollection accounts;
|
||||||
private final AccountResolver accountResolver;
|
private final AccountResolver accountResolver;
|
||||||
private final AccountCache accountCache;
|
private final AccountCache accountCache;
|
||||||
private final AccountInfo.Loader.Factory infoFactory;
|
private final AccountInfo.Loader.Factory infoFactory;
|
||||||
@ -86,7 +86,7 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
|
|||||||
@Inject
|
@Inject
|
||||||
AddMembers(AccountManager accountManager,
|
AddMembers(AccountManager accountManager,
|
||||||
AuthConfig authConfig,
|
AuthConfig authConfig,
|
||||||
Provider<AccountsCollection> accounts,
|
AccountsCollection accounts,
|
||||||
AccountResolver accountResolver,
|
AccountResolver accountResolver,
|
||||||
AccountCache accountCache,
|
AccountCache accountCache,
|
||||||
AccountInfo.Loader.Factory infoFactory,
|
AccountInfo.Loader.Factory infoFactory,
|
||||||
@ -155,7 +155,7 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
|
|||||||
private Account findAccount(String nameOrEmail) throws AuthException,
|
private Account findAccount(String nameOrEmail) throws AuthException,
|
||||||
UnprocessableEntityException, OrmException {
|
UnprocessableEntityException, OrmException {
|
||||||
try {
|
try {
|
||||||
return accounts.get().parse(nameOrEmail).getAccount();
|
return accounts.parse(nameOrEmail).getAccount();
|
||||||
} catch (UnprocessableEntityException e) {
|
} catch (UnprocessableEntityException e) {
|
||||||
// might be because the account does not exist or because the account is
|
// might be because the account does not exist or because the account is
|
||||||
// not visible
|
// not visible
|
||||||
@ -193,10 +193,10 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
|
|||||||
static class Input {
|
static class Input {
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Provider<AddMembers> put;
|
private final AddMembers put;
|
||||||
private final String id;
|
private final String id;
|
||||||
|
|
||||||
PutMember(Provider<AddMembers> put, String id) {
|
PutMember(AddMembers put, String id) {
|
||||||
this.put = put;
|
this.put = put;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
@ -207,7 +207,7 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
|
|||||||
UnprocessableEntityException, OrmException {
|
UnprocessableEntityException, OrmException {
|
||||||
AddMembers.Input in = new AddMembers.Input();
|
AddMembers.Input in = new AddMembers.Input();
|
||||||
in._oneMember = id;
|
in._oneMember = id;
|
||||||
List<AccountInfo> list = put.get().apply(resource, in);
|
List<AccountInfo> list = put.apply(resource, in);
|
||||||
if (list.size() == 1) {
|
if (list.size() == 1) {
|
||||||
return list.get(0);
|
return list.get(0);
|
||||||
}
|
}
|
||||||
@ -220,10 +220,10 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
|
|||||||
static class Input {
|
static class Input {
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Provider<GetMember> get;
|
private final GetMember get;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
UpdateMember(Provider<GetMember> get) {
|
UpdateMember(GetMember get) {
|
||||||
this.get = get;
|
this.get = get;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,7 +231,7 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
|
|||||||
public AccountInfo apply(MemberResource resource, PutMember.Input input)
|
public AccountInfo apply(MemberResource resource, PutMember.Input input)
|
||||||
throws OrmException {
|
throws OrmException {
|
||||||
// Do nothing, the user is already a member.
|
// Do nothing, the user is already a member.
|
||||||
return get.get().apply(resource);
|
return get.apply(resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,13 +44,13 @@ import java.util.Map;
|
|||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class DeleteIncludedGroups implements RestModifyView<GroupResource, Input> {
|
public class DeleteIncludedGroups implements RestModifyView<GroupResource, Input> {
|
||||||
private final Provider<GroupsCollection> groupsCollection;
|
private final GroupsCollection groupsCollection;
|
||||||
private final GroupIncludeCache groupIncludeCache;
|
private final GroupIncludeCache groupIncludeCache;
|
||||||
private final Provider<ReviewDb> db;
|
private final Provider<ReviewDb> db;
|
||||||
private final Provider<CurrentUser> self;
|
private final Provider<CurrentUser> self;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
DeleteIncludedGroups(Provider<GroupsCollection> groupsCollection,
|
DeleteIncludedGroups(GroupsCollection groupsCollection,
|
||||||
GroupIncludeCache groupIncludeCache,
|
GroupIncludeCache groupIncludeCache,
|
||||||
Provider<ReviewDb> db,
|
Provider<ReviewDb> db,
|
||||||
Provider<CurrentUser> self) {
|
Provider<CurrentUser> self) {
|
||||||
@ -75,7 +75,7 @@ public class DeleteIncludedGroups implements RestModifyView<GroupResource, Input
|
|||||||
final List<AccountGroupById> toRemove = Lists.newLinkedList();
|
final List<AccountGroupById> toRemove = Lists.newLinkedList();
|
||||||
|
|
||||||
for (final String includedGroup : input.groups) {
|
for (final String includedGroup : input.groups) {
|
||||||
GroupDescription.Basic d = groupsCollection.get().parse(includedGroup);
|
GroupDescription.Basic d = groupsCollection.parse(includedGroup);
|
||||||
if (!control.canRemoveGroup(d.getGroupUUID())) {
|
if (!control.canRemoveGroup(d.getGroupUUID())) {
|
||||||
throw new AuthException(String.format("Cannot delete group: %s",
|
throw new AuthException(String.format("Cannot delete group: %s",
|
||||||
d.getName()));
|
d.getName()));
|
||||||
|
@ -43,13 +43,13 @@ import java.util.Map;
|
|||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class DeleteMembers implements RestModifyView<GroupResource, Input> {
|
public class DeleteMembers implements RestModifyView<GroupResource, Input> {
|
||||||
private final Provider<AccountsCollection> accounts;
|
private final AccountsCollection accounts;
|
||||||
private final AccountCache accountCache;
|
private final AccountCache accountCache;
|
||||||
private final Provider<ReviewDb> db;
|
private final Provider<ReviewDb> db;
|
||||||
private final Provider<CurrentUser> self;
|
private final Provider<CurrentUser> self;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
DeleteMembers(Provider<AccountsCollection> accounts,
|
DeleteMembers(AccountsCollection accounts,
|
||||||
AccountCache accountCache, Provider<ReviewDb> db,
|
AccountCache accountCache, Provider<ReviewDb> db,
|
||||||
Provider<CurrentUser> self) {
|
Provider<CurrentUser> self) {
|
||||||
this.accounts = accounts;
|
this.accounts = accounts;
|
||||||
@ -73,7 +73,7 @@ public class DeleteMembers implements RestModifyView<GroupResource, Input> {
|
|||||||
final List<AccountGroupMember> toRemove = Lists.newLinkedList();
|
final List<AccountGroupMember> toRemove = Lists.newLinkedList();
|
||||||
|
|
||||||
for (final String nameOrEmail : input.members) {
|
for (final String nameOrEmail : input.members) {
|
||||||
Account a = accounts.get().parse(nameOrEmail).getAccount();
|
Account a = accounts.parse(nameOrEmail).getAccount();
|
||||||
|
|
||||||
if (!control.canRemoveMember(a.getId())) {
|
if (!control.canRemoveMember(a.getId())) {
|
||||||
throw new AuthException("Cannot delete member: " + a.getFullName());
|
throw new AuthException("Cannot delete member: " + a.getFullName());
|
||||||
|
@ -38,16 +38,17 @@ public class IncludedGroupsCollection implements
|
|||||||
ChildCollection<GroupResource, IncludedGroupResource>,
|
ChildCollection<GroupResource, IncludedGroupResource>,
|
||||||
AcceptsCreate<GroupResource> {
|
AcceptsCreate<GroupResource> {
|
||||||
private final DynamicMap<RestView<IncludedGroupResource>> views;
|
private final DynamicMap<RestView<IncludedGroupResource>> views;
|
||||||
private final Provider<ListIncludedGroups> list;
|
private final ListIncludedGroups list;
|
||||||
private final Provider<GroupsCollection> groupsCollection;
|
private final GroupsCollection groupsCollection;
|
||||||
private final Provider<ReviewDb> dbProvider;
|
private final Provider<ReviewDb> dbProvider;
|
||||||
private final Provider<AddIncludedGroups> put;
|
private final AddIncludedGroups put;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
IncludedGroupsCollection(DynamicMap<RestView<IncludedGroupResource>> views,
|
IncludedGroupsCollection(DynamicMap<RestView<IncludedGroupResource>> views,
|
||||||
Provider<ListIncludedGroups> list,
|
ListIncludedGroups list,
|
||||||
Provider<GroupsCollection> groupsCollection,
|
GroupsCollection groupsCollection,
|
||||||
Provider<ReviewDb> dbProvider, Provider<AddIncludedGroups> put) {
|
Provider<ReviewDb> dbProvider,
|
||||||
|
AddIncludedGroups put) {
|
||||||
this.views = views;
|
this.views = views;
|
||||||
this.list = list;
|
this.list = list;
|
||||||
this.groupsCollection = groupsCollection;
|
this.groupsCollection = groupsCollection;
|
||||||
@ -57,7 +58,7 @@ public class IncludedGroupsCollection implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RestView<GroupResource> list() {
|
public RestView<GroupResource> list() {
|
||||||
return list.get();
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -70,7 +71,7 @@ public class IncludedGroupsCollection implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
GroupDescription.Basic member =
|
GroupDescription.Basic member =
|
||||||
groupsCollection.get().parse(TopLevelResource.INSTANCE, id).getGroup();
|
groupsCollection.parse(TopLevelResource.INSTANCE, id).getGroup();
|
||||||
if (isMember(parent, member)
|
if (isMember(parent, member)
|
||||||
&& resource.getControl().canSeeGroup(member.getGroupUUID())) {
|
&& resource.getControl().canSeeGroup(member.getGroupUUID())) {
|
||||||
return new IncludedGroupResource(resource, member);
|
return new IncludedGroupResource(resource, member);
|
||||||
|
@ -39,16 +39,16 @@ public class MembersCollection implements
|
|||||||
AcceptsCreate<GroupResource> {
|
AcceptsCreate<GroupResource> {
|
||||||
private final DynamicMap<RestView<MemberResource>> views;
|
private final DynamicMap<RestView<MemberResource>> views;
|
||||||
private final Provider<ListMembers> list;
|
private final Provider<ListMembers> list;
|
||||||
private final Provider<AccountsCollection> accounts;
|
private final AccountsCollection accounts;
|
||||||
private final Provider<ReviewDb> db;
|
private final Provider<ReviewDb> db;
|
||||||
private final Provider<AddMembers> put;
|
private final AddMembers put;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
MembersCollection(DynamicMap<RestView<MemberResource>> views,
|
MembersCollection(DynamicMap<RestView<MemberResource>> views,
|
||||||
Provider<ListMembers> list,
|
Provider<ListMembers> list,
|
||||||
Provider<AccountsCollection> accounts,
|
AccountsCollection accounts,
|
||||||
Provider<ReviewDb> db,
|
Provider<ReviewDb> db,
|
||||||
Provider<AddMembers> put) {
|
AddMembers put) {
|
||||||
this.views = views;
|
this.views = views;
|
||||||
this.list = list;
|
this.list = list;
|
||||||
this.accounts = accounts;
|
this.accounts = accounts;
|
||||||
@ -70,7 +70,7 @@ public class MembersCollection implements
|
|||||||
throw new MethodNotAllowedException();
|
throw new MethodNotAllowedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
IdentifiedUser user = accounts.get().parse(TopLevelResource.INSTANCE, id).getUser();
|
IdentifiedUser user = accounts.parse(TopLevelResource.INSTANCE, id).getUser();
|
||||||
AccountGroupMember.Key key =
|
AccountGroupMember.Key key =
|
||||||
new AccountGroupMember.Key(user.getAccountId(), parent.toAccountGroup().getId());
|
new AccountGroupMember.Key(user.getAccountId(), parent.toAccountGroup().getId());
|
||||||
if (db.get().accountGroupMembers().get(key) != null
|
if (db.get().accountGroupMembers().get(key) != null
|
||||||
|
@ -42,13 +42,13 @@ public class PutOwner implements RestModifyView<GroupResource, Input> {
|
|||||||
public String owner;
|
public String owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Provider<GroupsCollection> groupsCollection;
|
private final GroupsCollection groupsCollection;
|
||||||
private final GroupCache groupCache;
|
private final GroupCache groupCache;
|
||||||
private final Provider<ReviewDb> db;
|
private final Provider<ReviewDb> db;
|
||||||
private final GroupJson json;
|
private final GroupJson json;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
PutOwner(Provider<GroupsCollection> groupsCollection, GroupCache groupCache,
|
PutOwner(GroupsCollection groupsCollection, GroupCache groupCache,
|
||||||
Provider<ReviewDb> db, GroupJson json) {
|
Provider<ReviewDb> db, GroupJson json) {
|
||||||
this.groupsCollection = groupsCollection;
|
this.groupsCollection = groupsCollection;
|
||||||
this.groupCache = groupCache;
|
this.groupCache = groupCache;
|
||||||
@ -77,7 +77,7 @@ public class PutOwner implements RestModifyView<GroupResource, Input> {
|
|||||||
throw new ResourceNotFoundException();
|
throw new ResourceNotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
GroupDescription.Basic owner = groupsCollection.get().parse(input.owner);
|
GroupDescription.Basic owner = groupsCollection.parse(input.owner);
|
||||||
if (!group.getOwnerGroupUUID().equals(owner.getGroupUUID())) {
|
if (!group.getOwnerGroupUUID().equals(owner.getGroupUUID())) {
|
||||||
group.setOwnerGroupUUID(owner.getGroupUUID());
|
group.setOwnerGroupUUID(owner.getGroupUUID());
|
||||||
db.get().accountGroups().update(Collections.singleton(group));
|
db.get().accountGroups().update(Collections.singleton(group));
|
||||||
|
@ -21,6 +21,7 @@ import com.google.gwtjsonrpc.server.ValidToken;
|
|||||||
import com.google.gwtjsonrpc.server.XsrfException;
|
import com.google.gwtjsonrpc.server.XsrfException;
|
||||||
import com.google.inject.AbstractModule;
|
import com.google.inject.AbstractModule;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import org.eclipse.jgit.util.Base64;
|
import org.eclipse.jgit.util.Base64;
|
||||||
|
|
||||||
@ -29,6 +30,7 @@ import java.util.regex.Matcher;
|
|||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/** Verifies the token sent by {@link RegisterNewEmailSender}. */
|
/** Verifies the token sent by {@link RegisterNewEmailSender}. */
|
||||||
|
@Singleton
|
||||||
public class SignedTokenEmailTokenVerifier implements EmailTokenVerifier {
|
public class SignedTokenEmailTokenVerifier implements EmailTokenVerifier {
|
||||||
private final SignedToken emailRegistrationToken;
|
private final SignedToken emailRegistrationToken;
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
|||||||
import com.google.gerrit.extensions.restapi.RestView;
|
import com.google.gerrit.extensions.restapi.RestView;
|
||||||
import com.google.gerrit.server.project.ListBranches.BranchInfo;
|
import com.google.gerrit.server.project.ListBranches.BranchInfo;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provider;
|
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import org.eclipse.jgit.lib.Constants;
|
import org.eclipse.jgit.lib.Constants;
|
||||||
@ -35,12 +34,12 @@ public class BranchesCollection implements
|
|||||||
ChildCollection<ProjectResource, BranchResource>,
|
ChildCollection<ProjectResource, BranchResource>,
|
||||||
AcceptsCreate<ProjectResource> {
|
AcceptsCreate<ProjectResource> {
|
||||||
private final DynamicMap<RestView<BranchResource>> views;
|
private final DynamicMap<RestView<BranchResource>> views;
|
||||||
private final Provider<ListBranches> list;
|
private final ListBranches list;
|
||||||
private final CreateBranch.Factory createBranchFactory;
|
private final CreateBranch.Factory createBranchFactory;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
BranchesCollection(DynamicMap<RestView<BranchResource>> views,
|
BranchesCollection(DynamicMap<RestView<BranchResource>> views,
|
||||||
Provider<ListBranches> list, CreateBranch.Factory createBranchFactory) {
|
ListBranches list, CreateBranch.Factory createBranchFactory) {
|
||||||
this.views = views;
|
this.views = views;
|
||||||
this.list = list;
|
this.list = list;
|
||||||
this.createBranchFactory = createBranchFactory;
|
this.createBranchFactory = createBranchFactory;
|
||||||
@ -48,7 +47,7 @@ public class BranchesCollection implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RestView<ProjectResource> list() {
|
public RestView<ProjectResource> list() {
|
||||||
return list.get();
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -59,7 +58,7 @@ public class BranchesCollection implements
|
|||||||
&& !branchName.equals(Constants.HEAD)) {
|
&& !branchName.equals(Constants.HEAD)) {
|
||||||
branchName = Constants.R_HEADS + branchName;
|
branchName = Constants.R_HEADS + branchName;
|
||||||
}
|
}
|
||||||
List<BranchInfo> branches = list.get().apply(parent);
|
List<BranchInfo> branches = list.apply(parent);
|
||||||
for (BranchInfo b : branches) {
|
for (BranchInfo b : branches) {
|
||||||
if (branchName.equals(b.ref)) {
|
if (branchName.equals(b.ref)) {
|
||||||
return new BranchResource(parent.getControl(), b);
|
return new BranchResource(parent.getControl(), b);
|
||||||
|
@ -31,12 +31,12 @@ import java.io.IOException;
|
|||||||
public class ChildProjectsCollection implements
|
public class ChildProjectsCollection implements
|
||||||
ChildCollection<ProjectResource, ChildProjectResource> {
|
ChildCollection<ProjectResource, ChildProjectResource> {
|
||||||
private final Provider<ListChildProjects> list;
|
private final Provider<ListChildProjects> list;
|
||||||
private final Provider<ProjectsCollection> projectsCollection;
|
private final ProjectsCollection projectsCollection;
|
||||||
private final DynamicMap<RestView<ChildProjectResource>> views;
|
private final DynamicMap<RestView<ChildProjectResource>> views;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ChildProjectsCollection(Provider<ListChildProjects> list,
|
ChildProjectsCollection(Provider<ListChildProjects> list,
|
||||||
Provider<ProjectsCollection> projectsCollection,
|
ProjectsCollection projectsCollection,
|
||||||
DynamicMap<RestView<ChildProjectResource>> views) {
|
DynamicMap<RestView<ChildProjectResource>> views) {
|
||||||
this.list = list;
|
this.list = list;
|
||||||
this.projectsCollection = projectsCollection;
|
this.projectsCollection = projectsCollection;
|
||||||
@ -53,7 +53,7 @@ public class ChildProjectsCollection implements
|
|||||||
public ChildProjectResource parse(ProjectResource parent, IdString id)
|
public ChildProjectResource parse(ProjectResource parent, IdString id)
|
||||||
throws ResourceNotFoundException, IOException {
|
throws ResourceNotFoundException, IOException {
|
||||||
ProjectResource p =
|
ProjectResource p =
|
||||||
projectsCollection.get().parse(TopLevelResource.INSTANCE, id);
|
projectsCollection.parse(TopLevelResource.INSTANCE, id);
|
||||||
for (ProjectState pp : p.getControl().getProjectState().parents()) {
|
for (ProjectState pp : p.getControl().getProjectState().parents()) {
|
||||||
if (parent.getNameKey().equals(pp.getProject().getNameKey())) {
|
if (parent.getNameKey().equals(pp.getProject().getNameKey())) {
|
||||||
return new ChildProjectResource(parent, p.getControl());
|
return new ChildProjectResource(parent, p.getControl());
|
||||||
|
Loading…
Reference in New Issue
Block a user