mirror of
https://github.com/google/nomulus.git
synced 2025-05-12 22:38:16 +02:00
Run automatic Java 8 conversion over codebase
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=171174380
This commit is contained in:
parent
44df5da771
commit
5edb7935ed
190 changed files with 2312 additions and 3096 deletions
|
@ -19,14 +19,12 @@ import static google.registry.request.Action.Method.POST;
|
|||
import static java.util.Arrays.asList;
|
||||
import static javax.servlet.http.HttpServletResponse.SC_OK;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Optional;
|
||||
import google.registry.config.RegistryConfig.Config;
|
||||
import google.registry.groups.GroupsConnection;
|
||||
import google.registry.groups.GroupsConnection.Role;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.model.registrar.RegistrarContact.Type;
|
||||
import google.registry.request.Action;
|
||||
import google.registry.request.HttpException.BadRequestException;
|
||||
import google.registry.request.HttpException.InternalServerErrorException;
|
||||
|
@ -70,26 +68,26 @@ public class CreateGroupsAction implements Runnable {
|
|||
List<RegistrarContact.Type> types = asList(RegistrarContact.Type.values());
|
||||
// Concurrently create the groups for each RegistrarContact.Type, collecting the results from
|
||||
// each call (which are either an Exception if it failed, or absent() if it succeeded).
|
||||
List<Optional<Exception>> results = Concurrent.transform(
|
||||
types,
|
||||
NUM_SIMULTANEOUS_CONNECTIONS,
|
||||
new Function<RegistrarContact.Type, Optional<Exception>>() {
|
||||
@Override
|
||||
public Optional<Exception> apply(Type type) {
|
||||
try {
|
||||
String groupKey = getGroupEmailAddressForContactType(
|
||||
registrar.getClientId(), type, gSuiteDomainName);
|
||||
String parentGroup =
|
||||
getGroupEmailAddressForContactType("registrar", type, gSuiteDomainName);
|
||||
// Creates the group, then adds it as a member to the global registrar group for
|
||||
// that type.
|
||||
groupsConnection.createGroup(groupKey);
|
||||
groupsConnection.addMemberToGroup(parentGroup, groupKey, Role.MEMBER);
|
||||
return Optional.<Exception> absent();
|
||||
} catch (Exception e) {
|
||||
return Optional.of(e);
|
||||
}
|
||||
}});
|
||||
List<Optional<Exception>> results =
|
||||
Concurrent.transform(
|
||||
types,
|
||||
NUM_SIMULTANEOUS_CONNECTIONS,
|
||||
type -> {
|
||||
try {
|
||||
String groupKey =
|
||||
getGroupEmailAddressForContactType(
|
||||
registrar.getClientId(), type, gSuiteDomainName);
|
||||
String parentGroup =
|
||||
getGroupEmailAddressForContactType("registrar", type, gSuiteDomainName);
|
||||
// Creates the group, then adds it as a member to the global registrar group for
|
||||
// that type.
|
||||
groupsConnection.createGroup(groupKey);
|
||||
groupsConnection.addMemberToGroup(parentGroup, groupKey, Role.MEMBER);
|
||||
return Optional.<Exception>absent();
|
||||
} catch (Exception e) {
|
||||
return Optional.of(e);
|
||||
}
|
||||
});
|
||||
// Return the correct server response based on the results of the group creations.
|
||||
if (Optional.presentInstances(results).iterator().hasNext()) {
|
||||
StringWriter responseString = new StringWriter();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue