Split off api classes from giant server lib
Moves the following classes to break dependency cycles: * GpgApiAdapter * AccountExternalIdCreator * AccountInfoComparator Change-Id: Ie081b5d95d7b79f888650752fd55cc4a80f7ef42
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
// Copyright (C) 2016 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.account;
|
||||
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.server.account.externalids.ExternalId;
|
||||
import java.util.List;
|
||||
|
||||
public interface AccountExternalIdCreator {
|
||||
|
||||
/**
|
||||
* Returns additional external identifiers to assign to a given user when creating an account.
|
||||
*
|
||||
* @param id the identifier of the account.
|
||||
* @param username the name of the user.
|
||||
* @param email an optional email address to assign to the external identifiers, or {@code null}.
|
||||
* @return a list of external identifiers, or an empty list.
|
||||
*/
|
||||
List<ExternalId> create(Account.Id id, String username, String email);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
// Copyright (C) 2015 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.account;
|
||||
|
||||
import com.google.common.collect.ComparisonChain;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class AccountInfoComparator extends Ordering<AccountInfo>
|
||||
implements Comparator<AccountInfo> {
|
||||
public static final AccountInfoComparator ORDER_NULLS_FIRST = new AccountInfoComparator();
|
||||
public static final AccountInfoComparator ORDER_NULLS_LAST =
|
||||
new AccountInfoComparator().setNullsLast();
|
||||
|
||||
private boolean nullsLast;
|
||||
|
||||
private AccountInfoComparator() {}
|
||||
|
||||
private AccountInfoComparator setNullsLast() {
|
||||
this.nullsLast = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(AccountInfo a, AccountInfo b) {
|
||||
return ComparisonChain.start()
|
||||
.compare(a.name, b.name, createOrdering())
|
||||
.compare(a.email, b.email, createOrdering())
|
||||
.compare(a._accountId, b._accountId, createOrdering())
|
||||
.result();
|
||||
}
|
||||
|
||||
private <S extends Comparable<?>> Ordering<S> createOrdering() {
|
||||
if (nullsLast) {
|
||||
return Ordering.natural().nullsLast();
|
||||
}
|
||||
return Ordering.natural().nullsFirst();
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,6 @@ import com.google.gerrit.server.Sequences;
|
||||
import com.google.gerrit.server.account.externalids.ExternalId;
|
||||
import com.google.gerrit.server.account.externalids.ExternalIds;
|
||||
import com.google.gerrit.server.account.externalids.ExternalIdsUpdate;
|
||||
import com.google.gerrit.server.api.accounts.AccountExternalIdCreator;
|
||||
import com.google.gerrit.server.group.GroupsCollection;
|
||||
import com.google.gerrit.server.group.UserInitiated;
|
||||
import com.google.gerrit.server.group.db.GroupsUpdate;
|
||||
|
||||
40
java/com/google/gerrit/server/account/GpgApiAdapter.java
Normal file
40
java/com/google/gerrit/server/account/GpgApiAdapter.java
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright (C) 2015 The Android Open Source Project
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.gerrit.server.account;
|
||||
|
||||
import com.google.gerrit.extensions.api.accounts.GpgKeyApi;
|
||||
import com.google.gerrit.extensions.common.GpgKeyInfo;
|
||||
import com.google.gerrit.extensions.common.PushCertificateInfo;
|
||||
import com.google.gerrit.extensions.restapi.IdString;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.server.GpgException;
|
||||
import com.google.gerrit.server.IdentifiedUser;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface GpgApiAdapter {
|
||||
boolean isEnabled();
|
||||
|
||||
Map<String, GpgKeyInfo> listGpgKeys(AccountResource account)
|
||||
throws RestApiException, GpgException;
|
||||
|
||||
Map<String, GpgKeyInfo> putGpgKeys(AccountResource account, List<String> add, List<String> delete)
|
||||
throws RestApiException, GpgException;
|
||||
|
||||
GpgKeyApi gpgKey(AccountResource account, IdString idStr) throws RestApiException, GpgException;
|
||||
|
||||
PushCertificateInfo checkPushCertificate(String certStr, IdentifiedUser expectedUser)
|
||||
throws GpgException;
|
||||
}
|
||||
@@ -28,7 +28,6 @@ import com.google.gerrit.index.query.QueryParseException;
|
||||
import com.google.gerrit.index.query.QueryResult;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.server.account.AccountDirectory.FillOptions;
|
||||
import com.google.gerrit.server.api.accounts.AccountInfoComparator;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.query.account.AccountPredicates;
|
||||
import com.google.gerrit.server.query.account.AccountQueryBuilder;
|
||||
|
||||
Reference in New Issue
Block a user