Rewrite our build as modular maven components

This refactoring splits the code up into different components, with
their own per-component CLASSPATH.  By moving all of our classes
into isolated components we can better isolate the classpaths and
try to avoid unexpected dependency problems.  It also allows us to
more clearly define which components are used by the GWT UI and
thus must be compiled under GWT, and which components are run on
the server and can therefore use more of the J2SE API.

Change-Id: I833cc22bacc5655d1c9099ed7c2b0e0a5b08855a
Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2009-11-07 12:55:26 -08:00
parent 2464ac82b7
commit 44671f5c69
719 changed files with 9467 additions and 2417 deletions

View File

@@ -0,0 +1,68 @@
// Copyright (C) 2008 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.common;
import com.google.gerrit.common.data.AccountInfo;
import com.google.gerrit.common.data.ChangeInfo;
import com.google.gerrit.reviewdb.Account;
import com.google.gerrit.reviewdb.Change;
import com.google.gwtorm.client.KeyUtil;
public class PageLinks {
public static final String SETTINGS = "settings";
public static final String SETTINGS_SSHKEYS = "settings,ssh-keys";
public static final String SETTINGS_WEBIDENT = "settings,web-identities";
public static final String SETTINGS_MYGROUPS = "settings,group-memberships";
public static final String SETTINGS_AGREEMENTS = "settings,agreements";
public static final String SETTINGS_CONTACT = "settings,contact";
public static final String SETTINGS_PROJECTS = "settings,projects";
public static final String SETTINGS_NEW_AGREEMENT = "settings,new-agreement";
public static final String REGISTER = "register";
public static final String MINE = "mine";
public static final String MINE_STARRED = "mine,starred";
public static final String MINE_DRAFTS = "mine,drafts";
public static final String ALL_ABANDONED = "all,abandoned,n,z";
public static final String ALL_MERGED = "all,merged,n,z";
public static final String ALL_OPEN = "all,open,n,z";
public static final String ADMIN_PEOPLE = "admin,people";
public static final String ADMIN_GROUPS = "admin,groups";
public static final String ADMIN_PROJECTS = "admin,projects";
public static String toChange(final ChangeInfo c) {
return toChange(c.getId());
}
public static String toChange(final Change.Id c) {
return "change," + c.toString();
}
public static String toAccountDashboard(final AccountInfo acct) {
return toAccountDashboard(acct.getId());
}
public static String toAccountDashboard(final Account.Id acct) {
return "dashboard," + acct.toString();
}
public static String toChangeQuery(final String query) {
return "q," + KeyUtil.encode(query) + ",n,z";
}
protected PageLinks() {
}
}

View File

@@ -0,0 +1,19 @@
// Copyright (C) 2008 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.common.auth;
public enum SignInMode {
SIGN_IN, LINK_IDENTIY, REGISTER;
}

View File

@@ -0,0 +1,33 @@
// Copyright (C) 2008 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.common.auth;
import com.google.gerrit.common.errors.NotSignedInException;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation indicating a service method requires a current user.
* <p>
* If there is no current user then {@link NotSignedInException} will be given
* to the callback's onFailure method.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface SignInRequired {
}

View File

@@ -0,0 +1,37 @@
// Copyright (C) 2009 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.common.auth.openid;
import java.util.Map;
public final class DiscoveryResult {
public boolean validProvider;
public String providerUrl;
public Map<String, String> providerArgs;
protected DiscoveryResult() {
}
public DiscoveryResult(final boolean valid, final String redirect,
final Map<String, String> args) {
validProvider = valid;
providerUrl = redirect;
providerArgs = args;
}
public DiscoveryResult(final boolean fail) {
this(false, null, null);
}
}

View File

@@ -0,0 +1,27 @@
// Copyright (C) 2009 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.common.auth.openid;
import com.google.gerrit.common.auth.SignInMode;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwtjsonrpc.client.AllowCrossSiteRequest;
import com.google.gwtjsonrpc.client.RemoteJsonService;
public interface OpenIdService extends RemoteJsonService {
@AllowCrossSiteRequest
void discover(String openidIdentifier, SignInMode mode,
boolean remember, String returnToken,
AsyncCallback<DiscoveryResult> callback);
}

View File

@@ -0,0 +1,24 @@
// Copyright (C) 2009 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.common.auth.openid;
public class OpenIdUrls {
public static final String OPENID_IDENTIFIER = "openid_identifier";
public static final String LASTID_COOKIE = "gerrit.last_openid";
public static final String URL_YAHOO = "https://me.yahoo.com";
public static final String URL_GOOGLE =
"https://www.google.com/accounts/o8/id";
}

View File

@@ -0,0 +1,20 @@
// Copyright (C) 2009 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.common.auth.userpass;
public class LoginResult {
public boolean success;
public boolean isNew;
}

View File

@@ -0,0 +1,25 @@
// Copyright (C) 2009 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.common.auth.userpass;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwtjsonrpc.client.AllowCrossSiteRequest;
import com.google.gwtjsonrpc.client.RemoteJsonService;
public interface UserPassAuthService extends RemoteJsonService {
@AllowCrossSiteRequest
void authenticate(String username, String password,
AsyncCallback<LoginResult> callback);
}

View File

@@ -0,0 +1,71 @@
// Copyright (C) 2008 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.common.data;
import com.google.gerrit.reviewdb.Account;
import java.util.List;
/** Summary information needed to display an account dashboard. */
public class AccountDashboardInfo {
protected AccountInfoCache accounts;
protected Account.Id owner;
protected List<ChangeInfo> byOwner;
protected List<ChangeInfo> forReview;
protected List<ChangeInfo> closed;
protected AccountDashboardInfo() {
}
public AccountDashboardInfo(final Account.Id forUser) {
owner = forUser;
}
public AccountInfoCache getAccounts() {
return accounts;
}
public void setAccounts(final AccountInfoCache ac) {
accounts = ac;
}
public Account.Id getOwner() {
return owner;
}
public List<ChangeInfo> getByOwner() {
return byOwner;
}
public void setByOwner(List<ChangeInfo> c) {
byOwner = c;
}
public List<ChangeInfo> getForReview() {
return forReview;
}
public void setForReview(List<ChangeInfo> c) {
forReview = c;
}
public List<ChangeInfo> getClosed() {
return closed;
}
public void setClosed(List<ChangeInfo> c) {
closed = c;
}
}

View File

@@ -0,0 +1,68 @@
// Copyright (C) 2008 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.common.data;
import com.google.gerrit.reviewdb.Account;
/** Summary information about an {@link Account}, for simple tabular displays. */
public class AccountInfo {
protected Account.Id id;
protected String fullName;
protected String preferredEmail;
protected AccountInfo() {
}
/**
* Create an 'Anonymous Coward' account info, when only the id is known.
* <p>
* This constructor should only be a last-ditch effort, when the usual account
* lookup has failed and a stale account id has been discovered in the data
* store.
*/
public AccountInfo(final Account.Id id) {
this.id = id;
}
/**
* Create an account description from a real data store record.
*
* @param a the data store record holding the specific account details.
*/
public AccountInfo(final Account a) {
id = a.getId();
fullName = a.getFullName();
preferredEmail = a.getPreferredEmail();
}
/** @return the unique local id of the account */
public Account.Id getId() {
return id;
}
/** @return the full name of the account holder; null if not supplied */
public String getFullName() {
return fullName;
}
/** @return the email address of the account holder; null if not supplied */
public String getPreferredEmail() {
return preferredEmail;
}
public void setPreferredEmail(final String email) {
preferredEmail = email;
}
}

View File

@@ -0,0 +1,79 @@
// Copyright (C) 2008 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.common.data;
import com.google.gerrit.reviewdb.Account;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/** In-memory table of {@link AccountInfo}, indexed by {@link Account.Id}. */
public class AccountInfoCache {
private static final AccountInfoCache EMPTY;
static {
EMPTY = new AccountInfoCache();
EMPTY.accounts = Collections.emptyMap();
}
/** Obtain an empty cache singleton. */
public static AccountInfoCache empty() {
return EMPTY;
}
protected Map<Account.Id, AccountInfo> accounts;
protected AccountInfoCache() {
}
public AccountInfoCache(final Iterable<AccountInfo> list) {
accounts = new HashMap<Account.Id, AccountInfo>();
for (final AccountInfo ai : list) {
accounts.put(ai.getId(), ai);
}
}
/**
* Lookup the account summary
* <p>
* The return value can take on one of three forms:
* <ul>
* <li><code>null</code>, if <code>id == null</code>.</li>
* <li>a valid info block, if <code>id</code> was loaded.</li>
* <li>an anonymous info block, if <code>id</code> was not loaded.</li>
* </ul>
*
* @param id the id desired.
* @return info block for the account.
*/
public AccountInfo get(final Account.Id id) {
if (id == null) {
return null;
}
AccountInfo r = accounts.get(id);
if (r == null) {
r = new AccountInfo(id);
accounts.put(id, r);
}
return r;
}
/** Merge the information from another cache into this one. */
public void merge(final AccountInfoCache other) {
assert this != EMPTY;
accounts.putAll(other.accounts);
}
}

View File

@@ -0,0 +1,39 @@
// Copyright (C) 2008 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.common.data;
import com.google.gerrit.reviewdb.AccountProjectWatch;
import com.google.gerrit.reviewdb.Project;
public final class AccountProjectWatchInfo {
protected AccountProjectWatch watch;
protected Project project;
protected AccountProjectWatchInfo() {
}
public AccountProjectWatchInfo(final AccountProjectWatch w, final Project p) {
watch = w;
project = p;
}
public AccountProjectWatch getWatch() {
return watch;
}
public Project getProject() {
return project;
}
}

View File

@@ -0,0 +1,68 @@
// Copyright (C) 2008 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.common.data;
import com.google.gerrit.common.auth.SignInRequired;
import com.google.gerrit.reviewdb.Account;
import com.google.gerrit.reviewdb.AccountExternalId;
import com.google.gerrit.reviewdb.AccountGroup;
import com.google.gerrit.reviewdb.AccountSshKey;
import com.google.gerrit.reviewdb.ContactInformation;
import com.google.gerrit.reviewdb.ContributorAgreement;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwtjsonrpc.client.RemoteJsonService;
import com.google.gwtjsonrpc.client.VoidResult;
import java.util.List;
import java.util.Set;
public interface AccountSecurity extends RemoteJsonService {
@SignInRequired
void mySshKeys(AsyncCallback<List<AccountSshKey>> callback);
@SignInRequired
void addSshKey(String keyText, AsyncCallback<AccountSshKey> callback);
@SignInRequired
void deleteSshKeys(Set<AccountSshKey.Id> ids,
AsyncCallback<VoidResult> callback);
@SignInRequired
void changeSshUserName(String newName, AsyncCallback<VoidResult> callback);
@SignInRequired
void myExternalIds(AsyncCallback<List<AccountExternalId>> callback);
@SignInRequired
void myGroups(AsyncCallback<List<AccountGroup>> callback);
@SignInRequired
void deleteExternalIds(Set<AccountExternalId.Key> keys,
AsyncCallback<Set<AccountExternalId.Key>> callback);
@SignInRequired
void updateContact(String fullName, String emailAddr,
ContactInformation info, AsyncCallback<Account> callback);
@SignInRequired
void enterAgreement(ContributorAgreement.Id id,
AsyncCallback<VoidResult> callback);
@SignInRequired
void registerEmail(String address, AsyncCallback<VoidResult> callback);
@SignInRequired
void validateEmail(String token, AsyncCallback<VoidResult> callback);
}

View File

@@ -0,0 +1,53 @@
// Copyright (C) 2008 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.common.data;
import com.google.gerrit.common.auth.SignInRequired;
import com.google.gerrit.reviewdb.Account;
import com.google.gerrit.reviewdb.AccountGeneralPreferences;
import com.google.gerrit.reviewdb.AccountProjectWatch;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwtjsonrpc.client.RemoteJsonService;
import com.google.gwtjsonrpc.client.VoidResult;
import java.util.List;
import java.util.Set;
public interface AccountService extends RemoteJsonService {
@SignInRequired
void myAccount(AsyncCallback<Account> callback);
@SignInRequired
void changePreferences(AccountGeneralPreferences pref,
AsyncCallback<VoidResult> gerritCallback);
@SignInRequired
void myProjectWatch(AsyncCallback<List<AccountProjectWatchInfo>> callback);
@SignInRequired
void addProjectWatch(String projectName,
AsyncCallback<AccountProjectWatchInfo> callback);
@SignInRequired
void updateProjectWatch(AccountProjectWatch watch,
AsyncCallback<VoidResult> callback);
@SignInRequired
void deleteProjectWatches(Set<AccountProjectWatch.Key> keys,
AsyncCallback<VoidResult> callback);
@SignInRequired
void myAgreements(AsyncCallback<AgreementInfo> callback);
}

View File

@@ -0,0 +1,79 @@
// Copyright (C) 2009 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.common.data;
import java.util.ArrayList;
import java.util.List;
/** Result from adding a reviewer to a change. */
public class AddReviewerResult {
protected List<Error> errors;
protected ChangeDetail change;
public AddReviewerResult() {
errors = new ArrayList<Error>();
}
public void addError(final Error e) {
errors.add(e);
}
public List<Error> getErrors() {
return errors;
}
public ChangeDetail getChange() {
return change;
}
public void setChange(final ChangeDetail d) {
change = d;
}
public static class Error {
public static enum Type {
/** Name supplied does not match to a registered account. */
ACCOUNT_NOT_FOUND,
/** The account is not permitted to see the change. */
CHANGE_NOT_VISIBLE
}
protected Type type;
protected String name;
protected Error() {
}
public Error(final Type type, final String who) {
this.type = type;
this.name = who;
}
public Type getType() {
return type;
}
public String getName() {
return name;
}
@Override
public String toString() {
return type + " " + name;
}
}
}

View File

@@ -0,0 +1,43 @@
// Copyright (C) 2008 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.common.data;
import com.google.gerrit.reviewdb.AccountAgreement;
import com.google.gerrit.reviewdb.AccountGroupAgreement;
import com.google.gerrit.reviewdb.ContributorAgreement;
import java.util.List;
import java.util.Map;
public class AgreementInfo {
public List<AccountAgreement> userAccepted;
public List<AccountGroupAgreement> groupAccepted;
public Map<ContributorAgreement.Id, ContributorAgreement> agreements;
public AgreementInfo() {
}
public void setUserAccepted(List<AccountAgreement> a) {
userAccepted = a;
}
public void setGroupAccepted(List<AccountGroupAgreement> a) {
groupAccepted = a;
}
public void setAgreements(Map<ContributorAgreement.Id, ContributorAgreement> a) {
agreements = a;
}
}

View File

@@ -0,0 +1,85 @@
// Copyright (C) 2008 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.common.data;
import com.google.gerrit.reviewdb.Account;
import com.google.gerrit.reviewdb.ApprovalCategory;
import com.google.gerrit.reviewdb.PatchSetApproval;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ApprovalDetail {
public static final Comparator<ApprovalDetail> SORT =
new Comparator<ApprovalDetail>() {
public int compare(final ApprovalDetail o1, final ApprovalDetail o2) {
int cmp;
cmp = o2.hasNonZero - o1.hasNonZero;
if (cmp != 0) return cmp;
return o1.sortOrder.compareTo(o2.sortOrder);
}
};
static final Timestamp EG_0 = new Timestamp(0);
static final Timestamp EG_D = new Timestamp(Long.MAX_VALUE);
protected Account.Id account;
protected List<PatchSetApproval> approvals;
private transient int hasNonZero;
private transient Timestamp sortOrder = EG_D;
protected ApprovalDetail() {
}
public ApprovalDetail(final Account.Id id) {
account = id;
approvals = new ArrayList<PatchSetApproval>();
}
public Account.Id getAccount() {
return account;
}
public Map<ApprovalCategory.Id, PatchSetApproval> getApprovalMap() {
final HashMap<ApprovalCategory.Id, PatchSetApproval> r;
r = new HashMap<ApprovalCategory.Id, PatchSetApproval>();
for (final PatchSetApproval ca : approvals) {
r.put(ca.getCategoryId(), ca);
}
return r;
}
public void sortFirst() {
hasNonZero = 1;
sortOrder = ApprovalDetail.EG_0;
}
public void add(final PatchSetApproval ca) {
approvals.add(ca);
final Timestamp g = ca.getGranted();
if (g != null && g.compareTo(sortOrder) < 0) {
sortOrder = g;
}
if (ca.getValue() != 0) {
hasNonZero = 1;
}
}
}

View File

@@ -0,0 +1,44 @@
// Copyright (C) 2009 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.common.data;
import com.google.gerrit.reviewdb.ApprovalCategory;
import com.google.gerrit.reviewdb.PatchSetApproval;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/** Summarizes the approvals (or negative approvals) for a patch set.
* This will typically contain zero or one approvals for each
* category, with all of the approvals coming from a single patch set.
*/
public class ApprovalSummary {
protected Map<ApprovalCategory.Id, PatchSetApproval> approvals;
protected ApprovalSummary() {
}
public ApprovalSummary(final Iterable<PatchSetApproval> list) {
approvals = new HashMap<ApprovalCategory.Id, PatchSetApproval>();
for (final PatchSetApproval a : list) {
approvals.put(a.getCategoryId(), a);
}
}
public Map<ApprovalCategory.Id, PatchSetApproval> getApprovalMap() {
return Collections.unmodifiableMap(approvals);
}
}

View File

@@ -0,0 +1,49 @@
// Copyright (C) 2009 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.common.data;
import com.google.gerrit.reviewdb.Change;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/** Contains a set of ApprovalSummary objects, keyed by the change id
* from which they were derived.
*/
public class ApprovalSummarySet {
protected AccountInfoCache accounts;
protected Map<Change.Id, ApprovalSummary> summaries;
protected ApprovalSummarySet() {
}
public ApprovalSummarySet(final AccountInfoCache accts,
final Map<Change.Id, ApprovalSummary> map) {
accounts = accts;
summaries = new HashMap<Change.Id, ApprovalSummary>();
summaries.putAll(map);
}
public AccountInfoCache getAccountInfoCache() {
return accounts;
}
public Map<Change.Id, ApprovalSummary> getSummaryMap() {
return Collections.unmodifiableMap(summaries);
}
}

View File

@@ -0,0 +1,110 @@
// Copyright (C) 2008 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.common.data;
import com.google.gerrit.reviewdb.ApprovalCategory;
import com.google.gerrit.reviewdb.ApprovalCategoryValue;
import com.google.gerrit.reviewdb.PatchSetApproval;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ApprovalType {
protected ApprovalCategory category;
protected List<ApprovalCategoryValue> values;
protected short maxNegative;
protected short maxPositive;
private transient Map<Short, ApprovalCategoryValue> byValue;
protected ApprovalType() {
}
public ApprovalType(final ApprovalCategory ac,
final List<ApprovalCategoryValue> valueList) {
category = ac;
values = new ArrayList<ApprovalCategoryValue>(valueList);
Collections.sort(values, new Comparator<ApprovalCategoryValue>() {
public int compare(ApprovalCategoryValue o1, ApprovalCategoryValue o2) {
return o1.getValue() - o2.getValue();
}
});
maxNegative = Short.MIN_VALUE;
maxPositive = Short.MAX_VALUE;
if (values.size() > 0) {
if (values.get(0).getValue() < 0) {
maxNegative = values.get(0).getValue();
}
if (values.get(values.size() - 1).getValue() > 0) {
maxPositive = values.get(values.size() - 1).getValue();
}
}
}
public ApprovalCategory getCategory() {
return category;
}
public List<ApprovalCategoryValue> getValues() {
return values;
}
public ApprovalCategoryValue getMin() {
if (values.isEmpty()) {
return null;
}
return values.get(0);
}
public ApprovalCategoryValue getMax() {
if (values.isEmpty()) {
return null;
}
final ApprovalCategoryValue v = values.get(values.size() - 1);
return v.getValue() > 0 ? v : null;
}
public boolean isMaxNegative(final PatchSetApproval ca) {
return maxNegative == ca.getValue();
}
public boolean isMaxPositive(final PatchSetApproval ca) {
return maxPositive == ca.getValue();
}
public ApprovalCategoryValue getValue(final short value) {
initByValue();
return byValue.get(value);
}
public ApprovalCategoryValue getValue(final PatchSetApproval ca) {
initByValue();
return byValue.get(ca.getValue());
}
private void initByValue() {
if (byValue == null) {
byValue = new HashMap<Short, ApprovalCategoryValue>();
for (final ApprovalCategoryValue acv : values) {
byValue.put(acv.getValue(), acv);
}
}
}
}

View File

@@ -0,0 +1,67 @@
// Copyright (C) 2009 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.common.data;
import com.google.gerrit.reviewdb.ApprovalCategory;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ApprovalTypes {
protected List<ApprovalType> approvalTypes;
protected List<ApprovalType> actionTypes;
private transient Map<ApprovalCategory.Id, ApprovalType> byCategoryId;
protected ApprovalTypes() {
}
public ApprovalTypes(final List<ApprovalType> approvals,
final List<ApprovalType> actions) {
approvalTypes = approvals;
actionTypes = actions;
byCategory();
}
public List<ApprovalType> getApprovalTypes() {
return approvalTypes;
}
public List<ApprovalType> getActionTypes() {
return actionTypes;
}
public ApprovalType getApprovalType(final ApprovalCategory.Id id) {
return byCategory().get(id);
}
private Map<ApprovalCategory.Id, ApprovalType> byCategory() {
if (byCategoryId == null) {
byCategoryId = new HashMap<ApprovalCategory.Id, ApprovalType>();
if (actionTypes != null) {
for (final ApprovalType t : actionTypes) {
byCategoryId.put(t.getCategory().getId(), t);
}
}
if (approvalTypes != null) {
for (final ApprovalType t : approvalTypes) {
byCategoryId.put(t.getCategory().getId(), t);
}
}
}
return byCategoryId;
}
}

View File

@@ -0,0 +1,177 @@
// Copyright (C) 2008 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.common.data;
import com.google.gerrit.reviewdb.ApprovalCategory;
import com.google.gerrit.reviewdb.Change;
import com.google.gerrit.reviewdb.ChangeMessage;
import com.google.gerrit.reviewdb.PatchSet;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
/** Detail necessary to display a change. */
public class ChangeDetail {
protected AccountInfoCache accounts;
protected boolean allowsAnonymous;
protected boolean canAbandon;
protected Change change;
protected boolean starred;
protected List<ChangeInfo> dependsOn;
protected List<ChangeInfo> neededBy;
protected List<PatchSet> patchSets;
protected List<ApprovalDetail> approvals;
protected Set<ApprovalCategory.Id> missingApprovals;
protected List<ChangeMessage> messages;
protected PatchSet.Id currentPatchSetId;
protected PatchSetDetail currentDetail;
protected Set<ApprovalCategory.Id> currentActions;
public ChangeDetail() {
}
public AccountInfoCache getAccounts() {
return accounts;
}
public void setAccounts(AccountInfoCache aic) {
accounts = aic;
}
public boolean isAllowsAnonymous() {
return allowsAnonymous;
}
public void setAllowsAnonymous(final boolean anon) {
allowsAnonymous = anon;
}
public boolean canAbandon() {
return canAbandon;
}
public void setCanAbandon(final boolean a) {
canAbandon = a;
}
public Change getChange() {
return change;
}
public void setChange(final Change change) {
this.change = change;
this.currentPatchSetId = change.currentPatchSetId();
}
public boolean isStarred() {
return starred;
}
public void setStarred(final boolean s) {
starred = s;
}
public List<ChangeInfo> getDependsOn() {
return dependsOn;
}
public void setDependsOn(List<ChangeInfo> d) {
dependsOn = d;
}
public List<ChangeInfo> getNeededBy() {
return neededBy;
}
public void setNeededBy(List<ChangeInfo> d) {
neededBy = d;
}
public List<ChangeMessage> getMessages() {
return messages;
}
public void setMessages(List<ChangeMessage> m) {
messages = m;
}
public List<PatchSet> getPatchSets() {
return patchSets;
}
public void setPatchSets(List<PatchSet> s) {
patchSets = s;
}
public List<ApprovalDetail> getApprovals() {
return approvals;
}
public void setApprovals(Collection<ApprovalDetail> list) {
approvals = new ArrayList<ApprovalDetail>(list);
Collections.sort(approvals, ApprovalDetail.SORT);
}
public Set<ApprovalCategory.Id> getMissingApprovals() {
return missingApprovals;
}
public void setMissingApprovals(Set<ApprovalCategory.Id> a) {
missingApprovals = a;
}
public Set<ApprovalCategory.Id> getCurrentActions() {
return currentActions;
}
public void setCurrentActions(Set<ApprovalCategory.Id> a) {
currentActions = a;
}
public boolean isCurrentPatchSet(final PatchSetDetail detail) {
return currentPatchSetId != null
&& detail.getPatchSet().getId().equals(currentPatchSetId);
}
public PatchSet getCurrentPatchSet() {
if (currentPatchSetId != null) {
// We search through the list backwards because its *very* likely
// that the current patch set is also the last patch set.
//
for (int i = patchSets.size() - 1; i >= 0; i--) {
final PatchSet ps = patchSets.get(i);
if (ps.getId().equals(currentPatchSetId)) {
return ps;
}
}
}
return null;
}
public PatchSetDetail getCurrentPatchSetDetail() {
return currentDetail;
}
public void setCurrentPatchSetDetail(PatchSetDetail d) {
currentDetail = d;
}
public String getDescription() {
return currentDetail != null ? currentDetail.getInfo().getMessage() : "";
}
}

View File

@@ -0,0 +1,31 @@
// Copyright (C) 2008 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.common.data;
import com.google.gerrit.common.auth.SignInRequired;
import com.google.gerrit.reviewdb.Change;
import com.google.gerrit.reviewdb.PatchSet;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwtjsonrpc.client.RemoteJsonService;
public interface ChangeDetailService extends RemoteJsonService {
void changeDetail(Change.Id id, AsyncCallback<ChangeDetail> callback);
void patchSetDetail(PatchSet.Id key, AsyncCallback<PatchSetDetail> callback);
@SignInRequired
void patchSetPublishDetail(PatchSet.Id key,
AsyncCallback<PatchSetPublishDetail> callback);
}

View File

@@ -0,0 +1,92 @@
// Copyright (C) 2008 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.common.data;
import com.google.gerrit.reviewdb.Account;
import com.google.gerrit.reviewdb.Change;
import java.sql.Timestamp;
public class ChangeInfo {
protected Change.Id id;
protected Change.Key key;
protected Account.Id owner;
protected String subject;
protected Change.Status status;
protected ProjectInfo project;
protected String branch;
protected boolean starred;
protected Timestamp lastUpdatedOn;
protected String sortKey;
protected ChangeInfo() {
}
public ChangeInfo(final Change c) {
id = c.getId();
key = c.getKey();
owner = c.getOwner();
subject = c.getSubject();
status = c.getStatus();
project = new ProjectInfo(c.getProject());
branch = c.getDest().getShortName();
lastUpdatedOn = c.getLastUpdatedOn();
sortKey = c.getSortKey();
}
public Change.Id getId() {
return id;
}
public Change.Key getKey() {
return key;
}
public Account.Id getOwner() {
return owner;
}
public String getSubject() {
return subject;
}
public Change.Status getStatus() {
return status;
}
public ProjectInfo getProject() {
return project;
}
public String getBranch() {
return branch;
}
public boolean isStarred() {
return starred;
}
public void setStarred(final boolean s) {
starred = s;
}
public java.sql.Timestamp getLastUpdatedOn() {
return lastUpdatedOn;
}
public String getSortKey() {
return sortKey;
}
}

View File

@@ -0,0 +1,96 @@
// Copyright (C) 2008 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.common.data;
import com.google.gerrit.common.auth.SignInRequired;
import com.google.gerrit.reviewdb.Account;
import com.google.gerrit.reviewdb.Change;
import com.google.gerrit.reviewdb.Project;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwtjsonrpc.client.RemoteJsonService;
import com.google.gwtjsonrpc.client.VoidResult;
import java.util.Set;
public interface ChangeListService extends RemoteJsonService {
/** Get all open changes more recent than pos, fetching at most limit rows. */
void allOpenPrev(String pos, int limit,
AsyncCallback<SingleListChangeInfo> callback);
/** Get all open changes older than pos, fetching at most limit rows. */
void allOpenNext(String pos, int limit,
AsyncCallback<SingleListChangeInfo> callback);
/** Get all open changes more recent than pos, fetching at most limit rows. */
void byProjectOpenPrev(Project.NameKey project, String pos, int limit,
AsyncCallback<SingleListChangeInfo> callback);
/** Get all open changes older than pos, fetching at most limit rows. */
void byProjectOpenNext(Project.NameKey project, String pos, int limit,
AsyncCallback<SingleListChangeInfo> callback);
/**
* Get all closed changes with same status, more recent than pos, fetching at
* most limit rows.
*/
void byProjectClosedPrev(Project.NameKey project, Change.Status status,
String pos, int limit, AsyncCallback<SingleListChangeInfo> callback);
/**
* Get all closed changes with same status, older than pos, fetching at most
* limit rows.
*/
void byProjectClosedNext(Project.NameKey project, Change.Status status,
String pos, int limit, AsyncCallback<SingleListChangeInfo> callback);
/** Get all closed changes more recent than pos, fetching at most limit rows. */
void allClosedPrev(Change.Status status, String pos, int limit,
AsyncCallback<SingleListChangeInfo> callback);
/** Get all closed changes older than pos, fetching at most limit rows. */
void allClosedNext(Change.Status status, String pos, int limit,
AsyncCallback<SingleListChangeInfo> callback);
/** Get all changes which match an arbitrary query string. */
void allQueryPrev(String query, String pos, int limit,
AsyncCallback<SingleListChangeInfo> callback);
/** Get all changes which match an arbitrary query string. */
void allQueryNext(String query, String pos, int limit,
AsyncCallback<SingleListChangeInfo> callback);
/** Get the data to show AccountDashboardScreen for an account. */
void forAccount(Account.Id id, AsyncCallback<AccountDashboardInfo> callback);
/** Get the changes starred by the caller. */
@SignInRequired
void myStarredChanges(AsyncCallback<SingleListChangeInfo> callback);
/** Get the changes with unpublished drafts by the caller. */
@SignInRequired
void myDraftChanges(AsyncCallback<SingleListChangeInfo> callback);
/** Get the ids of all changes starred by the caller. */
@SignInRequired
void myStarredChangeIds(AsyncCallback<Set<Change.Id>> callback);
/**
* Add and/or remove changes from the set of starred changes of the caller.
*
* @param req the add and remove cluster.
*/
@SignInRequired
void toggleStars(ToggleStarRequest req, AsyncCallback<VoidResult> callback);
}

View File

@@ -0,0 +1,29 @@
// Copyright (C) 2009 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.common.data;
import com.google.gerrit.common.auth.SignInRequired;
import com.google.gerrit.reviewdb.PatchSet;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwtjsonrpc.client.RemoteJsonService;
public interface ChangeManageService extends RemoteJsonService {
@SignInRequired
void submit(PatchSet.Id patchSetId, AsyncCallback<ChangeDetail> callback);
@SignInRequired
void abandonChange(PatchSet.Id patchSetId, String message,
AsyncCallback<ChangeDetail> callback);
}

View File

@@ -0,0 +1,195 @@
// Copyright (C) 2009 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.common.data;
import com.google.gerrit.reviewdb.Patch;
import com.google.gerrit.reviewdb.PatchLineComment;
import com.google.gerrit.reviewdb.PatchSet;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class CommentDetail {
protected List<PatchLineComment> commentsA;
protected List<PatchLineComment> commentsB;
protected List<Patch> history;
protected AccountInfoCache accounts;
private transient PatchSet.Id idA;
private transient PatchSet.Id idB;
private transient Map<Integer, List<PatchLineComment>> forA;
private transient Map<Integer, List<PatchLineComment>> forB;
public CommentDetail(final PatchSet.Id a, final PatchSet.Id b) {
commentsA = new ArrayList<PatchLineComment>();
commentsB = new ArrayList<PatchLineComment>();
idA = a;
idB = b;
}
protected CommentDetail() {
}
public boolean include(final PatchLineComment p) {
final PatchSet.Id psId = p.getKey().getParentKey().getParentKey();
switch (p.getSide()) {
case 0:
if (idA == null && idB.equals(psId)) {
commentsA.add(p);
return true;
}
break;
case 1:
if (idA != null && idA.equals(psId)) {
commentsA.add(p);
return true;
}
if (idB.equals(psId)) {
commentsB.add(p);
return true;
}
break;
}
return false;
}
public void setAccountInfoCache(final AccountInfoCache a) {
accounts = a;
}
public void setHistory(final List<Patch> h) {
history = h;
}
public AccountInfoCache getAccounts() {
return accounts;
}
public List<Patch> getHistory() {
return history;
}
public List<PatchLineComment> getCommentsA() {
return commentsA;
}
public List<PatchLineComment> getCommentsB() {
return commentsB;
}
public boolean isEmpty() {
return commentsA.isEmpty() && commentsB.isEmpty();
}
public List<PatchLineComment> getForA(final int lineNbr) {
if (lineNbr == 0) {
return Collections.emptyList();
}
if (forA == null) {
forA = index(commentsA);
}
return get(forA, lineNbr);
}
public List<PatchLineComment> getForB(final int lineNbr) {
if (lineNbr == 0) {
return Collections.emptyList();
}
if (forB == null) {
forB = index(commentsB);
}
return get(forB, lineNbr);
}
private static List<PatchLineComment> get(
final Map<Integer, List<PatchLineComment>> m, final int i) {
final List<PatchLineComment> r = m.get(i);
return r != null ? orderComments(r) : Collections.<PatchLineComment> emptyList();
}
/**
* Order the comments based on their parent_uuid parent. It is possible to do this by
* iterating over the list only once but it's probably overkill since the number of comments
* on a given line will be small most of the time.
*
* @param comments The list of comments for a given line.
* @return The comments sorted as they should appear in the UI
*/
private static List<PatchLineComment> orderComments(List<PatchLineComment> comments) {
// Map of comments keyed by their parent. The values are lists of comments since it is
// possible for several comments to have the same parent (this can happen if two reviewers
// click Reply on the same comment at the same time). Such comments will be displayed under
// their correct parent in chronological order.
Map<String, List<PatchLineComment>> parentMap = new HashMap<String, List<PatchLineComment>>();
// It's possible to have more than one root comment if two reviewers create a comment on the
// same line at the same time
List<PatchLineComment> rootComments = new ArrayList<PatchLineComment>();
// Store all the comments in parentMap, keyed by their parent
for (PatchLineComment c : comments) {
String parentUuid = c.getParentUuid();
List<PatchLineComment> l = parentMap.get(parentUuid);
if (l == null) {
l = new ArrayList<PatchLineComment>();
parentMap.put(parentUuid, l);
}
l.add(c);
if (parentUuid == null) rootComments.add(c);
}
// Add the comments in the list, starting with the head and then going through all the
// comments that have it as a parent, and so on
List<PatchLineComment> result = new ArrayList<PatchLineComment>();
addChildren(parentMap, rootComments, result);
return result;
}
/**
* Add the comments to <code>outResult</code>, depth first
*/
private static void addChildren(Map<String, List<PatchLineComment>> parentMap,
List<PatchLineComment> children, List<PatchLineComment> outResult) {
if (children != null) {
for (PatchLineComment c : children) {
outResult.add(c);
addChildren(parentMap, parentMap.get(c.getKey().get()), outResult);
}
}
}
private Map<Integer, List<PatchLineComment>> index(
final List<PatchLineComment> in) {
final HashMap<Integer, List<PatchLineComment>> r;
r = new HashMap<Integer, List<PatchLineComment>>();
for (final PatchLineComment p : in) {
List<PatchLineComment> l = r.get(p.getLine());
if (l == null) {
l = new ArrayList<PatchLineComment>();
r.put(p.getLine(), l);
}
l.add(p);
}
return r;
}
}

View File

@@ -0,0 +1,169 @@
// Copyright (C) 2009 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.common.data;
import org.eclipse.jgit.diff.Edit;
import java.util.Iterator;
import java.util.List;
public class EditList {
private final List<Edit> edits;
private final int context;
private final int aSize;
private final int bSize;
public EditList(final List<Edit> edits, final int contextLines,
final int aSize, final int bSize) {
this.edits = edits;
this.context = contextLines;
this.aSize = aSize;
this.bSize = bSize;
}
public List<Edit> getEdits() {
return edits;
}
public Iterable<Hunk> getHunks() {
return new Iterable<Hunk>() {
public Iterator<Hunk> iterator() {
return new Iterator<Hunk>() {
private int curIdx;
public boolean hasNext() {
return curIdx < edits.size();
}
public Hunk next() {
final int c = curIdx;
final int e = findCombinedEnd(c);
curIdx = e + 1;
return new Hunk(c, e);
}
public void remove() {
throw new UnsupportedOperationException();
}
};
}
};
}
private int findCombinedEnd(final int i) {
int end = i + 1;
while (end < edits.size() && (combineA(end) || combineB(end)))
end++;
return end - 1;
}
private boolean combineA(final int i) {
final Edit s = edits.get(i);
final Edit e = edits.get(i - 1);
return s.getBeginA() - e.getEndA() <= 2 * context;
}
private boolean combineB(final int i) {
final int s = edits.get(i).getBeginB();
final int e = edits.get(i - 1).getEndB();
return s - e <= 2 * context;
}
public class Hunk {
private int curIdx;
private Edit curEdit;
private final int endIdx;
private final Edit endEdit;
private int aCur;
private int bCur;
private final int aEnd;
private final int bEnd;
private Hunk(final int ci, final int ei) {
curIdx = ci;
endIdx = ei;
curEdit = edits.get(curIdx);
endEdit = edits.get(endIdx);
aCur = Math.max(0, curEdit.getBeginA() - context);
bCur = Math.max(0, curEdit.getBeginB() - context);
aEnd = Math.min(aSize, endEdit.getEndA() + context);
bEnd = Math.min(bSize, endEdit.getEndB() + context);
}
public int getCurA() {
return aCur;
}
public int getCurB() {
return bCur;
}
public int getEndA() {
return aEnd;
}
public int getEndB() {
return bEnd;
}
public void incA() {
aCur++;
}
public void incB() {
bCur++;
}
public void incBoth() {
incA();
incB();
}
public boolean isStartOfFile() {
return aCur == 0 && bCur == 0;
}
public boolean isContextLine() {
return !isModifiedLine();
}
public boolean isDeletedA() {
return curEdit.getBeginA() <= aCur && aCur < curEdit.getEndA();
}
public boolean isInsertedB() {
return curEdit.getBeginB() <= bCur && bCur < curEdit.getEndB();
}
public boolean isModifiedLine() {
return isDeletedA() || isInsertedB();
}
public boolean next() {
if (!in(curEdit)) {
if (curIdx < endIdx) {
curEdit = edits.get(++curIdx);
}
}
return aCur < aEnd || bCur < bEnd;
}
private boolean in(final Edit edit) {
return aCur < edit.getEndA() || bCur < edit.getEndB();
}
}
}

View File

@@ -0,0 +1,142 @@
// Copyright (C) 2008 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.common.data;
import com.google.gerrit.reviewdb.Account;
import com.google.gerrit.reviewdb.AuthType;
import com.google.gerrit.reviewdb.Project;
import com.google.gwtexpui.safehtml.client.RegexFindReplace;
import java.util.List;
import java.util.Set;
public class GerritConfig implements Cloneable {
protected String canonicalUrl;
protected GitwebLink gitweb;
protected boolean useContributorAgreements;
protected boolean useContactInfo;
protected boolean allowRegisterNewEmail;
protected AuthType authType;
protected boolean useRepoDownload;
protected String gitDaemonUrl;
protected String sshdAddress;
protected Project.NameKey wildProject;
protected ApprovalTypes approvalTypes;
protected Set<Account.FieldName> editableAccountFields;
protected List<RegexFindReplace> commentLinks;
public String getCanonicalUrl() {
return canonicalUrl;
}
public void setCanonicalUrl(final String u) {
canonicalUrl = u;
}
public AuthType getAuthType() {
return authType;
}
public void setAuthType(final AuthType t) {
authType = t;
}
public GitwebLink getGitwebLink() {
return gitweb;
}
public void setGitwebLink(final GitwebLink w) {
gitweb = w;
}
public boolean isUseContributorAgreements() {
return useContributorAgreements;
}
public void setUseContributorAgreements(final boolean r) {
useContributorAgreements = r;
}
public boolean isUseContactInfo() {
return useContactInfo;
}
public void setUseContactInfo(final boolean r) {
useContactInfo = r;
}
public boolean isUseRepoDownload() {
return useRepoDownload;
}
public void setUseRepoDownload(final boolean r) {
useRepoDownload = r;
}
public String getGitDaemonUrl() {
return gitDaemonUrl;
}
public void setGitDaemonUrl(String url) {
if (url != null && !url.endsWith("/")) {
url += "/";
}
gitDaemonUrl = url;
}
public String getSshdAddress() {
return sshdAddress;
}
public void setSshdAddress(final String addr) {
sshdAddress = addr;
}
public Project.NameKey getWildProject() {
return wildProject;
}
public void setWildProject(final Project.NameKey wp) {
wildProject = wp;
}
public ApprovalTypes getApprovalTypes() {
return approvalTypes;
}
public void setApprovalTypes(final ApprovalTypes at) {
approvalTypes = at;
}
public boolean canEdit(final Account.FieldName f) {
return editableAccountFields.contains(f);
}
public Set<Account.FieldName> getEditableAccountFields() {
return editableAccountFields;
}
public void setEditableAccountFields(final Set<Account.FieldName> af) {
editableAccountFields = af;
}
public List<RegexFindReplace> getCommentLinks() {
return commentLinks;
}
public void setCommentLinks(final List<RegexFindReplace> cl) {
commentLinks = cl;
}
}

View File

@@ -0,0 +1,84 @@
// Copyright (C) 2008 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.common.data;
import com.google.gerrit.reviewdb.Branch;
import com.google.gerrit.reviewdb.PatchSet;
import com.google.gerrit.reviewdb.Project;
import com.google.gwt.http.client.URL;
/** Link to an external gitweb server. */
public class GitwebLink {
protected String baseUrl;
protected GitwebLink() {
}
public GitwebLink(final String base) {
baseUrl = base + "?";
}
public String toRevision(final Project.NameKey project, final PatchSet ps) {
final StringBuilder r = new StringBuilder();
p(r, project);
a(r, "commit");
h(r, ps);
return baseUrl + r;
}
public String toProject(final Project.NameKey project) {
final StringBuilder r = new StringBuilder();
p(r, project);
a(r, "summary");
return baseUrl + r;
}
public String toBranch(final Branch.NameKey branch) {
final StringBuilder r = new StringBuilder();
p(r, branch.getParentKey());
h(r, branch);
a(r, "shortlog");
return baseUrl + r;
}
private static void p(final StringBuilder r, final Project.NameKey project) {
String n = project.get();
if (!n.endsWith(".git")) {
n += ".git";
}
var(r, "p", n);
}
private static void h(final StringBuilder r, final PatchSet ps) {
var(r, "h", ps.getRevision().get());
}
private static void h(final StringBuilder r, final Branch.NameKey branch) {
var(r, "h", branch.get());
}
private static void a(final StringBuilder r, final String where) {
var(r, "a", where);
}
private static void var(final StringBuilder r, final String n, final String v) {
if (r.length() > 0) {
r.append(";");
}
r.append(n);
r.append("=");
r.append(URL.encodeComponent(v));
}
}

View File

@@ -0,0 +1,68 @@
// Copyright (C) 2008 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.common.data;
import com.google.gerrit.common.auth.SignInRequired;
import com.google.gerrit.reviewdb.AccountGroup;
import com.google.gerrit.reviewdb.AccountGroupMember;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwtjsonrpc.client.RemoteJsonService;
import com.google.gwtjsonrpc.client.VoidResult;
import java.util.List;
import java.util.Set;
public interface GroupAdminService extends RemoteJsonService {
@SignInRequired
void ownedGroups(AsyncCallback<List<AccountGroup>> callback);
@SignInRequired
void createGroup(String newName, AsyncCallback<AccountGroup.Id> callback);
@SignInRequired
void groupDetail(AccountGroup.Id groupId, AsyncCallback<GroupDetail> callback);
@SignInRequired
void changeGroupDescription(AccountGroup.Id groupId, String description,
AsyncCallback<VoidResult> callback);
@SignInRequired
void changeGroupOwner(AccountGroup.Id groupId, String newOwnerName,
AsyncCallback<VoidResult> callback);
@SignInRequired
void renameGroup(AccountGroup.Id groupId, String newName,
AsyncCallback<VoidResult> callback);
@SignInRequired
void changeGroupType(AccountGroup.Id groupId, AccountGroup.Type newType,
AsyncCallback<VoidResult> callback);
@SignInRequired
void changeExternalGroup(AccountGroup.Id groupId,
AccountGroup.ExternalNameKey bindTo, AsyncCallback<VoidResult> callback);
@SignInRequired
void searchExternalGroups(String searchFilter,
AsyncCallback<List<AccountGroup.ExternalNameKey>> callback);
@SignInRequired
void addGroupMember(AccountGroup.Id groupId, String nameOrEmail,
AsyncCallback<GroupDetail> callback);
@SignInRequired
void deleteGroupMembers(AccountGroup.Id groupId,
Set<AccountGroupMember.Key> keys, AsyncCallback<VoidResult> callback);
}

View File

@@ -0,0 +1,46 @@
// Copyright (C) 2008 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.common.data;
import com.google.gerrit.reviewdb.AccountGroup;
import com.google.gerrit.reviewdb.AccountGroupMember;
import java.util.List;
public class GroupDetail {
public AccountInfoCache accounts;
public AccountGroup group;
public List<AccountGroupMember> members;
public AccountGroup ownerGroup;
public GroupDetail() {
}
public void setAccounts(AccountInfoCache c) {
accounts = c;
}
public void setGroup(AccountGroup g) {
group = g;
}
public void setMembers(List<AccountGroupMember> m) {
members = m;
}
public void setOwnerGroup(AccountGroup g) {
ownerGroup = g;
}
}

View File

@@ -0,0 +1,23 @@
// Copyright (C) 2009 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.common.data;
import com.google.gerrit.reviewdb.Account;
/** Data sent as part of the host page, to bootstrap the UI. */
public class HostPageData {
public Account userAccount;
public GerritConfig config;
}

View File

@@ -0,0 +1,66 @@
// Copyright (C) 2008 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.common.data;
import com.google.gerrit.common.auth.SignInRequired;
import com.google.gerrit.reviewdb.Account;
import com.google.gerrit.reviewdb.ApprovalCategoryValue;
import com.google.gerrit.reviewdb.Change;
import com.google.gerrit.reviewdb.Patch;
import com.google.gerrit.reviewdb.PatchLineComment;
import com.google.gerrit.reviewdb.PatchSet;
import com.google.gerrit.reviewdb.Patch.Key;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwtjsonrpc.client.RemoteJsonService;
import com.google.gwtjsonrpc.client.VoidResult;
import java.util.List;
import java.util.Set;
public interface PatchDetailService extends RemoteJsonService {
void patchScript(Patch.Key key, PatchSet.Id a, PatchSet.Id b,
PatchScriptSettings settings, AsyncCallback<PatchScript> callback);
void patchComments(Patch.Key key, PatchSet.Id a, PatchSet.Id b,
AsyncCallback<CommentDetail> callback);
@SignInRequired
void saveDraft(PatchLineComment comment,
AsyncCallback<PatchLineComment> callback);
@SignInRequired
void deleteDraft(PatchLineComment.Key key, AsyncCallback<VoidResult> callback);
@SignInRequired
void publishComments(PatchSet.Id psid, String message,
Set<ApprovalCategoryValue.Id> approvals,
AsyncCallback<VoidResult> callback);
@SignInRequired
void addReviewers(Change.Id id, List<String> reviewers,
AsyncCallback<AddReviewerResult> callback);
void userApprovals(Set<Change.Id> cids, Account.Id aid,
AsyncCallback<ApprovalSummarySet> callback);
void strongestApprovals(Set<Change.Id> cids,
AsyncCallback<ApprovalSummarySet> callback);
/**
* Update the reviewed status for the patch.
*/
@SignInRequired
void setReviewedByCurrentUser(Key patchKey, boolean reviewed, AsyncCallback<VoidResult> callback);
}

View File

@@ -0,0 +1,96 @@
// Copyright (C) 2009 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.common.data;
import com.google.gerrit.common.data.PatchScriptSettings.Whitespace;
import com.google.gerrit.reviewdb.Change;
import org.eclipse.jgit.diff.Edit;
import java.util.List;
public class PatchScript {
public static enum DisplayMethod {
NONE, DIFF, IMG
}
protected Change.Key changeId;
protected List<String> header;
protected PatchScriptSettings settings;
protected SparseFileContent a;
protected SparseFileContent b;
protected List<Edit> edits;
protected DisplayMethod displayMethodA;
protected DisplayMethod displayMethodB;
public PatchScript(final Change.Key ck, final List<String> h,
final PatchScriptSettings s, final SparseFileContent ca,
final SparseFileContent cb, final List<Edit> e, final DisplayMethod ma,
final DisplayMethod mb) {
changeId = ck;
header = h;
settings = s;
a = ca;
b = cb;
edits = e;
displayMethodA = ma;
displayMethodB = mb;
}
protected PatchScript() {
}
public Change.Key getChangeId() {
return changeId;
}
public DisplayMethod getDisplayMethodA() {
return displayMethodA;
}
public DisplayMethod getDisplayMethodB() {
return displayMethodB;
}
public List<String> getPatchHeader() {
return header;
}
public int getContext() {
return settings.getContext();
}
public boolean isIgnoreWhitespace() {
return settings.getWhitespace() != Whitespace.IGNORE_NONE;
}
public SparseFileContent getA() {
return a;
}
public SparseFileContent getB() {
return b;
}
public List<Edit> getEdits() {
return edits;
}
public Iterable<EditList.Hunk> getHunks() {
return new EditList(edits, getContext(), a.size(), b.size()).getHunks();
}
}

View File

@@ -0,0 +1,68 @@
// Copyright (C) 2009 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.common.data;
import com.google.gerrit.reviewdb.AccountGeneralPreferences;
import com.google.gerrit.reviewdb.CodedEnum;
public class PatchScriptSettings {
public static enum Whitespace implements CodedEnum {
IGNORE_NONE('N'), //
IGNORE_SPACE_AT_EOL('E'), //
IGNORE_SPACE_CHANGE('S'), //
IGNORE_ALL_SPACE('A');
private final char code;
private Whitespace(final char c) {
code = c;
}
public char getCode() {
return code;
}
}
protected int context;
protected Whitespace whitespace;
public PatchScriptSettings() {
context = AccountGeneralPreferences.DEFAULT_CONTEXT;
whitespace = Whitespace.IGNORE_NONE;
}
public PatchScriptSettings(final PatchScriptSettings s) {
context = s.context;
whitespace = s.whitespace;
}
public int getContext() {
return context;
}
public void setContext(final int ctx) {
assert 0 <= ctx || ctx == AccountGeneralPreferences.WHOLE_FILE_CONTEXT;
context = ctx;
}
public Whitespace getWhitespace() {
return whitespace;
}
public void setWhitespace(final Whitespace ws) {
assert ws != null;
whitespace = ws;
}
}

View File

@@ -0,0 +1,54 @@
// Copyright (C) 2008 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.common.data;
import com.google.gerrit.reviewdb.Patch;
import com.google.gerrit.reviewdb.PatchSet;
import com.google.gerrit.reviewdb.PatchSetInfo;
import java.util.List;
public class PatchSetDetail {
protected PatchSet patchSet;
protected PatchSetInfo info;
protected List<Patch> patches;
public PatchSetDetail() {
}
public PatchSet getPatchSet() {
return patchSet;
}
public void setPatchSet(final PatchSet ps) {
patchSet = ps;
}
public PatchSetInfo getInfo() {
return info;
}
public void setInfo(final PatchSetInfo i) {
info = i;
}
public List<Patch> getPatches() {
return patches;
}
public void setPatches(final List<Patch> p) {
patches = p;
}
}

View File

@@ -0,0 +1,97 @@
// Copyright (C) 2009 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.common.data;
import com.google.gerrit.reviewdb.ApprovalCategory;
import com.google.gerrit.reviewdb.ApprovalCategoryValue;
import com.google.gerrit.reviewdb.Change;
import com.google.gerrit.reviewdb.PatchLineComment;
import com.google.gerrit.reviewdb.PatchSetApproval;
import com.google.gerrit.reviewdb.PatchSetInfo;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class PatchSetPublishDetail {
protected AccountInfoCache accounts;
protected PatchSetInfo patchSetInfo;
protected Change change;
protected List<PatchLineComment> drafts;
protected Map<ApprovalCategory.Id, Set<ApprovalCategoryValue.Id>> allowed;
protected Map<ApprovalCategory.Id, PatchSetApproval> given;
public Map<ApprovalCategory.Id, Set<ApprovalCategoryValue.Id>> getAllowed() {
return allowed;
}
public void setAllowed(
Map<ApprovalCategory.Id, Set<ApprovalCategoryValue.Id>> allowed) {
this.allowed = allowed;
}
public Map<ApprovalCategory.Id, PatchSetApproval> getGiven() {
return given;
}
public void setGiven(Map<ApprovalCategory.Id, PatchSetApproval> given) {
this.given = given;
}
public void setAccounts(AccountInfoCache accounts) {
this.accounts = accounts;
}
public void setPatchSetInfo(PatchSetInfo patchSetInfo) {
this.patchSetInfo = patchSetInfo;
}
public void setChange(Change change) {
this.change = change;
}
public void setDrafts(List<PatchLineComment> drafts) {
this.drafts = drafts;
}
public AccountInfoCache getAccounts() {
return accounts;
}
public Change getChange() {
return change;
}
public PatchSetInfo getPatchSetInfo() {
return patchSetInfo;
}
public List<PatchLineComment> getDrafts() {
return drafts;
}
public boolean isAllowed(final ApprovalCategory.Id id) {
final Set<ApprovalCategoryValue.Id> s = getAllowed(id);
return s != null && !s.isEmpty();
}
public Set<ApprovalCategoryValue.Id> getAllowed(final ApprovalCategory.Id id) {
return allowed.get(id);
}
public PatchSetApproval getChangeApproval(final ApprovalCategory.Id id) {
return given.get(id);
}
}

View File

@@ -0,0 +1,61 @@
// Copyright (C) 2008 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.common.data;
import com.google.gerrit.common.auth.SignInRequired;
import com.google.gerrit.reviewdb.ApprovalCategory;
import com.google.gerrit.reviewdb.Branch;
import com.google.gerrit.reviewdb.Project;
import com.google.gerrit.reviewdb.ProjectRight;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwtjsonrpc.client.RemoteJsonService;
import com.google.gwtjsonrpc.client.VoidResult;
import java.util.List;
import java.util.Set;
public interface ProjectAdminService extends RemoteJsonService {
@SignInRequired
void ownedProjects(AsyncCallback<List<Project>> callback);
@SignInRequired
void projectDetail(Project.NameKey projectName,
AsyncCallback<ProjectDetail> callback);
@SignInRequired
void changeProjectSettings(Project update,
AsyncCallback<ProjectDetail> callback);
@SignInRequired
void deleteRight(Project.NameKey projectName, Set<ProjectRight.Key> ids,
AsyncCallback<VoidResult> callback);
@SignInRequired
void addRight(Project.NameKey projectName, ApprovalCategory.Id categoryId,
String groupName, short min, short max,
AsyncCallback<ProjectDetail> callback);
@SignInRequired
void listBranches(Project.NameKey projectName,
AsyncCallback<List<Branch>> callback);
@SignInRequired
void addBranch(Project.NameKey projectName, String branchName,
String startingRevision, AsyncCallback<List<Branch>> callback);
@SignInRequired
void deleteBranch(Project.NameKey projectName, Set<Branch.NameKey> ids,
AsyncCallback<Set<Branch.NameKey>> callback);
}

View File

@@ -0,0 +1,43 @@
// Copyright (C) 2008 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.common.data;
import com.google.gerrit.reviewdb.AccountGroup;
import com.google.gerrit.reviewdb.Project;
import com.google.gerrit.reviewdb.ProjectRight;
import java.util.List;
import java.util.Map;
public class ProjectDetail {
public Project project;
public Map<AccountGroup.Id, AccountGroup> groups;
public List<ProjectRight> rights;
public ProjectDetail() {
}
public void setProject(final Project p) {
project = p;
}
public void setGroups(final Map<AccountGroup.Id, AccountGroup> g) {
groups = g;
}
public void setRights(final List<ProjectRight> r) {
rights = r;
}
}

View File

@@ -0,0 +1,36 @@
// Copyright (C) 2008 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.common.data;
import com.google.gerrit.reviewdb.Project;
public class ProjectInfo {
protected Project.NameKey key;
protected ProjectInfo() {
}
public ProjectInfo(final Project.NameKey key) {
this.key = key;
}
public Project.NameKey getKey() {
return key;
}
public String getName() {
return key.get();
}
}

View File

@@ -0,0 +1,52 @@
// Copyright (C) 2008 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.common.data;
import java.util.List;
/** Summary information needed for screens showing a single list of changes}. */
public class SingleListChangeInfo {
protected AccountInfoCache accounts;
protected List<ChangeInfo> changes;
protected boolean atEnd;
public SingleListChangeInfo() {
}
public AccountInfoCache getAccounts() {
return accounts;
}
public void setAccounts(final AccountInfoCache ac) {
accounts = ac;
}
public List<ChangeInfo> getChanges() {
return changes;
}
public boolean isAtEnd() {
return atEnd;
}
public void setChanges(List<ChangeInfo> c) {
setChanges(c, true);
}
public void setChanges(List<ChangeInfo> c, boolean end) {
changes = c;
atEnd = end;
}
}

View File

@@ -0,0 +1,153 @@
// Copyright (C) 2009 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.common.data;
import java.util.ArrayList;
import java.util.List;
public class SparseFileContent {
protected List<Range> ranges;
protected int size;
protected boolean missingNewlineAtEnd;
private transient int currentRangeIdx;
public SparseFileContent() {
ranges = new ArrayList<Range>();
}
public int size() {
return size;
}
public void setSize(final int s) {
size = s;
}
public boolean isMissingNewlineAtEnd() {
return missingNewlineAtEnd;
}
public void setMissingNewlineAtEnd(final boolean missing) {
missingNewlineAtEnd = missing;
}
public String get(final int idx) {
final String line = getLine(idx);
if (line == null) {
throw new ArrayIndexOutOfBoundsException(idx);
}
return line;
}
public boolean contains(final int idx) {
return getLine(idx) != null;
}
private String getLine(final int idx) {
// Most requests are sequential in nature, fetching the next
// line from the current range, or the next range.
//
int high = ranges.size();
if (currentRangeIdx < high) {
Range cur = ranges.get(currentRangeIdx);
if (cur.contains(idx)) {
return cur.get(idx);
}
if (++currentRangeIdx < high) {
final Range next = ranges.get(currentRangeIdx);
if (next.contains(idx)) {
return next.get(idx);
}
}
}
// Binary search for the range, since we know its a sorted list.
//
int low = 0;
do {
final int mid = (low + high) / 2;
final Range cur = ranges.get(mid);
if (cur.contains(idx)) {
currentRangeIdx = mid;
return cur.get(idx);
}
if (idx < cur.base)
high = mid;
else
low = mid + 1;
} while (low < high);
return null;
}
public void addLine(final int i, final String content) {
final Range r;
if (!ranges.isEmpty() && i == last().end()) {
r = last();
} else {
r = new Range(i);
ranges.add(r);
}
r.lines.add(content);
}
private Range last() {
return ranges.get(ranges.size() - 1);
}
@Override
public String toString() {
final StringBuilder b = new StringBuilder();
b.append("SparseFileContent[\n");
for (Range r : ranges) {
b.append(" ");
b.append(r.toString());
b.append('\n');
}
b.append("]");
return b.toString();
}
static class Range {
protected int base;
protected List<String> lines;
private Range(final int b) {
base = b;
lines = new ArrayList<String>();
}
protected Range() {
}
private String get(final int i) {
return lines.get(i - base);
}
private int end() {
return base + lines.size();
}
private boolean contains(final int i) {
return base <= i && i < end();
}
@Override
public String toString() {
return "Range[" + base + "," + end() + ")";
}
}
}

View File

@@ -0,0 +1,46 @@
// Copyright (C) 2009 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.common.data;
/** Description of the SSH daemon host key used by Gerrit. */
public class SshHostKey {
protected String hostIdent;
protected String hostKey;
protected String fingerprint;
protected SshHostKey() {
}
public SshHostKey(final String hi, final String hk, final String fp) {
hostIdent = hi;
hostKey = hk;
fingerprint = fp;
}
/** @return host name string, to appear in a known_hosts file. */
public String getHostIdent() {
return hostIdent;
}
/** @return base 64 encoded host key string, starting with key type. */
public String getHostKey() {
return hostKey;
}
/** @return the key fingerprint, as displayed by a connecting client. */
public String getFingerprint() {
return fingerprint;
}
}

View File

@@ -0,0 +1,33 @@
// Copyright (C) 2008 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.common.data;
import com.google.gerrit.reviewdb.AccountGroup;
import com.google.gerrit.reviewdb.Project;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwtjsonrpc.client.RemoteJsonService;
import java.util.List;
public interface SuggestService extends RemoteJsonService {
void suggestProjectNameKey(String query, int limit,
AsyncCallback<List<Project.NameKey>> callback);
void suggestAccount(String query, int limit,
AsyncCallback<List<AccountInfo>> callback);
void suggestAccountGroup(String query, int limit,
AsyncCallback<List<AccountGroup>> callback);
}

View File

@@ -0,0 +1,31 @@
// Copyright (C) 2008 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.common.data;
import com.google.gerrit.common.auth.SignInRequired;
import com.google.gerrit.reviewdb.ContributorAgreement;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwtjsonrpc.client.AllowCrossSiteRequest;
import com.google.gwtjsonrpc.client.RemoteJsonService;
import java.util.List;
public interface SystemInfoService extends RemoteJsonService {
@AllowCrossSiteRequest
void daemonHostKeys(AsyncCallback<List<SshHostKey>> callback);
@SignInRequired
void contributorAgreements(AsyncCallback<List<ContributorAgreement>> callback);
}

View File

@@ -0,0 +1,63 @@
// Copyright (C) 2008 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.common.data;
import com.google.gerrit.reviewdb.Change;
import java.util.HashSet;
import java.util.Set;
/** Request parameters to update the changes the user has toggled. */
public class ToggleStarRequest {
protected Set<Change.Id> add;
protected Set<Change.Id> remove;
/**
* Request an update to the change's star status.
*
* @param id unique id of the change, must not be null.
* @param on true if the change should now be starred; false if it should now
* be not starred.
*/
public void toggle(final Change.Id id, final boolean on) {
if (on) {
if (add == null) {
add = new HashSet<Change.Id>();
}
add.add(id);
if (remove != null) {
remove.remove(id);
}
} else {
if (remove == null) {
remove = new HashSet<Change.Id>();
}
remove.add(id);
if (add != null) {
add.remove(id);
}
}
}
/** Get the set of changes which should have stars added; may be null. */
public Set<Change.Id> getAddSet() {
return add;
}
/** Get the set of changes which should have stars removed; may be null. */
public Set<Change.Id> getRemoveSet() {
return remove;
}
}

View File

@@ -0,0 +1,30 @@
// Copyright (C) 2009 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.common.errors;
/** Error indicating the server cannot store contact information. */
public class ContactInformationStoreException extends Exception {
private static final long serialVersionUID = 1L;
public static final String MESSAGE = "Cannot store contact information";
public ContactInformationStoreException() {
super(MESSAGE);
}
public ContactInformationStoreException(final Throwable why) {
super(MESSAGE, why);
}
}

View File

@@ -0,0 +1,28 @@
// Copyright (C) 2008 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.common.errors;
import com.google.gwtorm.client.Key;
/** Error indicating the entity's database records are invalid. */
public class CorruptEntityException extends Exception {
private static final long serialVersionUID = 1L;
public static final String MESSAGE_PREFIX = "Corrupt Database Entity: ";
public CorruptEntityException(final Key<?> key) {
super(MESSAGE_PREFIX + key);
}
}

View File

@@ -0,0 +1,26 @@
// Copyright (C) 2009 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.common.errors;
/** Error indicating the entity name is invalid as supplied. */
public class InvalidNameException extends Exception {
private static final long serialVersionUID = 1L;
public static final String MESSAGE = "Invalid Name";
public InvalidNameException() {
super(MESSAGE);
}
}

View File

@@ -0,0 +1,26 @@
// Copyright (C) 2009 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.common.errors;
/** Error indicating the revision is invalid as supplied. */
public class InvalidRevisionException extends Exception {
private static final long serialVersionUID = 1L;
public static final String MESSAGE = "Invalid Revision";
public InvalidRevisionException() {
super(MESSAGE);
}
}

View File

@@ -0,0 +1,26 @@
// Copyright (C) 2009 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.common.errors;
/** Error indicating the SSH key string is invalid as supplied. */
public class InvalidSshKeyException extends Exception {
private static final long serialVersionUID = 1L;
public static final String MESSAGE = "Invalid SSH Key";
public InvalidSshKeyException() {
super(MESSAGE);
}
}

View File

@@ -0,0 +1,30 @@
// Copyright (C) 2009 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.common.errors;
import com.google.gerrit.reviewdb.Account;
/** Error indicating the SSH user name does not match {@link Account#SSH_USER_NAME_PATTERN} pattern. */
public class InvalidSshUserNameException extends Exception {
private static final long serialVersionUID = 1L;
public static final String MESSAGE = "Invalid SSH user name.";
public InvalidSshUserNameException() {
super(MESSAGE);
}
}

View File

@@ -0,0 +1,26 @@
// Copyright (C) 2008 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.common.errors;
/** Error indicating entity name is already taken by another entity. */
public class NameAlreadyUsedException extends Exception {
private static final long serialVersionUID = 1L;
public static final String MESSAGE = "Name Already Used";
public NameAlreadyUsedException() {
super(MESSAGE);
}
}

View File

@@ -0,0 +1,26 @@
// Copyright (C) 2009 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.common.errors;
/** Error indicating the account requested doesn't exist. */
public class NoSuchAccountException extends Exception {
private static final long serialVersionUID = 1L;
public static final String MESSAGE = "Not Found: ";
public NoSuchAccountException(String who) {
super(MESSAGE + who);
}
}

View File

@@ -0,0 +1,26 @@
// Copyright (C) 2008 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.common.errors;
/** Error indicating the entity requested doesn't exist. */
public class NoSuchEntityException extends Exception {
private static final long serialVersionUID = 1L;
public static final String MESSAGE = "Not Found";
public NoSuchEntityException() {
super(MESSAGE);
}
}

View File

@@ -0,0 +1,26 @@
// Copyright (C) 2008 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.common.errors;
/** Error stating the user must be signed-in in order to perform this action. */
public class NotSignedInException extends Exception {
private static final long serialVersionUID = 1L;
public static final String MESSAGE = "Not Signed In";
public NotSignedInException() {
super(MESSAGE);
}
}