Move REST endpoints to singleton scope
The majority of REST endpoints don't maintain state and don't need to be created each time they are used. Exceptions are endpoints with @Option annotation and therefore must stay in default scope. Change-Id: Ia2ac8cfccf41966daa48334cedcb7a20101474d2
This commit is contained in:

committed by
Shawn Pearce

parent
f10c28adc7
commit
75f1583de0
@@ -22,7 +22,9 @@ import com.google.gerrit.extensions.restapi.RestView;
|
||||
import com.google.gerrit.extensions.restapi.TopLevelResource;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class AccessCollection implements
|
||||
RestCollection<TopLevelResource, AccessResource> {
|
||||
private final Provider<ListAccess> list;
|
||||
|
@@ -30,7 +30,9 @@ import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class AccountsCollection implements
|
||||
RestCollection<TopLevelResource, AccountResource>,
|
||||
AcceptsCreate<TopLevelResource>{
|
||||
|
@@ -35,11 +35,13 @@ import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gwtorm.server.ResultSet;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Collections;
|
||||
|
||||
@Singleton
|
||||
public class AddSshKey implements RestModifyView<AccountResource, Input> {
|
||||
public static class Input {
|
||||
public RawInput raw;
|
||||
|
@@ -25,7 +25,9 @@ import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.account.AccountResource.Capability;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
class Capabilities implements
|
||||
ChildCollection<AccountResource, AccountResource.Capability> {
|
||||
private final Provider<CurrentUser> self;
|
||||
|
@@ -25,10 +25,12 @@ import com.google.gerrit.server.account.DeleteActive.Input;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
|
||||
@Singleton
|
||||
public class DeleteActive implements RestModifyView<AccountResource, Input> {
|
||||
public static class Input {
|
||||
}
|
||||
|
@@ -29,7 +29,9 @@ import com.google.gerrit.server.account.DeleteEmail.Input;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class DeleteEmail implements RestModifyView<AccountResource.Email, Input> {
|
||||
public static class Input {
|
||||
}
|
||||
|
@@ -22,9 +22,11 @@ import com.google.gerrit.server.ssh.SshKeyCache;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@Singleton
|
||||
public class DeleteSshKey implements
|
||||
RestModifyView<AccountResource.SshKey, Input> {
|
||||
public static class Input {
|
||||
|
@@ -25,7 +25,9 @@ import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.account.AccountResource.Email;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class Emails implements
|
||||
ChildCollection<AccountResource, AccountResource.Email>,
|
||||
AcceptsCreate<AccountResource> {
|
||||
|
@@ -17,7 +17,9 @@ package com.google.gerrit.server.account;
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class GetAccount implements RestReadView<AccountResource> {
|
||||
private final AccountInfo.Loader.Factory infoFactory;
|
||||
|
||||
|
@@ -17,7 +17,9 @@ package com.google.gerrit.server.account;
|
||||
import com.google.gerrit.extensions.restapi.BinaryResult;
|
||||
import com.google.gerrit.extensions.restapi.Response;
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class GetActive implements RestReadView<AccountResource> {
|
||||
@Override
|
||||
public Object apply(AccountResource rsrc) {
|
||||
|
@@ -20,7 +20,9 @@ import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.server.avatar.AvatarProvider;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class GetAvatarChangeUrl implements RestReadView<AccountResource> {
|
||||
private final DynamicItem<AvatarProvider> avatarProvider;
|
||||
|
||||
|
@@ -48,6 +48,7 @@ import com.google.gerrit.server.git.QueueProvider;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.kohsuke.args4j.Option;
|
||||
|
||||
@@ -178,6 +179,7 @@ class GetCapabilities implements RestReadView<AccountResource> {
|
||||
}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
static class CheckOne implements RestReadView<AccountResource.Capability> {
|
||||
@Override
|
||||
public BinaryResult apply(Capability resource) {
|
||||
|
@@ -25,7 +25,9 @@ import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class GetDiffPreferences implements RestReadView<AccountResource> {
|
||||
private final Provider<CurrentUser> self;
|
||||
private final Provider<ReviewDb> db;
|
||||
|
@@ -16,7 +16,9 @@ package com.google.gerrit.server.account;
|
||||
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.server.account.GetEmails.EmailInfo;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class GetEmail implements RestReadView<AccountResource.Email> {
|
||||
@Override
|
||||
public EmailInfo apply(AccountResource.Email rsrc) {
|
||||
|
@@ -24,9 +24,11 @@ import com.google.gerrit.server.group.GroupJson;
|
||||
import com.google.gerrit.server.group.GroupJson.GroupInfo;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class GetGroups implements RestReadView<AccountResource> {
|
||||
private final GroupControl.Factory groupControlFactory;
|
||||
private final GroupJson json;
|
||||
|
@@ -20,7 +20,9 @@ import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class GetHttpPassword implements RestReadView<AccountResource> {
|
||||
|
||||
private final Provider<CurrentUser> self;
|
||||
|
@@ -16,7 +16,9 @@ package com.google.gerrit.server.account;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class GetName implements RestReadView<AccountResource> {
|
||||
@Override
|
||||
public String apply(AccountResource rsrc) {
|
||||
|
@@ -35,6 +35,7 @@ import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
@@ -46,6 +47,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class GetPreferences implements RestReadView<AccountResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(GetPreferences.class);
|
||||
|
||||
|
@@ -17,7 +17,9 @@ package com.google.gerrit.server.account;
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.server.account.AccountResource.SshKey;
|
||||
import com.google.gerrit.server.account.GetSshKeys.SshKeyInfo;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class GetSshKey implements RestReadView<AccountResource.SshKey> {
|
||||
|
||||
@Override
|
||||
|
@@ -20,7 +20,9 @@ import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class GetUsername implements RestReadView<AccountResource> {
|
||||
|
||||
private final Provider<CurrentUser> self;
|
||||
|
@@ -17,7 +17,9 @@ package com.google.gerrit.server.account;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||
import com.google.gerrit.server.account.CreateAccount.Input;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class PutAccount implements RestModifyView<AccountResource, Input> {
|
||||
@Override
|
||||
public Object apply(AccountResource resource, Input input)
|
||||
|
@@ -25,10 +25,12 @@ import com.google.gerrit.server.account.PutActive.Input;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
|
||||
@Singleton
|
||||
public class PutActive implements RestModifyView<AccountResource, Input> {
|
||||
public static class Input {
|
||||
}
|
||||
|
@@ -18,7 +18,9 @@ import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.extensions.restapi.Response;
|
||||
import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||
import com.google.gerrit.server.account.CreateEmail.Input;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class PutEmail implements RestModifyView<AccountResource.Email, Input> {
|
||||
@Override
|
||||
public Response<?> apply(AccountResource.Email rsrc, Input input)
|
||||
|
@@ -30,6 +30,7 @@ import com.google.gerrit.server.account.PutHttpPassword.Input;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
|
||||
@@ -37,6 +38,7 @@ import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Collections;
|
||||
|
||||
@Singleton
|
||||
public class PutHttpPassword implements RestModifyView<AccountResource, Input> {
|
||||
public static class Input {
|
||||
public String httpPassword;
|
||||
|
@@ -34,9 +34,11 @@ import com.google.gerrit.server.auth.ldap.LdapRealm;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@Singleton
|
||||
public class PutName implements RestModifyView<AccountResource, Input> {
|
||||
public static class Input {
|
||||
@DefaultInput
|
||||
|
@@ -26,9 +26,11 @@ import com.google.gerrit.server.account.PutPreferred.Input;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@Singleton
|
||||
public class PutPreferred implements
|
||||
RestModifyView<AccountResource.Email, Input> {
|
||||
static class Input {
|
||||
|
@@ -27,9 +27,11 @@ import com.google.gerrit.server.account.SetDiffPreferences.Input;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@Singleton
|
||||
public class SetDiffPreferences implements RestModifyView<AccountResource, Input> {
|
||||
static class Input {
|
||||
Short context;
|
||||
@@ -54,10 +56,10 @@ public class SetDiffPreferences implements RestModifyView<AccountResource, Input
|
||||
}
|
||||
|
||||
private final Provider<CurrentUser> self;
|
||||
private final ReviewDb db;
|
||||
private final Provider<ReviewDb> db;
|
||||
|
||||
@Inject
|
||||
SetDiffPreferences(Provider<CurrentUser> self, ReviewDb db) {
|
||||
SetDiffPreferences(Provider<CurrentUser> self, Provider<ReviewDb> db) {
|
||||
this.self = self;
|
||||
this.db = db;
|
||||
}
|
||||
@@ -76,9 +78,9 @@ public class SetDiffPreferences implements RestModifyView<AccountResource, Input
|
||||
Account.Id accountId = rsrc.getUser().getAccountId();
|
||||
AccountDiffPreference p;
|
||||
|
||||
db.accounts().beginTransaction(accountId);
|
||||
db.get().accounts().beginTransaction(accountId);
|
||||
try {
|
||||
p = db.accountDiffPreferences().get(accountId);
|
||||
p = db.get().accountDiffPreferences().get(accountId);
|
||||
if (p == null) {
|
||||
p = new AccountDiffPreference(accountId);
|
||||
}
|
||||
@@ -141,10 +143,10 @@ public class SetDiffPreferences implements RestModifyView<AccountResource, Input
|
||||
p.setHideEmptyPane(input.hideEmptyPane);
|
||||
}
|
||||
|
||||
db.accountDiffPreferences().upsert(Collections.singleton(p));
|
||||
db.commit();
|
||||
db.get().accountDiffPreferences().upsert(Collections.singleton(p));
|
||||
db.get().commit();
|
||||
} finally {
|
||||
db.rollback();
|
||||
db.get().rollback();
|
||||
}
|
||||
return DiffPreferencesInfo.parse(p);
|
||||
}
|
||||
|
@@ -41,6 +41,7 @@ import com.google.gerrit.server.git.MetaDataUpdate;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
@@ -49,6 +50,7 @@ import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class SetPreferences implements RestModifyView<AccountResource, Input> {
|
||||
public static class Input {
|
||||
public Short changesPerPage;
|
||||
@@ -72,13 +74,14 @@ public class SetPreferences implements RestModifyView<AccountResource, Input> {
|
||||
|
||||
private final Provider<CurrentUser> self;
|
||||
private final AccountCache cache;
|
||||
private final ReviewDb db;
|
||||
private final Provider<ReviewDb> db;
|
||||
private final MetaDataUpdate.User metaDataUpdateFactory;
|
||||
private final AllUsersName allUsersName;
|
||||
|
||||
@Inject
|
||||
SetPreferences(Provider<CurrentUser> self, AccountCache cache, ReviewDb db,
|
||||
MetaDataUpdate.User metaDataUpdateFactory, AllUsersName allUsersName) {
|
||||
SetPreferences(Provider<CurrentUser> self, AccountCache cache,
|
||||
Provider<ReviewDb> db, MetaDataUpdate.User metaDataUpdateFactory,
|
||||
AllUsersName allUsersName) {
|
||||
this.self = self;
|
||||
this.cache = cache;
|
||||
this.db = db;
|
||||
@@ -102,9 +105,9 @@ public class SetPreferences implements RestModifyView<AccountResource, Input> {
|
||||
AccountGeneralPreferences p;
|
||||
VersionedAccountPreferences versionedPrefs;
|
||||
MetaDataUpdate md = metaDataUpdateFactory.create(allUsersName);
|
||||
db.accounts().beginTransaction(accountId);
|
||||
db.get().accounts().beginTransaction(accountId);
|
||||
try {
|
||||
Account a = db.accounts().get(accountId);
|
||||
Account a = db.get().accounts().get(accountId);
|
||||
if (a == null) {
|
||||
throw new ResourceNotFoundException();
|
||||
}
|
||||
@@ -167,8 +170,8 @@ public class SetPreferences implements RestModifyView<AccountResource, Input> {
|
||||
p.setChangeScreen(i.changeScreen);
|
||||
}
|
||||
|
||||
db.accounts().update(Collections.singleton(a));
|
||||
db.commit();
|
||||
db.get().accounts().update(Collections.singleton(a));
|
||||
db.get().commit();
|
||||
storeMyMenus(versionedPrefs, i.my);
|
||||
versionedPrefs.commit(md);
|
||||
cache.evict(accountId);
|
||||
@@ -177,7 +180,7 @@ public class SetPreferences implements RestModifyView<AccountResource, Input> {
|
||||
md.getRepository());
|
||||
} finally {
|
||||
md.close();
|
||||
db.rollback();
|
||||
db.get().rollback();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -26,7 +26,9 @@ import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class SshKeys implements
|
||||
ChildCollection<AccountResource, AccountResource.SshKey> {
|
||||
private final DynamicMap<RestView<AccountResource.SshKey>> views;
|
||||
|
@@ -38,12 +38,14 @@ import com.google.gwtorm.server.OrmDuplicateKeyException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@Singleton
|
||||
public class StarredChanges implements
|
||||
ChildCollection<AccountResource, AccountResource.StarredChange>,
|
||||
AcceptsCreate<AccountResource> {
|
||||
@@ -112,6 +114,7 @@ public class StarredChanges implements
|
||||
}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class Create implements RestModifyView<AccountResource, EmptyInput> {
|
||||
private final Provider<CurrentUser> self;
|
||||
private final Provider<ReviewDb> dbProvider;
|
||||
@@ -146,6 +149,7 @@ public class StarredChanges implements
|
||||
}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
static class Put implements
|
||||
RestModifyView<AccountResource.StarredChange, EmptyInput> {
|
||||
private final Provider<CurrentUser> self;
|
||||
@@ -165,6 +169,7 @@ public class StarredChanges implements
|
||||
}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
public static class Delete implements
|
||||
RestModifyView<AccountResource.StarredChange, EmptyInput> {
|
||||
private final Provider<CurrentUser> self;
|
||||
|
@@ -20,7 +20,9 @@ import com.google.gerrit.extensions.api.changes.Changes;
|
||||
import com.google.gerrit.extensions.api.projects.Projects;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
class GerritApiImpl extends GerritApi.NotImplemented implements GerritApi {
|
||||
private final Provider<Accounts> accounts;
|
||||
private final Provider<Changes> changes;
|
||||
|
@@ -27,7 +27,9 @@ import com.google.gerrit.server.account.AccountsCollection;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class AccountsImpl extends Accounts.NotImplemented implements Accounts {
|
||||
private final AccountsCollection accounts;
|
||||
private final AccountApiImpl.Factory api;
|
||||
|
@@ -38,10 +38,12 @@ import com.google.gerrit.server.query.change.QueryChanges;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
class ChangesImpl implements Changes {
|
||||
private final ChangesCollection changes;
|
||||
private final ChangeApiImpl.Factory api;
|
||||
|
@@ -24,10 +24,12 @@ import com.google.gerrit.server.project.ListProjects;
|
||||
import com.google.gerrit.server.project.ProjectsCollection;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
class ProjectsImpl extends Projects.NotImplemented implements Projects {
|
||||
private final ProjectsCollection projects;
|
||||
private final ProjectApiImpl.Factory api;
|
||||
|
@@ -32,10 +32,12 @@ import com.google.gerrit.server.query.change.QueryChanges;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class ChangesCollection implements
|
||||
RestCollection<TopLevelResource, ChangeResource>,
|
||||
AcceptsPost<TopLevelResource> {
|
||||
|
@@ -22,6 +22,7 @@ import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.ChangeUtil;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.GerritPersonIdent;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.events.CommitReceivedEvent;
|
||||
@@ -39,6 +40,8 @@ import com.google.gerrit.server.ssh.NoSshInfo;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
||||
import org.eclipse.jgit.errors.MissingObjectException;
|
||||
@@ -57,30 +60,34 @@ import org.eclipse.jgit.util.ChangeIdUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
|
||||
@Singleton
|
||||
public class CherryPickChange {
|
||||
|
||||
private static final FooterKey CHANGE_ID = new FooterKey("Change-Id");
|
||||
|
||||
private final ReviewDb db;
|
||||
private final Provider<ReviewDb> db;
|
||||
private final GitRepositoryManager gitManager;
|
||||
private final PersonIdent myIdent;
|
||||
private final IdentifiedUser currentUser;
|
||||
private final TimeZone serverTimeZone;
|
||||
private final Provider<CurrentUser> currentUser;
|
||||
private final CommitValidators.Factory commitValidatorsFactory;
|
||||
private final ChangeInserter.Factory changeInserterFactory;
|
||||
private final PatchSetInserter.Factory patchSetInserterFactory;
|
||||
final MergeUtil.Factory mergeUtilFactory;
|
||||
|
||||
@Inject
|
||||
CherryPickChange(final ReviewDb db, @GerritPersonIdent final PersonIdent myIdent,
|
||||
final GitRepositoryManager gitManager, final IdentifiedUser currentUser,
|
||||
CherryPickChange(final Provider<ReviewDb> db,
|
||||
@GerritPersonIdent final PersonIdent myIdent,
|
||||
final GitRepositoryManager gitManager,
|
||||
final Provider<CurrentUser> currentUser,
|
||||
final CommitValidators.Factory commitValidatorsFactory,
|
||||
final ChangeInserter.Factory changeInserterFactory,
|
||||
final PatchSetInserter.Factory patchSetInserterFactory,
|
||||
final MergeUtil.Factory mergeUtilFactory) {
|
||||
this.db = db;
|
||||
this.gitManager = gitManager;
|
||||
this.myIdent = myIdent;
|
||||
this.serverTimeZone = myIdent.getTimeZone();
|
||||
this.currentUser = currentUser;
|
||||
this.commitValidatorsFactory = commitValidatorsFactory;
|
||||
this.changeInserterFactory = changeInserterFactory;
|
||||
@@ -96,7 +103,7 @@ public class CherryPickChange {
|
||||
InvalidChangeOperationException, MergeException {
|
||||
|
||||
final Change.Id changeId = patchSetId.getParentKey();
|
||||
final PatchSet patch = db.patchSets().get(patchSetId);
|
||||
final PatchSet patch = db.get().patchSets().get(patchSetId);
|
||||
if (patch == null) {
|
||||
throw new NoSuchChangeException(changeId);
|
||||
}
|
||||
@@ -105,7 +112,8 @@ public class CherryPickChange {
|
||||
"Cherry Pick: Destination branch cannot be null or empty");
|
||||
}
|
||||
|
||||
Project.NameKey project = db.changes().get(changeId).getProject();
|
||||
Project.NameKey project = db.get().changes().get(changeId).getProject();
|
||||
IdentifiedUser identifiedUser = (IdentifiedUser) currentUser.get();
|
||||
final Repository git;
|
||||
try {
|
||||
git = gitManager.openRepository(project);
|
||||
@@ -128,13 +136,13 @@ public class CherryPickChange {
|
||||
revWalk.parseCommit(ObjectId.fromString(patch.getRevision().get()));
|
||||
|
||||
PersonIdent committerIdent =
|
||||
currentUser.newCommitterIdent(myIdent.getWhen(),
|
||||
myIdent.getTimeZone());
|
||||
identifiedUser.newCommitterIdent(TimeUtil.nowTs(),
|
||||
serverTimeZone);
|
||||
|
||||
final ObjectId computedChangeId =
|
||||
ChangeIdUtil
|
||||
.computeChangeId(commitToCherryPick.getTree(), mergeTip,
|
||||
commitToCherryPick.getAuthorIdent(), myIdent, message);
|
||||
commitToCherryPick.getAuthorIdent(), committerIdent, message);
|
||||
String commitMessage =
|
||||
ChangeIdUtil.insertId(message, computedChangeId).trim() + '\n';
|
||||
|
||||
@@ -163,9 +171,9 @@ public class CherryPickChange {
|
||||
}
|
||||
|
||||
List<Change> destChanges =
|
||||
db.changes()
|
||||
db.get().changes()
|
||||
.byBranchKey(
|
||||
new Branch.NameKey(db.changes().get(changeId).getProject(),
|
||||
new Branch.NameKey(db.get().changes().get(changeId).getProject(),
|
||||
destRef.getName()), changeKey).toList();
|
||||
|
||||
if (destChanges.size() > 1) {
|
||||
@@ -176,12 +184,12 @@ public class CherryPickChange {
|
||||
// The change key exists on the destination branch. The cherry pick
|
||||
// will be added as a new patch set.
|
||||
return insertPatchSet(git, revWalk, destChanges.get(0), patchSetId,
|
||||
cherryPickCommit, refControl, currentUser);
|
||||
cherryPickCommit, refControl, identifiedUser);
|
||||
} else {
|
||||
// Change key not found on destination branch. We can create a new
|
||||
// change.
|
||||
return createNewChange(git, revWalk, changeKey, project, patchSetId, destRef,
|
||||
cherryPickCommit, refControl);
|
||||
cherryPickCommit, refControl, identifiedUser);
|
||||
}
|
||||
} finally {
|
||||
revWalk.release();
|
||||
@@ -193,7 +201,7 @@ public class CherryPickChange {
|
||||
|
||||
private Change.Id insertPatchSet(Repository git, RevWalk revWalk, Change change,
|
||||
PatchSet.Id patchSetId, RevCommit cherryPickCommit,
|
||||
RefControl refControl, IdentifiedUser uploader)
|
||||
RefControl refControl, IdentifiedUser identifiedUser)
|
||||
throws InvalidChangeOperationException, IOException, OrmException,
|
||||
NoSuchChangeException {
|
||||
final ChangeControl changeControl =
|
||||
@@ -201,11 +209,11 @@ public class CherryPickChange {
|
||||
final PatchSetInserter inserter = patchSetInserterFactory
|
||||
.create(git, revWalk, changeControl, cherryPickCommit);
|
||||
final PatchSet.Id newPatchSetId = inserter.getPatchSetId();
|
||||
final PatchSet current = db.patchSets().get(change.currentPatchSetId());
|
||||
PatchSet current = db.get().patchSets().get(change.currentPatchSetId());
|
||||
inserter
|
||||
.setMessage("Uploaded patch set " + newPatchSetId.get() + ".")
|
||||
.setDraft(current.isDraft())
|
||||
.setUploader(uploader.getAccountId())
|
||||
.setUploader(identifiedUser.getAccountId())
|
||||
.setCopyLabels(true)
|
||||
.insert();
|
||||
return change.getId();
|
||||
@@ -213,11 +221,12 @@ public class CherryPickChange {
|
||||
|
||||
private Change.Id createNewChange(Repository git, RevWalk revWalk,
|
||||
Change.Key changeKey, Project.NameKey project, PatchSet.Id patchSetId,
|
||||
Ref destRef, RevCommit cherryPickCommit, RefControl refControl)
|
||||
Ref destRef, RevCommit cherryPickCommit, RefControl refControl,
|
||||
IdentifiedUser identifiedUser)
|
||||
throws OrmException, InvalidChangeOperationException, IOException {
|
||||
Change change =
|
||||
new Change(changeKey, new Change.Id(db.nextChangeId()),
|
||||
currentUser.getAccountId(), new Branch.NameKey(project,
|
||||
new Change(changeKey, new Change.Id(db.get().nextChangeId()),
|
||||
identifiedUser.getAccountId(), new Branch.NameKey(project,
|
||||
destRef.getName()), TimeUtil.nowTs());
|
||||
ChangeInserter ins =
|
||||
changeInserterFactory.create(refControl, change, cherryPickCommit);
|
||||
@@ -229,7 +238,7 @@ public class CherryPickChange {
|
||||
new CommitReceivedEvent(new ReceiveCommand(ObjectId.zeroId(),
|
||||
cherryPickCommit.getId(), newPatchSet.getRefName()), refControl
|
||||
.getProjectControl().getProject(), refControl.getRefName(),
|
||||
cherryPickCommit, currentUser);
|
||||
cherryPickCommit, identifiedUser);
|
||||
|
||||
try {
|
||||
commitValidators.validateForGerritCommits(commitReceivedEvent);
|
||||
@@ -247,18 +256,20 @@ public class CherryPickChange {
|
||||
change.getDest().getParentKey().get(), ru.getResult()));
|
||||
}
|
||||
|
||||
ins.setMessage(buildChangeMessage(patchSetId, change, cherryPickCommit))
|
||||
ins.setMessage(buildChangeMessage(patchSetId, change, cherryPickCommit,
|
||||
identifiedUser))
|
||||
.insert();
|
||||
|
||||
return change.getId();
|
||||
}
|
||||
|
||||
private ChangeMessage buildChangeMessage(PatchSet.Id patchSetId, Change dest,
|
||||
RevCommit cherryPickCommit) throws OrmException {
|
||||
RevCommit cherryPickCommit, IdentifiedUser identifiedUser)
|
||||
throws OrmException {
|
||||
ChangeMessage cmsg = new ChangeMessage(
|
||||
new ChangeMessage.Key(
|
||||
patchSetId.getParentKey(), ChangeUtil.messageUUID(db)),
|
||||
currentUser.getAccountId(), TimeUtil.nowTs(), patchSetId);
|
||||
patchSetId.getParentKey(), ChangeUtil.messageUUID(db.get())),
|
||||
identifiedUser.getAccountId(), TimeUtil.nowTs(), patchSetId);
|
||||
String destBranchName = dest.getDest().get();
|
||||
StringBuilder msgBuf = new StringBuilder("Patch Set ")
|
||||
.append(patchSetId.get())
|
||||
|
@@ -24,7 +24,9 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
class Comments implements ChildCollection<RevisionResource, CommentResource> {
|
||||
private final DynamicMap<RestView<CommentResource>> views;
|
||||
private final Provider<ListComments> list;
|
||||
|
@@ -47,6 +47,7 @@ import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.jgit.lib.CommitBuilder;
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
@@ -67,6 +68,7 @@ import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
|
||||
@Singleton
|
||||
public class CreateChange implements
|
||||
RestModifyView<TopLevelResource, ChangeInfo> {
|
||||
|
||||
|
@@ -29,9 +29,11 @@ import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@Singleton
|
||||
class CreateDraft implements RestModifyView<RevisionResource, Input> {
|
||||
private final Provider<ReviewDb> db;
|
||||
|
||||
|
@@ -21,9 +21,11 @@ import com.google.gerrit.server.change.DeleteDraft.Input;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@Singleton
|
||||
class DeleteDraft implements RestModifyView<DraftResource, Input> {
|
||||
static class Input {
|
||||
}
|
||||
|
@@ -37,11 +37,13 @@ import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class DeleteReviewer implements RestModifyView<ReviewerResource, Input> {
|
||||
public static class Input {
|
||||
}
|
||||
|
@@ -26,7 +26,9 @@ import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
class Drafts implements ChildCollection<RevisionResource, DraftResource> {
|
||||
private final DynamicMap<RestView<DraftResource>> views;
|
||||
private final Provider<CurrentUser> user;
|
||||
|
@@ -18,7 +18,9 @@ import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.server.account.AccountInfo;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
class GetComment implements RestReadView<CommentResource> {
|
||||
|
||||
private final AccountInfo.Loader.Factory accountLoaderFactory;
|
||||
|
@@ -22,9 +22,11 @@ import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.server.patch.PatchSetInfoNotAvailableException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Singleton
|
||||
public class GetCommit implements RestReadView<RevisionResource> {
|
||||
private final ChangeJson json;
|
||||
|
||||
|
@@ -20,6 +20,7 @@ import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.jgit.lib.ObjectLoader;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
@@ -30,6 +31,7 @@ import org.eclipse.jgit.treewalk.TreeWalk;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
@Singleton
|
||||
public class GetContent implements RestReadView<FileResource> {
|
||||
private final GitRepositoryManager repoManager;
|
||||
|
||||
|
@@ -15,7 +15,9 @@
|
||||
package com.google.gerrit.server.change;
|
||||
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
class GetDraft implements RestReadView<DraftResource> {
|
||||
@Override
|
||||
public CommentInfo apply(DraftResource rsrc) {
|
||||
|
@@ -34,6 +34,7 @@ import com.google.gwtorm.server.OrmException;
|
||||
import com.google.gwtorm.server.ResultSet;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
||||
import org.eclipse.jgit.errors.RepositoryNotFoundException;
|
||||
@@ -57,6 +58,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Singleton
|
||||
public class GetRelated implements RestReadView<RevisionResource> {
|
||||
private static final Logger log = LoggerFactory.getLogger(GetRelated.class);
|
||||
|
||||
|
@@ -20,7 +20,9 @@ import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.server.change.ChangeJson.ChangeInfo;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class GetReview implements RestReadView<RevisionResource> {
|
||||
private final GetChange delegate;
|
||||
|
||||
|
@@ -18,9 +18,11 @@ import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.server.change.ReviewerJson.ReviewerInfo;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class GetReviewer implements RestReadView<ReviewerResource> {
|
||||
private final ReviewerJson json;
|
||||
|
||||
|
@@ -16,7 +16,9 @@ package com.google.gerrit.server.change;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
class GetTopic implements RestReadView<ChangeResource> {
|
||||
@Override
|
||||
public String apply(ChangeResource rsrc) {
|
||||
|
@@ -24,6 +24,7 @@ import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.project.ChangeControl;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
|
||||
import org.eclipse.jgit.errors.MissingObjectException;
|
||||
@@ -37,11 +38,11 @@ import java.util.Collection;
|
||||
|
||||
class IncludedIn implements RestReadView<ChangeResource> {
|
||||
|
||||
private final ReviewDb db;
|
||||
private final Provider<ReviewDb> db;
|
||||
private final GitRepositoryManager repoManager;
|
||||
|
||||
@Inject
|
||||
IncludedIn(ReviewDb db, GitRepositoryManager repoManager) {
|
||||
IncludedIn(Provider<ReviewDb> db, GitRepositoryManager repoManager) {
|
||||
this.db = db;
|
||||
this.repoManager = repoManager;
|
||||
}
|
||||
@@ -51,7 +52,7 @@ class IncludedIn implements RestReadView<ChangeResource> {
|
||||
ResourceConflictException, OrmException, IOException {
|
||||
ChangeControl ctl = rsrc.getControl();
|
||||
PatchSet ps =
|
||||
db.patchSets().get(ctl.getChange().currentPatchSetId());
|
||||
db.get().patchSets().get(ctl.getChange().currentPatchSetId());
|
||||
Repository r =
|
||||
repoManager.openRepository(ctl.getProject().getNameKey());
|
||||
try {
|
||||
|
@@ -23,10 +23,12 @@ import com.google.gerrit.server.change.Index.Input;
|
||||
import com.google.gerrit.server.index.ChangeIndexer;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
|
||||
@Singleton
|
||||
public class Index implements RestModifyView<ChangeResource, Input> {
|
||||
public static class Input {
|
||||
}
|
||||
|
@@ -36,6 +36,7 @@ import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.ApprovalsUtil;
|
||||
import com.google.gerrit.server.ChangeUtil;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.account.AccountCache;
|
||||
import com.google.gerrit.server.account.AccountInfo;
|
||||
@@ -54,6 +55,7 @@ import com.google.gerrit.server.project.NoSuchProjectException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.jgit.lib.Config;
|
||||
import org.slf4j.Logger;
|
||||
@@ -65,6 +67,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@Singleton
|
||||
public class PostReviewers implements RestModifyView<ChangeResource, AddReviewerInput> {
|
||||
private static final Logger log = LoggerFactory
|
||||
.getLogger(PostReviewers.class);
|
||||
@@ -81,7 +84,7 @@ public class PostReviewers implements RestModifyView<ChangeResource, AddReviewer
|
||||
private final AccountInfo.Loader.Factory accountLoaderFactory;
|
||||
private final Provider<ReviewDb> dbProvider;
|
||||
private final ChangeUpdate.Factory updateFactory;
|
||||
private final IdentifiedUser currentUser;
|
||||
private final Provider<CurrentUser> currentUser;
|
||||
private final IdentifiedUser.GenericFactory identifiedUserFactory;
|
||||
private final Config cfg;
|
||||
private final ChangeHooks hooks;
|
||||
@@ -99,7 +102,7 @@ public class PostReviewers implements RestModifyView<ChangeResource, AddReviewer
|
||||
AccountInfo.Loader.Factory accountLoaderFactory,
|
||||
Provider<ReviewDb> db,
|
||||
ChangeUpdate.Factory updateFactory,
|
||||
IdentifiedUser currentUser,
|
||||
Provider<CurrentUser> currentUser,
|
||||
IdentifiedUser.GenericFactory identifiedUserFactory,
|
||||
@GerritServerConfig Config cfg,
|
||||
ChangeHooks hooks,
|
||||
@@ -268,15 +271,16 @@ public class PostReviewers implements RestModifyView<ChangeResource, AddReviewer
|
||||
//
|
||||
// The user knows they added themselves, don't bother emailing them.
|
||||
List<Account.Id> toMail = Lists.newArrayListWithCapacity(added.size());
|
||||
IdentifiedUser identifiedUser = (IdentifiedUser) currentUser.get();
|
||||
for (PatchSetApproval psa : added) {
|
||||
if (!psa.getAccountId().equals(currentUser.getAccountId())) {
|
||||
if (!psa.getAccountId().equals(identifiedUser.getAccountId())) {
|
||||
toMail.add(psa.getAccountId());
|
||||
}
|
||||
}
|
||||
if (!toMail.isEmpty()) {
|
||||
try {
|
||||
AddReviewerSender cm = addReviewerSenderFactory.create(change);
|
||||
cm.setFrom(currentUser.getAccountId());
|
||||
cm.setFrom(identifiedUser.getAccountId());
|
||||
cm.addReviewers(toMail);
|
||||
cm.send();
|
||||
} catch (Exception err) {
|
||||
|
@@ -29,10 +29,12 @@ import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Collections;
|
||||
|
||||
@Singleton
|
||||
class PutDraft implements RestModifyView<DraftResource, Input> {
|
||||
static class Input {
|
||||
String kind;
|
||||
|
@@ -22,6 +22,7 @@ import com.google.gwtorm.server.OrmDuplicateKeyException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@@ -29,6 +30,7 @@ class Reviewed {
|
||||
static class Input {
|
||||
}
|
||||
|
||||
@Singleton
|
||||
static class PutReviewed implements RestModifyView<FileResource, Input> {
|
||||
private final Provider<ReviewDb> dbProvider;
|
||||
|
||||
@@ -57,6 +59,7 @@ class Reviewed {
|
||||
}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
static class DeleteReviewed implements RestModifyView<FileResource, Input> {
|
||||
private final Provider<ReviewDb> dbProvider;
|
||||
|
||||
|
@@ -35,12 +35,14 @@ import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
@Singleton
|
||||
public class ReviewerJson {
|
||||
private final Provider<ReviewDb> db;
|
||||
private final ChangeData.Factory changeDataFactory;
|
||||
|
@@ -28,9 +28,11 @@ import com.google.gerrit.server.account.AccountsCollection;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@Singleton
|
||||
public class Reviewers implements
|
||||
ChildCollection<ChangeResource, ReviewerResource> {
|
||||
private final DynamicMap<RestView<ReviewerResource>> views;
|
||||
|
@@ -27,10 +27,12 @@ import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class Revisions implements ChildCollection<ChangeResource, RevisionResource> {
|
||||
private final DynamicMap<RestView<RevisionResource>> views;
|
||||
private final Provider<ReviewDb> dbProvider;
|
||||
|
@@ -37,6 +37,7 @@ import com.google.gerrit.server.project.SubmitRuleEvaluator;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
import com.googlecode.prolog_cafe.lang.Term;
|
||||
|
||||
@@ -57,7 +58,7 @@ public class TestSubmitRule implements RestModifyView<RevisionResource, Input> {
|
||||
public Filters filters;
|
||||
}
|
||||
|
||||
private final ReviewDb db;
|
||||
private final Provider<ReviewDb> db;
|
||||
private final ChangeData.Factory changeDataFactory;
|
||||
private final RulesCache rules;
|
||||
private final AccountInfo.Loader.Factory accountInfoFactory;
|
||||
@@ -66,7 +67,7 @@ public class TestSubmitRule implements RestModifyView<RevisionResource, Input> {
|
||||
private Filters filters = Filters.RUN;
|
||||
|
||||
@Inject
|
||||
TestSubmitRule(ReviewDb db,
|
||||
TestSubmitRule(Provider<ReviewDb> db,
|
||||
ChangeData.Factory changeDataFactory,
|
||||
RulesCache rules,
|
||||
AccountInfo.Loader.Factory infoFactory) {
|
||||
@@ -88,12 +89,12 @@ public class TestSubmitRule implements RestModifyView<RevisionResource, Input> {
|
||||
input.filters = Objects.firstNonNull(input.filters, filters);
|
||||
|
||||
SubmitRuleEvaluator evaluator = new SubmitRuleEvaluator(
|
||||
db,
|
||||
db.get(),
|
||||
rsrc.getPatchSet(),
|
||||
rsrc.getControl().getProjectControl(),
|
||||
rsrc.getControl(),
|
||||
rsrc.getChange(),
|
||||
changeDataFactory.create(db, rsrc.getChange()),
|
||||
changeDataFactory.create(db.get(), rsrc.getChange()),
|
||||
false,
|
||||
"locate_submit_rule", "can_submit",
|
||||
"locate_submit_filter", "filter_submit_results",
|
||||
|
@@ -30,6 +30,7 @@ import com.google.gerrit.server.project.RuleEvalException;
|
||||
import com.google.gerrit.server.project.SubmitRuleEvaluator;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
|
||||
import com.googlecode.prolog_cafe.lang.SymbolTerm;
|
||||
import com.googlecode.prolog_cafe.lang.Term;
|
||||
@@ -40,7 +41,7 @@ import java.io.ByteArrayInputStream;
|
||||
import java.util.List;
|
||||
|
||||
public class TestSubmitType implements RestModifyView<RevisionResource, Input> {
|
||||
private final ReviewDb db;
|
||||
private final Provider<ReviewDb> db;
|
||||
private final ChangeData.Factory changeDataFactory;
|
||||
private final RulesCache rules;
|
||||
|
||||
@@ -48,7 +49,7 @@ public class TestSubmitType implements RestModifyView<RevisionResource, Input> {
|
||||
private Filters filters = Filters.RUN;
|
||||
|
||||
@Inject
|
||||
TestSubmitType(ReviewDb db,
|
||||
TestSubmitType(Provider<ReviewDb> db,
|
||||
ChangeData.Factory changeDataFactory,
|
||||
RulesCache rules) {
|
||||
this.db = db;
|
||||
@@ -68,12 +69,12 @@ public class TestSubmitType implements RestModifyView<RevisionResource, Input> {
|
||||
input.filters = Objects.firstNonNull(input.filters, filters);
|
||||
|
||||
SubmitRuleEvaluator evaluator = new SubmitRuleEvaluator(
|
||||
db,
|
||||
db.get(),
|
||||
rsrc.getPatchSet(),
|
||||
rsrc.getControl().getProjectControl(),
|
||||
rsrc.getControl(),
|
||||
rsrc.getChange(),
|
||||
changeDataFactory.create(db, rsrc.getChange()),
|
||||
changeDataFactory.create(db.get(), rsrc.getChange()),
|
||||
false,
|
||||
"locate_submit_type", "get_submit_type",
|
||||
"locate_submit_type_filter", "filter_submit_type_results",
|
||||
|
@@ -14,8 +14,6 @@
|
||||
|
||||
package com.google.gerrit.server.changedetail;
|
||||
|
||||
import static com.google.gerrit.server.change.PatchSetInserter.ValidatePolicy;
|
||||
|
||||
import com.google.gerrit.common.errors.EmailException;
|
||||
import com.google.gerrit.reviewdb.client.Branch;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
@@ -29,6 +27,7 @@ import com.google.gerrit.server.ChangeUtil;
|
||||
import com.google.gerrit.server.GerritPersonIdent;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.change.PatchSetInserter;
|
||||
import com.google.gerrit.server.change.PatchSetInserter.ValidatePolicy;
|
||||
import com.google.gerrit.server.change.RevisionResource;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.git.MergeUtil;
|
||||
@@ -38,6 +37,8 @@ import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.jgit.errors.RepositoryNotFoundException;
|
||||
import org.eclipse.jgit.lib.CommitBuilder;
|
||||
@@ -52,18 +53,20 @@ import org.eclipse.jgit.revwalk.RevWalk;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
|
||||
@Singleton
|
||||
public class RebaseChange {
|
||||
private final ChangeControl.GenericFactory changeControlFactory;
|
||||
private final ReviewDb db;
|
||||
private final Provider<ReviewDb> db;
|
||||
private final GitRepositoryManager gitManager;
|
||||
private final PersonIdent myIdent;
|
||||
private final TimeZone serverTimeZone;
|
||||
private final MergeUtil.Factory mergeUtilFactory;
|
||||
private final PatchSetInserter.Factory patchSetInserterFactory;
|
||||
|
||||
@Inject
|
||||
RebaseChange(final ChangeControl.GenericFactory changeControlFactory,
|
||||
final ReviewDb db,
|
||||
final Provider<ReviewDb> db,
|
||||
@GerritPersonIdent final PersonIdent myIdent,
|
||||
final GitRepositoryManager gitManager,
|
||||
final MergeUtil.Factory mergeUtilFactory,
|
||||
@@ -71,7 +74,7 @@ public class RebaseChange {
|
||||
this.changeControlFactory = changeControlFactory;
|
||||
this.db = db;
|
||||
this.gitManager = gitManager;
|
||||
this.myIdent = myIdent;
|
||||
this.serverTimeZone = myIdent.getTimeZone();
|
||||
this.mergeUtilFactory = mergeUtilFactory;
|
||||
this.patchSetInserterFactory = patchSetInserterFactory;
|
||||
}
|
||||
@@ -122,14 +125,14 @@ public class RebaseChange {
|
||||
rw = new RevWalk(git);
|
||||
inserter = git.newObjectInserter();
|
||||
|
||||
final String baseRev = findBaseRevision(patchSetId, db,
|
||||
final String baseRev = findBaseRevision(patchSetId, db.get(),
|
||||
change.getDest(), git, null, null, null);
|
||||
final RevCommit baseCommit =
|
||||
rw.parseCommit(ObjectId.fromString(baseRev));
|
||||
|
||||
PersonIdent committerIdent =
|
||||
uploader.newCommitterIdent(myIdent.getWhen(),
|
||||
myIdent.getTimeZone());
|
||||
uploader.newCommitterIdent(TimeUtil.nowTs(),
|
||||
serverTimeZone);
|
||||
|
||||
rebase(git, rw, inserter, patchSetId, change,
|
||||
uploader, baseCommit, mergeUtilFactory.create(
|
||||
@@ -282,7 +285,7 @@ public class RebaseChange {
|
||||
if (!change.currentPatchSetId().equals(patchSetId)) {
|
||||
throw new InvalidChangeOperationException("patch set is not current");
|
||||
}
|
||||
final PatchSet originalPatchSet = db.patchSets().get(patchSetId);
|
||||
final PatchSet originalPatchSet = db.get().patchSets().get(patchSetId);
|
||||
|
||||
final RevCommit rebasedCommit;
|
||||
ObjectId oldId = ObjectId.fromString(originalPatchSet.getRevision().get());
|
||||
@@ -305,8 +308,9 @@ public class RebaseChange {
|
||||
|
||||
final PatchSet.Id newPatchSetId = patchSetInserter.getPatchSetId();
|
||||
final ChangeMessage cmsg = new ChangeMessage(
|
||||
new ChangeMessage.Key(change.getId(), ChangeUtil.messageUUID(db)),
|
||||
uploader.getAccountId(), TimeUtil.nowTs(), patchSetId);
|
||||
new ChangeMessage.Key(change.getId(),
|
||||
ChangeUtil.messageUUID(db.get())), uploader.getAccountId(),
|
||||
TimeUtil.nowTs(), patchSetId);
|
||||
|
||||
cmsg.setMessage("Patch Set " + newPatchSetId.get()
|
||||
+ ": Patch Set " + patchSetId.get() + " was rebased");
|
||||
@@ -315,7 +319,7 @@ public class RebaseChange {
|
||||
.setMessage(cmsg)
|
||||
.insert();
|
||||
|
||||
return db.patchSets().get(newChange.currentPatchSetId());
|
||||
return db.get().patchSets().get(newChange.currentPatchSetId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -375,7 +379,7 @@ public class RebaseChange {
|
||||
try {
|
||||
findBaseRevision(
|
||||
r.getPatchSet().getId(),
|
||||
db,
|
||||
db.get(),
|
||||
r.getChange().getDest(),
|
||||
git,
|
||||
null,
|
||||
|
@@ -21,7 +21,9 @@ import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.extensions.restapi.RestView;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class CapabilitiesCollection implements
|
||||
ChildCollection<ConfigResource, CapabilityResource> {
|
||||
private final DynamicMap<RestView<CapabilityResource>> views;
|
||||
|
@@ -19,12 +19,14 @@ import com.google.gerrit.server.account.GetPreferences.PreferenceInfo;
|
||||
import com.google.gerrit.server.account.VersionedAccountPreferences;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Singleton
|
||||
public class GetPreferences implements RestReadView<ConfigResource> {
|
||||
private final AllUsersName allUsersName;
|
||||
private final GitRepositoryManager gitMgr;
|
||||
|
@@ -17,7 +17,9 @@ package com.google.gerrit.server.config;
|
||||
import com.google.gerrit.common.Version;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class GetVersion implements RestReadView<ConfigResource> {
|
||||
@Override
|
||||
public String apply(ConfigResource resource) throws ResourceNotFoundException {
|
||||
|
@@ -23,12 +23,14 @@ import com.google.gerrit.server.account.SetPreferences.Input;
|
||||
import com.google.gerrit.server.account.VersionedAccountPreferences;
|
||||
import com.google.gerrit.server.git.MetaDataUpdate;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
|
||||
@Singleton
|
||||
public class SetPreferences implements RestModifyView<ConfigResource, Input> {
|
||||
private final MetaDataUpdate.User metaDataUpdateFactory;
|
||||
private final AllUsersName allUsersName;
|
||||
|
@@ -21,7 +21,9 @@ import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.extensions.restapi.RestView;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
class TopMenuCollection implements
|
||||
ChildCollection<ConfigResource, TopMenuResource> {
|
||||
private final DynamicMap<RestView<TopMenuResource>> views;
|
||||
|
@@ -38,10 +38,12 @@ import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Singleton
|
||||
public class AddIncludedGroups implements RestModifyView<GroupResource, Input> {
|
||||
public static class Input {
|
||||
@DefaultInput
|
||||
@@ -71,13 +73,13 @@ public class AddIncludedGroups implements RestModifyView<GroupResource, Input> {
|
||||
|
||||
private final Provider<GroupsCollection> groupsCollection;
|
||||
private final GroupIncludeCache groupIncludeCache;
|
||||
private final ReviewDb db;
|
||||
private final Provider<ReviewDb> db;
|
||||
private final GroupJson json;
|
||||
|
||||
@Inject
|
||||
public AddIncludedGroups(Provider<GroupsCollection> groupsCollection,
|
||||
GroupIncludeCache groupIncludeCache,
|
||||
ReviewDb db, GroupJson json) {
|
||||
Provider<ReviewDb> db, GroupJson json) {
|
||||
this.groupsCollection = groupsCollection;
|
||||
this.groupIncludeCache = groupIncludeCache;
|
||||
this.db = db;
|
||||
@@ -111,7 +113,7 @@ public class AddIncludedGroups implements RestModifyView<GroupResource, Input> {
|
||||
AccountGroupById.Key agiKey =
|
||||
new AccountGroupById.Key(group.getId(),
|
||||
d.getGroupUUID());
|
||||
AccountGroupById agi = db.accountGroupById().get(agiKey);
|
||||
AccountGroupById agi = db.get().accountGroupById().get(agiKey);
|
||||
if (agi == null) {
|
||||
agi = new AccountGroupById(agiKey);
|
||||
newIncludedGroups.put(d.getGroupUUID(), agi);
|
||||
@@ -123,8 +125,8 @@ public class AddIncludedGroups implements RestModifyView<GroupResource, Input> {
|
||||
}
|
||||
|
||||
if (!newIncludedGroups.isEmpty()) {
|
||||
db.accountGroupByIdAud().insert(newIncludedGroupsAudits);
|
||||
db.accountGroupById().insert(newIncludedGroups.values());
|
||||
db.get().accountGroupByIdAud().insert(newIncludedGroupsAudits);
|
||||
db.get().accountGroupById().insert(newIncludedGroups.values());
|
||||
for (AccountGroupById agi : newIncludedGroups.values()) {
|
||||
groupIncludeCache.evictMemberIn(agi.getIncludeUUID());
|
||||
}
|
||||
@@ -134,6 +136,7 @@ public class AddIncludedGroups implements RestModifyView<GroupResource, Input> {
|
||||
return result;
|
||||
}
|
||||
|
||||
@Singleton
|
||||
static class PutIncludedGroup implements RestModifyView<GroupResource, PutIncludedGroup.Input> {
|
||||
static class Input {
|
||||
}
|
||||
@@ -160,6 +163,7 @@ public class AddIncludedGroups implements RestModifyView<GroupResource, Input> {
|
||||
}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
static class UpdateIncludedGroup implements RestModifyView<IncludedGroupResource, PutIncludedGroup.Input> {
|
||||
static class Input {
|
||||
}
|
||||
|
@@ -43,10 +43,12 @@ import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Singleton
|
||||
public class AddMembers implements RestModifyView<GroupResource, Input> {
|
||||
public static class Input {
|
||||
@DefaultInput
|
||||
@@ -79,7 +81,7 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
|
||||
private final AccountResolver accountResolver;
|
||||
private final AccountCache accountCache;
|
||||
private final AccountInfo.Loader.Factory infoFactory;
|
||||
private final ReviewDb db;
|
||||
private final Provider<ReviewDb> db;
|
||||
|
||||
@Inject
|
||||
AddMembers(AccountManager accountManager,
|
||||
@@ -88,7 +90,7 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
|
||||
AccountResolver accountResolver,
|
||||
AccountCache accountCache,
|
||||
AccountInfo.Loader.Factory infoFactory,
|
||||
ReviewDb db) {
|
||||
Provider<ReviewDb> db) {
|
||||
this.accountManager = accountManager;
|
||||
this.authType = authConfig.getAuthType();
|
||||
this.accounts = accounts;
|
||||
@@ -129,7 +131,7 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
|
||||
if (!newAccountGroupMembers.containsKey(a.getId())) {
|
||||
AccountGroupMember.Key key =
|
||||
new AccountGroupMember.Key(a.getId(), internalGroup.getId());
|
||||
AccountGroupMember m = db.accountGroupMembers().get(key);
|
||||
AccountGroupMember m = db.get().accountGroupMembers().get(key);
|
||||
if (m == null) {
|
||||
m = new AccountGroupMember(key);
|
||||
newAccountGroupMembers.put(m.getAccountId(), m);
|
||||
@@ -140,8 +142,8 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
|
||||
result.add(loader.get(a.getId()));
|
||||
}
|
||||
|
||||
db.accountGroupMembersAudit().insert(newAccountGroupMemberAudits);
|
||||
db.accountGroupMembers().insert(newAccountGroupMembers.values());
|
||||
db.get().accountGroupMembersAudit().insert(newAccountGroupMemberAudits);
|
||||
db.get().accountGroupMembers().insert(newAccountGroupMembers.values());
|
||||
for (AccountGroupMember m : newAccountGroupMembers.values()) {
|
||||
accountCache.evict(m.getAccountId());
|
||||
}
|
||||
@@ -213,6 +215,7 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
|
||||
}
|
||||
}
|
||||
|
||||
@Singleton
|
||||
static class UpdateMember implements RestModifyView<MemberResource, PutMember.Input> {
|
||||
static class Input {
|
||||
}
|
||||
|
@@ -37,19 +37,22 @@ import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Singleton
|
||||
public class DeleteIncludedGroups implements RestModifyView<GroupResource, Input> {
|
||||
private final Provider<GroupsCollection> groupsCollection;
|
||||
private final GroupIncludeCache groupIncludeCache;
|
||||
private final ReviewDb db;
|
||||
private final Provider<ReviewDb> db;
|
||||
private final Provider<CurrentUser> self;
|
||||
|
||||
@Inject
|
||||
DeleteIncludedGroups(Provider<GroupsCollection> groupsCollection,
|
||||
GroupIncludeCache groupIncludeCache, ReviewDb db,
|
||||
GroupIncludeCache groupIncludeCache,
|
||||
Provider<ReviewDb> db,
|
||||
Provider<CurrentUser> self) {
|
||||
this.groupsCollection = groupsCollection;
|
||||
this.groupIncludeCache = groupIncludeCache;
|
||||
@@ -86,7 +89,7 @@ public class DeleteIncludedGroups implements RestModifyView<GroupResource, Input
|
||||
|
||||
if (!toRemove.isEmpty()) {
|
||||
writeAudits(toRemove);
|
||||
db.accountGroupById().delete(toRemove);
|
||||
db.get().accountGroupById().delete(toRemove);
|
||||
for (final AccountGroupById g : toRemove) {
|
||||
groupIncludeCache.evictMemberIn(g.getIncludeUUID());
|
||||
}
|
||||
@@ -100,7 +103,7 @@ public class DeleteIncludedGroups implements RestModifyView<GroupResource, Input
|
||||
final AccountGroup.Id groupId) throws OrmException {
|
||||
final Map<AccountGroup.UUID, AccountGroupById> groups =
|
||||
Maps.newHashMap();
|
||||
for (final AccountGroupById g : db.accountGroupById().byGroup(groupId)) {
|
||||
for (AccountGroupById g : db.get().accountGroupById().byGroup(groupId)) {
|
||||
groups.put(g.getIncludeUUID(), g);
|
||||
}
|
||||
return groups;
|
||||
@@ -112,7 +115,7 @@ public class DeleteIncludedGroups implements RestModifyView<GroupResource, Input
|
||||
final List<AccountGroupByIdAud> auditUpdates = Lists.newLinkedList();
|
||||
for (final AccountGroupById g : toBeRemoved) {
|
||||
AccountGroupByIdAud audit = null;
|
||||
for (AccountGroupByIdAud a : db
|
||||
for (AccountGroupByIdAud a : db.get()
|
||||
.accountGroupByIdAud().byGroupInclude(g.getGroupId(),
|
||||
g.getIncludeUUID())) {
|
||||
if (a.isActive()) {
|
||||
@@ -126,9 +129,10 @@ public class DeleteIncludedGroups implements RestModifyView<GroupResource, Input
|
||||
auditUpdates.add(audit);
|
||||
}
|
||||
}
|
||||
db.accountGroupByIdAud().update(auditUpdates);
|
||||
db.get().accountGroupByIdAud().update(auditUpdates);
|
||||
}
|
||||
|
||||
@Singleton
|
||||
static class DeleteIncludedGroup implements
|
||||
RestModifyView<IncludedGroupResource, DeleteIncludedGroup.Input> {
|
||||
static class Input {
|
||||
|
@@ -36,19 +36,22 @@ import com.google.gerrit.server.util.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Singleton
|
||||
public class DeleteMembers implements RestModifyView<GroupResource, Input> {
|
||||
private final Provider<AccountsCollection> accounts;
|
||||
private final AccountCache accountCache;
|
||||
private final ReviewDb db;
|
||||
private final Provider<ReviewDb> db;
|
||||
private final Provider<CurrentUser> self;
|
||||
|
||||
@Inject
|
||||
DeleteMembers(Provider<AccountsCollection> accounts,
|
||||
AccountCache accountCache, ReviewDb db, Provider<CurrentUser> self) {
|
||||
AccountCache accountCache, Provider<ReviewDb> db,
|
||||
Provider<CurrentUser> self) {
|
||||
this.accounts = accounts;
|
||||
this.accountCache = accountCache;
|
||||
this.db = db;
|
||||
@@ -83,7 +86,7 @@ public class DeleteMembers implements RestModifyView<GroupResource, Input> {
|
||||
}
|
||||
|
||||
writeAudits(toRemove);
|
||||
db.accountGroupMembers().delete(toRemove);
|
||||
db.get().accountGroupMembers().delete(toRemove);
|
||||
for (final AccountGroupMember m : toRemove) {
|
||||
accountCache.evict(m.getAccountId());
|
||||
}
|
||||
@@ -98,7 +101,7 @@ public class DeleteMembers implements RestModifyView<GroupResource, Input> {
|
||||
final List<AccountGroupMemberAudit> auditInserts = Lists.newLinkedList();
|
||||
for (final AccountGroupMember m : toBeRemoved) {
|
||||
AccountGroupMemberAudit audit = null;
|
||||
for (AccountGroupMemberAudit a : db.accountGroupMembersAudit()
|
||||
for (AccountGroupMemberAudit a : db.get().accountGroupMembersAudit()
|
||||
.byGroupAccount(m.getAccountGroupId(), m.getAccountId())) {
|
||||
if (a.isActive()) {
|
||||
audit = a;
|
||||
@@ -115,19 +118,21 @@ public class DeleteMembers implements RestModifyView<GroupResource, Input> {
|
||||
auditInserts.add(audit);
|
||||
}
|
||||
}
|
||||
db.accountGroupMembersAudit().update(auditUpdates);
|
||||
db.accountGroupMembersAudit().insert(auditInserts);
|
||||
db.get().accountGroupMembersAudit().update(auditUpdates);
|
||||
db.get().accountGroupMembersAudit().insert(auditInserts);
|
||||
}
|
||||
|
||||
private Map<Account.Id, AccountGroupMember> getMembers(
|
||||
final AccountGroup.Id groupId) throws OrmException {
|
||||
final Map<Account.Id, AccountGroupMember> members = Maps.newHashMap();
|
||||
for (final AccountGroupMember m : db.accountGroupMembers().byGroup(groupId)) {
|
||||
for (final AccountGroupMember m : db.get().accountGroupMembers()
|
||||
.byGroup(groupId)) {
|
||||
members.put(m.getAccountId(), m);
|
||||
}
|
||||
return members;
|
||||
}
|
||||
|
||||
@Singleton
|
||||
static class DeleteMember implements RestModifyView<MemberResource, DeleteMember.Input> {
|
||||
static class Input {
|
||||
}
|
||||
|
@@ -18,7 +18,9 @@ import com.google.common.base.Strings;
|
||||
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
class GetDescription implements RestReadView<GroupResource> {
|
||||
@Override
|
||||
public String apply(GroupResource resource) throws MethodNotAllowedException {
|
||||
|
@@ -19,7 +19,9 @@ import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.server.group.GroupJson.GroupInfo;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class GetDetail implements RestReadView<GroupResource> {
|
||||
private final GroupJson json;
|
||||
|
||||
|
@@ -18,7 +18,9 @@ import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.server.group.GroupJson.GroupInfo;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
class GetGroup implements RestReadView<GroupResource> {
|
||||
private final GroupJson json;
|
||||
|
||||
|
@@ -18,7 +18,9 @@ import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.server.group.GroupJson.GroupInfo;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class GetIncludedGroup implements RestReadView<IncludedGroupResource> {
|
||||
private final GroupJson json;
|
||||
|
||||
|
@@ -18,7 +18,9 @@ import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.server.account.AccountInfo;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class GetMember implements RestReadView<MemberResource> {
|
||||
private final AccountInfo.Loader.Factory infoFactory;
|
||||
|
||||
|
@@ -15,7 +15,9 @@
|
||||
package com.google.gerrit.server.group;
|
||||
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class GetName implements RestReadView<GroupResource> {
|
||||
|
||||
@Override
|
||||
|
@@ -15,7 +15,9 @@
|
||||
package com.google.gerrit.server.group;
|
||||
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class GetOptions implements RestReadView<GroupResource> {
|
||||
|
||||
@Override
|
||||
|
@@ -23,7 +23,9 @@ import com.google.gerrit.server.account.GroupControl;
|
||||
import com.google.gerrit.server.group.GroupJson.GroupInfo;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class GetOwner implements RestReadView<GroupResource> {
|
||||
|
||||
private final GroupControl.Factory controlFactory;
|
||||
|
@@ -35,7 +35,9 @@ import com.google.gerrit.server.account.GroupBackends;
|
||||
import com.google.gerrit.server.account.GroupControl;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class GroupsCollection implements
|
||||
RestCollection<TopLevelResource, GroupResource>,
|
||||
AcceptsCreate<TopLevelResource> {
|
||||
|
@@ -31,7 +31,9 @@ import com.google.gerrit.server.group.AddIncludedGroups.PutIncludedGroup;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class IncludedGroupsCollection implements
|
||||
ChildCollection<GroupResource, IncludedGroupResource>,
|
||||
AcceptsCreate<GroupResource> {
|
||||
|
@@ -27,6 +27,7 @@ import com.google.gerrit.server.group.GroupJson.GroupInfo;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@@ -34,6 +35,7 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class ListIncludedGroups implements RestReadView<GroupResource> {
|
||||
private static final Logger log = org.slf4j.LoggerFactory.getLogger(ListIncludedGroups.class);
|
||||
|
||||
|
@@ -31,7 +31,9 @@ import com.google.gerrit.server.group.AddMembers.PutMember;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class MembersCollection implements
|
||||
ChildCollection<GroupResource, MemberResource>,
|
||||
AcceptsCreate<GroupResource> {
|
||||
|
@@ -27,9 +27,12 @@ import com.google.gerrit.server.account.GroupCache;
|
||||
import com.google.gerrit.server.group.PutDescription.Input;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@Singleton
|
||||
public class PutDescription implements RestModifyView<GroupResource, Input> {
|
||||
public static class Input {
|
||||
@DefaultInput
|
||||
@@ -37,10 +40,10 @@ public class PutDescription implements RestModifyView<GroupResource, Input> {
|
||||
}
|
||||
|
||||
private final GroupCache groupCache;
|
||||
private final ReviewDb db;
|
||||
private final Provider<ReviewDb> db;
|
||||
|
||||
@Inject
|
||||
PutDescription(GroupCache groupCache, ReviewDb db) {
|
||||
PutDescription(GroupCache groupCache, Provider<ReviewDb> db) {
|
||||
this.groupCache = groupCache;
|
||||
this.db = db;
|
||||
}
|
||||
@@ -59,14 +62,14 @@ public class PutDescription implements RestModifyView<GroupResource, Input> {
|
||||
throw new AuthException("Not group owner");
|
||||
}
|
||||
|
||||
AccountGroup group = db.accountGroups().get(
|
||||
AccountGroup group = db.get().accountGroups().get(
|
||||
resource.toAccountGroup().getId());
|
||||
if (group == null) {
|
||||
throw new ResourceNotFoundException();
|
||||
}
|
||||
|
||||
group.setDescription(Strings.emptyToNull(input.description));
|
||||
db.accountGroups().update(Collections.singleton(group));
|
||||
db.get().accountGroups().update(Collections.singleton(group));
|
||||
groupCache.evict(group);
|
||||
|
||||
return Strings.isNullOrEmpty(input.description)
|
||||
|
@@ -18,7 +18,9 @@ import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.extensions.restapi.Response;
|
||||
import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||
import com.google.gerrit.server.group.CreateGroup.Input;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class PutGroup implements RestModifyView<GroupResource, Input> {
|
||||
@Override
|
||||
public Response<?> apply(GroupResource resource, Input input)
|
||||
|
@@ -29,7 +29,9 @@ import com.google.gerrit.server.account.PerformRenameGroup;
|
||||
import com.google.gerrit.server.group.PutName.Input;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class PutName implements RestModifyView<GroupResource, Input> {
|
||||
public static class Input {
|
||||
@DefaultInput
|
||||
|
@@ -25,19 +25,22 @@ import com.google.gerrit.server.account.GroupCache;
|
||||
import com.google.gerrit.server.group.PutOptions.Input;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@Singleton
|
||||
public class PutOptions implements RestModifyView<GroupResource, Input> {
|
||||
public static class Input {
|
||||
public Boolean visibleToAll;
|
||||
}
|
||||
|
||||
private final GroupCache groupCache;
|
||||
private final ReviewDb db;
|
||||
private final Provider<ReviewDb> db;
|
||||
|
||||
@Inject
|
||||
PutOptions(GroupCache groupCache, ReviewDb db) {
|
||||
PutOptions(GroupCache groupCache, Provider<ReviewDb> db) {
|
||||
this.groupCache = groupCache;
|
||||
this.db = db;
|
||||
}
|
||||
@@ -59,14 +62,14 @@ public class PutOptions implements RestModifyView<GroupResource, Input> {
|
||||
input.visibleToAll = false;
|
||||
}
|
||||
|
||||
AccountGroup group = db.accountGroups().get(
|
||||
AccountGroup group = db.get().accountGroups().get(
|
||||
resource.toAccountGroup().getId());
|
||||
if (group == null) {
|
||||
throw new ResourceNotFoundException();
|
||||
}
|
||||
|
||||
group.setVisibleToAll(input.visibleToAll);
|
||||
db.accountGroups().update(Collections.singleton(group));
|
||||
db.get().accountGroups().update(Collections.singleton(group));
|
||||
groupCache.evict(group);
|
||||
|
||||
return new GroupOptionsInfo(group);
|
||||
|
@@ -31,9 +31,11 @@ import com.google.gerrit.server.group.PutOwner.Input;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
@Singleton
|
||||
public class PutOwner implements RestModifyView<GroupResource, Input> {
|
||||
public static class Input {
|
||||
@DefaultInput
|
||||
@@ -42,12 +44,12 @@ public class PutOwner implements RestModifyView<GroupResource, Input> {
|
||||
|
||||
private final Provider<GroupsCollection> groupsCollection;
|
||||
private final GroupCache groupCache;
|
||||
private final ReviewDb db;
|
||||
private final Provider<ReviewDb> db;
|
||||
private final GroupJson json;
|
||||
|
||||
@Inject
|
||||
PutOwner(Provider<GroupsCollection> groupsCollection, GroupCache groupCache,
|
||||
ReviewDb db, GroupJson json) {
|
||||
Provider<ReviewDb> db, GroupJson json) {
|
||||
this.groupsCollection = groupsCollection;
|
||||
this.groupCache = groupCache;
|
||||
this.db = db;
|
||||
@@ -70,7 +72,7 @@ public class PutOwner implements RestModifyView<GroupResource, Input> {
|
||||
throw new BadRequestException("owner is required");
|
||||
}
|
||||
|
||||
group = db.accountGroups().get(group.getId());
|
||||
group = db.get().accountGroups().get(group.getId());
|
||||
if (group == null) {
|
||||
throw new ResourceNotFoundException();
|
||||
}
|
||||
@@ -78,7 +80,7 @@ public class PutOwner implements RestModifyView<GroupResource, Input> {
|
||||
GroupDescription.Basic owner = groupsCollection.get().parse(input.owner);
|
||||
if (!group.getOwnerGroupUUID().equals(owner.getGroupUUID())) {
|
||||
group.setOwnerGroupUUID(owner.getGroupUUID());
|
||||
db.accountGroups().update(Collections.singleton(group));
|
||||
db.get().accountGroups().update(Collections.singleton(group));
|
||||
groupCache.evict(group);
|
||||
}
|
||||
return json.format(owner);
|
||||
|
@@ -22,8 +22,10 @@ import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||
import com.google.gerrit.server.plugins.DisablePlugin.Input;
|
||||
import com.google.gerrit.server.plugins.ListPlugins.PluginInfo;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
|
||||
@Singleton
|
||||
class DisablePlugin implements RestModifyView<PluginResource, Input> {
|
||||
static class Input {
|
||||
}
|
||||
|
@@ -23,11 +23,13 @@ import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||
import com.google.gerrit.server.plugins.EnablePlugin.Input;
|
||||
import com.google.gerrit.server.plugins.ListPlugins.PluginInfo;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
@RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
|
||||
@Singleton
|
||||
class EnablePlugin implements RestModifyView<PluginResource, Input> {
|
||||
static class Input {
|
||||
}
|
||||
|
@@ -16,7 +16,9 @@ package com.google.gerrit.server.plugins;
|
||||
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.server.plugins.ListPlugins.PluginInfo;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
class GetStatus implements RestReadView<PluginResource> {
|
||||
@Override
|
||||
public PluginInfo apply(PluginResource resource) {
|
||||
|
@@ -24,7 +24,9 @@ import com.google.gerrit.extensions.restapi.RestView;
|
||||
import com.google.gerrit.extensions.restapi.TopLevelResource;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class PluginsCollection implements
|
||||
RestCollection<TopLevelResource, PluginResource>,
|
||||
AcceptsCreate<TopLevelResource> {
|
||||
|
@@ -22,11 +22,13 @@ import com.google.gerrit.extensions.restapi.RestModifyView;
|
||||
import com.google.gerrit.server.plugins.ListPlugins.PluginInfo;
|
||||
import com.google.gerrit.server.plugins.ReloadPlugin.Input;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
||||
@RequiresCapability(GlobalCapability.ADMINISTRATE_SERVER)
|
||||
@Singleton
|
||||
class ReloadPlugin implements RestModifyView<PluginResource, Input> {
|
||||
static class Input {
|
||||
}
|
||||
|
@@ -23,12 +23,14 @@ import com.google.gerrit.extensions.restapi.RestView;
|
||||
import com.google.gerrit.server.project.ListBranches.BranchInfo;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.jgit.lib.Constants;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
public class BranchesCollection implements
|
||||
ChildCollection<ProjectResource, BranchResource>,
|
||||
AcceptsCreate<ProjectResource> {
|
||||
|
@@ -23,9 +23,11 @@ import com.google.gerrit.extensions.restapi.RestView;
|
||||
import com.google.gerrit.extensions.restapi.TopLevelResource;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Singleton
|
||||
public class ChildProjectsCollection implements
|
||||
ChildCollection<ProjectResource, ChildProjectResource> {
|
||||
private final Provider<ListChildProjects> list;
|
||||
|
@@ -37,6 +37,7 @@ import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.jgit.errors.AmbiguousObjectException;
|
||||
import org.eclipse.jgit.errors.ConfigInvalidException;
|
||||
@@ -51,9 +52,10 @@ import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.List;
|
||||
|
||||
@Singleton
|
||||
class DashboardsCollection implements
|
||||
ChildCollection<ProjectResource, DashboardResource>,
|
||||
AcceptsCreate<ProjectResource>{
|
||||
AcceptsCreate<ProjectResource> {
|
||||
private final GitRepositoryManager gitManager;
|
||||
private final DynamicMap<RestView<DashboardResource>> views;
|
||||
private final Provider<ListDashboards> list;
|
||||
|
@@ -27,6 +27,7 @@ import com.google.gerrit.server.project.DeleteBranch.Input;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import org.eclipse.jgit.lib.RefUpdate;
|
||||
import org.eclipse.jgit.lib.Repository;
|
||||
@@ -35,6 +36,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Singleton
|
||||
public class DeleteBranch implements RestModifyView<BranchResource, Input>{
|
||||
private static final Logger log = LoggerFactory.getLogger(DeleteBranch.class);
|
||||
|
||||
|
@@ -25,9 +25,11 @@ import com.google.gerrit.server.project.DashboardsCollection.DashboardInfo;
|
||||
import com.google.gerrit.server.project.DeleteDashboard.Input;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Singleton
|
||||
class DeleteDashboard implements RestModifyView<DashboardResource, Input> {
|
||||
static class Input {
|
||||
String commitMessage;
|
||||
|
@@ -21,7 +21,9 @@ import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.extensions.restapi.RestView;
|
||||
import com.google.gerrit.server.project.BranchResource;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class FilesCollection implements
|
||||
ChildCollection<BranchResource, FileResource> {
|
||||
private final DynamicMap<RestView<FileResource>> views;
|
||||
|
@@ -16,7 +16,9 @@ package com.google.gerrit.server.project;
|
||||
|
||||
import com.google.gerrit.extensions.restapi.RestReadView;
|
||||
import com.google.gerrit.server.project.ListBranches.BranchInfo;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class GetBranch implements RestReadView<BranchResource> {
|
||||
|
||||
@Override
|
||||
|
@@ -24,7 +24,9 @@ import com.google.gerrit.server.config.ProjectConfigEntry;
|
||||
import com.google.gerrit.server.git.TransferConfig;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class GetConfig implements RestReadView<ProjectResource> {
|
||||
|
||||
private final TransferConfig config;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user