Merge branch 'stable-2.15' into stable-2.16
* stable-2.15: Upgrade google-java-format to 1.7 Change-Id: Ia7383822ef59fb60bb5559956a065ae46b2e4f4a
This commit is contained in:
@@ -164,7 +164,7 @@ Guide].
|
|||||||
|
|
||||||
To format Java source code, Gerrit uses the
|
To format Java source code, Gerrit uses the
|
||||||
link:https://github.com/google/google-java-format[`google-java-format`]
|
link:https://github.com/google/google-java-format[`google-java-format`]
|
||||||
tool (version 1.6), and to format Bazel BUILD, WORKSPACE and .bzl files the
|
tool (version 1.7), and to format Bazel BUILD, WORKSPACE and .bzl files the
|
||||||
link:https://github.com/bazelbuild/buildtools/tree/master/buildifier[`buildifier`]
|
link:https://github.com/bazelbuild/buildtools/tree/master/buildifier[`buildifier`]
|
||||||
tool (version 0.20.0).
|
tool (version 0.20.0).
|
||||||
These tools automatically apply format according to the style guides; this
|
These tools automatically apply format according to the style guides; this
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ Java 8 is still the default:
|
|||||||
|
|
||||||
To format source code, Gerrit uses the
|
To format source code, Gerrit uses the
|
||||||
link:https://github.com/google/google-java-format[`google-java-format`]
|
link:https://github.com/google/google-java-format[`google-java-format`]
|
||||||
tool (version 1.3), which automatically formats code to follow the
|
tool (version 1.7), which automatically formats code to follow the
|
||||||
style guide. See link:dev-contributing.html#style[Code Style] for the
|
style guide. See link:dev-contributing.html#style[Code Style] for the
|
||||||
instruction how to set up command line tool that uses this formatter.
|
instruction how to set up command line tool that uses this formatter.
|
||||||
The Eclipse plugin is provided that allows to format with the same
|
The Eclipse plugin is provided that allows to format with the same
|
||||||
|
|||||||
@@ -140,8 +140,7 @@ class Labels extends Grid {
|
|||||||
|
|
||||||
void set(ChangeInfo info) {
|
void set(ChangeInfo info) {
|
||||||
List<String> names =
|
List<String> names =
|
||||||
info.labels()
|
info.labels().stream()
|
||||||
.stream()
|
|
||||||
.sorted()
|
.sorted()
|
||||||
.collect(collectingAndThen(toList(), Collections::unmodifiableList));
|
.collect(collectingAndThen(toList(), Collections::unmodifiableList));
|
||||||
Set<Integer> removable = info.removableReviewerIds();
|
Set<Integer> removable = info.removableReviewerIds();
|
||||||
|
|||||||
@@ -126,9 +126,7 @@ public class ReplyBox extends Composite {
|
|||||||
initWidget(uiBinder.createAndBindUi(this));
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
|
|
||||||
List<String> names =
|
List<String> names =
|
||||||
permitted
|
permitted.keySet().stream()
|
||||||
.keySet()
|
|
||||||
.stream()
|
|
||||||
.sorted()
|
.sorted()
|
||||||
.collect(collectingAndThen(toList(), Collections::unmodifiableList));
|
.collect(collectingAndThen(toList(), Collections::unmodifiableList));
|
||||||
if (names.isEmpty()) {
|
if (names.isEmpty()) {
|
||||||
@@ -446,8 +444,7 @@ public class ReplyBox extends Composite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<String> paths =
|
List<String> paths =
|
||||||
m.keySet()
|
m.keySet().stream()
|
||||||
.stream()
|
|
||||||
.sorted()
|
.sorted()
|
||||||
.collect(collectingAndThen(toList(), Collections::unmodifiableList));
|
.collect(collectingAndThen(toList(), Collections::unmodifiableList));
|
||||||
|
|
||||||
|
|||||||
@@ -116,9 +116,7 @@ public abstract class AbstractNotificationTest extends AbstractDaemonTest {
|
|||||||
recipients.put(CC, parseAddresses(message, "Cc"));
|
recipients.put(CC, parseAddresses(message, "Cc"));
|
||||||
recipients.put(
|
recipients.put(
|
||||||
BCC,
|
BCC,
|
||||||
message
|
message.rcpt().stream()
|
||||||
.rcpt()
|
|
||||||
.stream()
|
|
||||||
.map(Address::getEmail)
|
.map(Address::getEmail)
|
||||||
.filter(e -> !recipients.get(TO).contains(e) && !recipients.get(CC).contains(e))
|
.filter(e -> !recipients.get(TO).contains(e) && !recipients.get(CC).contains(e))
|
||||||
.collect(toList()));
|
.collect(toList()));
|
||||||
|
|||||||
@@ -65,8 +65,7 @@ public class HttpResponse {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableList<String> getHeaders(String name) {
|
public ImmutableList<String> getHeaders(String name) {
|
||||||
return Arrays.asList(response.getHeaders(name))
|
return Arrays.asList(response.getHeaders(name)).stream()
|
||||||
.stream()
|
|
||||||
.map(Header::getValue)
|
.map(Header::getValue)
|
||||||
.collect(toImmutableList());
|
.collect(toImmutableList());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -260,9 +260,7 @@ public class ProjectResetter implements AutoCloseable {
|
|||||||
refsPatternByProject.asMap().entrySet()) {
|
refsPatternByProject.asMap().entrySet()) {
|
||||||
try (Repository repo = repoManager.openRepository(e.getKey())) {
|
try (Repository repo = repoManager.openRepository(e.getKey())) {
|
||||||
Collection<Ref> nonRestoredRefs =
|
Collection<Ref> nonRestoredRefs =
|
||||||
repo.getRefDatabase()
|
repo.getRefDatabase().getRefs().stream()
|
||||||
.getRefs()
|
|
||||||
.stream()
|
|
||||||
.filter(
|
.filter(
|
||||||
r ->
|
r ->
|
||||||
!keptRefsByProject.containsEntry(e.getKey(), r.getName())
|
!keptRefsByProject.containsEntry(e.getKey(), r.getName())
|
||||||
@@ -315,9 +313,7 @@ public class ProjectResetter implements AutoCloseable {
|
|||||||
|
|
||||||
private Set<Project.NameKey> projectsWithConfigChanges(
|
private Set<Project.NameKey> projectsWithConfigChanges(
|
||||||
Multimap<Project.NameKey, String> projects) {
|
Multimap<Project.NameKey, String> projects) {
|
||||||
return projects
|
return projects.entries().stream()
|
||||||
.entries()
|
|
||||||
.stream()
|
|
||||||
.filter(e -> e.getValue().equals(RefNames.REFS_CONFIG))
|
.filter(e -> e.getValue().equals(RefNames.REFS_CONFIG))
|
||||||
.map(Map.Entry::getKey)
|
.map(Map.Entry::getKey)
|
||||||
.collect(toSet());
|
.collect(toSet());
|
||||||
|
|||||||
@@ -42,9 +42,7 @@ public class ReindexProjectsAtStartup implements LifecycleListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start() {
|
public void start() {
|
||||||
repoMgr
|
repoMgr.list().stream()
|
||||||
.list()
|
|
||||||
.stream()
|
|
||||||
.forEach(
|
.forEach(
|
||||||
projectName -> {
|
projectName -> {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -54,11 +54,8 @@ class ElasticIndexVersionDiscovery {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new JsonParser()
|
return new JsonParser()
|
||||||
.parse(AbstractElasticIndex.getContent(response))
|
.parse(AbstractElasticIndex.getContent(response)).getAsJsonObject().entrySet().stream()
|
||||||
.getAsJsonObject()
|
.map(e -> e.getKey().replace(name, ""))
|
||||||
.entrySet()
|
.collect(toList());
|
||||||
.stream()
|
|
||||||
.map(e -> e.getKey().replace(name, ""))
|
|
||||||
.collect(toList());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -226,8 +226,7 @@ public class DynamicSet<T> implements Iterable<T> {
|
|||||||
* @return sorted set of active plugins that supply at least one item.
|
* @return sorted set of active plugins that supply at least one item.
|
||||||
*/
|
*/
|
||||||
public ImmutableSortedSet<String> plugins() {
|
public ImmutableSortedSet<String> plugins() {
|
||||||
return items
|
return items.stream()
|
||||||
.stream()
|
|
||||||
.map(i -> i.get().getPluginName())
|
.map(i -> i.get().getPluginName())
|
||||||
.collect(toImmutableSortedSet(naturalOrder()));
|
.collect(toImmutableSortedSet(naturalOrder()));
|
||||||
}
|
}
|
||||||
@@ -239,8 +238,7 @@ public class DynamicSet<T> implements Iterable<T> {
|
|||||||
* @return items exported by a plugin.
|
* @return items exported by a plugin.
|
||||||
*/
|
*/
|
||||||
public ImmutableSet<Provider<T>> byPlugin(String pluginName) {
|
public ImmutableSet<Provider<T>> byPlugin(String pluginName) {
|
||||||
return items
|
return items.stream()
|
||||||
.stream()
|
|
||||||
.filter(i -> i.get().getPluginName().equals(pluginName))
|
.filter(i -> i.get().getPluginName().equals(pluginName))
|
||||||
.map(i -> i.get().getProvider())
|
.map(i -> i.get().getProvider())
|
||||||
.collect(toImmutableSet());
|
.collect(toImmutableSet());
|
||||||
|
|||||||
@@ -61,9 +61,7 @@ public class ProjectField {
|
|||||||
storedOnly("ref_state")
|
storedOnly("ref_state")
|
||||||
.buildRepeatable(
|
.buildRepeatable(
|
||||||
projectData ->
|
projectData ->
|
||||||
projectData
|
projectData.tree().stream()
|
||||||
.tree()
|
|
||||||
.stream()
|
|
||||||
.filter(p -> p.getProject().getConfigRefState() != null)
|
.filter(p -> p.getProject().getConfigRefState() != null)
|
||||||
.map(p -> toRefState(p.getProject()))
|
.map(p -> toRefState(p.getProject()))
|
||||||
.collect(toImmutableList()));
|
.collect(toImmutableList()));
|
||||||
|
|||||||
@@ -373,8 +373,7 @@ public abstract class QueryProcessor<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Optional<QueryParseException> findQueryParseException(Throwable t) {
|
private static Optional<QueryParseException> findQueryParseException(Throwable t) {
|
||||||
return Throwables.getCausalChain(t)
|
return Throwables.getCausalChain(t).stream()
|
||||||
.stream()
|
|
||||||
.filter(c -> c instanceof QueryParseException)
|
.filter(c -> c instanceof QueryParseException)
|
||||||
.map(QueryParseException.class::cast)
|
.map(QueryParseException.class::cast)
|
||||||
.findFirst();
|
.findFirst();
|
||||||
|
|||||||
@@ -626,9 +626,7 @@ public final class GerritLauncher {
|
|||||||
* @return true if any thread has a stack frame in {@code org.eclipse.jdt}.
|
* @return true if any thread has a stack frame in {@code org.eclipse.jdt}.
|
||||||
*/
|
*/
|
||||||
public static boolean isRunningInEclipse() {
|
public static boolean isRunningInEclipse() {
|
||||||
return Thread.getAllStackTraces()
|
return Thread.getAllStackTraces().values().stream()
|
||||||
.values()
|
|
||||||
.stream()
|
|
||||||
.flatMap(Arrays::stream)
|
.flatMap(Arrays::stream)
|
||||||
.anyMatch(e -> e.getClassName().startsWith("org.eclipse.jdt."));
|
.anyMatch(e -> e.getClassName().startsWith("org.eclipse.jdt."));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -655,8 +655,7 @@ public class LuceneChangeIndex implements ChangeIndex {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static List<byte[]> copyAsBytes(Collection<IndexableField> fields) {
|
private static List<byte[]> copyAsBytes(Collection<IndexableField> fields) {
|
||||||
return fields
|
return fields.stream()
|
||||||
.stream()
|
|
||||||
.map(
|
.map(
|
||||||
f -> {
|
f -> {
|
||||||
BytesRef ref = f.binaryValue();
|
BytesRef ref = f.binaryValue();
|
||||||
|
|||||||
@@ -78,8 +78,7 @@ public class HtmlParser {
|
|||||||
for (Element e : d.body().getAllElements()) {
|
for (Element e : d.body().getAllElements()) {
|
||||||
String elementName = e.tagName();
|
String elementName = e.tagName();
|
||||||
boolean isInBlockQuote =
|
boolean isInBlockQuote =
|
||||||
e.parents()
|
e.parents().stream()
|
||||||
.stream()
|
|
||||||
.anyMatch(
|
.anyMatch(
|
||||||
p ->
|
p ->
|
||||||
p.tagName().equals("blockquote")
|
p.tagName().equals("blockquote")
|
||||||
|
|||||||
@@ -85,10 +85,7 @@ public class RawMailParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add additional headers
|
// Add additional headers
|
||||||
mimeMessage
|
mimeMessage.getHeader().getFields().stream()
|
||||||
.getHeader()
|
|
||||||
.getFields()
|
|
||||||
.stream()
|
|
||||||
.filter(f -> !MAIN_HEADERS.contains(f.getName().toLowerCase()))
|
.filter(f -> !MAIN_HEADERS.contains(f.getName().toLowerCase()))
|
||||||
.forEach(f -> messageBuilder.addAdditionalHeader(f.getName() + ": " + f.getBody()));
|
.forEach(f -> messageBuilder.addAdditionalHeader(f.getName() + ": " + f.getBody()));
|
||||||
|
|
||||||
|
|||||||
@@ -53,8 +53,7 @@ public class InitLogging implements InitStep {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isSet(List<String> javaOptions, String javaOptionName) {
|
private static boolean isSet(List<String> javaOptions, String javaOptionName) {
|
||||||
return javaOptions
|
return javaOptions.stream()
|
||||||
.stream()
|
|
||||||
.anyMatch(
|
.anyMatch(
|
||||||
o ->
|
o ->
|
||||||
o.startsWith("-D" + javaOptionName + "=")
|
o.startsWith("-D" + javaOptionName + "=")
|
||||||
|
|||||||
@@ -221,8 +221,7 @@ public class CommentsUtil {
|
|||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
return draftByChangeAuthor(db, notes, user.getAccountId())
|
return draftByChangeAuthor(db, notes, user.getAccountId()).stream()
|
||||||
.stream()
|
|
||||||
.filter(c -> key.equals(c.key))
|
.filter(c -> key.equals(c.key))
|
||||||
.findFirst();
|
.findFirst();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,9 +107,7 @@ public class CreateGroupPermissionSyncer implements ChangeMergedListener {
|
|||||||
config.getAccessSection(RefNames.REFS_GROUPS + "*", true);
|
config.getAccessSection(RefNames.REFS_GROUPS + "*", true);
|
||||||
if (createGroupsGlobal.isEmpty()) {
|
if (createGroupsGlobal.isEmpty()) {
|
||||||
createGroupAccessSection.setPermissions(
|
createGroupAccessSection.setPermissions(
|
||||||
createGroupAccessSection
|
createGroupAccessSection.getPermissions().stream()
|
||||||
.getPermissions()
|
|
||||||
.stream()
|
|
||||||
.filter(p -> !Permission.CREATE.equals(p.getName()))
|
.filter(p -> !Permission.CREATE.equals(p.getName()))
|
||||||
.collect(toList()));
|
.collect(toList()));
|
||||||
config.replace(createGroupAccessSection);
|
config.replace(createGroupAccessSection);
|
||||||
|
|||||||
@@ -27,8 +27,7 @@ public class ModuleOverloader {
|
|||||||
|
|
||||||
// group candidates by annotation existence
|
// group candidates by annotation existence
|
||||||
Map<Boolean, List<Module>> grouped =
|
Map<Boolean, List<Module>> grouped =
|
||||||
overrideCandidates
|
overrideCandidates.stream()
|
||||||
.stream()
|
|
||||||
.collect(
|
.collect(
|
||||||
Collectors.groupingBy(m -> m.getClass().getAnnotation(ModuleImpl.class) != null));
|
Collectors.groupingBy(m -> m.getClass().getAnnotation(ModuleImpl.class) != null));
|
||||||
|
|
||||||
@@ -44,16 +43,14 @@ public class ModuleOverloader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// swipe cache implementation with alternative provided in lib
|
// swipe cache implementation with alternative provided in lib
|
||||||
return modules
|
return modules.stream()
|
||||||
.stream()
|
|
||||||
.map(
|
.map(
|
||||||
m -> {
|
m -> {
|
||||||
ModuleImpl a = m.getClass().getAnnotation(ModuleImpl.class);
|
ModuleImpl a = m.getClass().getAnnotation(ModuleImpl.class);
|
||||||
if (a == null) {
|
if (a == null) {
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
return overrides
|
return overrides.stream()
|
||||||
.stream()
|
|
||||||
.filter(
|
.filter(
|
||||||
o ->
|
o ->
|
||||||
o.getClass()
|
o.getClass()
|
||||||
|
|||||||
@@ -298,9 +298,7 @@ public class StarredChangesUtil {
|
|||||||
|
|
||||||
private static Set<String> getRefNames(Repository repo, String prefix) throws IOException {
|
private static Set<String> getRefNames(Repository repo, String prefix) throws IOException {
|
||||||
RefDatabase refDb = repo.getRefDatabase();
|
RefDatabase refDb = repo.getRefDatabase();
|
||||||
return refDb
|
return refDb.getRefsByPrefix(prefix).stream()
|
||||||
.getRefsByPrefix(prefix)
|
|
||||||
.stream()
|
|
||||||
.map(r -> r.getName().substring(prefix.length()))
|
.map(r -> r.getName().substring(prefix.length()))
|
||||||
.collect(toSet());
|
.collect(toSet());
|
||||||
}
|
}
|
||||||
@@ -425,8 +423,7 @@ public class StarredChangesUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Set<Integer> getStarredPatchSets(Set<String> labels, String label) {
|
public static Set<Integer> getStarredPatchSets(Set<String> labels, String label) {
|
||||||
return labels
|
return labels.stream()
|
||||||
.stream()
|
|
||||||
.filter(l -> l.startsWith(label + "/"))
|
.filter(l -> l.startsWith(label + "/"))
|
||||||
.filter(l -> Ints.tryParse(l.substring(label.length() + 1)) != null)
|
.filter(l -> Ints.tryParse(l.substring(label.length() + 1)) != null)
|
||||||
.map(l -> Integer.valueOf(l.substring(label.length() + 1)))
|
.map(l -> Integer.valueOf(l.substring(label.length() + 1)))
|
||||||
|
|||||||
@@ -215,9 +215,7 @@ public class AccountControl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Set<AccountGroup.UUID> groupsOf(IdentifiedUser user) {
|
private Set<AccountGroup.UUID> groupsOf(IdentifiedUser user) {
|
||||||
return user.getEffectiveGroups()
|
return user.getEffectiveGroups().getKnownGroups().stream()
|
||||||
.getKnownGroups()
|
|
||||||
.stream()
|
|
||||||
.filter(a -> !SystemGroupBackend.isSystemGroup(a))
|
.filter(a -> !SystemGroupBackend.isSystemGroup(a))
|
||||||
.collect(toSet());
|
.collect(toSet());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -456,8 +456,7 @@ public class AccountManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (filteredExtIdsByScheme.size() > 1
|
if (filteredExtIdsByScheme.size() > 1
|
||||||
|| !filteredExtIdsByScheme
|
|| !filteredExtIdsByScheme.stream()
|
||||||
.stream()
|
|
||||||
.anyMatch(e -> e.key().equals(who.getExternalIdKey()))) {
|
.anyMatch(e -> e.key().equals(who.getExternalIdKey()))) {
|
||||||
u.deleteExternalIds(filteredExtIdsByScheme);
|
u.deleteExternalIds(filteredExtIdsByScheme);
|
||||||
}
|
}
|
||||||
@@ -514,8 +513,7 @@ public class AccountManager {
|
|||||||
(a, u) -> {
|
(a, u) -> {
|
||||||
u.deleteExternalIds(extIds);
|
u.deleteExternalIds(extIds);
|
||||||
if (a.getAccount().getPreferredEmail() != null
|
if (a.getAccount().getPreferredEmail() != null
|
||||||
&& extIds
|
&& extIds.stream()
|
||||||
.stream()
|
|
||||||
.anyMatch(e -> a.getAccount().getPreferredEmail().equals(e.email()))) {
|
.anyMatch(e -> a.getAccount().getPreferredEmail().equals(e.email()))) {
|
||||||
u.setPreferredEmail(null);
|
u.setPreferredEmail(null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,10 +205,7 @@ public class AccountResolver {
|
|||||||
// and pray we come up with a reasonable result list.
|
// and pray we come up with a reasonable result list.
|
||||||
// TODO(dborowitz): This doesn't match the documentation; consider whether it's possible to be
|
// TODO(dborowitz): This doesn't match the documentation; consider whether it's possible to be
|
||||||
// more strict here.
|
// more strict here.
|
||||||
return accountQueryProvider
|
return accountQueryProvider.get().byDefault(nameOrEmail).stream()
|
||||||
.get()
|
|
||||||
.byDefault(nameOrEmail)
|
|
||||||
.stream()
|
|
||||||
.map(a -> a.getAccount().getId())
|
.map(a -> a.getAccount().getId())
|
||||||
.collect(toSet());
|
.collect(toSet());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,9 +140,7 @@ public class Accounts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Stream<Account.Id> readUserRefs(Repository repo) throws IOException {
|
public static Stream<Account.Id> readUserRefs(Repository repo) throws IOException {
|
||||||
return repo.getRefDatabase()
|
return repo.getRefDatabase().getRefsByPrefix(RefNames.REFS_USERS).stream()
|
||||||
.getRefsByPrefix(RefNames.REFS_USERS)
|
|
||||||
.stream()
|
|
||||||
.map(r -> Account.Id.fromRef(r.getName()))
|
.map(r -> Account.Id.fromRef(r.getName()))
|
||||||
.filter(Objects::nonNull);
|
.filter(Objects::nonNull);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,9 +37,7 @@ public class AccountsConsistencyChecker {
|
|||||||
for (AccountState accountState : accounts.all()) {
|
for (AccountState accountState : accounts.all()) {
|
||||||
Account account = accountState.getAccount();
|
Account account = accountState.getAccount();
|
||||||
if (account.getPreferredEmail() != null) {
|
if (account.getPreferredEmail() != null) {
|
||||||
if (!accountState
|
if (!accountState.getExternalIds().stream()
|
||||||
.getExternalIds()
|
|
||||||
.stream()
|
|
||||||
.anyMatch(e -> account.getPreferredEmail().equals(e.email()))) {
|
.anyMatch(e -> account.getPreferredEmail().equals(e.email()))) {
|
||||||
addError(
|
addError(
|
||||||
String.format(
|
String.format(
|
||||||
|
|||||||
@@ -462,9 +462,7 @@ public class AccountsUpdate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Set<Account.Id> getUpdatedAccounts(BatchRefUpdate batchRefUpdate) {
|
private static Set<Account.Id> getUpdatedAccounts(BatchRefUpdate batchRefUpdate) {
|
||||||
return batchRefUpdate
|
return batchRefUpdate.getCommands().stream()
|
||||||
.getCommands()
|
|
||||||
.stream()
|
|
||||||
.map(c -> Account.Id.fromRef(c.getRefName()))
|
.map(c -> Account.Id.fromRef(c.getRefName()))
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.collect(toSet());
|
.collect(toSet());
|
||||||
|
|||||||
@@ -85,10 +85,7 @@ public class Emails {
|
|||||||
public ImmutableSetMultimap<String, Account.Id> getAccountsFor(String... emails)
|
public ImmutableSetMultimap<String, Account.Id> getAccountsFor(String... emails)
|
||||||
throws IOException, OrmException {
|
throws IOException, OrmException {
|
||||||
ImmutableSetMultimap.Builder<String, Account.Id> builder = ImmutableSetMultimap.builder();
|
ImmutableSetMultimap.Builder<String, Account.Id> builder = ImmutableSetMultimap.builder();
|
||||||
externalIds
|
externalIds.byEmails(emails).entries().stream()
|
||||||
.byEmails(emails)
|
|
||||||
.entries()
|
|
||||||
.stream()
|
|
||||||
.forEach(e -> builder.put(e.getKey(), e.getValue().accountId()));
|
.forEach(e -> builder.put(e.getKey(), e.getValue().accountId()));
|
||||||
executeIndexQuery(() -> queryProvider.get().byPreferredEmail(emails).entries().stream())
|
executeIndexQuery(() -> queryProvider.get().byPreferredEmail(emails).entries().stream())
|
||||||
.forEach(e -> builder.put(e.getKey(), e.getValue().getAccount().getId()));
|
.forEach(e -> builder.put(e.getKey(), e.getValue().getAccount().getId()));
|
||||||
|
|||||||
@@ -154,10 +154,7 @@ public class GroupIncludeCacheImpl implements GroupIncludeCache {
|
|||||||
@Override
|
@Override
|
||||||
public ImmutableSet<AccountGroup.UUID> load(Account.Id memberId) throws OrmException {
|
public ImmutableSet<AccountGroup.UUID> load(Account.Id memberId) throws OrmException {
|
||||||
try (TraceTimer timer = TraceContext.newTimer("Loading groups with member %s", memberId)) {
|
try (TraceTimer timer = TraceContext.newTimer("Loading groups with member %s", memberId)) {
|
||||||
return groupQueryProvider
|
return groupQueryProvider.get().byMember(memberId).stream()
|
||||||
.get()
|
|
||||||
.byMember(memberId)
|
|
||||||
.stream()
|
|
||||||
.map(InternalGroup::getGroupUUID)
|
.map(InternalGroup::getGroupUUID)
|
||||||
.collect(toImmutableSet());
|
.collect(toImmutableSet());
|
||||||
}
|
}
|
||||||
@@ -176,10 +173,7 @@ public class GroupIncludeCacheImpl implements GroupIncludeCache {
|
|||||||
@Override
|
@Override
|
||||||
public ImmutableList<AccountGroup.UUID> load(AccountGroup.UUID key) throws OrmException {
|
public ImmutableList<AccountGroup.UUID> load(AccountGroup.UUID key) throws OrmException {
|
||||||
try (TraceTimer timer = TraceContext.newTimer("Loading parent groups of %s", key)) {
|
try (TraceTimer timer = TraceContext.newTimer("Loading parent groups of %s", key)) {
|
||||||
return groupQueryProvider
|
return groupQueryProvider.get().bySubgroup(key).stream()
|
||||||
.get()
|
|
||||||
.bySubgroup(key)
|
|
||||||
.stream()
|
|
||||||
.map(InternalGroup::getGroupUUID)
|
.map(InternalGroup::getGroupUUID)
|
||||||
.collect(toImmutableList());
|
.collect(toImmutableList());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,9 +127,7 @@ public class GroupMembers {
|
|||||||
GroupControl groupControl = groupControlFactory.controlFor(new InternalGroupDescription(group));
|
GroupControl groupControl = groupControlFactory.controlFor(new InternalGroupDescription(group));
|
||||||
|
|
||||||
Set<Account> directMembers =
|
Set<Account> directMembers =
|
||||||
group
|
group.getMembers().stream()
|
||||||
.getMembers()
|
|
||||||
.stream()
|
|
||||||
.filter(groupControl::canSeeMember)
|
.filter(groupControl::canSeeMember)
|
||||||
.map(accountCache::get)
|
.map(accountCache::get)
|
||||||
.flatMap(Streams::stream)
|
.flatMap(Streams::stream)
|
||||||
|
|||||||
@@ -202,9 +202,7 @@ public class ProjectWatches {
|
|||||||
private static ImmutableMap<ProjectWatchKey, ImmutableSet<NotifyType>> immutableCopyOf(
|
private static ImmutableMap<ProjectWatchKey, ImmutableSet<NotifyType>> immutableCopyOf(
|
||||||
Map<ProjectWatchKey, Set<NotifyType>> projectWatches) {
|
Map<ProjectWatchKey, Set<NotifyType>> projectWatches) {
|
||||||
ImmutableMap.Builder<ProjectWatchKey, ImmutableSet<NotifyType>> b = ImmutableMap.builder();
|
ImmutableMap.Builder<ProjectWatchKey, ImmutableSet<NotifyType>> b = ImmutableMap.builder();
|
||||||
projectWatches
|
projectWatches.entrySet().stream()
|
||||||
.entrySet()
|
|
||||||
.stream()
|
|
||||||
.forEach(e -> b.put(e.getKey(), ImmutableSet.copyOf(e.getValue())));
|
.forEach(e -> b.put(e.getKey(), ImmutableSet.copyOf(e.getValue())));
|
||||||
return b.build();
|
return b.build();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -218,8 +218,7 @@ public class UniversalGroupBackend implements GroupBackend {
|
|||||||
@Override
|
@Override
|
||||||
public void check() throws StartupException {
|
public void check() throws StartupException {
|
||||||
String invalid =
|
String invalid =
|
||||||
cfg.getSubsections("groups")
|
cfg.getSubsections("groups").stream()
|
||||||
.stream()
|
|
||||||
.filter(
|
.filter(
|
||||||
sub -> {
|
sub -> {
|
||||||
AccountGroup.UUID uuid = new AccountGroup.UUID(sub);
|
AccountGroup.UUID uuid = new AccountGroup.UUID(sub);
|
||||||
|
|||||||
@@ -45,8 +45,7 @@ public abstract class AllExternalIds {
|
|||||||
|
|
||||||
private static ImmutableSetMultimap<String, ExternalId> byEmailCopy(
|
private static ImmutableSetMultimap<String, ExternalId> byEmailCopy(
|
||||||
Collection<ExternalId> externalIds) {
|
Collection<ExternalId> externalIds) {
|
||||||
return externalIds
|
return externalIds.stream()
|
||||||
.stream()
|
|
||||||
.filter(e -> !Strings.isNullOrEmpty(e.email()))
|
.filter(e -> !Strings.isNullOrEmpty(e.email()))
|
||||||
.collect(toImmutableSetMultimap(e -> e.email(), e -> e));
|
.collect(toImmutableSetMultimap(e -> e.email(), e -> e));
|
||||||
}
|
}
|
||||||
@@ -62,10 +61,7 @@ public abstract class AllExternalIds {
|
|||||||
public byte[] serialize(AllExternalIds object) {
|
public byte[] serialize(AllExternalIds object) {
|
||||||
ObjectIdConverter idConverter = ObjectIdConverter.create();
|
ObjectIdConverter idConverter = ObjectIdConverter.create();
|
||||||
AllExternalIdsProto.Builder allBuilder = AllExternalIdsProto.newBuilder();
|
AllExternalIdsProto.Builder allBuilder = AllExternalIdsProto.newBuilder();
|
||||||
object
|
object.byAccount().values().stream()
|
||||||
.byAccount()
|
|
||||||
.values()
|
|
||||||
.stream()
|
|
||||||
.map(extId -> toProto(idConverter, extId))
|
.map(extId -> toProto(idConverter, extId))
|
||||||
.forEach(allBuilder::addExternalId);
|
.forEach(allBuilder::addExternalId);
|
||||||
return ProtoCacheSerializers.toByteArray(allBuilder.build());
|
return ProtoCacheSerializers.toByteArray(allBuilder.build());
|
||||||
@@ -92,8 +88,7 @@ public abstract class AllExternalIds {
|
|||||||
public AllExternalIds deserialize(byte[] in) {
|
public AllExternalIds deserialize(byte[] in) {
|
||||||
ObjectIdConverter idConverter = ObjectIdConverter.create();
|
ObjectIdConverter idConverter = ObjectIdConverter.create();
|
||||||
return create(
|
return create(
|
||||||
ProtoCacheSerializers.parseUnchecked(AllExternalIdsProto.parser(), in)
|
ProtoCacheSerializers.parseUnchecked(AllExternalIdsProto.parser(), in).getExternalIdList()
|
||||||
.getExternalIdList()
|
|
||||||
.stream()
|
.stream()
|
||||||
.map(proto -> toExternalId(idConverter, proto))
|
.map(proto -> toExternalId(idConverter, proto))
|
||||||
.collect(toList()));
|
.collect(toList()));
|
||||||
|
|||||||
@@ -82,8 +82,7 @@ public abstract class ExternalId implements Serializable {
|
|||||||
* ExternalId#SCHEME_USERNAME} scheme
|
* ExternalId#SCHEME_USERNAME} scheme
|
||||||
*/
|
*/
|
||||||
public static Optional<String> getUserName(Collection<ExternalId> extIds) {
|
public static Optional<String> getUserName(Collection<ExternalId> extIds) {
|
||||||
return extIds
|
return extIds.stream()
|
||||||
.stream()
|
|
||||||
.filter(e -> e.isScheme(SCHEME_USERNAME))
|
.filter(e -> e.isScheme(SCHEME_USERNAME))
|
||||||
.map(e -> e.key().id())
|
.map(e -> e.key().id())
|
||||||
.filter(u -> !Strings.isNullOrEmpty(u))
|
.filter(u -> !Strings.isNullOrEmpty(u))
|
||||||
|
|||||||
@@ -762,8 +762,7 @@ public class ExternalIdNotes extends VersionedMetaData {
|
|||||||
noteMapUpdates.clear();
|
noteMapUpdates.clear();
|
||||||
if (!footers.isEmpty()) {
|
if (!footers.isEmpty()) {
|
||||||
commit.setMessage(
|
commit.setMessage(
|
||||||
footers
|
footers.stream()
|
||||||
.stream()
|
|
||||||
.sorted()
|
.sorted()
|
||||||
.collect(joining("\n", commit.getMessage().trim() + "\n\n", "")));
|
.collect(joining("\n", commit.getMessage().trim() + "\n\n", "")));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,8 +71,7 @@ public class ExternalIds {
|
|||||||
|
|
||||||
/** Returns the external IDs of the specified account that have the given scheme. */
|
/** Returns the external IDs of the specified account that have the given scheme. */
|
||||||
public Set<ExternalId> byAccount(Account.Id accountId, String scheme) throws IOException {
|
public Set<ExternalId> byAccount(Account.Id accountId, String scheme) throws IOException {
|
||||||
return byAccount(accountId)
|
return byAccount(accountId).stream()
|
||||||
.stream()
|
|
||||||
.filter(e -> e.key().isScheme(scheme))
|
.filter(e -> e.key().isScheme(scheme))
|
||||||
.collect(toImmutableSet());
|
.collect(toImmutableSet());
|
||||||
}
|
}
|
||||||
@@ -85,8 +84,7 @@ public class ExternalIds {
|
|||||||
/** Returns the external IDs of the specified account that have the given scheme. */
|
/** Returns the external IDs of the specified account that have the given scheme. */
|
||||||
public Set<ExternalId> byAccount(Account.Id accountId, String scheme, ObjectId rev)
|
public Set<ExternalId> byAccount(Account.Id accountId, String scheme, ObjectId rev)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
return byAccount(accountId, rev)
|
return byAccount(accountId, rev).stream()
|
||||||
.stream()
|
|
||||||
.filter(e -> e.key().isScheme(scheme))
|
.filter(e -> e.key().isScheme(scheme))
|
||||||
.collect(toImmutableSet());
|
.collect(toImmutableSet());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,10 +93,7 @@ public class ExternalIdsConsistencyChecker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emails
|
emails.asMap().entrySet().stream()
|
||||||
.asMap()
|
|
||||||
.entrySet()
|
|
||||||
.stream()
|
|
||||||
.filter(e -> e.getValue().size() > 1)
|
.filter(e -> e.getValue().size() > 1)
|
||||||
.forEach(
|
.forEach(
|
||||||
e ->
|
e ->
|
||||||
@@ -104,8 +101,7 @@ public class ExternalIdsConsistencyChecker {
|
|||||||
String.format(
|
String.format(
|
||||||
"Email '%s' is not unique, it's used by the following external IDs: %s",
|
"Email '%s' is not unique, it's used by the following external IDs: %s",
|
||||||
e.getKey(),
|
e.getKey(),
|
||||||
e.getValue()
|
e.getValue().stream()
|
||||||
.stream()
|
|
||||||
.map(k -> "'" + k.get() + "'")
|
.map(k -> "'" + k.get() + "'")
|
||||||
.sorted()
|
.sorted()
|
||||||
.collect(joining(", "))),
|
.collect(joining(", "))),
|
||||||
|
|||||||
@@ -345,8 +345,7 @@ public class H2CacheImpl<K, V> extends AbstractLoadingCache<K, V> implements Per
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (Throwables.getCausalChain(e)
|
if (Throwables.getCausalChain(e).stream()
|
||||||
.stream()
|
|
||||||
.anyMatch(InvalidClassException.class::isInstance)) {
|
.anyMatch(InvalidClassException.class::isInstance)) {
|
||||||
// If deserialization failed using default Java serialization, this means we are using
|
// If deserialization failed using default Java serialization, this means we are using
|
||||||
// the old serialVersionUID-based invalidation strategy. In that case, authors are
|
// the old serialVersionUID-based invalidation strategy. In that case, authors are
|
||||||
|
|||||||
@@ -81,8 +81,7 @@ public class SerializedClassSubject extends Subject<SerializedClassSubject, Clas
|
|||||||
public void hasFields(Map<String, Type> expectedFields) {
|
public void hasFields(Map<String, Type> expectedFields) {
|
||||||
isConcrete();
|
isConcrete();
|
||||||
assertThat(
|
assertThat(
|
||||||
FieldUtils.getAllFieldsList(actual())
|
FieldUtils.getAllFieldsList(actual()).stream()
|
||||||
.stream()
|
|
||||||
.filter(f -> !Modifier.isStatic(f.getModifiers()))
|
.filter(f -> !Modifier.isStatic(f.getModifiers()))
|
||||||
.collect(toImmutableMap(Field::getName, Field::getGenericType)))
|
.collect(toImmutableMap(Field::getName, Field::getGenericType)))
|
||||||
.containsExactlyEntriesIn(expectedFields);
|
.containsExactlyEntriesIn(expectedFields);
|
||||||
|
|||||||
@@ -263,8 +263,7 @@ public class AddReviewersOp implements BatchUpdateOp {
|
|||||||
!change.isWorkInProgress());
|
!change.isWorkInProgress());
|
||||||
if (!addedReviewers.isEmpty()) {
|
if (!addedReviewers.isEmpty()) {
|
||||||
List<AccountState> reviewers =
|
List<AccountState> reviewers =
|
||||||
addedReviewers
|
addedReviewers.stream()
|
||||||
.stream()
|
|
||||||
.map(r -> accountCache.get(r.getAccountId()))
|
.map(r -> accountCache.get(r.getAccountId()))
|
||||||
.flatMap(Streams::stream)
|
.flatMap(Streams::stream)
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
|
|||||||
@@ -480,9 +480,7 @@ public class ChangeInserter implements InsertChangeOp {
|
|||||||
cm.setNotify(notify);
|
cm.setNotify(notify);
|
||||||
cm.setAccountsToNotify(accountsToNotify);
|
cm.setAccountsToNotify(accountsToNotify);
|
||||||
cm.addReviewers(
|
cm.addReviewers(
|
||||||
reviewerAdditions
|
reviewerAdditions.flattenResults(AddReviewersOp.Result::addedReviewers).stream()
|
||||||
.flattenResults(AddReviewersOp.Result::addedReviewers)
|
|
||||||
.stream()
|
|
||||||
.map(PatchSetApproval::getAccountId)
|
.map(PatchSetApproval::getAccountId)
|
||||||
.collect(toImmutableSet()));
|
.collect(toImmutableSet()));
|
||||||
cm.addReviewersByEmail(
|
cm.addReviewersByEmail(
|
||||||
|
|||||||
@@ -613,8 +613,7 @@ public class ChangeJson {
|
|||||||
if (has(TRACKING_IDS)) {
|
if (has(TRACKING_IDS)) {
|
||||||
ListMultimap<String, String> set = trackingFooters.extract(cd.commitFooters());
|
ListMultimap<String, String> set = trackingFooters.extract(cd.commitFooters());
|
||||||
out.trackingIds =
|
out.trackingIds =
|
||||||
set.entries()
|
set.entries().stream()
|
||||||
.stream()
|
|
||||||
.map(e -> new TrackingIdInfo(e.getKey(), e.getValue()))
|
.map(e -> new TrackingIdInfo(e.getKey(), e.getValue()))
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
}
|
}
|
||||||
@@ -754,16 +753,14 @@ public class ChangeJson {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Collection<AccountInfo> toAccountInfo(Collection<Account.Id> accounts) {
|
private Collection<AccountInfo> toAccountInfo(Collection<Account.Id> accounts) {
|
||||||
return accounts
|
return accounts.stream()
|
||||||
.stream()
|
|
||||||
.map(accountLoader::get)
|
.map(accountLoader::get)
|
||||||
.sorted(AccountInfoComparator.ORDER_NULLS_FIRST)
|
.sorted(AccountInfoComparator.ORDER_NULLS_FIRST)
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Collection<AccountInfo> toAccountInfoByEmail(Collection<Address> addresses) {
|
private Collection<AccountInfo> toAccountInfoByEmail(Collection<Address> addresses) {
|
||||||
return addresses
|
return addresses.stream()
|
||||||
.stream()
|
|
||||||
.map(a -> new AccountInfo(a.getName(), a.getEmail()))
|
.map(a -> new AccountInfo(a.getName(), a.getEmail()))
|
||||||
.sorted(AccountInfoComparator.ORDER_NULLS_FIRST)
|
.sorted(AccountInfoComparator.ORDER_NULLS_FIRST)
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
|
|||||||
@@ -154,9 +154,7 @@ public class ChangeResource implements RestResource, HasETag {
|
|||||||
accounts.add(getChange().getAssignee());
|
accounts.add(getChange().getAssignee());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
patchSetUtil
|
patchSetUtil.byChange(db.get(), notes).stream()
|
||||||
.byChange(db.get(), notes)
|
|
||||||
.stream()
|
|
||||||
.map(PatchSet::getUploader)
|
.map(PatchSet::getUploader)
|
||||||
.forEach(accounts::add);
|
.forEach(accounts::add);
|
||||||
|
|
||||||
|
|||||||
@@ -173,8 +173,7 @@ public class IncludedInResolver {
|
|||||||
*/
|
*/
|
||||||
private static ImmutableSortedSet<String> getMatchingRefNames(
|
private static ImmutableSortedSet<String> getMatchingRefNames(
|
||||||
Set<String> matchingRefs, Collection<Ref> allRefs) {
|
Set<String> matchingRefs, Collection<Ref> allRefs) {
|
||||||
return allRefs
|
return allRefs.stream()
|
||||||
.stream()
|
|
||||||
.map(Ref::getName)
|
.map(Ref::getName)
|
||||||
.filter(matchingRefs::contains)
|
.filter(matchingRefs::contains)
|
||||||
.map(Repository::shortenRefName)
|
.map(Repository::shortenRefName)
|
||||||
|
|||||||
@@ -326,9 +326,7 @@ public class LabelsJson {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (detailed) {
|
if (detailed) {
|
||||||
labels
|
labels.entrySet().stream()
|
||||||
.entrySet()
|
|
||||||
.stream()
|
|
||||||
.filter(e -> labelTypes.byLabel(e.getKey()) != null)
|
.filter(e -> labelTypes.byLabel(e.getKey()) != null)
|
||||||
.forEach(e -> setLabelValues(labelTypes.byLabel(e.getKey()), e.getValue()));
|
.forEach(e -> setLabelValues(labelTypes.byLabel(e.getKey()), e.getValue()));
|
||||||
}
|
}
|
||||||
@@ -524,9 +522,7 @@ public class LabelsJson {
|
|||||||
Maps.newHashMapWithExpectedSize(permittedLabels.size());
|
Maps.newHashMapWithExpectedSize(permittedLabels.size());
|
||||||
for (String label : permittedLabels.keySet()) {
|
for (String label : permittedLabels.keySet()) {
|
||||||
List<Integer> permittedVotingRange =
|
List<Integer> permittedVotingRange =
|
||||||
permittedLabels
|
permittedLabels.get(label).stream()
|
||||||
.get(label)
|
|
||||||
.stream()
|
|
||||||
.map(this::parseRangeValue)
|
.map(this::parseRangeValue)
|
||||||
.filter(java.util.Objects::nonNull)
|
.filter(java.util.Objects::nonNull)
|
||||||
.sorted()
|
.sorted()
|
||||||
|
|||||||
@@ -608,8 +608,7 @@ public class ReviewerAdder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableList<ReviewerAddition> getFailures() {
|
public ImmutableList<ReviewerAddition> getFailures() {
|
||||||
return additions
|
return additions.stream()
|
||||||
.stream()
|
|
||||||
.filter(a -> a.isFailure() && !a.isIgnorableFailure())
|
.filter(a -> a.isFailure() && !a.isIgnorableFailure())
|
||||||
.collect(toImmutableList());
|
.collect(toImmutableList());
|
||||||
}
|
}
|
||||||
@@ -639,8 +638,7 @@ public class ReviewerAdder {
|
|||||||
a ->
|
a ->
|
||||||
checkArgument(
|
checkArgument(
|
||||||
a.op != null && a.op.getResult() != null, "missing result on %s", a));
|
a.op != null && a.op.getResult() != null, "missing result on %s", a));
|
||||||
return additions()
|
return additions().stream()
|
||||||
.stream()
|
|
||||||
.map(a -> a.op.getResult())
|
.map(a -> a.op.getResult())
|
||||||
.map(func)
|
.map(func)
|
||||||
.flatMap(Collection::stream)
|
.flatMap(Collection::stream)
|
||||||
@@ -648,8 +646,7 @@ public class ReviewerAdder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ImmutableList<ReviewerAddition> additions() {
|
private ImmutableList<ReviewerAddition> additions() {
|
||||||
return additions
|
return additions.stream()
|
||||||
.stream()
|
|
||||||
.filter(
|
.filter(
|
||||||
a -> {
|
a -> {
|
||||||
if (a.isFailure()) {
|
if (a.isFailure()) {
|
||||||
|
|||||||
@@ -97,8 +97,7 @@ public class ConfigUpdatedEvent {
|
|||||||
private Multimap<UpdateResult, ConfigUpdateEntry> createUpdate(
|
private Multimap<UpdateResult, ConfigUpdateEntry> createUpdate(
|
||||||
Set<ConfigKey> entries, UpdateResult updateResult) {
|
Set<ConfigKey> entries, UpdateResult updateResult) {
|
||||||
Multimap<UpdateResult, ConfigUpdateEntry> updates = ArrayListMultimap.create();
|
Multimap<UpdateResult, ConfigUpdateEntry> updates = ArrayListMultimap.create();
|
||||||
entries
|
entries.stream()
|
||||||
.stream()
|
|
||||||
.filter(this::isValueUpdated)
|
.filter(this::isValueUpdated)
|
||||||
.map(e -> new ConfigUpdateEntry(e, getString(e, oldConfig), getString(e, newConfig)))
|
.map(e -> new ConfigUpdateEntry(e, getString(e, oldConfig), getString(e, newConfig)))
|
||||||
.forEach(e -> updates.put(updateResult, e));
|
.forEach(e -> updates.put(updateResult, e));
|
||||||
|
|||||||
@@ -61,8 +61,7 @@ public class RepositoryConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ImmutableList<Path> getAllBasePaths() {
|
public ImmutableList<Path> getAllBasePaths() {
|
||||||
return cfg.getSubsections(SECTION_NAME)
|
return cfg.getSubsections(SECTION_NAME).stream()
|
||||||
.stream()
|
|
||||||
.map(sub -> cfg.getString(SECTION_NAME, sub, BASE_PATH_NAME))
|
.map(sub -> cfg.getString(SECTION_NAME, sub, BASE_PATH_NAME))
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.map(Paths::get)
|
.map(Paths::get)
|
||||||
@@ -90,8 +89,7 @@ public class RepositoryConfig {
|
|||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
private String findSubSection(String project) {
|
private String findSubSection(String project) {
|
||||||
return cfg.getSubsections(SECTION_NAME)
|
return cfg.getSubsections(SECTION_NAME).stream()
|
||||||
.stream()
|
|
||||||
.filter(ss -> isMatch(ss, project))
|
.filter(ss -> isMatch(ss, project))
|
||||||
.max(comparing(String::length))
|
.max(comparing(String::length))
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
|||||||
@@ -36,9 +36,7 @@ public class LockFailureException extends IOException {
|
|||||||
public LockFailureException(String message, BatchRefUpdate batchRefUpdate) {
|
public LockFailureException(String message, BatchRefUpdate batchRefUpdate) {
|
||||||
super(message);
|
super(message);
|
||||||
refs =
|
refs =
|
||||||
batchRefUpdate
|
batchRefUpdate.getCommands().stream()
|
||||||
.getCommands()
|
|
||||||
.stream()
|
|
||||||
.filter(c -> c.getResult() == ReceiveCommand.Result.LOCK_FAILURE)
|
.filter(c -> c.getResult() == ReceiveCommand.Result.LOCK_FAILURE)
|
||||||
.map(ReceiveCommand::getRefName)
|
.map(ReceiveCommand::getRefName)
|
||||||
.collect(toImmutableList());
|
.collect(toImmutableList());
|
||||||
|
|||||||
@@ -291,9 +291,7 @@ public class MergeUtil {
|
|||||||
((ResolveMerger) m).getMergeResults();
|
((ResolveMerger) m).getMergeResults();
|
||||||
|
|
||||||
filesWithGitConflicts =
|
filesWithGitConflicts =
|
||||||
mergeResults
|
mergeResults.entrySet().stream()
|
||||||
.entrySet()
|
|
||||||
.stream()
|
|
||||||
.filter(e -> e.getValue().containsConflicts())
|
.filter(e -> e.getValue().containsConflicts())
|
||||||
.map(Map.Entry::getKey)
|
.map(Map.Entry::getKey)
|
||||||
.collect(toImmutableSet());
|
.collect(toImmutableSet());
|
||||||
|
|||||||
@@ -700,9 +700,7 @@ class ReceiveCommits {
|
|||||||
List<CreateRequest> created =
|
List<CreateRequest> created =
|
||||||
newChanges.stream().filter(r -> r.change != null).collect(toList());
|
newChanges.stream().filter(r -> r.change != null).collect(toList());
|
||||||
List<ReplaceRequest> updated =
|
List<ReplaceRequest> updated =
|
||||||
replaceByChange
|
replaceByChange.values().stream()
|
||||||
.values()
|
|
||||||
.stream()
|
|
||||||
.filter(r -> r.inputCommand.getResult() == OK)
|
.filter(r -> r.inputCommand.getResult() == OK)
|
||||||
.sorted(comparingInt(r -> r.notes.getChangeId().get()))
|
.sorted(comparingInt(r -> r.notes.getChangeId().get()))
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
@@ -812,9 +810,7 @@ class ReceiveCommits {
|
|||||||
throw INSERT_EXCEPTION.apply(e);
|
throw INSERT_EXCEPTION.apply(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
replaceByChange
|
replaceByChange.values().stream()
|
||||||
.values()
|
|
||||||
.stream()
|
|
||||||
.forEach(req -> resultChangeIds.add(Key.REPLACED, req.ontoChange));
|
.forEach(req -> resultChangeIds.add(Key.REPLACED, req.ontoChange));
|
||||||
newChanges.stream().forEach(req -> resultChangeIds.add(Key.CREATED, req.changeId));
|
newChanges.stream().forEach(req -> resultChangeIds.add(Key.CREATED, req.changeId));
|
||||||
|
|
||||||
|
|||||||
@@ -383,13 +383,9 @@ public class ReplaceOp implements BatchUpdateOp {
|
|||||||
inputs =
|
inputs =
|
||||||
Streams.concat(
|
Streams.concat(
|
||||||
inputs,
|
inputs,
|
||||||
magicBranch
|
magicBranch.getCombinedReviewers(fromFooters).stream()
|
||||||
.getCombinedReviewers(fromFooters)
|
|
||||||
.stream()
|
|
||||||
.map(r -> newAddReviewerInput(r, ReviewerState.REVIEWER)),
|
.map(r -> newAddReviewerInput(r, ReviewerState.REVIEWER)),
|
||||||
magicBranch
|
magicBranch.getCombinedCcs(fromFooters).stream()
|
||||||
.getCombinedCcs(fromFooters)
|
|
||||||
.stream()
|
|
||||||
.map(r -> newAddReviewerInput(r, ReviewerState.CC)));
|
.map(r -> newAddReviewerInput(r, ReviewerState.CC)));
|
||||||
}
|
}
|
||||||
return inputs.collect(toImmutableList());
|
return inputs.collect(toImmutableList());
|
||||||
@@ -582,9 +578,7 @@ public class ReplaceOp implements BatchUpdateOp {
|
|||||||
cm.addReviewers(
|
cm.addReviewers(
|
||||||
Streams.concat(
|
Streams.concat(
|
||||||
oldRecipients.getReviewers().stream(),
|
oldRecipients.getReviewers().stream(),
|
||||||
reviewerAdditions
|
reviewerAdditions.flattenResults(AddReviewersOp.Result::addedReviewers).stream()
|
||||||
.flattenResults(AddReviewersOp.Result::addedReviewers)
|
|
||||||
.stream()
|
|
||||||
.map(PatchSetApproval::getAccountId))
|
.map(PatchSetApproval::getAccountId))
|
||||||
.collect(toImmutableSet()));
|
.collect(toImmutableSet()));
|
||||||
cm.addExtraCC(
|
cm.addExtraCC(
|
||||||
|
|||||||
@@ -114,9 +114,7 @@ public class AccountValidator {
|
|||||||
accountConfig.load(allUsersName, rw, commit);
|
accountConfig.load(allUsersName, rw, commit);
|
||||||
if (messages != null) {
|
if (messages != null) {
|
||||||
messages.addAll(
|
messages.addAll(
|
||||||
accountConfig
|
accountConfig.getValidationErrors().stream()
|
||||||
.getValidationErrors()
|
|
||||||
.stream()
|
|
||||||
.map(ValidationError::getMessage)
|
.map(ValidationError::getMessage)
|
||||||
.collect(toSet()));
|
.collect(toSet()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -699,8 +699,7 @@ public class CommitValidators {
|
|||||||
List<ConsistencyProblemInfo> problems =
|
List<ConsistencyProblemInfo> problems =
|
||||||
externalIdsConsistencyChecker.check(receiveEvent.commit);
|
externalIdsConsistencyChecker.check(receiveEvent.commit);
|
||||||
List<CommitValidationMessage> msgs =
|
List<CommitValidationMessage> msgs =
|
||||||
problems
|
problems.stream()
|
||||||
.stream()
|
|
||||||
.map(
|
.map(
|
||||||
p ->
|
p ->
|
||||||
new CommitValidationMessage(
|
new CommitValidationMessage(
|
||||||
@@ -766,8 +765,7 @@ public class CommitValidators {
|
|||||||
if (!errorMessages.isEmpty()) {
|
if (!errorMessages.isEmpty()) {
|
||||||
throw new CommitValidationException(
|
throw new CommitValidationException(
|
||||||
"invalid account configuration",
|
"invalid account configuration",
|
||||||
errorMessages
|
errorMessages.stream()
|
||||||
.stream()
|
|
||||||
.map(m -> new CommitValidationMessage(m, Type.ERROR))
|
.map(m -> new CommitValidationMessage(m, Type.ERROR))
|
||||||
.collect(toList()));
|
.collect(toList()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,8 +125,7 @@ public class PeriodicGroupIndexer implements Runnable {
|
|||||||
public synchronized void run() {
|
public synchronized void run() {
|
||||||
try (Repository allUsers = repoManager.openRepository(allUsersName)) {
|
try (Repository allUsers = repoManager.openRepository(allUsersName)) {
|
||||||
ImmutableSet<AccountGroup.UUID> newGroupUuids =
|
ImmutableSet<AccountGroup.UUID> newGroupUuids =
|
||||||
GroupNameNotes.loadAllGroups(allUsers)
|
GroupNameNotes.loadAllGroups(allUsers).stream()
|
||||||
.stream()
|
|
||||||
.map(GroupReference::getUUID)
|
.map(GroupReference::getUUID)
|
||||||
.collect(toImmutableSet());
|
.collect(toImmutableSet());
|
||||||
GroupIndexer groupIndexer = groupIndexerProvider.get();
|
GroupIndexer groupIndexer = groupIndexerProvider.get();
|
||||||
|
|||||||
@@ -107,13 +107,11 @@ class GroupConfigCommitMessage {
|
|||||||
Function<T, String> toString = element -> toParsableString.apply(auditLogFormatter, element);
|
Function<T, String> toString = element -> toParsableString.apply(auditLogFormatter, element);
|
||||||
|
|
||||||
Stream<String> removedElements =
|
Stream<String> removedElements =
|
||||||
Sets.difference(oldElements, newElements)
|
Sets.difference(oldElements, newElements).stream()
|
||||||
.stream()
|
|
||||||
.map(toString)
|
.map(toString)
|
||||||
.map((removalFooterKey.getName() + ": ")::concat);
|
.map((removalFooterKey.getName() + ": ")::concat);
|
||||||
Stream<String> addedElements =
|
Stream<String> addedElements =
|
||||||
Sets.difference(newElements, oldElements)
|
Sets.difference(newElements, oldElements).stream()
|
||||||
.stream()
|
|
||||||
.map(toString)
|
.map(toString)
|
||||||
.map((additionFooterKey.getName() + ": ")::concat);
|
.map((additionFooterKey.getName() + ": ")::concat);
|
||||||
return Stream.concat(removedElements, addedElements);
|
return Stream.concat(removedElements, addedElements);
|
||||||
|
|||||||
@@ -295,8 +295,7 @@ public class GroupNameNotes extends VersionedMetaData {
|
|||||||
private static ImmutableBiMap<AccountGroup.UUID, String> toBiMap(
|
private static ImmutableBiMap<AccountGroup.UUID, String> toBiMap(
|
||||||
Collection<GroupReference> groupReferences) {
|
Collection<GroupReference> groupReferences) {
|
||||||
try {
|
try {
|
||||||
return groupReferences
|
return groupReferences.stream()
|
||||||
.stream()
|
|
||||||
.collect(toImmutableBiMap(GroupReference::getUUID, GroupReference::getName));
|
.collect(toImmutableBiMap(GroupReference::getUUID, GroupReference::getName));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
throw new IllegalArgumentException(UNIQUE_REF_ERROR, e);
|
throw new IllegalArgumentException(UNIQUE_REF_ERROR, e);
|
||||||
|
|||||||
@@ -124,9 +124,7 @@ public class Groups {
|
|||||||
getGroupFromNoteDb(allUsersName, allUsersRepo, internalGroup.getUUID());
|
getGroupFromNoteDb(allUsersName, allUsersRepo, internalGroup.getUUID());
|
||||||
group.map(InternalGroup::getSubgroups).ifPresent(allSubgroups::addAll);
|
group.map(InternalGroup::getSubgroups).ifPresent(allSubgroups::addAll);
|
||||||
}
|
}
|
||||||
return allSubgroups
|
return allSubgroups.build().stream()
|
||||||
.build()
|
|
||||||
.stream()
|
|
||||||
.filter(groupUuid -> !AccountGroup.isInternalGroup(groupUuid));
|
.filter(groupUuid -> !AccountGroup.isInternalGroup(groupUuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -157,8 +157,7 @@ public class AccountField {
|
|||||||
storedOnly("external_id_state")
|
storedOnly("external_id_state")
|
||||||
.buildRepeatable(
|
.buildRepeatable(
|
||||||
a ->
|
a ->
|
||||||
a.getExternalIds()
|
a.getExternalIds().stream()
|
||||||
.stream()
|
|
||||||
.filter(e -> e.blobId() != null)
|
.filter(e -> e.blobId() != null)
|
||||||
.map(ExternalId::toByteArray)
|
.map(ExternalId::toByteArray)
|
||||||
.collect(toSet()));
|
.collect(toSet()));
|
||||||
|
|||||||
@@ -135,9 +135,7 @@ public class AllChangesIndexer extends SiteIndexer<Change.Id, ChangeData, Change
|
|||||||
// Estimate size based on IDs that show up in ref names. This is not perfect, since patch set
|
// Estimate size based on IDs that show up in ref names. This is not perfect, since patch set
|
||||||
// refs may exist for changes whose metadata was never successfully stored. But that's ok, as
|
// refs may exist for changes whose metadata was never successfully stored. But that's ok, as
|
||||||
// the estimate is just used as a heuristic for sorting projects.
|
// the estimate is just used as a heuristic for sorting projects.
|
||||||
return repo.getRefDatabase()
|
return repo.getRefDatabase().getRefsByPrefix(RefNames.REFS_CHANGES).stream()
|
||||||
.getRefsByPrefix(RefNames.REFS_CHANGES)
|
|
||||||
.stream()
|
|
||||||
.map(r -> Change.Id.fromRef(r.getName()))
|
.map(r -> Change.Id.fromRef(r.getName()))
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.distinct()
|
.distinct()
|
||||||
|
|||||||
@@ -737,8 +737,7 @@ public class ChangeField {
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
static List<SubmitRecord> parseSubmitRecords(Collection<String> values) {
|
static List<SubmitRecord> parseSubmitRecords(Collection<String> values) {
|
||||||
return values
|
return values.stream()
|
||||||
.stream()
|
|
||||||
.map(v -> GSON.fromJson(v, StoredSubmitRecord.class).toSubmitRecord())
|
.map(v -> GSON.fromJson(v, StoredSubmitRecord.class).toSubmitRecord())
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,9 +66,7 @@ public class StalenessChecker {
|
|||||||
|
|
||||||
SetMultimap<Project.NameKey, RefState> currentRefStates =
|
SetMultimap<Project.NameKey, RefState> currentRefStates =
|
||||||
MultimapBuilder.hashKeys().hashSetValues().build();
|
MultimapBuilder.hashKeys().hashSetValues().build();
|
||||||
projectData
|
projectData.tree().stream()
|
||||||
.tree()
|
|
||||||
.stream()
|
|
||||||
.filter(p -> p.getProject().getConfigRefState() != null)
|
.filter(p -> p.getProject().getConfigRefState() != null)
|
||||||
.forEach(
|
.forEach(
|
||||||
p ->
|
p ->
|
||||||
|
|||||||
@@ -170,8 +170,7 @@ public abstract class CallerFinder {
|
|||||||
public LazyArg<String> findCaller() {
|
public LazyArg<String> findCaller() {
|
||||||
return lazy(
|
return lazy(
|
||||||
() ->
|
() ->
|
||||||
targets()
|
targets().stream()
|
||||||
.stream()
|
|
||||||
.map(t -> findCallerOf(t, skip() + 1))
|
.map(t -> findCallerOf(t, skip() + 1))
|
||||||
.filter(Optional::isPresent)
|
.filter(Optional::isPresent)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
|
|||||||
@@ -134,10 +134,7 @@ public class TraceContext implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Optional<String> existingTraceId =
|
Optional<String> existingTraceId =
|
||||||
LoggingContext.getInstance()
|
LoggingContext.getInstance().getTagsAsMap().get(RequestId.Type.TRACE_ID.name()).stream()
|
||||||
.getTagsAsMap()
|
|
||||||
.get(RequestId.Type.TRACE_ID.name())
|
|
||||||
.stream()
|
|
||||||
.findAny();
|
.findAny();
|
||||||
if (existingTraceId.isPresent()) {
|
if (existingTraceId.isPresent()) {
|
||||||
// request tracing was already started, no need to generate a new trace ID
|
// request tracing was already started, no need to generate a new trace ID
|
||||||
|
|||||||
@@ -233,8 +233,7 @@ public class MailProcessor {
|
|||||||
// comments from the outbound email.
|
// comments from the outbound email.
|
||||||
// TODO(hiesel) Also filter by original comment author.
|
// TODO(hiesel) Also filter by original comment author.
|
||||||
Collection<Comment> comments =
|
Collection<Comment> comments =
|
||||||
cd.publishedComments()
|
cd.publishedComments().stream()
|
||||||
.stream()
|
|
||||||
.filter(c -> (c.writtenOn.getTime() / 1000) == (metadata.timestamp.getTime() / 1000))
|
.filter(c -> (c.writtenOn.getTime() / 1000) == (metadata.timestamp.getTime() / 1000))
|
||||||
.sorted(CommentsUtil.COMMENT_ORDER)
|
.sorted(CommentsUtil.COMMENT_ORDER)
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
@@ -427,8 +426,7 @@ public class MailProcessor {
|
|||||||
|
|
||||||
private Set<String> existingMessageIds(ChangeData cd) throws OrmException {
|
private Set<String> existingMessageIds(ChangeData cd) throws OrmException {
|
||||||
Set<String> existingMessageIds = new HashSet<>();
|
Set<String> existingMessageIds = new HashSet<>();
|
||||||
cd.messages()
|
cd.messages().stream()
|
||||||
.stream()
|
|
||||||
.forEach(
|
.forEach(
|
||||||
m -> {
|
m -> {
|
||||||
String messageId = CommentsUtil.extractMessageId(m.getTag());
|
String messageId = CommentsUtil.extractMessageId(m.getTag());
|
||||||
@@ -436,8 +434,7 @@ public class MailProcessor {
|
|||||||
existingMessageIds.add(messageId);
|
existingMessageIds.add(messageId);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
cd.publishedComments()
|
cd.publishedComments().stream()
|
||||||
.stream()
|
|
||||||
.forEach(
|
.forEach(
|
||||||
c -> {
|
c -> {
|
||||||
String messageId = CommentsUtil.extractMessageId(c.tag);
|
String messageId = CommentsUtil.extractMessageId(c.tag);
|
||||||
|
|||||||
@@ -458,8 +458,7 @@ public class CommentSender extends ReplyToChangeSender {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<Map<String, Object>> commentBlocksToSoyData(List<CommentFormatter.Block> blocks) {
|
private List<Map<String, Object>> commentBlocksToSoyData(List<CommentFormatter.Block> blocks) {
|
||||||
return blocks
|
return blocks.stream()
|
||||||
.stream()
|
|
||||||
.map(
|
.map(
|
||||||
b -> {
|
b -> {
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
|||||||
@@ -557,8 +557,7 @@ public class ChangeBundle {
|
|||||||
}
|
}
|
||||||
if (!bs.isEmpty()) {
|
if (!bs.isEmpty()) {
|
||||||
sb.append("Only in B:");
|
sb.append("Only in B:");
|
||||||
bs.values()
|
bs.values().stream()
|
||||||
.stream()
|
|
||||||
.sorted(CHANGE_MESSAGE_COMPARATOR)
|
.sorted(CHANGE_MESSAGE_COMPARATOR)
|
||||||
.forEach(cm -> sb.append("\n ").append(cm));
|
.forEach(cm -> sb.append("\n ").append(cm));
|
||||||
}
|
}
|
||||||
@@ -675,9 +674,7 @@ public class ChangeBundle {
|
|||||||
private static boolean createdOnIsMonotonic(
|
private static boolean createdOnIsMonotonic(
|
||||||
Map<?, PatchSet> patchSets, Set<PatchSet.Id> limitToIds) {
|
Map<?, PatchSet> patchSets, Set<PatchSet.Id> limitToIds) {
|
||||||
List<PatchSet> orderedById =
|
List<PatchSet> orderedById =
|
||||||
patchSets
|
patchSets.values().stream()
|
||||||
.values()
|
|
||||||
.stream()
|
|
||||||
.filter(ps -> limitToIds.contains(ps.getId()))
|
.filter(ps -> limitToIds.contains(ps.getId()))
|
||||||
.sorted(ChangeUtil.PS_ID_ORDER)
|
.sorted(ChangeUtil.PS_ID_ORDER)
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
|
|||||||
@@ -336,8 +336,7 @@ public class ChangeNotes extends AbstractChangeNotes<ChangeNotes> {
|
|||||||
ScanResult sr = scanChangeIds(repo);
|
ScanResult sr = scanChangeIds(repo);
|
||||||
PrimaryStorage defaultStorage = args.migration.changePrimaryStorage();
|
PrimaryStorage defaultStorage = args.migration.changePrimaryStorage();
|
||||||
|
|
||||||
return sr.all()
|
return sr.all().stream()
|
||||||
.stream()
|
|
||||||
.map(id -> scanOneNoteDbChange(db, project, sr, defaultStorage, id))
|
.map(id -> scanOneNoteDbChange(db, project, sr, defaultStorage, id))
|
||||||
.filter(Objects::nonNull);
|
.filter(Objects::nonNull);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -565,23 +565,17 @@ public abstract class ChangeNotesState {
|
|||||||
.changeId(changeId)
|
.changeId(changeId)
|
||||||
.columns(toChangeColumns(changeId, proto.getColumns()))
|
.columns(toChangeColumns(changeId, proto.getColumns()))
|
||||||
.pastAssignees(
|
.pastAssignees(
|
||||||
proto
|
proto.getPastAssigneeList().stream()
|
||||||
.getPastAssigneeList()
|
|
||||||
.stream()
|
|
||||||
.map(Account.Id::new)
|
.map(Account.Id::new)
|
||||||
.collect(toImmutableSet()))
|
.collect(toImmutableSet()))
|
||||||
.hashtags(proto.getHashtagList())
|
.hashtags(proto.getHashtagList())
|
||||||
.patchSets(
|
.patchSets(
|
||||||
proto
|
proto.getPatchSetList().stream()
|
||||||
.getPatchSetList()
|
|
||||||
.stream()
|
|
||||||
.map(PATCH_SET_CODEC::decode)
|
.map(PATCH_SET_CODEC::decode)
|
||||||
.map(ps -> Maps.immutableEntry(ps.getId(), ps))
|
.map(ps -> Maps.immutableEntry(ps.getId(), ps))
|
||||||
.collect(toImmutableList()))
|
.collect(toImmutableList()))
|
||||||
.approvals(
|
.approvals(
|
||||||
proto
|
proto.getApprovalList().stream()
|
||||||
.getApprovalList()
|
|
||||||
.stream()
|
|
||||||
.map(APPROVAL_CODEC::decode)
|
.map(APPROVAL_CODEC::decode)
|
||||||
.map(a -> Maps.immutableEntry(a.getPatchSetId(), a))
|
.map(a -> Maps.immutableEntry(a.getPatchSetId(), a))
|
||||||
.collect(toImmutableList()))
|
.collect(toImmutableList()))
|
||||||
@@ -590,28 +584,20 @@ public abstract class ChangeNotesState {
|
|||||||
.pendingReviewers(toReviewerSet(proto.getPendingReviewerList()))
|
.pendingReviewers(toReviewerSet(proto.getPendingReviewerList()))
|
||||||
.pendingReviewersByEmail(toReviewerByEmailSet(proto.getPendingReviewerByEmailList()))
|
.pendingReviewersByEmail(toReviewerByEmailSet(proto.getPendingReviewerByEmailList()))
|
||||||
.allPastReviewers(
|
.allPastReviewers(
|
||||||
proto
|
proto.getPastReviewerList().stream()
|
||||||
.getPastReviewerList()
|
|
||||||
.stream()
|
|
||||||
.map(Account.Id::new)
|
.map(Account.Id::new)
|
||||||
.collect(toImmutableList()))
|
.collect(toImmutableList()))
|
||||||
.reviewerUpdates(toReviewerStatusUpdateList(proto.getReviewerUpdateList()))
|
.reviewerUpdates(toReviewerStatusUpdateList(proto.getReviewerUpdateList()))
|
||||||
.submitRecords(
|
.submitRecords(
|
||||||
proto
|
proto.getSubmitRecordList().stream()
|
||||||
.getSubmitRecordList()
|
|
||||||
.stream()
|
|
||||||
.map(r -> GSON.fromJson(r, StoredSubmitRecord.class).toSubmitRecord())
|
.map(r -> GSON.fromJson(r, StoredSubmitRecord.class).toSubmitRecord())
|
||||||
.collect(toImmutableList()))
|
.collect(toImmutableList()))
|
||||||
.changeMessages(
|
.changeMessages(
|
||||||
proto
|
proto.getChangeMessageList().stream()
|
||||||
.getChangeMessageList()
|
|
||||||
.stream()
|
|
||||||
.map(MESSAGE_CODEC::decode)
|
.map(MESSAGE_CODEC::decode)
|
||||||
.collect(toImmutableList()))
|
.collect(toImmutableList()))
|
||||||
.publishedComments(
|
.publishedComments(
|
||||||
proto
|
proto.getPublishedCommentList().stream()
|
||||||
.getPublishedCommentList()
|
|
||||||
.stream()
|
|
||||||
.map(r -> GSON.fromJson(r, Comment.class))
|
.map(r -> GSON.fromJson(r, Comment.class))
|
||||||
.collect(toImmutableListMultimap(c -> new RevId(c.revId), c -> c)));
|
.collect(toImmutableListMultimap(c -> new RevId(c.revId), c -> c)));
|
||||||
if (proto.getHasReadOnlyUntil()) {
|
if (proto.getHasReadOnlyUntil()) {
|
||||||
|
|||||||
@@ -141,9 +141,7 @@ public class DeleteCommentRewriter implements NoteDbRewriter {
|
|||||||
throws IOException, ConfigInvalidException {
|
throws IOException, ConfigInvalidException {
|
||||||
return RevisionNoteMap.parse(
|
return RevisionNoteMap.parse(
|
||||||
changeNoteJson, legacyChangeNoteRead, changeId, reader, noteMap, PUBLISHED)
|
changeNoteJson, legacyChangeNoteRead, changeId, reader, noteMap, PUBLISHED)
|
||||||
.revisionNotes
|
.revisionNotes.values().stream()
|
||||||
.values()
|
|
||||||
.stream()
|
|
||||||
.flatMap(n -> n.getComments().stream())
|
.flatMap(n -> n.getComments().stream())
|
||||||
.collect(toMap(c -> c.key.uuid, Function.identity()));
|
.collect(toMap(c -> c.key.uuid, Function.identity()));
|
||||||
}
|
}
|
||||||
@@ -189,9 +187,7 @@ public class DeleteCommentRewriter implements NoteDbRewriter {
|
|||||||
*/
|
*/
|
||||||
private List<Comment> getDeletedComments(
|
private List<Comment> getDeletedComments(
|
||||||
Map<String, Comment> parMap, Map<String, Comment> curMap) {
|
Map<String, Comment> parMap, Map<String, Comment> curMap) {
|
||||||
return parMap
|
return parMap.entrySet().stream()
|
||||||
.entrySet()
|
|
||||||
.stream()
|
|
||||||
.filter(c -> !curMap.containsKey(c.getKey()))
|
.filter(c -> !curMap.containsKey(c.getKey()))
|
||||||
.map(Map.Entry::getValue)
|
.map(Map.Entry::getValue)
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
|
|||||||
@@ -419,9 +419,7 @@ public class ChangeRebuilderImpl extends ChangeRebuilder {
|
|||||||
|
|
||||||
private static List<Comment> getComments(
|
private static List<Comment> getComments(
|
||||||
ChangeBundle bundle, String serverId, PatchLineComment.Status status, PatchSet ps) {
|
ChangeBundle bundle, String serverId, PatchLineComment.Status status, PatchSet ps) {
|
||||||
return bundle
|
return bundle.getPatchLineComments().stream()
|
||||||
.getPatchLineComments()
|
|
||||||
.stream()
|
|
||||||
.filter(c -> c.getPatchSetId().equals(ps.getId()) && c.getStatus() == status)
|
.filter(c -> c.getPatchSetId().equals(ps.getId()) && c.getStatus() == status)
|
||||||
.map(plc -> plc.asComment(serverId))
|
.map(plc -> plc.asComment(serverId))
|
||||||
.sorted(CommentsUtil.COMMENT_ORDER)
|
.sorted(CommentsUtil.COMMENT_ORDER)
|
||||||
|
|||||||
@@ -447,8 +447,7 @@ public class NoteDbMigrator implements AutoCloseable {
|
|||||||
int sequenceGap,
|
int sequenceGap,
|
||||||
boolean autoMigrate)
|
boolean autoMigrate)
|
||||||
throws MigrationException {
|
throws MigrationException {
|
||||||
if (ImmutableList.of(!changes.isEmpty(), !projects.isEmpty(), !skipProjects.isEmpty())
|
if (ImmutableList.of(!changes.isEmpty(), !projects.isEmpty(), !skipProjects.isEmpty()).stream()
|
||||||
.stream()
|
|
||||||
.filter(e -> e)
|
.filter(e -> e)
|
||||||
.count()
|
.count()
|
||||||
> 1) {
|
> 1) {
|
||||||
@@ -628,8 +627,7 @@ public class NoteDbMigrator implements AutoCloseable {
|
|||||||
|
|
||||||
try (ContextHelper contextHelper = new ContextHelper()) {
|
try (ContextHelper contextHelper = new ContextHelper()) {
|
||||||
List<ListenableFuture<Boolean>> futures =
|
List<ListenableFuture<Boolean>> futures =
|
||||||
allChanges
|
allChanges.stream()
|
||||||
.stream()
|
|
||||||
.map(
|
.map(
|
||||||
id ->
|
id ->
|
||||||
executor.submit(
|
executor.submit(
|
||||||
|
|||||||
@@ -89,8 +89,7 @@ class EditTransformer {
|
|||||||
* @return the transformed edits per file path
|
* @return the transformed edits per file path
|
||||||
*/
|
*/
|
||||||
public Multimap<String, ContextAwareEdit> getEditsPerFilePath() {
|
public Multimap<String, ContextAwareEdit> getEditsPerFilePath() {
|
||||||
return edits
|
return edits.stream()
|
||||||
.stream()
|
|
||||||
.collect(
|
.collect(
|
||||||
toMultimap(
|
toMultimap(
|
||||||
ContextAwareEdit::getNewFilePath, Function.identity(), ArrayListMultimap::create));
|
ContextAwareEdit::getNewFilePath, Function.identity(), ArrayListMultimap::create));
|
||||||
@@ -112,9 +111,7 @@ class EditTransformer {
|
|||||||
transformingEntries.stream().collect(groupingBy(EditTransformer::getOldFilePath));
|
transformingEntries.stream().collect(groupingBy(EditTransformer::getOldFilePath));
|
||||||
|
|
||||||
edits =
|
edits =
|
||||||
editsPerFilePath
|
editsPerFilePath.entrySet().stream()
|
||||||
.entrySet()
|
|
||||||
.stream()
|
|
||||||
.flatMap(
|
.flatMap(
|
||||||
pathAndEdits -> {
|
pathAndEdits -> {
|
||||||
List<PatchListEntry> transEntries =
|
List<PatchListEntry> transEntries =
|
||||||
@@ -137,12 +134,11 @@ class EditTransformer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO(aliceks): Find a way to prevent an explosion of the number of entries.
|
// TODO(aliceks): Find a way to prevent an explosion of the number of entries.
|
||||||
return transformingEntries
|
return transformingEntries.stream()
|
||||||
.stream()
|
|
||||||
.flatMap(
|
.flatMap(
|
||||||
transEntry ->
|
transEntry ->
|
||||||
transformEdits(
|
transformEdits(
|
||||||
sideStrategy, originalEdits, transEntry.getEdits(), transEntry.getNewName())
|
sideStrategy, originalEdits, transEntry.getEdits(), transEntry.getNewName())
|
||||||
.stream());
|
.stream());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -287,8 +287,7 @@ public class PatchListLoader implements Callable<PatchList> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<DiffEntry> relevantDiffEntries =
|
List<DiffEntry> relevantDiffEntries =
|
||||||
diffEntries
|
diffEntries.stream()
|
||||||
.stream()
|
|
||||||
.filter(diffEntry -> isTouched(touchedFilePaths, diffEntry))
|
.filter(diffEntry -> isTouched(touchedFilePaths, diffEntry))
|
||||||
.collect(toImmutableList());
|
.collect(toImmutableList());
|
||||||
|
|
||||||
@@ -397,8 +396,7 @@ public class PatchListLoader implements Callable<PatchList> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Set<Edit> getContentEdits(Set<ContextAwareEdit> editsDueToRebase) {
|
private static Set<Edit> getContentEdits(Set<ContextAwareEdit> editsDueToRebase) {
|
||||||
return editsDueToRebase
|
return editsDueToRebase.stream()
|
||||||
.stream()
|
|
||||||
.map(ContextAwareEdit::toEdit)
|
.map(ContextAwareEdit::toEdit)
|
||||||
.filter(Optional::isPresent)
|
.filter(Optional::isPresent)
|
||||||
.map(Optional::get)
|
.map(Optional::get)
|
||||||
|
|||||||
@@ -252,8 +252,7 @@ public class DefaultPermissionBackend extends PermissionBackend {
|
|||||||
private boolean allow(Collection<PermissionRule> rules) {
|
private boolean allow(Collection<PermissionRule> rules) {
|
||||||
return user.getEffectiveGroups()
|
return user.getEffectiveGroups()
|
||||||
.containsAnyOf(
|
.containsAnyOf(
|
||||||
rules
|
rules.stream()
|
||||||
.stream()
|
|
||||||
.filter(r -> r.getAction() == Action.ALLOW)
|
.filter(r -> r.getAction() == Action.ALLOW)
|
||||||
.map(r -> r.getGroup().getUUID())
|
.map(r -> r.getGroup().getUUID())
|
||||||
.collect(toSet()));
|
.collect(toSet()));
|
||||||
@@ -261,8 +260,7 @@ public class DefaultPermissionBackend extends PermissionBackend {
|
|||||||
|
|
||||||
private boolean notDenied(Collection<PermissionRule> rules) {
|
private boolean notDenied(Collection<PermissionRule> rules) {
|
||||||
Set<AccountGroup.UUID> denied =
|
Set<AccountGroup.UUID> denied =
|
||||||
rules
|
rules.stream()
|
||||||
.stream()
|
|
||||||
.filter(r -> r.getAction() != Action.ALLOW)
|
.filter(r -> r.getAction() != Action.ALLOW)
|
||||||
.map(r -> r.getGroup().getUUID())
|
.map(r -> r.getGroup().getUUID())
|
||||||
.collect(toSet());
|
.collect(toSet());
|
||||||
|
|||||||
@@ -502,9 +502,7 @@ public abstract class PermissionBackend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Set<LabelPermission.WithValue> valuesOf(LabelType label) {
|
private static Set<LabelPermission.WithValue> valuesOf(LabelType label) {
|
||||||
return label
|
return label.getValues().stream()
|
||||||
.getValues()
|
|
||||||
.stream()
|
|
||||||
.map((v) -> new LabelPermission.WithValue(label, v))
|
.map((v) -> new LabelPermission.WithValue(label, v))
|
||||||
.collect(toSet());
|
.collect(toSet());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,8 +151,7 @@ public class PermissionCollection {
|
|||||||
Lists.reverse(Lists.newArrayList(sectionToProject.entrySet()));
|
Lists.reverse(Lists.newArrayList(sectionToProject.entrySet()));
|
||||||
|
|
||||||
Map<Project.NameKey, List<AccessSection>> accessByProject =
|
Map<Project.NameKey, List<AccessSection>> accessByProject =
|
||||||
accessDescending
|
accessDescending.stream()
|
||||||
.stream()
|
|
||||||
.collect(
|
.collect(
|
||||||
Collectors.groupingBy(
|
Collectors.groupingBy(
|
||||||
Map.Entry::getValue,
|
Map.Entry::getValue,
|
||||||
|
|||||||
@@ -93,8 +93,7 @@ public class ChildProjects {
|
|||||||
Project.NameKey parent)
|
Project.NameKey parent)
|
||||||
throws PermissionBackendException {
|
throws PermissionBackendException {
|
||||||
List<Project.NameKey> canSee =
|
List<Project.NameKey> canSee =
|
||||||
perm.filter(ProjectPermission.ACCESS, children.get(parent))
|
perm.filter(ProjectPermission.ACCESS, children.get(parent)).stream()
|
||||||
.stream()
|
|
||||||
.sorted()
|
.sorted()
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
children.removeAll(parent); // removing all entries prevents cycles.
|
children.removeAll(parent); // removing all entries prevents cycles.
|
||||||
|
|||||||
@@ -235,8 +235,7 @@ public class ProjectCacheImpl implements ProjectCache {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Set<AccountGroup.UUID> guessRelevantGroupUUIDs() {
|
public Set<AccountGroup.UUID> guessRelevantGroupUUIDs() {
|
||||||
return all()
|
return all().stream()
|
||||||
.stream()
|
|
||||||
.map(n -> byName.getIfPresent(n.get()))
|
.map(n -> byName.getIfPresent(n.get()))
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.flatMap(p -> p.getConfig().getAllGroupUUIDs().stream())
|
.flatMap(p -> p.getConfig().getAllGroupUUIDs().stream())
|
||||||
|
|||||||
@@ -1168,14 +1168,12 @@ public class ProjectConfig extends VersionedMetaData implements ValidationError.
|
|||||||
|
|
||||||
private void saveNotifySections(Config rc, Set<AccountGroup.UUID> keepGroups) {
|
private void saveNotifySections(Config rc, Set<AccountGroup.UUID> keepGroups) {
|
||||||
for (NotifyConfig nc : sort(notifySections.values())) {
|
for (NotifyConfig nc : sort(notifySections.values())) {
|
||||||
nc.getGroups()
|
nc.getGroups().stream()
|
||||||
.stream()
|
|
||||||
.map(gr -> gr.getUUID())
|
.map(gr -> gr.getUUID())
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.forEach(keepGroups::add);
|
.forEach(keepGroups::add);
|
||||||
List<String> email =
|
List<String> email =
|
||||||
nc.getGroups()
|
nc.getGroups().stream()
|
||||||
.stream()
|
|
||||||
.map(gr -> new PermissionRule(gr).asString(false))
|
.map(gr -> new PermissionRule(gr).asString(false))
|
||||||
.sorted()
|
.sorted()
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
|
|||||||
@@ -219,8 +219,7 @@ public class ProjectState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If not, we check the parents.
|
// If not, we check the parents.
|
||||||
return parents()
|
return parents().stream()
|
||||||
.stream()
|
|
||||||
.map(ProjectState::getConfig)
|
.map(ProjectState::getConfig)
|
||||||
.map(ProjectConfig::getRulesId)
|
.map(ProjectConfig::getRulesId)
|
||||||
.anyMatch(Objects::nonNull);
|
.anyMatch(Objects::nonNull);
|
||||||
|
|||||||
@@ -296,9 +296,7 @@ public class ProjectsConsistencyChecker {
|
|||||||
|
|
||||||
// Auto-close by commit
|
// Auto-close by commit
|
||||||
for (ObjectId patchSetSha1 :
|
for (ObjectId patchSetSha1 :
|
||||||
autoCloseableChange
|
autoCloseableChange.patchSets().stream()
|
||||||
.patchSets()
|
|
||||||
.stream()
|
|
||||||
.map(ps -> ObjectId.fromString(ps.getRevision().get()))
|
.map(ps -> ObjectId.fromString(ps.getRevision().get()))
|
||||||
.collect(toSet())) {
|
.collect(toSet())) {
|
||||||
if (mergedSha1s.contains(patchSetSha1)) {
|
if (mergedSha1s.contains(patchSetSha1)) {
|
||||||
|
|||||||
@@ -42,9 +42,7 @@ public class SuggestParentCandidates {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<Project.NameKey> getNameKeys() throws PermissionBackendException {
|
public List<Project.NameKey> getNameKeys() throws PermissionBackendException {
|
||||||
return permissionBackend
|
return permissionBackend.currentUser().filter(ProjectPermission.ACCESS, readableParents())
|
||||||
.currentUser()
|
|
||||||
.filter(ProjectPermission.ACCESS, readableParents())
|
|
||||||
.stream()
|
.stream()
|
||||||
.sorted()
|
.sorted()
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
|
|||||||
@@ -108,8 +108,7 @@ public class InternalAccountQuery extends InternalQuery<AccountState> {
|
|||||||
return ImmutableList.of();
|
return ImmutableList.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
return query(AccountPredicates.preferredEmail(email))
|
return query(AccountPredicates.preferredEmail(email)).stream()
|
||||||
.stream()
|
|
||||||
.filter(a -> a.getAccount().getPreferredEmail().equals(email))
|
.filter(a -> a.getAccount().getPreferredEmail().equals(email))
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
}
|
}
|
||||||
@@ -145,8 +144,7 @@ public class InternalAccountQuery extends InternalQuery<AccountState> {
|
|||||||
for (int i = 0; i < emailList.size(); i++) {
|
for (int i = 0; i < emailList.size(); i++) {
|
||||||
String email = emailList.get(i);
|
String email = emailList.get(i);
|
||||||
Set<AccountState> matchingAccounts =
|
Set<AccountState> matchingAccounts =
|
||||||
r.get(i)
|
r.get(i).stream()
|
||||||
.stream()
|
|
||||||
.filter(a -> a.getAccount().getPreferredEmail().equals(email))
|
.filter(a -> a.getAccount().getPreferredEmail().equals(email))
|
||||||
.collect(toSet());
|
.collect(toSet());
|
||||||
accountsByEmail.putAll(email, matchingAccounts);
|
accountsByEmail.putAll(email, matchingAccounts);
|
||||||
|
|||||||
@@ -1358,8 +1358,7 @@ public class ChangeQueryBuilder extends QueryBuilder<ChangeData> {
|
|||||||
if (!forDefaultField || accounts.size() <= MAX_ACCOUNTS_PER_DEFAULT_FIELD) {
|
if (!forDefaultField || accounts.size() <= MAX_ACCOUNTS_PER_DEFAULT_FIELD) {
|
||||||
reviewerPredicate =
|
reviewerPredicate =
|
||||||
Predicate.or(
|
Predicate.or(
|
||||||
accounts
|
accounts.stream()
|
||||||
.stream()
|
|
||||||
.map(id -> ReviewerPredicate.forState(id, state))
|
.map(id -> ReviewerPredicate.forState(id, state))
|
||||||
.collect(toList()));
|
.collect(toList()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,8 +31,7 @@ public class SubmitRecordPredicate extends ChangeIndexPredicate {
|
|||||||
return new SubmitRecordPredicate(status.name() + ',' + lowerLabel);
|
return new SubmitRecordPredicate(status.name() + ',' + lowerLabel);
|
||||||
}
|
}
|
||||||
return Predicate.or(
|
return Predicate.or(
|
||||||
accounts
|
accounts.stream()
|
||||||
.stream()
|
|
||||||
.map(a -> new SubmitRecordPredicate(status.name() + ',' + lowerLabel + ',' + a.get()))
|
.map(a -> new SubmitRecordPredicate(status.name() + ',' + lowerLabel + ',' + a.get()))
|
||||||
.collect(toList()));
|
.collect(toList()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,8 +28,7 @@ public class SubmittablePredicate extends ChangeIndexPredicate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean match(ChangeData cd) throws OrmException {
|
public boolean match(ChangeData cd) throws OrmException {
|
||||||
return cd.submitRecords(ChangeField.SUBMIT_RULE_OPTIONS_STRICT)
|
return cd.submitRecords(ChangeField.SUBMIT_RULE_OPTIONS_STRICT).stream()
|
||||||
.stream()
|
|
||||||
.anyMatch(r -> r.status == status);
|
.anyMatch(r -> r.status == status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,9 +85,7 @@ public class DeleteEmail implements RestModifyView<AccountResource.Email, Input>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Set<ExternalId> extIds =
|
Set<ExternalId> extIds =
|
||||||
externalIds
|
externalIds.byAccount(user.getAccountId()).stream()
|
||||||
.byAccount(user.getAccountId())
|
|
||||||
.stream()
|
|
||||||
.filter(e -> email.equals(e.email()))
|
.filter(e -> email.equals(e.email()))
|
||||||
.collect(toSet());
|
.collect(toSet());
|
||||||
if (extIds.isEmpty()) {
|
if (extIds.isEmpty()) {
|
||||||
|
|||||||
@@ -77,9 +77,7 @@ public class DeleteExternalIds implements RestModifyView<AccountResource, List<S
|
|||||||
}
|
}
|
||||||
|
|
||||||
Map<ExternalId.Key, ExternalId> externalIdMap =
|
Map<ExternalId.Key, ExternalId> externalIdMap =
|
||||||
externalIds
|
externalIds.byAccount(resource.getUser().getAccountId()).stream()
|
||||||
.byAccount(resource.getUser().getAccountId())
|
|
||||||
.stream()
|
|
||||||
.collect(toMap(ExternalId::key, Function.identity()));
|
.collect(toMap(ExternalId::key, Function.identity()));
|
||||||
|
|
||||||
List<ExternalId> toDelete = new ArrayList<>();
|
List<ExternalId> toDelete = new ArrayList<>();
|
||||||
|
|||||||
@@ -76,8 +76,7 @@ public class DeleteWatchedProjects
|
|||||||
accountId,
|
accountId,
|
||||||
u ->
|
u ->
|
||||||
u.deleteProjectWatches(
|
u.deleteProjectWatches(
|
||||||
input
|
input.stream()
|
||||||
.stream()
|
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.map(w -> ProjectWatchKey.create(new Project.NameKey(w.project), w.filter))
|
.map(w -> ProjectWatchKey.create(new Project.NameKey(w.project), w.filter))
|
||||||
.collect(toList())));
|
.collect(toList())));
|
||||||
|
|||||||
@@ -48,9 +48,7 @@ public class GetEmails implements RestReadView<AccountResource> {
|
|||||||
if (!self.get().hasSameAccountId(rsrc.getUser())) {
|
if (!self.get().hasSameAccountId(rsrc.getUser())) {
|
||||||
permissionBackend.currentUser().check(GlobalPermission.MODIFY_ACCOUNT);
|
permissionBackend.currentUser().check(GlobalPermission.MODIFY_ACCOUNT);
|
||||||
}
|
}
|
||||||
return rsrc.getUser()
|
return rsrc.getUser().getEmailAddresses().stream()
|
||||||
.getEmailAddresses()
|
|
||||||
.stream()
|
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.map(e -> toEmailInfo(rsrc, e))
|
.map(e -> toEmailInfo(rsrc, e))
|
||||||
.sorted(comparing((EmailInfo e) -> e.email))
|
.sorted(comparing((EmailInfo e) -> e.email))
|
||||||
|
|||||||
@@ -65,10 +65,7 @@ public class GetWatchedProjects implements RestReadView<AccountResource> {
|
|||||||
|
|
||||||
Account.Id accountId = rsrc.getUser().getAccountId();
|
Account.Id accountId = rsrc.getUser().getAccountId();
|
||||||
AccountState account = accounts.get(accountId).orElseThrow(ResourceNotFoundException::new);
|
AccountState account = accounts.get(accountId).orElseThrow(ResourceNotFoundException::new);
|
||||||
return account
|
return account.getProjectWatches().entrySet().stream()
|
||||||
.getProjectWatches()
|
|
||||||
.entrySet()
|
|
||||||
.stream()
|
|
||||||
.map(e -> toProjectWatchInfo(e.getKey(), e.getValue()))
|
.map(e -> toProjectWatchInfo(e.getKey(), e.getValue()))
|
||||||
.sorted(
|
.sorted(
|
||||||
comparing((ProjectWatchInfo pwi) -> pwi.project)
|
comparing((ProjectWatchInfo pwi) -> pwi.project)
|
||||||
|
|||||||
@@ -93,8 +93,7 @@ public class PutPreferred implements RestModifyView<AccountResource.Email, Input
|
|||||||
// check if the user has a matching email
|
// check if the user has a matching email
|
||||||
String matchingEmail = null;
|
String matchingEmail = null;
|
||||||
for (String email :
|
for (String email :
|
||||||
a.getExternalIds()
|
a.getExternalIds().stream()
|
||||||
.stream()
|
|
||||||
.map(ExternalId::email)
|
.map(ExternalId::email)
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.collect(toSet())) {
|
.collect(toSet())) {
|
||||||
@@ -121,8 +120,7 @@ public class PutPreferred implements RestModifyView<AccountResource.Email, Input
|
|||||||
+ " by the following account(s): %s",
|
+ " by the following account(s): %s",
|
||||||
preferredEmail,
|
preferredEmail,
|
||||||
user.getAccountId(),
|
user.getAccountId(),
|
||||||
existingExtIdsWithThisEmail
|
existingExtIdsWithThisEmail.stream()
|
||||||
.stream()
|
|
||||||
.map(ExternalId::accountId)
|
.map(ExternalId::accountId)
|
||||||
.collect(toList()));
|
.collect(toList()));
|
||||||
exception.set(
|
exception.set(
|
||||||
|
|||||||
@@ -389,9 +389,7 @@ public class CherryPickChange {
|
|||||||
|
|
||||||
if (!cherryPickCommit.getFilesWithGitConflicts().isEmpty()) {
|
if (!cherryPickCommit.getFilesWithGitConflicts().isEmpty()) {
|
||||||
stringBuilder.append("\n\nThe following files contain Git conflicts:\n");
|
stringBuilder.append("\n\nThe following files contain Git conflicts:\n");
|
||||||
cherryPickCommit
|
cherryPickCommit.getFilesWithGitConflicts().stream()
|
||||||
.getFilesWithGitConflicts()
|
|
||||||
.stream()
|
|
||||||
.sorted()
|
.sorted()
|
||||||
.forEach(filePath -> stringBuilder.append("* ").append(filePath).append("\n"));
|
.forEach(filePath -> stringBuilder.append("* ").append(filePath).append("\n"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,9 +127,7 @@ public class GetRelated implements RestReadView<RevisionResource> {
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public static Set<String> getAllGroups(ChangeNotes notes, ReviewDb db, PatchSetUtil psUtil)
|
public static Set<String> getAllGroups(ChangeNotes notes, ReviewDb db, PatchSetUtil psUtil)
|
||||||
throws OrmException {
|
throws OrmException {
|
||||||
return psUtil
|
return psUtil.byChange(db, notes).stream()
|
||||||
.byChange(db, notes)
|
|
||||||
.stream()
|
|
||||||
.flatMap(ps -> ps.getGroups().stream())
|
.flatMap(ps -> ps.getGroups().stream())
|
||||||
.collect(toSet());
|
.collect(toSet());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,8 +53,7 @@ public class ListChangeMessages implements RestReadView<ChangeResource> {
|
|||||||
List<ChangeMessage> messages =
|
List<ChangeMessage> messages =
|
||||||
changeMessagesUtil.byChange(dbProvider.get(), resource.getNotes());
|
changeMessagesUtil.byChange(dbProvider.get(), resource.getNotes());
|
||||||
List<ChangeMessageInfo> messageInfos =
|
List<ChangeMessageInfo> messageInfos =
|
||||||
messages
|
messages.stream()
|
||||||
.stream()
|
|
||||||
.map(m -> createChangeMessageInfo(m, accountLoader))
|
.map(m -> createChangeMessageInfo(m, accountLoader))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
accountLoader.fill();
|
accountLoader.fill();
|
||||||
|
|||||||
@@ -806,8 +806,7 @@ public class PostReview
|
|||||||
private static void ensureRangesDoNotOverlap(
|
private static void ensureRangesDoNotOverlap(
|
||||||
String commentPath, List<FixReplacementInfo> fixReplacementInfos) throws BadRequestException {
|
String commentPath, List<FixReplacementInfo> fixReplacementInfos) throws BadRequestException {
|
||||||
List<Range> sortedRanges =
|
List<Range> sortedRanges =
|
||||||
fixReplacementInfos
|
fixReplacementInfos.stream()
|
||||||
.stream()
|
|
||||||
.map(fixReplacementInfo -> fixReplacementInfo.range)
|
.map(fixReplacementInfo -> fixReplacementInfo.range)
|
||||||
.sorted()
|
.sorted()
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
@@ -1078,17 +1077,13 @@ public class PostReview
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Set<CommentSetEntry> readExistingComments(ChangeContext ctx) throws OrmException {
|
private Set<CommentSetEntry> readExistingComments(ChangeContext ctx) throws OrmException {
|
||||||
return commentsUtil
|
return commentsUtil.publishedByChange(ctx.getDb(), ctx.getNotes()).stream()
|
||||||
.publishedByChange(ctx.getDb(), ctx.getNotes())
|
|
||||||
.stream()
|
|
||||||
.map(CommentSetEntry::create)
|
.map(CommentSetEntry::create)
|
||||||
.collect(toSet());
|
.collect(toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<CommentSetEntry> readExistingRobotComments(ChangeContext ctx) throws OrmException {
|
private Set<CommentSetEntry> readExistingRobotComments(ChangeContext ctx) throws OrmException {
|
||||||
return commentsUtil
|
return commentsUtil.robotCommentsByChange(ctx.getNotes()).stream()
|
||||||
.robotCommentsByChange(ctx.getNotes())
|
|
||||||
.stream()
|
|
||||||
.map(CommentSetEntry::create)
|
.map(CommentSetEntry::create)
|
||||||
.collect(toSet());
|
.collect(toSet());
|
||||||
}
|
}
|
||||||
@@ -1313,8 +1308,7 @@ public class PostReview
|
|||||||
if (!reduced.isEmpty()) {
|
if (!reduced.isEmpty()) {
|
||||||
throw new ResourceConflictException(
|
throw new ResourceConflictException(
|
||||||
"Cannot reduce vote on labels for closed change: "
|
"Cannot reduce vote on labels for closed change: "
|
||||||
+ reduced
|
+ reduced.stream()
|
||||||
.stream()
|
|
||||||
.map(PatchSetApproval::getLabel)
|
.map(PatchSetApproval::getLabel)
|
||||||
.distinct()
|
.distinct()
|
||||||
.sorted()
|
.sorted()
|
||||||
|
|||||||
@@ -195,9 +195,7 @@ public class ReviewerRecommender {
|
|||||||
|
|
||||||
// Sort results
|
// Sort results
|
||||||
Stream<Entry<Account.Id, MutableDouble>> sorted =
|
Stream<Entry<Account.Id, MutableDouble>> sorted =
|
||||||
reviewerScores
|
reviewerScores.entrySet().stream()
|
||||||
.entrySet()
|
|
||||||
.stream()
|
|
||||||
.sorted(Collections.reverseOrder(Map.Entry.comparingByValue()));
|
.sorted(Collections.reverseOrder(Map.Entry.comparingByValue()));
|
||||||
List<Account.Id> sortedSuggestions = sorted.map(Map.Entry::getKey).collect(toList());
|
List<Account.Id> sortedSuggestions = sorted.map(Map.Entry::getKey).collect(toList());
|
||||||
logger.atFine().log("Sorted suggestions: %s", sortedSuggestions);
|
logger.atFine().log("Sorted suggestions: %s", sortedSuggestions);
|
||||||
|
|||||||
@@ -247,9 +247,7 @@ public class ReviewersUtil {
|
|||||||
ImmutableSet.of(AccountField.ID.getName())))
|
ImmutableSet.of(AccountField.ID.getName())))
|
||||||
.readRaw();
|
.readRaw();
|
||||||
List<Account.Id> matches =
|
List<Account.Id> matches =
|
||||||
result
|
result.toList().stream()
|
||||||
.toList()
|
|
||||||
.stream()
|
|
||||||
.map(f -> new Account.Id(f.getValue(AccountField.ID).intValue()))
|
.map(f -> new Account.Id(f.getValue(AccountField.ID).intValue()))
|
||||||
.collect(toList());
|
.collect(toList());
|
||||||
logger.atFine().log("Matches: %s", matches);
|
logger.atFine().log("Matches: %s", matches);
|
||||||
@@ -310,8 +308,7 @@ public class ReviewersUtil {
|
|||||||
|
|
||||||
try (Timer0.Context ctx = metrics.loadAccountsLatency.start()) {
|
try (Timer0.Context ctx = metrics.loadAccountsLatency.start()) {
|
||||||
List<SuggestedReviewerInfo> reviewer =
|
List<SuggestedReviewerInfo> reviewer =
|
||||||
accountIds
|
accountIds.stream()
|
||||||
.stream()
|
|
||||||
.map(accountLoader::get)
|
.map(accountLoader::get)
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.map(
|
.map(
|
||||||
@@ -431,8 +428,7 @@ public class ReviewersUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static String formatSuggestedReviewers(List<SuggestedReviewerInfo> suggestedReviewers) {
|
private static String formatSuggestedReviewers(List<SuggestedReviewerInfo> suggestedReviewers) {
|
||||||
return suggestedReviewers
|
return suggestedReviewers.stream()
|
||||||
.stream()
|
|
||||||
.map(
|
.map(
|
||||||
r -> {
|
r -> {
|
||||||
if (r.account != null) {
|
if (r.account != null) {
|
||||||
|
|||||||
@@ -106,9 +106,7 @@ public class ListTasks implements RestReadView<ConfigResource> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private List<TaskInfo> getTasks() {
|
private List<TaskInfo> getTasks() {
|
||||||
return workQueue
|
return workQueue.getTaskInfos(TaskInfo::new).stream()
|
||||||
.getTaskInfos(TaskInfo::new)
|
|
||||||
.stream()
|
|
||||||
.sorted(
|
.sorted(
|
||||||
comparing((TaskInfo t) -> t.state.ordinal())
|
comparing((TaskInfo t) -> t.state.ordinal())
|
||||||
.thenComparing(t -> t.delay)
|
.thenComparing(t -> t.delay)
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user