Rename OrmException to StorageException and move to exceptions package
Subclasses are also renamed: * OrmDuplicateKeyException -> DuplicateKeyException * OrmRuntimeException -> StorageRuntimeException Change-Id: I0e934f177e98667ec7cb9912f246ac649a4efd99
This commit is contained in:
@@ -22,6 +22,7 @@ import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Table;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.client.ChangeKind;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
@@ -32,7 +33,6 @@ import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.project.ProjectState;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -74,7 +74,7 @@ public class ApprovalCopier {
|
||||
|
||||
Iterable<PatchSetApproval> getForPatchSet(
|
||||
ChangeNotes notes, PatchSet.Id psId, @Nullable RevWalk rw, @Nullable Config repoConfig)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
return getForPatchSet(notes, psId, rw, repoConfig, Collections.emptyList());
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public class ApprovalCopier {
|
||||
@Nullable RevWalk rw,
|
||||
@Nullable Config repoConfig,
|
||||
Iterable<PatchSetApproval> dontCopy)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
PatchSet ps = psUtil.get(notes, psId);
|
||||
if (ps == null) {
|
||||
return Collections.emptyList();
|
||||
@@ -98,7 +98,7 @@ public class ApprovalCopier {
|
||||
@Nullable RevWalk rw,
|
||||
@Nullable Config repoConfig,
|
||||
Iterable<PatchSetApproval> dontCopy)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
requireNonNull(ps, "ps should not be null");
|
||||
ChangeData cd = changeDataFactory.create(notes);
|
||||
try {
|
||||
@@ -153,11 +153,11 @@ public class ApprovalCopier {
|
||||
}
|
||||
return labelNormalizer.normalize(notes, byUser.values()).getNormalized();
|
||||
} catch (IOException e) {
|
||||
throw new OrmException(e);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static TreeMap<Integer, PatchSet> getPatchSets(ChangeData cd) throws OrmException {
|
||||
private static TreeMap<Integer, PatchSet> getPatchSets(ChangeData cd) throws StorageException {
|
||||
Collection<PatchSet> patchSets = cd.patchSets();
|
||||
TreeMap<Integer, PatchSet> result = new TreeMap<>();
|
||||
for (PatchSet ps : patchSets) {
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.google.common.primitives.Shorts;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
@@ -47,7 +48,6 @@ import com.google.gerrit.server.permissions.PermissionBackend;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.util.LabelVote;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -112,9 +112,9 @@ public class ApprovalsUtil {
|
||||
*
|
||||
* @param notes change notes.
|
||||
* @return reviewers for the change.
|
||||
* @throws OrmException if reviewers for the change could not be read.
|
||||
* @throws StorageException if reviewers for the change could not be read.
|
||||
*/
|
||||
public ReviewerSet getReviewers(ChangeNotes notes) throws OrmException {
|
||||
public ReviewerSet getReviewers(ChangeNotes notes) throws StorageException {
|
||||
return notes.load().getReviewers();
|
||||
}
|
||||
|
||||
@@ -123,10 +123,10 @@ public class ApprovalsUtil {
|
||||
*
|
||||
* @param allApprovals all approvals to consider; must all belong to the same change.
|
||||
* @return reviewers for the change.
|
||||
* @throws OrmException if reviewers for the change could not be read.
|
||||
* @throws StorageException if reviewers for the change could not be read.
|
||||
*/
|
||||
public ReviewerSet getReviewers(ChangeNotes notes, Iterable<PatchSetApproval> allApprovals)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
return notes.load().getReviewers();
|
||||
}
|
||||
|
||||
@@ -135,9 +135,9 @@ public class ApprovalsUtil {
|
||||
*
|
||||
* @param notes change notes.
|
||||
* @return reviewer updates for the change.
|
||||
* @throws OrmException if reviewer updates for the change could not be read.
|
||||
* @throws StorageException if reviewer updates for the change could not be read.
|
||||
*/
|
||||
public List<ReviewerStatusUpdate> getReviewerUpdates(ChangeNotes notes) throws OrmException {
|
||||
public List<ReviewerStatusUpdate> getReviewerUpdates(ChangeNotes notes) throws StorageException {
|
||||
return notes.load().getReviewerUpdates();
|
||||
}
|
||||
|
||||
@@ -166,7 +166,7 @@ public class ApprovalsUtil {
|
||||
LabelTypes labelTypes,
|
||||
Change change,
|
||||
Iterable<Account.Id> wantReviewers)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
PatchSet.Id psId = change.currentPatchSetId();
|
||||
Collection<Account.Id> existingReviewers;
|
||||
existingReviewers = notes.load().getReviewers().byState(REVIEWER);
|
||||
@@ -245,10 +245,11 @@ public class ApprovalsUtil {
|
||||
* @param update change update.
|
||||
* @param wantCCs accounts to CC.
|
||||
* @return whether a change was made.
|
||||
* @throws OrmException
|
||||
* @throws StorageException
|
||||
*/
|
||||
public Collection<Account.Id> addCcs(
|
||||
ChangeNotes notes, ChangeUpdate update, Collection<Account.Id> wantCCs) throws OrmException {
|
||||
ChangeNotes notes, ChangeUpdate update, Collection<Account.Id> wantCCs)
|
||||
throws StorageException {
|
||||
return addCcs(update, wantCCs, notes.load().getReviewers());
|
||||
}
|
||||
|
||||
@@ -272,7 +273,7 @@ public class ApprovalsUtil {
|
||||
* @param user user adding approvals.
|
||||
* @param approvals approvals to add.
|
||||
* @throws RestApiException
|
||||
* @throws OrmException
|
||||
* @throws StorageException
|
||||
*/
|
||||
public Iterable<PatchSetApproval> addApprovalsForNewPatchSet(
|
||||
ChangeUpdate update,
|
||||
@@ -280,7 +281,7 @@ public class ApprovalsUtil {
|
||||
PatchSet ps,
|
||||
CurrentUser user,
|
||||
Map<String, Short> approvals)
|
||||
throws RestApiException, OrmException, PermissionBackendException {
|
||||
throws RestApiException, StorageException, PermissionBackendException {
|
||||
Account.Id accountId = user.getAccountId();
|
||||
checkArgument(
|
||||
accountId.equals(ps.getUploader()),
|
||||
@@ -331,13 +332,13 @@ public class ApprovalsUtil {
|
||||
}
|
||||
|
||||
public ListMultimap<PatchSet.Id, PatchSetApproval> byChange(ChangeNotes notes)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
return notes.load().getApprovals();
|
||||
}
|
||||
|
||||
public Iterable<PatchSetApproval> byPatchSet(
|
||||
ChangeNotes notes, PatchSet.Id psId, @Nullable RevWalk rw, @Nullable Config repoConfig)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
return copier.getForPatchSet(notes, psId, rw, repoConfig);
|
||||
}
|
||||
|
||||
@@ -347,7 +348,7 @@ public class ApprovalsUtil {
|
||||
Account.Id accountId,
|
||||
@Nullable RevWalk rw,
|
||||
@Nullable Config repoConfig)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
return filterApprovals(byPatchSet(notes, psId, rw, repoConfig), accountId);
|
||||
}
|
||||
|
||||
@@ -358,7 +359,7 @@ public class ApprovalsUtil {
|
||||
try {
|
||||
// Submit approval is never copied, so bypass expensive byPatchSet call.
|
||||
return getSubmitter(c, byChange(notes).get(c));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import static com.google.common.base.Preconditions.checkState;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.common.ChangeMessageInfo;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
||||
@@ -26,7 +27,6 @@ import com.google.gerrit.server.account.AccountLoader;
|
||||
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Singleton;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
@@ -87,7 +87,7 @@ public class ChangeMessagesUtil {
|
||||
return workInProgress ? TAG_UPLOADED_WIP_PATCH_SET : TAG_UPLOADED_PATCH_SET;
|
||||
}
|
||||
|
||||
public List<ChangeMessage> byChange(ChangeNotes notes) throws OrmException {
|
||||
public List<ChangeMessage> byChange(ChangeNotes notes) throws StorageException {
|
||||
return notes.load().getChangeMessages();
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.client.Side;
|
||||
import com.google.gerrit.extensions.common.CommentInfo;
|
||||
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||
@@ -42,7 +43,6 @@ import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||
import com.google.gerrit.server.patch.PatchListCache;
|
||||
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -124,7 +124,7 @@ public class CommentsUtil {
|
||||
String message,
|
||||
@Nullable Boolean unresolved,
|
||||
@Nullable String parentUuid)
|
||||
throws OrmException, UnprocessableEntityException {
|
||||
throws StorageException, UnprocessableEntityException {
|
||||
if (unresolved == null) {
|
||||
if (parentUuid == null) {
|
||||
// Default to false if comment is not descended from another.
|
||||
@@ -175,28 +175,29 @@ public class CommentsUtil {
|
||||
return c;
|
||||
}
|
||||
|
||||
public Optional<Comment> getPublished(ChangeNotes notes, Comment.Key key) throws OrmException {
|
||||
public Optional<Comment> getPublished(ChangeNotes notes, Comment.Key key)
|
||||
throws StorageException {
|
||||
return publishedByChange(notes).stream().filter(c -> key.equals(c.key)).findFirst();
|
||||
}
|
||||
|
||||
public Optional<Comment> getDraft(ChangeNotes notes, IdentifiedUser user, Comment.Key key)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
return draftByChangeAuthor(notes, user.getAccountId()).stream()
|
||||
.filter(c -> key.equals(c.key))
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
public List<Comment> publishedByChange(ChangeNotes notes) throws OrmException {
|
||||
public List<Comment> publishedByChange(ChangeNotes notes) throws StorageException {
|
||||
notes.load();
|
||||
return sort(Lists.newArrayList(notes.getComments().values()));
|
||||
}
|
||||
|
||||
public List<RobotComment> robotCommentsByChange(ChangeNotes notes) throws OrmException {
|
||||
public List<RobotComment> robotCommentsByChange(ChangeNotes notes) throws StorageException {
|
||||
notes.load();
|
||||
return sort(Lists.newArrayList(notes.getRobotComments().values()));
|
||||
}
|
||||
|
||||
public List<Comment> draftByChange(ChangeNotes notes) throws OrmException {
|
||||
public List<Comment> draftByChange(ChangeNotes notes) throws StorageException {
|
||||
List<Comment> comments = new ArrayList<>();
|
||||
for (Ref ref : getDraftRefs(notes.getChangeId())) {
|
||||
Account.Id account = Account.Id.fromRefSuffix(ref.getName());
|
||||
@@ -207,7 +208,7 @@ public class CommentsUtil {
|
||||
return sort(comments);
|
||||
}
|
||||
|
||||
public List<Comment> byPatchSet(ChangeNotes notes, PatchSet.Id psId) throws OrmException {
|
||||
public List<Comment> byPatchSet(ChangeNotes notes, PatchSet.Id psId) throws StorageException {
|
||||
List<Comment> comments = new ArrayList<>();
|
||||
comments.addAll(publishedByPatchSet(notes, psId));
|
||||
|
||||
@@ -220,18 +221,19 @@ public class CommentsUtil {
|
||||
return sort(comments);
|
||||
}
|
||||
|
||||
public List<Comment> publishedByChangeFile(ChangeNotes notes, String file) throws OrmException {
|
||||
public List<Comment> publishedByChangeFile(ChangeNotes notes, String file)
|
||||
throws StorageException {
|
||||
return commentsOnFile(notes.load().getComments().values(), file);
|
||||
}
|
||||
|
||||
public List<Comment> publishedByPatchSet(ChangeNotes notes, PatchSet.Id psId)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
return removeCommentsOnAncestorOfCommitMessage(
|
||||
commentsOnPatchSet(notes.load().getComments().values(), psId));
|
||||
}
|
||||
|
||||
public List<RobotComment> robotCommentsByPatchSet(ChangeNotes notes, PatchSet.Id psId)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
return commentsOnPatchSet(notes.load().getRobotComments().values(), psId);
|
||||
}
|
||||
|
||||
@@ -249,17 +251,17 @@ public class CommentsUtil {
|
||||
}
|
||||
|
||||
public List<Comment> draftByPatchSetAuthor(PatchSet.Id psId, Account.Id author, ChangeNotes notes)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
return commentsOnPatchSet(notes.load().getDraftComments(author).values(), psId);
|
||||
}
|
||||
|
||||
public List<Comment> draftByChangeFileAuthor(ChangeNotes notes, String file, Account.Id author)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
return commentsOnFile(notes.load().getDraftComments(author).values(), file);
|
||||
}
|
||||
|
||||
public List<Comment> draftByChangeAuthor(ChangeNotes notes, Account.Id author)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
List<Comment> comments = new ArrayList<>();
|
||||
comments.addAll(notes.getDraftComments(author).values());
|
||||
return sort(comments);
|
||||
@@ -343,11 +345,11 @@ public class CommentsUtil {
|
||||
* @param changeId change ID.
|
||||
* @return raw refs from All-Users repo.
|
||||
*/
|
||||
public Collection<Ref> getDraftRefs(Change.Id changeId) throws OrmException {
|
||||
public Collection<Ref> getDraftRefs(Change.Id changeId) throws StorageException {
|
||||
try (Repository repo = repoManager.openRepository(allUsers)) {
|
||||
return getDraftRefs(repo, changeId);
|
||||
} catch (IOException e) {
|
||||
throw new OrmException(e);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.gerrit.common.data.LabelFunction;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
@@ -33,7 +34,6 @@ import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.project.ProjectState;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -63,24 +63,25 @@ public class PatchSetUtil {
|
||||
this.repoManager = repoManager;
|
||||
}
|
||||
|
||||
public PatchSet current(ChangeNotes notes) throws OrmException {
|
||||
public PatchSet current(ChangeNotes notes) throws StorageException {
|
||||
return get(notes, notes.getChange().currentPatchSetId());
|
||||
}
|
||||
|
||||
public PatchSet get(ChangeNotes notes, PatchSet.Id psId) throws OrmException {
|
||||
public PatchSet get(ChangeNotes notes, PatchSet.Id psId) throws StorageException {
|
||||
return notes.load().getPatchSets().get(psId);
|
||||
}
|
||||
|
||||
public ImmutableCollection<PatchSet> byChange(ChangeNotes notes) throws OrmException {
|
||||
public ImmutableCollection<PatchSet> byChange(ChangeNotes notes) throws StorageException {
|
||||
return notes.load().getPatchSets().values();
|
||||
}
|
||||
|
||||
public ImmutableMap<PatchSet.Id, PatchSet> byChangeAsMap(ChangeNotes notes) throws OrmException {
|
||||
public ImmutableMap<PatchSet.Id, PatchSet> byChangeAsMap(ChangeNotes notes)
|
||||
throws StorageException {
|
||||
return notes.load().getPatchSets();
|
||||
}
|
||||
|
||||
public ImmutableMap<PatchSet.Id, PatchSet> getAsMap(
|
||||
ChangeNotes notes, Set<PatchSet.Id> patchSetIds) throws OrmException {
|
||||
ChangeNotes notes, Set<PatchSet.Id> patchSetIds) throws StorageException {
|
||||
return ImmutableMap.copyOf(Maps.filterKeys(notes.load().getPatchSets(), patchSetIds::contains));
|
||||
}
|
||||
|
||||
@@ -135,7 +136,7 @@ public class PatchSetUtil {
|
||||
|
||||
/** Check if the current patch set of the change is locked. */
|
||||
public void checkPatchSetNotLocked(ChangeNotes notes)
|
||||
throws OrmException, IOException, ResourceConflictException {
|
||||
throws StorageException, IOException, ResourceConflictException {
|
||||
if (isPatchSetLocked(notes)) {
|
||||
throw new ResourceConflictException(
|
||||
String.format("The current patch set of change %s is locked", notes.getChangeId()));
|
||||
@@ -143,7 +144,7 @@ public class PatchSetUtil {
|
||||
}
|
||||
|
||||
/** Is the current patch set locked against state changes? */
|
||||
public boolean isPatchSetLocked(ChangeNotes notes) throws OrmException, IOException {
|
||||
public boolean isPatchSetLocked(ChangeNotes notes) throws StorageException, IOException {
|
||||
Change change = notes.getChange();
|
||||
if (change.isMerged()) {
|
||||
return false;
|
||||
|
||||
@@ -19,13 +19,13 @@ import static com.google.gerrit.reviewdb.client.PatchLineComment.Status.PUBLISHE
|
||||
import static java.util.stream.Collectors.toSet;
|
||||
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.Comment;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gerrit.server.patch.PatchListCache;
|
||||
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.util.Collection;
|
||||
@@ -47,7 +47,7 @@ public class PublishCommentUtil {
|
||||
|
||||
public void publish(
|
||||
ChangeContext ctx, PatchSet.Id psId, Collection<Comment> drafts, @Nullable String tag)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
ChangeNotes notes = ctx.getNotes();
|
||||
checkArgument(notes != null);
|
||||
if (drafts.isEmpty()) {
|
||||
@@ -59,7 +59,7 @@ public class PublishCommentUtil {
|
||||
for (Comment d : drafts) {
|
||||
PatchSet ps = patchSets.get(psId(notes, d));
|
||||
if (ps == null) {
|
||||
throw new OrmException("patch set " + ps + " not found");
|
||||
throw new StorageException("patch set " + ps + " not found");
|
||||
}
|
||||
d.writtenOn = ctx.getWhen();
|
||||
d.tag = tag;
|
||||
@@ -69,7 +69,7 @@ public class PublishCommentUtil {
|
||||
try {
|
||||
CommentsUtil.setCommentRevId(d, patchListCache, notes.getChange(), ps);
|
||||
} catch (PatchListNotAvailableException e) {
|
||||
throw new OrmException(e);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
}
|
||||
commentsUtil.putComments(ctx.getUpdate(psId), PUBLISHED, drafts);
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.google.common.collect.Sets;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
@@ -46,7 +47,6 @@ import com.google.gerrit.server.logging.TraceContext.TraceTimer;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.InternalChangeQuery;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -187,11 +187,11 @@ public class StarredChangesUtil {
|
||||
}
|
||||
|
||||
public ImmutableSortedSet<String> getLabels(Account.Id accountId, Change.Id changeId)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
try (Repository repo = repoManager.openRepository(allUsers)) {
|
||||
return readLabels(repo, RefNames.refsStarredChanges(changeId, accountId)).labels();
|
||||
} catch (IOException e) {
|
||||
throw new OrmException(
|
||||
throw new StorageException(
|
||||
String.format(
|
||||
"Reading stars from change %d for account %d failed",
|
||||
changeId.get(), accountId.get()),
|
||||
@@ -205,7 +205,7 @@ public class StarredChangesUtil {
|
||||
Change.Id changeId,
|
||||
Set<String> labelsToAdd,
|
||||
Set<String> labelsToRemove)
|
||||
throws OrmException, IllegalLabelException {
|
||||
throws StorageException, IllegalLabelException {
|
||||
try (Repository repo = repoManager.openRepository(allUsers)) {
|
||||
String refName = RefNames.refsStarredChanges(changeId, accountId);
|
||||
StarRef old = readLabels(repo, refName);
|
||||
@@ -228,13 +228,13 @@ public class StarredChangesUtil {
|
||||
indexer.index(project, changeId);
|
||||
return ImmutableSortedSet.copyOf(labels);
|
||||
} catch (IOException e) {
|
||||
throw new OrmException(
|
||||
throw new StorageException(
|
||||
String.format("Star change %d for account %d failed", changeId.get(), accountId.get()),
|
||||
e);
|
||||
}
|
||||
}
|
||||
|
||||
public void unstarAll(Project.NameKey project, Change.Id changeId) throws OrmException {
|
||||
public void unstarAll(Project.NameKey project, Change.Id changeId) throws StorageException {
|
||||
try (Repository repo = repoManager.openRepository(allUsers);
|
||||
RevWalk rw = new RevWalk(repo)) {
|
||||
BatchRefUpdate batchUpdate = repo.getRefDatabase().newBatchUpdate();
|
||||
@@ -257,11 +257,11 @@ public class StarredChangesUtil {
|
||||
}
|
||||
indexer.index(project, changeId);
|
||||
} catch (IOException e) {
|
||||
throw new OrmException(String.format("Unstar change %d failed", changeId.get()), e);
|
||||
throw new StorageException(String.format("Unstar change %d failed", changeId.get()), e);
|
||||
}
|
||||
}
|
||||
|
||||
public ImmutableMap<Account.Id, StarRef> byChange(Change.Id changeId) throws OrmException {
|
||||
public ImmutableMap<Account.Id, StarRef> byChange(Change.Id changeId) throws StorageException {
|
||||
try (Repository repo = repoManager.openRepository(allUsers)) {
|
||||
ImmutableMap.Builder<Account.Id, StarRef> builder = ImmutableMap.builder();
|
||||
for (String refPart : getRefNames(repo, RefNames.refsStarredChangesPrefix(changeId))) {
|
||||
@@ -274,13 +274,13 @@ public class StarredChangesUtil {
|
||||
}
|
||||
return builder.build();
|
||||
} catch (IOException e) {
|
||||
throw new OrmException(
|
||||
throw new StorageException(
|
||||
String.format("Get accounts that starred change %d failed", changeId.get()), e);
|
||||
}
|
||||
}
|
||||
|
||||
public ImmutableListMultimap<Account.Id, String> byChangeFromIndex(Change.Id changeId)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
List<ChangeData> changeData =
|
||||
queryProvider
|
||||
.get()
|
||||
@@ -311,7 +311,7 @@ public class StarredChangesUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public void ignore(ChangeResource rsrc) throws OrmException, IllegalLabelException {
|
||||
public void ignore(ChangeResource rsrc) throws StorageException, IllegalLabelException {
|
||||
star(
|
||||
rsrc.getUser().asIdentifiedUser().getAccountId(),
|
||||
rsrc.getProject(),
|
||||
@@ -320,7 +320,7 @@ public class StarredChangesUtil {
|
||||
ImmutableSet.of());
|
||||
}
|
||||
|
||||
public void unignore(ChangeResource rsrc) throws OrmException, IllegalLabelException {
|
||||
public void unignore(ChangeResource rsrc) throws StorageException, IllegalLabelException {
|
||||
star(
|
||||
rsrc.getUser().asIdentifiedUser().getAccountId(),
|
||||
rsrc.getProject(),
|
||||
@@ -329,11 +329,11 @@ public class StarredChangesUtil {
|
||||
ImmutableSet.of(IGNORE_LABEL));
|
||||
}
|
||||
|
||||
public boolean isIgnoredBy(Change.Id changeId, Account.Id accountId) throws OrmException {
|
||||
public boolean isIgnoredBy(Change.Id changeId, Account.Id accountId) throws StorageException {
|
||||
return getLabels(accountId, changeId).contains(IGNORE_LABEL);
|
||||
}
|
||||
|
||||
public boolean isIgnored(ChangeResource rsrc) throws OrmException {
|
||||
public boolean isIgnored(ChangeResource rsrc) throws StorageException {
|
||||
return isIgnoredBy(rsrc.getChange().getId(), rsrc.getUser().asIdentifiedUser().getAccountId());
|
||||
}
|
||||
|
||||
@@ -353,7 +353,7 @@ public class StarredChangesUtil {
|
||||
return UNREVIEWED_LABEL + "/" + ps;
|
||||
}
|
||||
|
||||
public void markAsReviewed(ChangeResource rsrc) throws OrmException, IllegalLabelException {
|
||||
public void markAsReviewed(ChangeResource rsrc) throws StorageException, IllegalLabelException {
|
||||
star(
|
||||
rsrc.getUser().asIdentifiedUser().getAccountId(),
|
||||
rsrc.getProject(),
|
||||
@@ -362,7 +362,7 @@ public class StarredChangesUtil {
|
||||
ImmutableSet.of(getUnreviewedLabel(rsrc.getChange())));
|
||||
}
|
||||
|
||||
public void markAsUnreviewed(ChangeResource rsrc) throws OrmException, IllegalLabelException {
|
||||
public void markAsUnreviewed(ChangeResource rsrc) throws StorageException, IllegalLabelException {
|
||||
star(
|
||||
rsrc.getUser().asIdentifiedUser().getAccountId(),
|
||||
rsrc.getProject(),
|
||||
@@ -444,7 +444,7 @@ public class StarredChangesUtil {
|
||||
|
||||
private void updateLabels(
|
||||
Repository repo, String refName, ObjectId oldObjectId, Collection<String> labels)
|
||||
throws IOException, OrmException, InvalidLabelsException {
|
||||
throws IOException, StorageException, InvalidLabelsException {
|
||||
try (TraceTimer traceTimer =
|
||||
TraceContext.newTimer("Update star labels in %s (labels=%s)", refName, labels);
|
||||
RevWalk rw = new RevWalk(repo)) {
|
||||
@@ -471,14 +471,14 @@ public class StarredChangesUtil {
|
||||
case REJECTED_MISSING_OBJECT:
|
||||
case REJECTED_OTHER_REASON:
|
||||
default:
|
||||
throw new OrmException(
|
||||
throw new StorageException(
|
||||
String.format("Update star labels on ref %s failed: %s", refName, result.name()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteRef(Repository repo, String refName, ObjectId oldObjectId)
|
||||
throws IOException, OrmException {
|
||||
throws IOException, StorageException {
|
||||
if (ObjectId.zeroId().equals(oldObjectId)) {
|
||||
// ref doesn't exist
|
||||
return;
|
||||
@@ -507,7 +507,7 @@ public class StarredChangesUtil {
|
||||
case REJECTED_MISSING_OBJECT:
|
||||
case REJECTED_OTHER_REASON:
|
||||
default:
|
||||
throw new OrmException(
|
||||
throw new StorageException(
|
||||
String.format("Delete star ref %s failed: %s", refName, result.name()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gerrit.exceptions.DuplicateKeyException;
|
||||
import com.google.gerrit.extensions.client.DiffPreferencesInfo;
|
||||
import com.google.gerrit.extensions.client.EditPreferencesInfo;
|
||||
import com.google.gerrit.extensions.client.GeneralPreferencesInfo;
|
||||
@@ -34,7 +35,6 @@ import com.google.gerrit.server.git.ValidationError;
|
||||
import com.google.gerrit.server.git.meta.MetaDataUpdate;
|
||||
import com.google.gerrit.server.git.meta.VersionedMetaData;
|
||||
import com.google.gerrit.server.util.time.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmDuplicateKeyException;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
@@ -200,9 +200,9 @@ public class AccountConfig extends VersionedMetaData implements ValidationError.
|
||||
* Creates a new account.
|
||||
*
|
||||
* @return the new account
|
||||
* @throws OrmDuplicateKeyException if the user branch already exists
|
||||
* @throws DuplicateKeyException if the user branch already exists
|
||||
*/
|
||||
public Account getNewAccount() throws OrmDuplicateKeyException {
|
||||
public Account getNewAccount() throws DuplicateKeyException {
|
||||
return getNewAccount(TimeUtil.nowTs());
|
||||
}
|
||||
|
||||
@@ -210,12 +210,12 @@ public class AccountConfig extends VersionedMetaData implements ValidationError.
|
||||
* Creates a new account.
|
||||
*
|
||||
* @return the new account
|
||||
* @throws OrmDuplicateKeyException if the user branch already exists
|
||||
* @throws DuplicateKeyException if the user branch already exists
|
||||
*/
|
||||
Account getNewAccount(Timestamp registeredOn) throws OrmDuplicateKeyException {
|
||||
Account getNewAccount(Timestamp registeredOn) throws DuplicateKeyException {
|
||||
checkLoaded();
|
||||
if (revision != null) {
|
||||
throw new OrmDuplicateKeyException(String.format("account %s already exists", accountId));
|
||||
throw new DuplicateKeyException(String.format("account %s already exists", accountId));
|
||||
}
|
||||
this.loadedAccountProperties =
|
||||
Optional.of(new AccountProperties(accountId, registeredOn, new Config(), null));
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.google.gerrit.common.data.AccessSection;
|
||||
import com.google.gerrit.common.data.GlobalCapability;
|
||||
import com.google.gerrit.common.data.Permission;
|
||||
import com.google.gerrit.exceptions.NoSuchGroupException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.client.AccountFieldName;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
@@ -42,7 +43,6 @@ import com.google.gerrit.server.group.db.InternalGroupUpdate;
|
||||
import com.google.gerrit.server.notedb.Sequences;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.ssh.SshKeyCache;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -163,7 +163,7 @@ public class AccountManager {
|
||||
// return the identity to the caller.
|
||||
update(who, extId);
|
||||
return new AuthResult(extId.accountId(), who.getExternalIdKey(), false);
|
||||
} catch (OrmException | ConfigInvalidException e) {
|
||||
} catch (StorageException | ConfigInvalidException e) {
|
||||
throw new AccountException("Authentication error", e);
|
||||
}
|
||||
}
|
||||
@@ -214,7 +214,7 @@ public class AccountManager {
|
||||
}
|
||||
|
||||
private void update(AuthRequest who, ExternalId extId)
|
||||
throws OrmException, IOException, ConfigInvalidException, AccountException {
|
||||
throws StorageException, IOException, ConfigInvalidException, AccountException {
|
||||
IdentifiedUser user = userFactory.create(extId.accountId());
|
||||
List<Consumer<InternalAccountUpdate.Builder>> accountUpdates = new ArrayList<>();
|
||||
|
||||
@@ -266,12 +266,12 @@ public class AccountManager {
|
||||
user.getAccountId(),
|
||||
AccountUpdater.joinConsumers(accountUpdates))
|
||||
.orElseThrow(
|
||||
() -> new OrmException("Account " + user.getAccountId() + " has been deleted"));
|
||||
() -> new StorageException("Account " + user.getAccountId() + " has been deleted"));
|
||||
}
|
||||
}
|
||||
|
||||
private AuthResult create(AuthRequest who)
|
||||
throws OrmException, AccountException, IOException, ConfigInvalidException {
|
||||
throws StorageException, AccountException, IOException, ConfigInvalidException {
|
||||
Account.Id newId = new Account.Id(sequences.nextAccountId());
|
||||
logger.atFine().log("Assigning new Id %s to account", newId);
|
||||
|
||||
@@ -375,7 +375,7 @@ public class AccountManager {
|
||||
}
|
||||
|
||||
private void addGroupMember(AccountGroup.UUID groupUuid, IdentifiedUser user)
|
||||
throws OrmException, IOException, ConfigInvalidException, AccountException {
|
||||
throws StorageException, IOException, ConfigInvalidException, AccountException {
|
||||
// The user initiated this request by logging in. -> Attribute all modifications to that user.
|
||||
GroupsUpdate groupsUpdate = groupsUpdateFactory.create(user);
|
||||
InternalGroupUpdate groupUpdate =
|
||||
@@ -400,7 +400,7 @@ public class AccountManager {
|
||||
* this time.
|
||||
*/
|
||||
public AuthResult link(Account.Id to, AuthRequest who)
|
||||
throws AccountException, OrmException, IOException, ConfigInvalidException {
|
||||
throws AccountException, StorageException, IOException, ConfigInvalidException {
|
||||
Optional<ExternalId> optionalExtId = externalIds.get(who.getExternalIdKey());
|
||||
if (optionalExtId.isPresent()) {
|
||||
ExternalId extId = optionalExtId.get();
|
||||
@@ -437,12 +437,12 @@ public class AccountManager {
|
||||
* @param to account to link the identity onto.
|
||||
* @param who the additional identity.
|
||||
* @return the result of linking the identity to the user.
|
||||
* @throws OrmException
|
||||
* @throws StorageException
|
||||
* @throws AccountException the identity belongs to a different account, or it cannot be linked at
|
||||
* this time.
|
||||
*/
|
||||
public AuthResult updateLink(Account.Id to, AuthRequest who)
|
||||
throws OrmException, AccountException, IOException, ConfigInvalidException {
|
||||
throws StorageException, AccountException, IOException, ConfigInvalidException {
|
||||
accountsUpdateProvider
|
||||
.get()
|
||||
.update(
|
||||
@@ -474,7 +474,7 @@ public class AccountManager {
|
||||
* found
|
||||
*/
|
||||
public void unlink(Account.Id from, ExternalId.Key extIdKey)
|
||||
throws AccountException, OrmException, IOException, ConfigInvalidException {
|
||||
throws AccountException, StorageException, IOException, ConfigInvalidException {
|
||||
unlink(from, ImmutableList.of(extIdKey));
|
||||
}
|
||||
|
||||
@@ -487,7 +487,7 @@ public class AccountManager {
|
||||
* identity was not found
|
||||
*/
|
||||
public void unlink(Account.Id from, Collection<ExternalId.Key> extIdKeys)
|
||||
throws AccountException, OrmException, IOException, ConfigInvalidException {
|
||||
throws AccountException, StorageException, IOException, ConfigInvalidException {
|
||||
if (extIdKeys.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.google.common.base.Suppliers;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||
import com.google.gerrit.index.Schema;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
@@ -34,7 +35,6 @@ import com.google.gerrit.server.IdentifiedUser;
|
||||
import com.google.gerrit.server.account.externalids.ExternalId;
|
||||
import com.google.gerrit.server.config.AnonymousCowardName;
|
||||
import com.google.gerrit.server.query.account.InternalAccountQuery;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -216,14 +216,15 @@ public class AccountResolver {
|
||||
return false;
|
||||
}
|
||||
|
||||
Optional<I> tryParse(String input) throws IOException, OrmException;
|
||||
Optional<I> tryParse(String input) throws IOException, StorageException;
|
||||
|
||||
Stream<AccountState> search(I input) throws OrmException, IOException, ConfigInvalidException;
|
||||
Stream<AccountState> search(I input)
|
||||
throws StorageException, IOException, ConfigInvalidException;
|
||||
|
||||
boolean shortCircuitIfNoResults();
|
||||
|
||||
default Optional<Stream<AccountState>> trySearch(String input)
|
||||
throws OrmException, IOException, ConfigInvalidException {
|
||||
throws StorageException, IOException, ConfigInvalidException {
|
||||
Optional<I> parsed = tryParse(input);
|
||||
return parsed.isPresent() ? Optional.of(search(parsed.get())) : Optional.empty();
|
||||
}
|
||||
@@ -335,7 +336,7 @@ public class AccountResolver {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<AccountState> search(String nameOrEmail) throws OrmException, IOException {
|
||||
public Stream<AccountState> search(String nameOrEmail) throws StorageException, IOException {
|
||||
// TODO(dborowitz): This would probably work as a Searcher<Address>
|
||||
int lt = nameOrEmail.indexOf('<');
|
||||
int gt = nameOrEmail.indexOf('>');
|
||||
@@ -368,7 +369,7 @@ public class AccountResolver {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<AccountState> search(String input) throws OrmException, IOException {
|
||||
public Stream<AccountState> search(String input) throws StorageException, IOException {
|
||||
return toAccountStates(emails.getAccountFor(input));
|
||||
}
|
||||
|
||||
@@ -397,7 +398,7 @@ public class AccountResolver {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<AccountState> tryParse(String input) throws OrmException {
|
||||
public Optional<AccountState> tryParse(String input) throws StorageException {
|
||||
List<AccountState> results =
|
||||
accountQueryProvider.get().enforceVisibility(true).byFullName(input);
|
||||
return results.size() == 1 ? Optional.of(results.get(0)) : Optional.empty();
|
||||
@@ -426,7 +427,7 @@ public class AccountResolver {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<AccountState> search(String input) throws OrmException {
|
||||
public Stream<AccountState> search(String input) throws StorageException {
|
||||
// At this point we have no clue. Just perform a whole bunch of suggestions and pray we come
|
||||
// up with a reasonable result list.
|
||||
// TODO(dborowitz): This doesn't match the documentation; consider whether it's possible to be
|
||||
@@ -513,11 +514,11 @@ public class AccountResolver {
|
||||
*
|
||||
* @param input input string.
|
||||
* @return a result describing matching accounts. Never null even if the result set is empty.
|
||||
* @throws OrmException if an error occurs.
|
||||
* @throws StorageException if an error occurs.
|
||||
* @throws ConfigInvalidException if an error occurs.
|
||||
* @throws IOException if an error occurs.
|
||||
*/
|
||||
public Result resolve(String input) throws OrmException, ConfigInvalidException, IOException {
|
||||
public Result resolve(String input) throws StorageException, ConfigInvalidException, IOException {
|
||||
return searchImpl(input, searchers, visibilitySupplier());
|
||||
}
|
||||
|
||||
@@ -539,7 +540,7 @@ public class AccountResolver {
|
||||
*
|
||||
* @param input input string.
|
||||
* @return a result describing matching accounts. Never null even if the result set is empty.
|
||||
* @throws OrmException if an error occurs.
|
||||
* @throws StorageException if an error occurs.
|
||||
* @throws ConfigInvalidException if an error occurs.
|
||||
* @throws IOException if an error occurs.
|
||||
* @deprecated for use only by MailUtil for parsing commit footers; that class needs to be
|
||||
@@ -547,7 +548,7 @@ public class AccountResolver {
|
||||
*/
|
||||
@Deprecated
|
||||
public Result resolveByNameOrEmail(String input)
|
||||
throws OrmException, ConfigInvalidException, IOException {
|
||||
throws StorageException, ConfigInvalidException, IOException {
|
||||
return searchImpl(input, nameOrEmailSearchers, visibilitySupplier());
|
||||
}
|
||||
|
||||
@@ -560,7 +561,7 @@ public class AccountResolver {
|
||||
String input,
|
||||
ImmutableList<Searcher<?>> searchers,
|
||||
Supplier<Predicate<AccountState>> visibilitySupplier)
|
||||
throws OrmException, ConfigInvalidException, IOException {
|
||||
throws StorageException, ConfigInvalidException, IOException {
|
||||
visibilitySupplier = Suppliers.memoize(visibilitySupplier::get);
|
||||
List<AccountState> inactive = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.util.concurrent.Runnables;
|
||||
import com.google.gerrit.exceptions.DuplicateKeyException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.git.LockFailureException;
|
||||
import com.google.gerrit.git.RefUpdateUtil;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
@@ -41,8 +43,6 @@ import com.google.gerrit.server.notedb.Sequences;
|
||||
import com.google.gerrit.server.update.RetryHelper;
|
||||
import com.google.gerrit.server.update.RetryHelper.Action;
|
||||
import com.google.gerrit.server.update.RetryHelper.ActionType;
|
||||
import com.google.gwtorm.server.OrmDuplicateKeyException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.google.inject.assistedinject.AssistedInject;
|
||||
@@ -293,14 +293,14 @@ public class AccountsUpdate {
|
||||
* @param accountId ID of the new account
|
||||
* @param init consumer to populate the new account
|
||||
* @return the newly created account
|
||||
* @throws OrmDuplicateKeyException if the account already exists
|
||||
* @throws DuplicateKeyException if the account already exists
|
||||
* @throws IOException if creating the user branch fails due to an IO error
|
||||
* @throws OrmException if creating the user branch fails
|
||||
* @throws StorageException if creating the user branch fails
|
||||
* @throws ConfigInvalidException if any of the account fields has an invalid value
|
||||
*/
|
||||
public AccountState insert(
|
||||
String message, Account.Id accountId, Consumer<InternalAccountUpdate.Builder> init)
|
||||
throws OrmException, IOException, ConfigInvalidException {
|
||||
throws StorageException, IOException, ConfigInvalidException {
|
||||
return insert(message, accountId, AccountUpdater.fromConsumer(init));
|
||||
}
|
||||
|
||||
@@ -311,13 +311,13 @@ public class AccountsUpdate {
|
||||
* @param accountId ID of the new account
|
||||
* @param updater updater to populate the new account
|
||||
* @return the newly created account
|
||||
* @throws OrmDuplicateKeyException if the account already exists
|
||||
* @throws DuplicateKeyException if the account already exists
|
||||
* @throws IOException if creating the user branch fails due to an IO error
|
||||
* @throws OrmException if creating the user branch fails
|
||||
* @throws StorageException if creating the user branch fails
|
||||
* @throws ConfigInvalidException if any of the account fields has an invalid value
|
||||
*/
|
||||
public AccountState insert(String message, Account.Id accountId, AccountUpdater updater)
|
||||
throws OrmException, IOException, ConfigInvalidException {
|
||||
throws StorageException, IOException, ConfigInvalidException {
|
||||
return updateAccount(
|
||||
r -> {
|
||||
AccountConfig accountConfig = read(r, accountId);
|
||||
@@ -351,12 +351,12 @@ public class AccountsUpdate {
|
||||
* @throws IOException if updating the user branch fails due to an IO error
|
||||
* @throws LockFailureException if updating the user branch still fails due to concurrent updates
|
||||
* after the retry timeout exceeded
|
||||
* @throws OrmException if updating the user branch fails
|
||||
* @throws StorageException if updating the user branch fails
|
||||
* @throws ConfigInvalidException if any of the account fields has an invalid value
|
||||
*/
|
||||
public Optional<AccountState> update(
|
||||
String message, Account.Id accountId, Consumer<InternalAccountUpdate.Builder> update)
|
||||
throws OrmException, LockFailureException, IOException, ConfigInvalidException {
|
||||
throws StorageException, LockFailureException, IOException, ConfigInvalidException {
|
||||
return update(message, accountId, AccountUpdater.fromConsumer(update));
|
||||
}
|
||||
|
||||
@@ -372,11 +372,11 @@ public class AccountsUpdate {
|
||||
* @throws IOException if updating the user branch fails due to an IO error
|
||||
* @throws LockFailureException if updating the user branch still fails due to concurrent updates
|
||||
* after the retry timeout exceeded
|
||||
* @throws OrmException if updating the user branch fails
|
||||
* @throws StorageException if updating the user branch fails
|
||||
* @throws ConfigInvalidException if any of the account fields has an invalid value
|
||||
*/
|
||||
public Optional<AccountState> update(String message, Account.Id accountId, AccountUpdater updater)
|
||||
throws OrmException, LockFailureException, IOException, ConfigInvalidException {
|
||||
throws StorageException, LockFailureException, IOException, ConfigInvalidException {
|
||||
return updateAccount(
|
||||
r -> {
|
||||
AccountConfig accountConfig = read(r, accountId);
|
||||
@@ -407,7 +407,7 @@ public class AccountsUpdate {
|
||||
}
|
||||
|
||||
private Optional<AccountState> updateAccount(AccountUpdate accountUpdate)
|
||||
throws IOException, ConfigInvalidException, OrmException {
|
||||
throws IOException, ConfigInvalidException, StorageException {
|
||||
return executeAccountUpdate(
|
||||
() -> {
|
||||
try (Repository allUsersRepo = repoManager.openRepository(allUsersName)) {
|
||||
@@ -423,7 +423,7 @@ public class AccountsUpdate {
|
||||
}
|
||||
|
||||
private Optional<AccountState> executeAccountUpdate(Action<Optional<AccountState>> action)
|
||||
throws IOException, ConfigInvalidException, OrmException {
|
||||
throws IOException, ConfigInvalidException, StorageException {
|
||||
try {
|
||||
return retryHelper.execute(
|
||||
ActionType.ACCOUNT_UPDATE, action, LockFailureException.class::isInstance);
|
||||
@@ -431,8 +431,8 @@ public class AccountsUpdate {
|
||||
Throwables.throwIfUnchecked(e);
|
||||
Throwables.throwIfInstanceOf(e, IOException.class);
|
||||
Throwables.throwIfInstanceOf(e, ConfigInvalidException.class);
|
||||
Throwables.throwIfInstanceOf(e, OrmException.class);
|
||||
throw new OrmException(e);
|
||||
Throwables.throwIfInstanceOf(e, StorageException.class);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,7 +441,7 @@ public class AccountsUpdate {
|
||||
Optional<ObjectId> rev,
|
||||
Account.Id accountId,
|
||||
InternalAccountUpdate update)
|
||||
throws IOException, ConfigInvalidException, OrmDuplicateKeyException {
|
||||
throws IOException, ConfigInvalidException, DuplicateKeyException {
|
||||
ExternalIdNotes.checkSameAccount(
|
||||
Iterables.concat(
|
||||
update.getCreatedExternalIds(),
|
||||
@@ -563,7 +563,7 @@ public class AccountsUpdate {
|
||||
@FunctionalInterface
|
||||
private static interface AccountUpdate {
|
||||
UpdatedAccount update(Repository allUsersRepo)
|
||||
throws IOException, ConfigInvalidException, OrmException;
|
||||
throws IOException, ConfigInvalidException, StorageException;
|
||||
}
|
||||
|
||||
private static class UpdatedAccount {
|
||||
|
||||
@@ -16,11 +16,11 @@ package com.google.gerrit.server.account;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.client.AccountFieldName;
|
||||
import com.google.gerrit.extensions.client.AuthType;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.server.config.AuthConfig;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -87,7 +87,7 @@ public class DefaultRealm extends AbstractRealm {
|
||||
if (1 == c.size()) {
|
||||
return c.iterator().next();
|
||||
}
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
throw new IOException("Failed to query accounts by email", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.ImmutableSetMultimap;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.server.account.externalids.ExternalId;
|
||||
import com.google.gerrit.server.account.externalids.ExternalIds;
|
||||
@@ -27,7 +28,6 @@ import com.google.gerrit.server.query.account.InternalAccountQuery;
|
||||
import com.google.gerrit.server.update.RetryHelper;
|
||||
import com.google.gerrit.server.update.RetryHelper.Action;
|
||||
import com.google.gerrit.server.update.RetryHelper.ActionType;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -69,7 +69,7 @@ public class Emails {
|
||||
*
|
||||
* @see #getAccountsFor(String...)
|
||||
*/
|
||||
public ImmutableSet<Account.Id> getAccountFor(String email) throws IOException, OrmException {
|
||||
public ImmutableSet<Account.Id> getAccountFor(String email) throws IOException, StorageException {
|
||||
return Streams.concat(
|
||||
externalIds.byEmail(email).stream().map(ExternalId::accountId),
|
||||
executeIndexQuery(() -> queryProvider.get().byPreferredEmail(email).stream())
|
||||
@@ -83,7 +83,7 @@ public class Emails {
|
||||
* @see #getAccountFor(String)
|
||||
*/
|
||||
public ImmutableSetMultimap<String, Account.Id> getAccountsFor(String... emails)
|
||||
throws IOException, OrmException {
|
||||
throws IOException, StorageException {
|
||||
ImmutableSetMultimap.Builder<String, Account.Id> builder = ImmutableSetMultimap.builder();
|
||||
externalIds.byEmails(emails).entries().stream()
|
||||
.forEach(e -> builder.put(e.getKey(), e.getValue().accountId()));
|
||||
@@ -102,13 +102,14 @@ public class Emails {
|
||||
return externalIds.byEmail(email).stream().map(ExternalId::accountId).collect(toImmutableSet());
|
||||
}
|
||||
|
||||
private <T> T executeIndexQuery(Action<T> action) throws OrmException {
|
||||
private <T> T executeIndexQuery(Action<T> action) throws StorageException {
|
||||
try {
|
||||
return retryHelper.execute(ActionType.INDEX_QUERY, action, OrmException.class::isInstance);
|
||||
return retryHelper.execute(
|
||||
ActionType.INDEX_QUERY, action, StorageException.class::isInstance);
|
||||
} catch (Exception e) {
|
||||
Throwables.throwIfUnchecked(e);
|
||||
Throwables.throwIfInstanceOf(e, OrmException.class);
|
||||
throw new OrmException(e);
|
||||
Throwables.throwIfInstanceOf(e, StorageException.class);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.server.cache.CacheModule;
|
||||
@@ -30,7 +31,6 @@ import com.google.gerrit.server.group.db.Groups;
|
||||
import com.google.gerrit.server.logging.TraceContext;
|
||||
import com.google.gerrit.server.logging.TraceContext.TraceTimer;
|
||||
import com.google.gerrit.server.query.group.InternalGroupQuery;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provider;
|
||||
@@ -152,7 +152,7 @@ public class GroupIncludeCacheImpl implements GroupIncludeCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableSet<AccountGroup.UUID> load(Account.Id memberId) throws OrmException {
|
||||
public ImmutableSet<AccountGroup.UUID> load(Account.Id memberId) throws StorageException {
|
||||
try (TraceTimer timer = TraceContext.newTimer("Loading groups with member %s", memberId)) {
|
||||
return groupQueryProvider.get().byMember(memberId).stream()
|
||||
.map(InternalGroup::getGroupUUID)
|
||||
@@ -171,7 +171,7 @@ public class GroupIncludeCacheImpl implements GroupIncludeCache {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ImmutableList<AccountGroup.UUID> load(AccountGroup.UUID key) throws OrmException {
|
||||
public ImmutableList<AccountGroup.UUID> load(AccountGroup.UUID key) throws StorageException {
|
||||
try (TraceTimer timer = TraceContext.newTimer("Loading parent groups of %s", key)) {
|
||||
return groupQueryProvider.get().bySubgroup(key).stream()
|
||||
.map(InternalGroup::getGroupUUID)
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.account;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceNotFoundException;
|
||||
import com.google.gerrit.extensions.restapi.Response;
|
||||
@@ -23,7 +24,6 @@ import com.google.gerrit.server.ServerInitiated;
|
||||
import com.google.gerrit.server.plugincontext.PluginSetContext;
|
||||
import com.google.gerrit.server.validators.AccountActivationValidationListener;
|
||||
import com.google.gerrit.server.validators.ValidationException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -48,7 +48,7 @@ public class SetInactiveFlag {
|
||||
}
|
||||
|
||||
public Response<?> deactivate(Account.Id accountId)
|
||||
throws RestApiException, IOException, ConfigInvalidException, OrmException {
|
||||
throws RestApiException, IOException, ConfigInvalidException, StorageException {
|
||||
AtomicBoolean alreadyInactive = new AtomicBoolean(false);
|
||||
AtomicReference<Optional<RestApiException>> exception = new AtomicReference<>(Optional.empty());
|
||||
accountsUpdateProvider
|
||||
@@ -81,7 +81,7 @@ public class SetInactiveFlag {
|
||||
}
|
||||
|
||||
public Response<String> activate(Account.Id accountId)
|
||||
throws RestApiException, IOException, ConfigInvalidException, OrmException {
|
||||
throws RestApiException, IOException, ConfigInvalidException, StorageException {
|
||||
AtomicBoolean alreadyActive = new AtomicBoolean(false);
|
||||
AtomicReference<Optional<RestApiException>> exception = new AtomicReference<>(Optional.empty());
|
||||
accountsUpdateProvider
|
||||
|
||||
@@ -14,13 +14,13 @@
|
||||
|
||||
package com.google.gerrit.server.account.externalids;
|
||||
|
||||
import com.google.gwtorm.server.OrmDuplicateKeyException;
|
||||
import com.google.gerrit.exceptions.DuplicateKeyException;
|
||||
|
||||
/**
|
||||
* Exception that is thrown if an external ID cannot be inserted because an external ID with the
|
||||
* same key already exists.
|
||||
*/
|
||||
public class DuplicateExternalIdKeyException extends OrmDuplicateKeyException {
|
||||
public class DuplicateExternalIdKeyException extends DuplicateKeyException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final ExternalId.Key duplicateKey;
|
||||
|
||||
@@ -7,13 +7,13 @@ java_library(
|
||||
deps = [
|
||||
"//java/com/google/gerrit/common:annotations",
|
||||
"//java/com/google/gerrit/common:server",
|
||||
"//java/com/google/gerrit/exceptions",
|
||||
"//java/com/google/gerrit/extensions:api",
|
||||
"//java/com/google/gerrit/lifecycle",
|
||||
"//java/com/google/gerrit/reviewdb:server",
|
||||
"//java/com/google/gerrit/server",
|
||||
"//java/com/google/gerrit/server/restapi",
|
||||
"//java/com/google/gerrit/util/cli",
|
||||
"//java/com/google/gwtorm",
|
||||
"//lib:args4j",
|
||||
"//lib:guava",
|
||||
"//lib:servlet-api-3_1",
|
||||
|
||||
@@ -19,6 +19,7 @@ import static com.google.gerrit.server.api.ApiUtil.asRestApiException;
|
||||
import com.google.common.collect.ImmutableListMultimap;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.AbandonInput;
|
||||
import com.google.gerrit.extensions.api.changes.AddReviewerInput;
|
||||
import com.google.gerrit.extensions.api.changes.AddReviewerResult;
|
||||
@@ -103,7 +104,6 @@ import com.google.gerrit.server.restapi.change.SubmittedTogether;
|
||||
import com.google.gerrit.server.restapi.change.SuggestChangeReviewers;
|
||||
import com.google.gerrit.server.restapi.change.Unignore;
|
||||
import com.google.gerrit.util.cli.CmdLineParser;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Provider;
|
||||
@@ -613,7 +613,7 @@ class ChangeApiImpl implements ChangeApi {
|
||||
} else {
|
||||
unignore.apply(change, new Input());
|
||||
}
|
||||
} catch (OrmException | IllegalLabelException e) {
|
||||
} catch (StorageException | IllegalLabelException e) {
|
||||
throw asRestApiException("Cannot ignore change", e);
|
||||
}
|
||||
}
|
||||
@@ -622,7 +622,7 @@ class ChangeApiImpl implements ChangeApi {
|
||||
public boolean ignored() throws RestApiException {
|
||||
try {
|
||||
return stars.isIgnored(change);
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
throw asRestApiException("Cannot check if ignored", e);
|
||||
}
|
||||
}
|
||||
@@ -637,7 +637,7 @@ class ChangeApiImpl implements ChangeApi {
|
||||
} else {
|
||||
markAsUnreviewed.apply(change, new Input());
|
||||
}
|
||||
} catch (OrmException | IllegalLabelException e) {
|
||||
} catch (StorageException | IllegalLabelException e) {
|
||||
throw asRestApiException(
|
||||
"Cannot mark change as " + (reviewed ? "reviewed" : "unreviewed"), e);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.api.changes;
|
||||
|
||||
import static com.google.gerrit.server.api.ApiUtil.asRestApiException;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.ChangeEditApi;
|
||||
import com.google.gerrit.extensions.api.changes.PublishChangeEditInput;
|
||||
import com.google.gerrit.extensions.client.ChangeEditDetailOption;
|
||||
@@ -34,7 +35,6 @@ import com.google.gerrit.server.restapi.change.ChangeEdits;
|
||||
import com.google.gerrit.server.restapi.change.DeleteChangeEdit;
|
||||
import com.google.gerrit.server.restapi.change.PublishChangeEdit;
|
||||
import com.google.gerrit.server.restapi.change.RebaseChangeEdit;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
@@ -242,7 +242,7 @@ public class ChangeEditApiImpl implements ChangeEditApi {
|
||||
}
|
||||
|
||||
private ChangeEditResource getChangeEditResource(String filePath)
|
||||
throws ResourceNotFoundException, AuthException, IOException, OrmException {
|
||||
throws ResourceNotFoundException, AuthException, IOException, StorageException {
|
||||
return changeEdits.parse(changeResource, IdString.fromDecoded(filePath));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.api.projects;
|
||||
|
||||
import static com.google.gerrit.server.api.ApiUtil.asRestApiException;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.projects.ProjectApi;
|
||||
import com.google.gerrit.extensions.api.projects.ProjectInput;
|
||||
import com.google.gerrit.extensions.api.projects.Projects;
|
||||
@@ -28,7 +29,6 @@ import com.google.gerrit.server.restapi.project.ListProjects;
|
||||
import com.google.gerrit.server.restapi.project.ListProjects.FilterType;
|
||||
import com.google.gerrit.server.restapi.project.ProjectsCollection;
|
||||
import com.google.gerrit.server.restapi.project.QueryProjects;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -155,7 +155,7 @@ class ProjectsImpl implements Projects {
|
||||
.withLimit(r.getLimit())
|
||||
.withStart(r.getStart())
|
||||
.apply();
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
throw new RestApiException("Cannot query projects", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.args4j;
|
||||
|
||||
import static com.google.gerrit.util.cli.Localizable.localizable;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.client.AuthType;
|
||||
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
@@ -25,7 +26,6 @@ import com.google.gerrit.server.account.AccountResolver;
|
||||
import com.google.gerrit.server.account.AuthRequest;
|
||||
import com.google.gerrit.server.account.externalids.ExternalId;
|
||||
import com.google.gerrit.server.config.AuthConfig;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.io.IOException;
|
||||
@@ -81,7 +81,7 @@ public class AccountIdHandler extends OptionHandler<Account.Id> {
|
||||
throw new CmdLineException(owner, localizable("user \"%s\" not found"), token);
|
||||
}
|
||||
}
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
throw new CmdLineException(owner, localizable("database is down"));
|
||||
} catch (IOException e) {
|
||||
throw new CmdLineException(owner, "Failed to load account", e);
|
||||
|
||||
@@ -17,12 +17,12 @@ package com.google.gerrit.server.args4j;
|
||||
import static com.google.gerrit.util.cli.Localizable.localizable;
|
||||
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.Branch;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.InternalChangeQuery;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
@@ -67,7 +67,7 @@ public class ChangeIdHandler extends OptionHandler<Change.Id> {
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new CmdLineException(owner, localizable("Change-Id is not valid"));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
throw new CmdLineException(owner, localizable("Database error: %s"), e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ java_library(
|
||||
"//java/com/google/gerrit/server/util/time",
|
||||
"//java/com/google/gerrit/util/cli",
|
||||
"//java/com/google/gerrit/util/ssl",
|
||||
"//java/com/google/gwtorm",
|
||||
"//java/org/apache/commons/net",
|
||||
"//java/org/eclipse/jgit:server",
|
||||
"//lib:args4j",
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.google.gerrit.server.change;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
||||
@@ -32,7 +33,6 @@ import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
@@ -79,7 +79,8 @@ public class AbandonOp implements BatchUpdateOp {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx) throws OrmException, ResourceConflictException {
|
||||
public boolean updateChange(ChangeContext ctx)
|
||||
throws StorageException, ResourceConflictException {
|
||||
change = ctx.getChange();
|
||||
PatchSet.Id psId = change.currentPatchSetId();
|
||||
ChangeUpdate update = ctx.getUpdate(psId);
|
||||
@@ -108,7 +109,7 @@ public class AbandonOp implements BatchUpdateOp {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postUpdate(Context ctx) throws OrmException {
|
||||
public void postUpdate(Context ctx) throws StorageException {
|
||||
NotifyResolver.Result notify = ctx.getNotify(change.getId());
|
||||
try {
|
||||
ReplyToChangeSender cm = abandonedSenderFactory.create(ctx.getProject(), change.getId());
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.google.gerrit.server.change;
|
||||
import com.google.common.collect.ImmutableListMultimap;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.index.query.QueryParseException;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.InternalUser;
|
||||
@@ -25,7 +26,6 @@ import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.ChangeQueryBuilder;
|
||||
import com.google.gerrit.server.query.change.ChangeQueryProcessor;
|
||||
import com.google.gerrit.server.update.BatchUpdate;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -96,14 +96,14 @@ public class AbandonUtil {
|
||||
}
|
||||
}
|
||||
logger.atInfo().log("Auto-Abandoned %d of %d changes.", count, changesToAbandon.size());
|
||||
} catch (QueryParseException | OrmException e) {
|
||||
} catch (QueryParseException | StorageException e) {
|
||||
logger.atSevere().withCause(e).log(
|
||||
"Failed to query inactive open changes for auto-abandoning.");
|
||||
}
|
||||
}
|
||||
|
||||
private Collection<ChangeData> getValidChanges(Collection<ChangeData> changes, String query)
|
||||
throws OrmException, QueryParseException {
|
||||
throws StorageException, QueryParseException {
|
||||
Collection<ChangeData> validChanges = new ArrayList<>();
|
||||
for (ChangeData cd : changes) {
|
||||
String newQuery = query + " change:" + cd.getId();
|
||||
|
||||
@@ -16,9 +16,9 @@ package com.google.gerrit.server.change;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -54,9 +54,9 @@ public interface AccountPatchReviewStore {
|
||||
* @param path file path
|
||||
* @return {@code true} if the reviewed flag was updated, {@code false} if the reviewed flag was
|
||||
* already set
|
||||
* @throws OrmException thrown if updating the reviewed flag failed
|
||||
* @throws StorageException thrown if updating the reviewed flag failed
|
||||
*/
|
||||
boolean markReviewed(PatchSet.Id psId, Account.Id accountId, String path) throws OrmException;
|
||||
boolean markReviewed(PatchSet.Id psId, Account.Id accountId, String path) throws StorageException;
|
||||
|
||||
/**
|
||||
* Marks the given files in the given patch set as reviewed by the given user.
|
||||
@@ -64,10 +64,10 @@ public interface AccountPatchReviewStore {
|
||||
* @param psId patch set ID
|
||||
* @param accountId account ID of the user
|
||||
* @param paths file paths
|
||||
* @throws OrmException thrown if updating the reviewed flag failed
|
||||
* @throws StorageException thrown if updating the reviewed flag failed
|
||||
*/
|
||||
void markReviewed(PatchSet.Id psId, Account.Id accountId, Collection<String> paths)
|
||||
throws OrmException;
|
||||
throws StorageException;
|
||||
|
||||
/**
|
||||
* Clears the reviewed flag for the given file in the given patch set for the given user.
|
||||
@@ -75,17 +75,17 @@ public interface AccountPatchReviewStore {
|
||||
* @param psId patch set ID
|
||||
* @param accountId account ID of the user
|
||||
* @param path file path
|
||||
* @throws OrmException thrown if clearing the reviewed flag failed
|
||||
* @throws StorageException thrown if clearing the reviewed flag failed
|
||||
*/
|
||||
void clearReviewed(PatchSet.Id psId, Account.Id accountId, String path) throws OrmException;
|
||||
void clearReviewed(PatchSet.Id psId, Account.Id accountId, String path) throws StorageException;
|
||||
|
||||
/**
|
||||
* Clears the reviewed flags for all files in the given patch set for all users.
|
||||
*
|
||||
* @param psId patch set ID
|
||||
* @throws OrmException thrown if clearing the reviewed flags failed
|
||||
* @throws StorageException thrown if clearing the reviewed flags failed
|
||||
*/
|
||||
void clearReviewed(PatchSet.Id psId) throws OrmException;
|
||||
void clearReviewed(PatchSet.Id psId) throws StorageException;
|
||||
|
||||
/**
|
||||
* Find the latest patch set, that is smaller or equals to the given patch set, where at least,
|
||||
@@ -95,8 +95,8 @@ public interface AccountPatchReviewStore {
|
||||
* @param accountId account ID of the user
|
||||
* @return optionally, all files the have been reviewed by the given user that belong to the patch
|
||||
* set that is smaller or equals to the given patch set
|
||||
* @throws OrmException thrown if accessing the reviewed flags failed
|
||||
* @throws StorageException thrown if accessing the reviewed flags failed
|
||||
*/
|
||||
Optional<PatchSetWithReviewedFiles> findReviewed(PatchSet.Id psId, Account.Id accountId)
|
||||
throws OrmException;
|
||||
throws StorageException;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.ActionVisitor;
|
||||
import com.google.gerrit.extensions.common.ActionInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
@@ -32,7 +33,6 @@ import com.google.gerrit.extensions.webui.UiAction;
|
||||
import com.google.gerrit.server.CurrentUser;
|
||||
import com.google.gerrit.server.extensions.webui.UiActions;
|
||||
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -70,7 +70,7 @@ public class ActionJson {
|
||||
this.userProvider = userProvider;
|
||||
}
|
||||
|
||||
public Map<String, ActionInfo> format(RevisionResource rsrc) throws OrmException {
|
||||
public Map<String, ActionInfo> format(RevisionResource rsrc) throws StorageException {
|
||||
ChangeInfo changeInfo = null;
|
||||
RevisionInfo revisionInfo = null;
|
||||
List<ActionVisitor> visitors = visitors();
|
||||
@@ -97,7 +97,8 @@ public class ActionJson {
|
||||
}
|
||||
|
||||
public RevisionInfo addRevisionActions(
|
||||
@Nullable ChangeInfo changeInfo, RevisionInfo to, RevisionResource rsrc) throws OrmException {
|
||||
@Nullable ChangeInfo changeInfo, RevisionInfo to, RevisionResource rsrc)
|
||||
throws StorageException {
|
||||
List<ActionVisitor> visitors = visitors();
|
||||
if (!visitors.isEmpty()) {
|
||||
if (changeInfo != null) {
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.client.ReviewerState;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.mail.Address;
|
||||
@@ -44,7 +45,6 @@ import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.io.IOException;
|
||||
@@ -158,7 +158,7 @@ public class AddReviewersOp implements BatchUpdateOp {
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx)
|
||||
throws RestApiException, OrmException, IOException {
|
||||
throws RestApiException, StorageException, IOException {
|
||||
change = ctx.getChange();
|
||||
if (!accountIds.isEmpty()) {
|
||||
if (state == CC) {
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.DeprecatedIdentifierException;
|
||||
import com.google.gerrit.extensions.restapi.Url;
|
||||
import com.google.gerrit.index.IndexConfig;
|
||||
@@ -37,7 +38,6 @@ import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.InternalChangeQuery;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provider;
|
||||
@@ -106,7 +106,7 @@ public class ChangeFinder {
|
||||
this.allowedIdTypes = ImmutableSet.copyOf(configuredChangeIdTypes);
|
||||
}
|
||||
|
||||
public ChangeNotes findOne(String id) throws OrmException {
|
||||
public ChangeNotes findOne(String id) throws StorageException {
|
||||
List<ChangeNotes> ctls = find(id);
|
||||
if (ctls.size() != 1) {
|
||||
return null;
|
||||
@@ -119,14 +119,14 @@ public class ChangeFinder {
|
||||
*
|
||||
* @param id change identifier.
|
||||
* @return possibly-empty list of notes for all matching changes; may or may not be visible.
|
||||
* @throws OrmException if an error occurred querying the database.
|
||||
* @throws StorageException if an error occurred querying the database.
|
||||
*/
|
||||
public List<ChangeNotes> find(String id) throws OrmException {
|
||||
public List<ChangeNotes> find(String id) throws StorageException {
|
||||
try {
|
||||
return find(id, false);
|
||||
} catch (DeprecatedIdentifierException e) {
|
||||
// This can't happen because we don't enforce deprecation
|
||||
throw new OrmException(e);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,11 +137,11 @@ public class ChangeFinder {
|
||||
* @param enforceDeprecation boolean to see if we should throw {@link
|
||||
* DeprecatedIdentifierException} in case the identifier is deprecated
|
||||
* @return possibly-empty list of notes for all matching changes; may or may not be visible.
|
||||
* @throws OrmException if an error occurred querying the database
|
||||
* @throws StorageException if an error occurred querying the database
|
||||
* @throws DeprecatedIdentifierException if the identifier is deprecated.
|
||||
*/
|
||||
public List<ChangeNotes> find(String id, boolean enforceDeprecation)
|
||||
throws OrmException, DeprecatedIdentifierException {
|
||||
throws StorageException, DeprecatedIdentifierException {
|
||||
if (id.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -195,16 +195,16 @@ public class ChangeFinder {
|
||||
}
|
||||
|
||||
private List<ChangeNotes> fromProjectNumber(String project, int changeNumber)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
Change.Id cId = new Change.Id(changeNumber);
|
||||
try {
|
||||
return ImmutableList.of(
|
||||
changeNotesFactory.createChecked(Project.NameKey.parse(project), cId));
|
||||
} catch (NoSuchChangeException e) {
|
||||
return Collections.emptyList();
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
// Distinguish between a RepositoryNotFoundException (project argument invalid) and
|
||||
// other OrmExceptions (failure in the persistence layer).
|
||||
// other StorageExceptions (failure in the persistence layer).
|
||||
if (Throwables.getRootCause(e) instanceof RepositoryNotFoundException) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -212,7 +212,7 @@ public class ChangeFinder {
|
||||
}
|
||||
}
|
||||
|
||||
public ChangeNotes findOne(Change.Id id) throws OrmException {
|
||||
public ChangeNotes findOne(Change.Id id) throws StorageException {
|
||||
List<ChangeNotes> notes = find(id);
|
||||
if (notes.size() != 1) {
|
||||
throw new NoSuchChangeException(id);
|
||||
@@ -220,7 +220,7 @@ public class ChangeFinder {
|
||||
return notes.get(0);
|
||||
}
|
||||
|
||||
public List<ChangeNotes> find(Change.Id id) throws OrmException {
|
||||
public List<ChangeNotes> find(Change.Id id) throws StorageException {
|
||||
String project = changeIdProjectCache.getIfPresent(id);
|
||||
if (project != null) {
|
||||
return fromProjectNumber(project, id.get());
|
||||
@@ -236,7 +236,7 @@ public class ChangeFinder {
|
||||
return asChangeNotes(r);
|
||||
}
|
||||
|
||||
private List<ChangeNotes> asChangeNotes(List<ChangeData> cds) throws OrmException {
|
||||
private List<ChangeNotes> asChangeNotes(List<ChangeData> cds) throws StorageException {
|
||||
List<ChangeNotes> notes = new ArrayList<>(cds.size());
|
||||
if (!indexConfig.separateChangeSubIndexes()) {
|
||||
for (ChangeData cd : cds) {
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.FooterConstants;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.client.ReviewerState;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
@@ -68,7 +69,6 @@ import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.update.InsertChangeOp;
|
||||
import com.google.gerrit.server.update.RepoContext;
|
||||
import com.google.gerrit.server.util.RequestScopePropagator;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.io.IOException;
|
||||
@@ -369,7 +369,7 @@ public class ChangeInserter implements InsertChangeOp {
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx)
|
||||
throws RestApiException, OrmException, IOException, PermissionBackendException,
|
||||
throws RestApiException, StorageException, IOException, PermissionBackendException,
|
||||
ConfigInvalidException {
|
||||
change = ctx.getChange(); // Use defensive copy created by ChangeControl.
|
||||
patchSetInfo =
|
||||
|
||||
@@ -48,6 +48,7 @@ import com.google.gerrit.common.data.SubmitRecord;
|
||||
import com.google.gerrit.common.data.SubmitRecord.Status;
|
||||
import com.google.gerrit.common.data.SubmitRequirement;
|
||||
import com.google.gerrit.common.data.SubmitTypeRecord;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.FixInput;
|
||||
import com.google.gerrit.extensions.client.ListChangesOption;
|
||||
import com.google.gerrit.extensions.client.ReviewerState;
|
||||
@@ -96,7 +97,6 @@ import com.google.gerrit.server.project.RemoveReviewerControl;
|
||||
import com.google.gerrit.server.project.SubmitRuleOptions;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.ChangeData.ChangedLines;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -268,23 +268,23 @@ public class ChangeJson {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ChangeInfo format(ChangeResource rsrc) throws OrmException {
|
||||
public ChangeInfo format(ChangeResource rsrc) throws StorageException {
|
||||
return format(changeDataFactory.create(rsrc.getNotes()));
|
||||
}
|
||||
|
||||
public ChangeInfo format(Change change) throws OrmException {
|
||||
public ChangeInfo format(Change change) throws StorageException {
|
||||
return format(changeDataFactory.create(change));
|
||||
}
|
||||
|
||||
public ChangeInfo format(Project.NameKey project, Change.Id id) throws OrmException {
|
||||
public ChangeInfo format(Project.NameKey project, Change.Id id) throws StorageException {
|
||||
return format(project, id, ChangeInfo::new);
|
||||
}
|
||||
|
||||
public ChangeInfo format(ChangeData cd) throws OrmException {
|
||||
public ChangeInfo format(ChangeData cd) throws StorageException {
|
||||
return format(cd, Optional.empty(), true, ChangeInfo::new);
|
||||
}
|
||||
|
||||
public ChangeInfo format(RevisionResource rsrc) throws OrmException {
|
||||
public ChangeInfo format(RevisionResource rsrc) throws StorageException {
|
||||
ChangeData cd = changeDataFactory.create(rsrc.getNotes());
|
||||
return format(cd, Optional.of(rsrc.getPatchSet().getId()), true, ChangeInfo::new);
|
||||
}
|
||||
@@ -309,7 +309,7 @@ public class ChangeJson {
|
||||
}
|
||||
|
||||
public List<ChangeInfo> format(Collection<ChangeData> in)
|
||||
throws OrmException, PermissionBackendException {
|
||||
throws StorageException, PermissionBackendException {
|
||||
accountLoader = accountLoaderFactory.create(has(DETAILED_ACCOUNTS));
|
||||
ensureLoaded(in);
|
||||
List<ChangeInfo> out = new ArrayList<>(in.size());
|
||||
@@ -321,11 +321,12 @@ public class ChangeJson {
|
||||
}
|
||||
|
||||
public <I extends ChangeInfo> I format(
|
||||
Project.NameKey project, Change.Id id, Supplier<I> changeInfoSupplier) throws OrmException {
|
||||
Project.NameKey project, Change.Id id, Supplier<I> changeInfoSupplier)
|
||||
throws StorageException {
|
||||
ChangeNotes notes;
|
||||
try {
|
||||
notes = notesFactory.createChecked(project, id);
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
if (!has(CHECK)) {
|
||||
throw e;
|
||||
}
|
||||
@@ -367,7 +368,7 @@ public class ChangeJson {
|
||||
Optional<PatchSet.Id> limitToPsId,
|
||||
boolean fillAccountLoader,
|
||||
Supplier<I> changeInfoSupplier)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
try {
|
||||
if (fillAccountLoader) {
|
||||
accountLoader = accountLoaderFactory.create(has(DETAILED_ACCOUNTS));
|
||||
@@ -378,19 +379,19 @@ public class ChangeJson {
|
||||
return toChangeInfo(cd, limitToPsId, changeInfoSupplier);
|
||||
} catch (PatchListNotAvailableException
|
||||
| GpgException
|
||||
| OrmException
|
||||
| StorageException
|
||||
| IOException
|
||||
| PermissionBackendException
|
||||
| RuntimeException e) {
|
||||
if (!has(CHECK)) {
|
||||
Throwables.throwIfInstanceOf(e, OrmException.class);
|
||||
throw new OrmException(e);
|
||||
Throwables.throwIfInstanceOf(e, StorageException.class);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
return checkOnly(cd, changeInfoSupplier);
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureLoaded(Iterable<ChangeData> all) throws OrmException {
|
||||
private void ensureLoaded(Iterable<ChangeData> all) throws StorageException {
|
||||
if (lazyLoad) {
|
||||
ChangeData.ensureChangeLoaded(all);
|
||||
if (has(ALL_REVISIONS)) {
|
||||
@@ -425,7 +426,7 @@ public class ChangeJson {
|
||||
try {
|
||||
ensureLoaded(Collections.singleton(cd));
|
||||
changeInfos.add(format(cd, Optional.empty(), false, ChangeInfo::new));
|
||||
} catch (OrmException | RuntimeException e) {
|
||||
} catch (StorageException | RuntimeException e) {
|
||||
logger.atWarning().withCause(e).log(
|
||||
"Omitting corrupt change %s from results", cd.getId());
|
||||
}
|
||||
@@ -438,7 +439,7 @@ public class ChangeJson {
|
||||
ChangeNotes notes;
|
||||
try {
|
||||
notes = cd.notes();
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
String msg = "Error loading change";
|
||||
logger.atWarning().withCause(e).log(msg + " %s", cd.getId());
|
||||
I info = changeInfoSupplier.get();
|
||||
@@ -477,8 +478,8 @@ public class ChangeJson {
|
||||
|
||||
private <I extends ChangeInfo> I toChangeInfo(
|
||||
ChangeData cd, Optional<PatchSet.Id> limitToPsId, Supplier<I> changeInfoSupplier)
|
||||
throws PatchListNotAvailableException, GpgException, OrmException, PermissionBackendException,
|
||||
IOException {
|
||||
throws PatchListNotAvailableException, GpgException, StorageException,
|
||||
PermissionBackendException, IOException {
|
||||
try (Timer0.Context ignored = metrics.toChangeInfoLatency.start()) {
|
||||
return toChangeInfoImpl(cd, limitToPsId, changeInfoSupplier);
|
||||
}
|
||||
@@ -486,8 +487,8 @@ public class ChangeJson {
|
||||
|
||||
private <I extends ChangeInfo> I toChangeInfoImpl(
|
||||
ChangeData cd, Optional<PatchSet.Id> limitToPsId, Supplier<I> changeInfoSupplier)
|
||||
throws PatchListNotAvailableException, GpgException, OrmException, PermissionBackendException,
|
||||
IOException {
|
||||
throws PatchListNotAvailableException, GpgException, StorageException,
|
||||
PermissionBackendException, IOException {
|
||||
I out = changeInfoSupplier.get();
|
||||
CurrentUser user = userProvider.get();
|
||||
|
||||
@@ -638,7 +639,7 @@ public class ChangeJson {
|
||||
return reviewerMap;
|
||||
}
|
||||
|
||||
private Collection<ReviewerUpdateInfo> reviewerUpdates(ChangeData cd) throws OrmException {
|
||||
private Collection<ReviewerUpdateInfo> reviewerUpdates(ChangeData cd) throws StorageException {
|
||||
List<ReviewerStatusUpdate> reviewerUpdates = cd.reviewerUpdates();
|
||||
List<ReviewerUpdateInfo> result = new ArrayList<>(reviewerUpdates.size());
|
||||
for (ReviewerStatusUpdate c : reviewerUpdates) {
|
||||
@@ -656,7 +657,7 @@ public class ChangeJson {
|
||||
return SubmitRecord.allRecordsOK(cd.submitRecords(SUBMIT_RULE_OPTIONS_STRICT));
|
||||
}
|
||||
|
||||
private void setSubmitter(ChangeData cd, ChangeInfo out) throws OrmException {
|
||||
private void setSubmitter(ChangeData cd, ChangeInfo out) throws StorageException {
|
||||
Optional<PatchSetApproval> s = cd.getSubmitApproval();
|
||||
if (!s.isPresent()) {
|
||||
return;
|
||||
@@ -665,7 +666,7 @@ public class ChangeJson {
|
||||
out.submitter = accountLoader.get(s.get().getAccountId());
|
||||
}
|
||||
|
||||
private Collection<ChangeMessageInfo> messages(ChangeData cd) throws OrmException {
|
||||
private Collection<ChangeMessageInfo> messages(ChangeData cd) throws StorageException {
|
||||
List<ChangeMessage> messages = cmUtil.byChange(cd.notes());
|
||||
if (messages.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
@@ -679,7 +680,7 @@ public class ChangeJson {
|
||||
}
|
||||
|
||||
private Collection<AccountInfo> removableReviewers(ChangeData cd, ChangeInfo out)
|
||||
throws PermissionBackendException, OrmException {
|
||||
throws PermissionBackendException, StorageException {
|
||||
// Although this is called removableReviewers, this method also determines
|
||||
// which CCs are removable.
|
||||
//
|
||||
@@ -768,7 +769,7 @@ public class ChangeJson {
|
||||
}
|
||||
|
||||
private Map<PatchSet.Id, PatchSet> loadPatchSets(ChangeData cd, Optional<PatchSet.Id> limitToPsId)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
Collection<PatchSet> src;
|
||||
if (has(ALL_REVISIONS) || has(MESSAGES)) {
|
||||
src = cd.patchSets();
|
||||
@@ -777,12 +778,12 @@ public class ChangeJson {
|
||||
if (limitToPsId.isPresent()) {
|
||||
ps = cd.patchSet(limitToPsId.get());
|
||||
if (ps == null) {
|
||||
throw new OrmException("missing patch set " + limitToPsId.get());
|
||||
throw new StorageException("missing patch set " + limitToPsId.get());
|
||||
}
|
||||
} else {
|
||||
ps = cd.currentPatchSet();
|
||||
if (ps == null) {
|
||||
throw new OrmException("missing current patch set for change " + cd.getId());
|
||||
throw new StorageException("missing current patch set for change " + cd.getId());
|
||||
}
|
||||
}
|
||||
src = Collections.singletonList(ps);
|
||||
@@ -800,7 +801,7 @@ public class ChangeJson {
|
||||
* lazyload}.
|
||||
*/
|
||||
private PermissionBackend.ForChange permissionBackendForChange(CurrentUser user, ChangeData cd)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
PermissionBackend.WithUser withUser = permissionBackend.user(user);
|
||||
return lazyLoad
|
||||
? withUser.change(cd)
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.google.common.cache.Weigher;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.client.ChangeKind;
|
||||
import com.google.gerrit.proto.Protos;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
@@ -38,7 +39,6 @@ import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.git.InMemoryInserter;
|
||||
import com.google.gerrit.server.git.MergeUtil;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.name.Named;
|
||||
@@ -392,7 +392,7 @@ public class ChangeKindCacheImpl implements ChangeKindCache {
|
||||
ObjectId.fromString(priorPs.getRevision().get()),
|
||||
ObjectId.fromString(patch.getRevision().get()));
|
||||
}
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
// Do nothing; assume we have a complex change
|
||||
logger.atWarning().withCause(e).log(
|
||||
"Unable to get change kind for patchSet %s of change %s",
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.hash.Hasher;
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.RestResource;
|
||||
import com.google.gerrit.extensions.restapi.RestResource.HasETag;
|
||||
import com.google.gerrit.extensions.restapi.RestView;
|
||||
@@ -39,7 +40,6 @@ import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gerrit.server.permissions.PermissionBackend;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.project.ProjectState;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
@@ -159,7 +159,7 @@ public class ChangeResource implements RestResource, HasETag {
|
||||
// message is automatically added as reviewer. Hence if we include removed reviewers we can
|
||||
// be sure that we have all accounts that posted messages on the change.
|
||||
accounts.addAll(approvalUtil.getReviewers(notes).all());
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
// This ETag will be invalidated if it loads next time.
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ public class ChangeResource implements RestResource, HasETag {
|
||||
ObjectId noteId;
|
||||
try {
|
||||
noteId = notes.loadRevision();
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
noteId = null; // This ETag will be invalidated if it loads next time.
|
||||
}
|
||||
hashObjectId(h, noteId, buf);
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.google.common.collect.SetMultimap;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.FooterConstants;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.FixInput;
|
||||
import com.google.gerrit.extensions.common.ProblemInfo;
|
||||
import com.google.gerrit.extensions.common.ProblemInfo.Status;
|
||||
@@ -55,7 +56,6 @@ import com.google.gerrit.server.update.RepoContext;
|
||||
import com.google.gerrit.server.update.RetryHelper;
|
||||
import com.google.gerrit.server.update.UpdateException;
|
||||
import com.google.gerrit.server.util.time.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import java.io.IOException;
|
||||
@@ -232,7 +232,7 @@ public class ConsistencyChecker {
|
||||
problem(
|
||||
String.format("Current patch set %d not found", change().currentPatchSetId().get()));
|
||||
}
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
error("Failed to look up current patch set", e);
|
||||
}
|
||||
}
|
||||
@@ -256,7 +256,7 @@ public class ConsistencyChecker {
|
||||
try {
|
||||
// Iterate in descending order.
|
||||
all = PS_ID_ORDER.sortedCopy(psUtil.byChange(notes));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
return error("Failed to look up patch sets", e);
|
||||
}
|
||||
patchSetsBySha = MultimapBuilder.hashKeys(all.size()).treeSetValues(PS_ID_ORDER).build();
|
||||
@@ -425,7 +425,7 @@ public class ConsistencyChecker {
|
||||
if (!c.getDest().equals(change().getDest())) {
|
||||
continue;
|
||||
}
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
warn(e);
|
||||
// Include this patch set; should cause an error below, which is good.
|
||||
}
|
||||
@@ -556,7 +556,7 @@ public class ConsistencyChecker {
|
||||
notes = notesFactory.createChecked(inserter.getChange());
|
||||
insertPatchSetProblem.status = Status.FIXED;
|
||||
insertPatchSetProblem.outcome = "Inserted as patch set " + psId.get();
|
||||
} catch (OrmException | IOException | UpdateException | RestApiException e) {
|
||||
} catch (StorageException | IOException | UpdateException | RestApiException e) {
|
||||
warn(e);
|
||||
for (ProblemInfo pi : currProblems) {
|
||||
pi.status = Status.FIX_FAILED;
|
||||
@@ -574,7 +574,7 @@ public class ConsistencyChecker {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx) throws OrmException {
|
||||
public boolean updateChange(ChangeContext ctx) throws StorageException {
|
||||
ctx.getChange().setStatus(Change.Status.MERGED);
|
||||
ctx.getUpdate(ctx.getChange().currentPatchSetId()).fixStatus(Change.Status.MERGED);
|
||||
p.status = Status.FIXED;
|
||||
@@ -673,9 +673,9 @@ public class ConsistencyChecker {
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx)
|
||||
throws OrmException, PatchSetInfoNotAvailableException {
|
||||
throws StorageException, PatchSetInfoNotAvailableException {
|
||||
// Delete dangling key references.
|
||||
accountPatchReviewStore.run(s -> s.clearReviewed(psId), OrmException.class);
|
||||
accountPatchReviewStore.run(s -> s.clearReviewed(psId), StorageException.class);
|
||||
|
||||
// For NoteDb setting the state to deleted is sufficient to filter everything out.
|
||||
ctx.getUpdate(psId).setPatchSetState(PatchSetState.DELETED);
|
||||
@@ -706,7 +706,8 @@ public class ConsistencyChecker {
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx)
|
||||
throws OrmException, PatchSetInfoNotAvailableException, NoPatchSetsWouldRemainException {
|
||||
throws StorageException, PatchSetInfoNotAvailableException,
|
||||
NoPatchSetsWouldRemainException {
|
||||
if (!toDelete.contains(ctx.getChange().currentPatchSetId())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.server.change;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.MethodNotAllowedException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
@@ -27,7 +28,6 @@ import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.RepoContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.io.IOException;
|
||||
@@ -67,7 +67,7 @@ public class DeleteChangeOp implements BatchUpdateOp {
|
||||
// fail gracefully if the second delete fails, but fortunately that's not what happens.
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx)
|
||||
throws RestApiException, OrmException, IOException {
|
||||
throws RestApiException, StorageException, IOException {
|
||||
Collection<PatchSet> patchSets = psUtil.byChange(ctx.getNotes());
|
||||
|
||||
ensureDeletable(ctx, id, patchSets);
|
||||
@@ -107,9 +107,9 @@ public class DeleteChangeOp implements BatchUpdateOp {
|
||||
}
|
||||
|
||||
private void cleanUpReferences(ChangeContext ctx, Change.Id id, Collection<PatchSet> patchSets)
|
||||
throws OrmException, NoSuchChangeException {
|
||||
throws StorageException, NoSuchChangeException {
|
||||
for (PatchSet ps : patchSets) {
|
||||
accountPatchReviewStore.run(s -> s.clearReviewed(ps.getId()), OrmException.class);
|
||||
accountPatchReviewStore.run(s -> s.clearReviewed(ps.getId()), StorageException.class);
|
||||
}
|
||||
|
||||
// Non-atomic operation on Accounts table; not much we can do to make it
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.change;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.mail.Address;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
||||
@@ -24,7 +25,6 @@ import com.google.gerrit.server.mail.send.DeleteReviewerSender;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.util.Collections;
|
||||
@@ -50,7 +50,7 @@ public class DeleteReviewerByEmailOp implements BatchUpdateOp {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx) throws OrmException {
|
||||
public boolean updateChange(ChangeContext ctx) throws StorageException {
|
||||
change = ctx.getChange();
|
||||
PatchSet.Id psId = ctx.getChange().currentPatchSetId();
|
||||
String msg = "Removed reviewer " + reviewer;
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.exceptions.EmailException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.DeleteReviewerInput;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
@@ -43,7 +44,6 @@ import com.google.gerrit.server.project.RemoveReviewerControl;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
@@ -108,7 +108,7 @@ public class DeleteReviewerOp implements BatchUpdateOp {
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx)
|
||||
throws AuthException, ResourceNotFoundException, OrmException, PermissionBackendException,
|
||||
throws AuthException, ResourceNotFoundException, StorageException, PermissionBackendException,
|
||||
IOException {
|
||||
Account.Id reviewerId = reviewer.getAccount().getId();
|
||||
// Check of removing this reviewer (even if there is no vote processed by the loop below) is OK
|
||||
@@ -195,7 +195,7 @@ public class DeleteReviewerOp implements BatchUpdateOp {
|
||||
}
|
||||
|
||||
private Iterable<PatchSetApproval> approvals(ChangeContext ctx, Account.Id accountId)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
Iterable<PatchSetApproval> approvals;
|
||||
approvals = approvalsUtil.byChange(ctx.getNotes()).values();
|
||||
return Iterables.filter(approvals, psa -> accountId.equals(psa.getAccountId()));
|
||||
|
||||
@@ -36,6 +36,7 @@ import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.common.data.LabelValue;
|
||||
import com.google.gerrit.common.data.SubmitRecord;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.client.ListChangesOption;
|
||||
import com.google.gerrit.extensions.common.ApprovalInfo;
|
||||
import com.google.gerrit.extensions.common.LabelInfo;
|
||||
@@ -51,7 +52,6 @@ import com.google.gerrit.server.permissions.LabelPermission;
|
||||
import com.google.gerrit.server.permissions.PermissionBackend;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.sql.Timestamp;
|
||||
@@ -100,7 +100,7 @@ public class LabelsJson {
|
||||
*/
|
||||
Map<String, LabelInfo> labelsFor(
|
||||
AccountLoader accountLoader, ChangeData cd, boolean standard, boolean detailed)
|
||||
throws OrmException, PermissionBackendException {
|
||||
throws StorageException, PermissionBackendException {
|
||||
if (!standard && !detailed) {
|
||||
return null;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public class LabelsJson {
|
||||
|
||||
/** Returns all labels that the provided user has permission to vote on. */
|
||||
Map<String, Collection<String>> permittedLabels(Account.Id filterApprovalsBy, ChangeData cd)
|
||||
throws OrmException, PermissionBackendException {
|
||||
throws StorageException, PermissionBackendException {
|
||||
boolean isMerged = cd.change().isMerged();
|
||||
LabelTypes labelTypes = cd.getLabelTypes();
|
||||
Map<String, LabelType> toCheck = new HashMap<>();
|
||||
@@ -194,7 +194,7 @@ public class LabelsJson {
|
||||
LabelTypes labelTypes,
|
||||
boolean standard,
|
||||
boolean detailed)
|
||||
throws OrmException, PermissionBackendException {
|
||||
throws StorageException, PermissionBackendException {
|
||||
Map<String, LabelWithStatus> labels = initLabels(accountLoader, cd, labelTypes, standard);
|
||||
if (detailed) {
|
||||
setAllApprovals(accountLoader, cd, labels);
|
||||
@@ -253,7 +253,7 @@ public class LabelsJson {
|
||||
}
|
||||
|
||||
private Map<String, Short> currentLabels(Account.Id accountId, ChangeData cd)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
Map<String, Short> result = new HashMap<>();
|
||||
for (PatchSetApproval psa :
|
||||
approvalsUtil.byPatchSetUser(
|
||||
@@ -273,7 +273,7 @@ public class LabelsJson {
|
||||
LabelTypes labelTypes,
|
||||
boolean standard,
|
||||
boolean detailed)
|
||||
throws OrmException, PermissionBackendException {
|
||||
throws StorageException, PermissionBackendException {
|
||||
Set<Account.Id> allUsers = new HashSet<>();
|
||||
if (detailed) {
|
||||
// Users expect to see all reviewers on closed changes, even if they
|
||||
@@ -431,7 +431,7 @@ public class LabelsJson {
|
||||
|
||||
private void setAllApprovals(
|
||||
AccountLoader accountLoader, ChangeData cd, Map<String, LabelWithStatus> labels)
|
||||
throws OrmException, PermissionBackendException {
|
||||
throws StorageException, PermissionBackendException {
|
||||
checkState(
|
||||
!cd.change().isMerged(),
|
||||
"should not call setAllApprovals on %s change",
|
||||
@@ -500,7 +500,7 @@ public class LabelsJson {
|
||||
* lazyload}.
|
||||
*/
|
||||
private PermissionBackend.ForChange permissionBackendForChange(Account.Id user, ChangeData cd)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
PermissionBackend.WithUser withUser = permissionBackend.absentUser(user);
|
||||
return lazyLoad
|
||||
? withUser.change(cd)
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.google.auto.value.AutoValue;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSetMultimap;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyInfo;
|
||||
import com.google.gerrit.extensions.api.changes.RecipientType;
|
||||
@@ -28,7 +29,6 @@ import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.server.account.AccountResolver;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -81,7 +81,7 @@ public class NotifyResolver {
|
||||
|
||||
public Result resolve(
|
||||
NotifyHandling handling, @Nullable Map<RecipientType, NotifyInfo> notifyDetails)
|
||||
throws BadRequestException, OrmException, IOException, ConfigInvalidException {
|
||||
throws BadRequestException, StorageException, IOException, ConfigInvalidException {
|
||||
requireNonNull(handling);
|
||||
ImmutableSetMultimap.Builder<RecipientType, Account.Id> b = ImmutableSetMultimap.builder();
|
||||
if (notifyDetails != null) {
|
||||
@@ -93,7 +93,7 @@ public class NotifyResolver {
|
||||
}
|
||||
|
||||
private ImmutableList<Account.Id> find(@Nullable List<String> inputs)
|
||||
throws OrmException, BadRequestException, IOException, ConfigInvalidException {
|
||||
throws StorageException, BadRequestException, IOException, ConfigInvalidException {
|
||||
if (inputs == null || inputs.isEmpty()) {
|
||||
return ImmutableList.of();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
@@ -49,7 +50,6 @@ import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.update.RepoContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.io.IOException;
|
||||
@@ -187,7 +187,7 @@ public class PatchSetInserter implements BatchUpdateOp {
|
||||
|
||||
@Override
|
||||
public void updateRepo(RepoContext ctx)
|
||||
throws AuthException, ResourceConflictException, IOException, OrmException,
|
||||
throws AuthException, ResourceConflictException, IOException, StorageException,
|
||||
PermissionBackendException {
|
||||
validate(ctx);
|
||||
ctx.addRefUpdate(ObjectId.zeroId(), commitId, getPatchSetId().toRefName());
|
||||
@@ -195,7 +195,7 @@ public class PatchSetInserter implements BatchUpdateOp {
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx)
|
||||
throws ResourceConflictException, OrmException, IOException {
|
||||
throws ResourceConflictException, StorageException, IOException {
|
||||
change = ctx.getChange();
|
||||
ChangeUpdate update = ctx.getUpdate(psId);
|
||||
update.setSubjectForCommit("Create patch set " + psId.get());
|
||||
@@ -272,7 +272,7 @@ public class PatchSetInserter implements BatchUpdateOp {
|
||||
|
||||
private void validate(RepoContext ctx)
|
||||
throws AuthException, ResourceConflictException, IOException, PermissionBackendException,
|
||||
OrmException {
|
||||
StorageException {
|
||||
// Not allowed to create a new patch set if the current patch set is locked.
|
||||
psUtil.checkPatchSetNotLocked(origNotes);
|
||||
|
||||
|
||||
@@ -14,12 +14,12 @@
|
||||
|
||||
package com.google.gerrit.server.change;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.server.git.PureRevertCache;
|
||||
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -38,7 +38,7 @@ public class PureRevert {
|
||||
}
|
||||
|
||||
public boolean get(ChangeNotes notes, Optional<String> claimedOriginal)
|
||||
throws OrmException, IOException, BadRequestException, ResourceConflictException {
|
||||
throws StorageException, IOException, BadRequestException, ResourceConflictException {
|
||||
PatchSet currentPatchSet = notes.getCurrentPatchSet();
|
||||
if (currentPatchSet == null) {
|
||||
throw new ResourceConflictException("current revision is missing");
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.change;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.MergeConflictException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
@@ -37,7 +38,6 @@ import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.update.RepoContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.io.IOException;
|
||||
@@ -149,7 +149,7 @@ public class RebaseChangeOp implements BatchUpdateOp {
|
||||
@Override
|
||||
public void updateRepo(RepoContext ctx)
|
||||
throws MergeConflictException, InvalidChangeOperationException, RestApiException, IOException,
|
||||
OrmException, NoSuchChangeException, PermissionBackendException {
|
||||
StorageException, NoSuchChangeException, PermissionBackendException {
|
||||
// Ok that originalPatchSet was not read in a transaction, since we just
|
||||
// need its revision.
|
||||
RevId oldRev = originalPatchSet.getRevision();
|
||||
@@ -214,14 +214,14 @@ public class RebaseChangeOp implements BatchUpdateOp {
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx)
|
||||
throws ResourceConflictException, OrmException, IOException {
|
||||
throws ResourceConflictException, StorageException, IOException {
|
||||
boolean ret = patchSetInserter.updateChange(ctx);
|
||||
rebasedPatchSet = patchSetInserter.getPatchSet();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postUpdate(Context ctx) throws OrmException {
|
||||
public void postUpdate(Context ctx) throws StorageException {
|
||||
patchSetInserter.postUpdate(ctx);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.google.gerrit.server.change;
|
||||
import com.google.auto.value.AutoValue;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||
@@ -28,7 +29,6 @@ import com.google.gerrit.server.PatchSetUtil;
|
||||
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.InternalChangeQuery;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import java.io.IOException;
|
||||
@@ -62,7 +62,7 @@ public class RebaseUtil {
|
||||
return true;
|
||||
} catch (RestApiException e) {
|
||||
return false;
|
||||
} catch (OrmException | IOException e) {
|
||||
} catch (StorageException | IOException e) {
|
||||
logger.atWarning().withCause(e).log(
|
||||
"Error checking if patch set %s on %s can be rebased", patchSet.getId(), dest);
|
||||
return false;
|
||||
@@ -83,7 +83,7 @@ public class RebaseUtil {
|
||||
public abstract PatchSet patchSet();
|
||||
}
|
||||
|
||||
public Base parseBase(RevisionResource rsrc, String base) throws OrmException {
|
||||
public Base parseBase(RevisionResource rsrc, String base) throws StorageException {
|
||||
// Try parsing the base as a ref string.
|
||||
PatchSet.Id basePatchSetId = PatchSet.Id.fromRef(base);
|
||||
if (basePatchSetId != null) {
|
||||
@@ -119,7 +119,7 @@ public class RebaseUtil {
|
||||
return ret;
|
||||
}
|
||||
|
||||
private ChangeNotes notesFor(RevisionResource rsrc, Change.Id id) throws OrmException {
|
||||
private ChangeNotes notesFor(RevisionResource rsrc, Change.Id id) throws StorageException {
|
||||
if (rsrc.getChange().getId().equals(id)) {
|
||||
return rsrc.getNotes();
|
||||
}
|
||||
@@ -139,11 +139,11 @@ public class RebaseUtil {
|
||||
* @return the commit onto which the patch set should be rebased.
|
||||
* @throws RestApiException if rebase is not possible.
|
||||
* @throws IOException if accessing the repository fails.
|
||||
* @throws OrmException if accessing the database fails.
|
||||
* @throws StorageException if accessing the database fails.
|
||||
*/
|
||||
public ObjectId findBaseRevision(
|
||||
PatchSet patchSet, Branch.NameKey destBranch, Repository git, RevWalk rw)
|
||||
throws RestApiException, IOException, OrmException {
|
||||
throws RestApiException, IOException, StorageException {
|
||||
String baseRev = null;
|
||||
RevCommit commit = rw.parseCommit(ObjectId.fromString(patchSet.getRevision().get()));
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.google.common.collect.Streams;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.GroupDescription;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.AddReviewerInput;
|
||||
import com.google.gerrit.extensions.api.changes.AddReviewerResult;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
@@ -68,7 +69,6 @@ import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import java.io.IOException;
|
||||
@@ -188,14 +188,14 @@ public class ReviewerAdder {
|
||||
* @return handle describing the addition operation. If the {@code op} field is present, this
|
||||
* operation may be added to a {@code BatchUpdate}. Otherwise, the {@code error} field
|
||||
* contains information about an error that occurred
|
||||
* @throws OrmException
|
||||
* @throws StorageException
|
||||
* @throws IOException
|
||||
* @throws PermissionBackendException
|
||||
* @throws ConfigInvalidException
|
||||
*/
|
||||
public ReviewerAddition prepare(
|
||||
ChangeNotes notes, CurrentUser user, AddReviewerInput input, boolean allowGroup)
|
||||
throws OrmException, IOException, PermissionBackendException, ConfigInvalidException {
|
||||
throws StorageException, IOException, PermissionBackendException, ConfigInvalidException {
|
||||
requireNonNull(input.reviewer);
|
||||
boolean confirmed = input.confirmed();
|
||||
boolean allowByEmail =
|
||||
@@ -245,7 +245,7 @@ public class ReviewerAdder {
|
||||
@Nullable
|
||||
private ReviewerAddition addByAccountId(
|
||||
AddReviewerInput input, ChangeNotes notes, CurrentUser user)
|
||||
throws OrmException, PermissionBackendException, IOException, ConfigInvalidException {
|
||||
throws StorageException, PermissionBackendException, IOException, ConfigInvalidException {
|
||||
IdentifiedUser reviewerUser;
|
||||
boolean exactMatchFound = false;
|
||||
try {
|
||||
@@ -449,7 +449,7 @@ public class ReviewerAdder {
|
||||
: ImmutableSet.of();
|
||||
}
|
||||
|
||||
public void gatherResults(ChangeData cd) throws OrmException, PermissionBackendException {
|
||||
public void gatherResults(ChangeData cd) throws StorageException, PermissionBackendException {
|
||||
checkState(op != null, "addition did not result in an update op");
|
||||
checkState(op.getResult() != null, "op did not return a result");
|
||||
|
||||
@@ -510,7 +510,7 @@ public class ReviewerAdder {
|
||||
CurrentUser user,
|
||||
Iterable<? extends AddReviewerInput> inputs,
|
||||
boolean allowGroup)
|
||||
throws OrmException, IOException, PermissionBackendException, ConfigInvalidException {
|
||||
throws StorageException, IOException, PermissionBackendException, ConfigInvalidException {
|
||||
// Process CC ops before reviewer ops, so a user that appears in both lists ends up as a
|
||||
// reviewer; the last call to ChangeUpdate#putReviewer wins. This can happen if the caller
|
||||
// specifies the same string twice, or less obviously if they specify multiple groups with
|
||||
@@ -558,7 +558,7 @@ public class ReviewerAdder {
|
||||
// We never call updateRepo on the addition ops, which is only ok because it's a no-op.
|
||||
|
||||
public void updateChange(ChangeContext ctx, PatchSet patchSet)
|
||||
throws OrmException, RestApiException, IOException {
|
||||
throws StorageException, RestApiException, IOException {
|
||||
for (ReviewerAddition addition : additions()) {
|
||||
addition.op.setPatchSet(patchSet);
|
||||
addition.op.updateChange(ctx);
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.google.common.collect.Lists;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.common.data.SubmitRecord;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.ReviewerInfo;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.mail.Address;
|
||||
@@ -35,7 +36,6 @@ import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gerrit.server.project.SubmitRuleEvaluator;
|
||||
import com.google.gerrit.server.project.SubmitRuleOptions;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.util.Collection;
|
||||
@@ -65,7 +65,7 @@ public class ReviewerJson {
|
||||
}
|
||||
|
||||
public List<ReviewerInfo> format(Collection<ReviewerResource> rsrcs)
|
||||
throws OrmException, PermissionBackendException {
|
||||
throws StorageException, PermissionBackendException {
|
||||
List<ReviewerInfo> infos = Lists.newArrayListWithCapacity(rsrcs.size());
|
||||
AccountLoader loader = accountLoaderFactory.create(true);
|
||||
ChangeData cd = null;
|
||||
@@ -89,12 +89,12 @@ public class ReviewerJson {
|
||||
}
|
||||
|
||||
public List<ReviewerInfo> format(ReviewerResource rsrc)
|
||||
throws OrmException, PermissionBackendException {
|
||||
throws StorageException, PermissionBackendException {
|
||||
return format(ImmutableList.of(rsrc));
|
||||
}
|
||||
|
||||
public ReviewerInfo format(ReviewerInfo out, Account.Id reviewerAccountId, ChangeData cd)
|
||||
throws OrmException, PermissionBackendException {
|
||||
throws StorageException, PermissionBackendException {
|
||||
PatchSet.Id psId = cd.change().currentPatchSetId();
|
||||
return format(
|
||||
out,
|
||||
@@ -108,7 +108,7 @@ public class ReviewerJson {
|
||||
Account.Id reviewerAccountId,
|
||||
ChangeData cd,
|
||||
Iterable<PatchSetApproval> approvals)
|
||||
throws OrmException, PermissionBackendException {
|
||||
throws StorageException, PermissionBackendException {
|
||||
LabelTypes labelTypes = cd.getLabelTypes();
|
||||
|
||||
out.approvals = new TreeMap<>(labelTypes.nameComparator());
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.client.ListChangesOption;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.extensions.common.CommitInfo;
|
||||
@@ -65,7 +66,6 @@ import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.project.ProjectState;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
@@ -155,7 +155,7 @@ public class RevisionJson {
|
||||
* depending on the options provided when constructing this instance.
|
||||
*/
|
||||
public RevisionInfo getRevisionInfo(ChangeData cd, PatchSet in)
|
||||
throws PatchListNotAvailableException, GpgException, OrmException, IOException,
|
||||
throws PatchListNotAvailableException, GpgException, StorageException, IOException,
|
||||
PermissionBackendException {
|
||||
AccountLoader accountLoader = accountLoaderFactory.create(has(DETAILED_ACCOUNTS));
|
||||
try (Repository repo = openRepoIfNecessary(cd.project());
|
||||
@@ -213,7 +213,7 @@ public class RevisionJson {
|
||||
Map<PatchSet.Id, PatchSet> map,
|
||||
Optional<PatchSet.Id> limitToPsId,
|
||||
ChangeInfo changeInfo)
|
||||
throws PatchListNotAvailableException, GpgException, OrmException, IOException,
|
||||
throws PatchListNotAvailableException, GpgException, StorageException, IOException,
|
||||
PermissionBackendException {
|
||||
Map<String, RevisionInfo> res = new LinkedHashMap<>();
|
||||
try (Repository repo = openRepoIfNecessary(cd.project());
|
||||
@@ -239,7 +239,7 @@ public class RevisionJson {
|
||||
}
|
||||
|
||||
private Map<String, FetchInfo> makeFetchMap(ChangeData cd, PatchSet in)
|
||||
throws PermissionBackendException, OrmException, IOException {
|
||||
throws PermissionBackendException, StorageException, IOException {
|
||||
Map<String, FetchInfo> r = new LinkedHashMap<>();
|
||||
for (Extension<DownloadScheme> e : downloadSchemes) {
|
||||
String schemeName = e.getExportName();
|
||||
@@ -275,7 +275,7 @@ public class RevisionJson {
|
||||
@Nullable RevWalk rw,
|
||||
boolean fillCommit,
|
||||
@Nullable ChangeInfo changeInfo)
|
||||
throws PatchListNotAvailableException, GpgException, OrmException, IOException,
|
||||
throws PatchListNotAvailableException, GpgException, StorageException, IOException,
|
||||
PermissionBackendException {
|
||||
Change c = cd.change();
|
||||
RevisionInfo out = new RevisionInfo();
|
||||
@@ -350,14 +350,14 @@ public class RevisionJson {
|
||||
* lazyload}.
|
||||
*/
|
||||
private PermissionBackend.ForChange permissionBackendForChange(
|
||||
PermissionBackend.WithUser withUser, ChangeData cd) throws OrmException {
|
||||
PermissionBackend.WithUser withUser, ChangeData cd) throws StorageException {
|
||||
return lazyLoad
|
||||
? withUser.change(cd)
|
||||
: withUser.indexedChange(cd, notesFactory.createFromIndexedChange(cd.change()));
|
||||
}
|
||||
|
||||
private boolean isWorldReadable(ChangeData cd)
|
||||
throws OrmException, PermissionBackendException, IOException {
|
||||
throws StorageException, PermissionBackendException, IOException {
|
||||
try {
|
||||
permissionBackendForChange(permissionBackend.user(anonymous), cd)
|
||||
.check(ChangePermission.READ);
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.google.gerrit.server.change;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.extensions.restapi.RestApiException;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
@@ -32,7 +33,6 @@ import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.validators.AssigneeValidationListener;
|
||||
import com.google.gerrit.server.validators.ValidationException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
@@ -74,7 +74,7 @@ public class SetAssigneeOp implements BatchUpdateOp {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx) throws OrmException, RestApiException {
|
||||
public boolean updateChange(ChangeContext ctx) throws StorageException, RestApiException {
|
||||
change = ctx.getChange();
|
||||
if (newAssignee.getAccountId().equals(change.getAssignee())) {
|
||||
return false;
|
||||
@@ -117,7 +117,7 @@ public class SetAssigneeOp implements BatchUpdateOp {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postUpdate(Context ctx) throws OrmException {
|
||||
public void postUpdate(Context ctx) throws StorageException {
|
||||
try {
|
||||
SetAssigneeSender cm =
|
||||
setAssigneeSenderFactory.create(
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.HashtagsInput;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
@@ -38,7 +39,6 @@ import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.validators.HashtagValidationListener;
|
||||
import com.google.gerrit.server.validators.ValidationException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.io.IOException;
|
||||
@@ -82,7 +82,7 @@ public class SetHashtagsOp implements BatchUpdateOp {
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx)
|
||||
throws AuthException, BadRequestException, MethodNotAllowedException, OrmException,
|
||||
throws AuthException, BadRequestException, MethodNotAllowedException, StorageException,
|
||||
IOException {
|
||||
if (input == null || (input.add == null && input.remove == null)) {
|
||||
updatedHashtags = ImmutableSortedSet.of();
|
||||
@@ -146,7 +146,7 @@ public class SetHashtagsOp implements BatchUpdateOp {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postUpdate(Context ctx) throws OrmException {
|
||||
public void postUpdate(Context ctx) throws StorageException {
|
||||
if (updated() && fireEvent) {
|
||||
hashtagsEdited.fire(
|
||||
change, ctx.getAccount(), updatedHashtags, toAdd, toRemove, ctx.getWhen());
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.change;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
@@ -30,7 +31,6 @@ import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
@@ -75,7 +75,7 @@ public class SetPrivateOp implements BatchUpdateOp {
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx)
|
||||
throws ResourceConflictException, OrmException, BadRequestException {
|
||||
throws ResourceConflictException, StorageException, BadRequestException {
|
||||
change = ctx.getChange();
|
||||
if (ctx.getChange().isPrivate() == isPrivate) {
|
||||
// No-op
|
||||
|
||||
@@ -24,11 +24,11 @@ import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.MultimapBuilder;
|
||||
import com.google.common.collect.Ordering;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.git.GitRepositoryManager;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayDeque;
|
||||
@@ -73,7 +73,7 @@ public class WalkSorter {
|
||||
}
|
||||
try {
|
||||
return in.get(0).data().change().getProject();
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
});
|
||||
@@ -98,7 +98,7 @@ public class WalkSorter {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Iterable<PatchSetData> sort(Iterable<ChangeData> in) throws OrmException, IOException {
|
||||
public Iterable<PatchSetData> sort(Iterable<ChangeData> in) throws StorageException, IOException {
|
||||
ListMultimap<Project.NameKey, ChangeData> byProject =
|
||||
MultimapBuilder.hashKeys().arrayListValues().build();
|
||||
for (ChangeData cd : in) {
|
||||
@@ -114,7 +114,7 @@ public class WalkSorter {
|
||||
}
|
||||
|
||||
private List<PatchSetData> sortProject(Project.NameKey project, Collection<ChangeData> in)
|
||||
throws OrmException, IOException {
|
||||
throws StorageException, IOException {
|
||||
try (Repository repo = repoManager.openRepository(project);
|
||||
RevWalk rw = new RevWalk(repo)) {
|
||||
rw.setRetainBody(retainBody);
|
||||
@@ -217,7 +217,7 @@ public class WalkSorter {
|
||||
}
|
||||
|
||||
private ListMultimap<RevCommit, PatchSetData> byCommit(RevWalk rw, Collection<ChangeData> in)
|
||||
throws OrmException, IOException {
|
||||
throws StorageException, IOException {
|
||||
ListMultimap<RevCommit, PatchSetData> byCommit =
|
||||
MultimapBuilder.hashKeys(in.size()).arrayListValues(1).build();
|
||||
for (ChangeData cd : in) {
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.google.gerrit.server.change;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
||||
@@ -29,7 +30,6 @@ import com.google.gerrit.server.notedb.ChangeUpdate;
|
||||
import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
@@ -85,7 +85,7 @@ public class WorkInProgressOp implements BatchUpdateOp {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx) throws OrmException {
|
||||
public boolean updateChange(ChangeContext ctx) throws StorageException {
|
||||
change = ctx.getChange();
|
||||
notes = ctx.getNotes();
|
||||
ps = psUtil.get(ctx.getNotes(), change.currentPatchSetId());
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.edit;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
import com.google.gerrit.extensions.restapi.MergeConflictException;
|
||||
@@ -43,7 +44,6 @@ import com.google.gerrit.server.project.InvalidChangeOperationException;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.util.CommitMessageUtil;
|
||||
import com.google.gerrit.server.util.time.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -114,7 +114,7 @@ public class ChangeEditModifier {
|
||||
* @throws PermissionBackendException
|
||||
*/
|
||||
public void createEdit(Repository repository, ChangeNotes notes)
|
||||
throws AuthException, IOException, InvalidChangeOperationException, OrmException,
|
||||
throws AuthException, IOException, InvalidChangeOperationException, StorageException,
|
||||
PermissionBackendException, ResourceConflictException {
|
||||
assertCanEdit(notes);
|
||||
|
||||
@@ -142,7 +142,7 @@ public class ChangeEditModifier {
|
||||
* @throws PermissionBackendException
|
||||
*/
|
||||
public void rebaseEdit(Repository repository, ChangeNotes notes)
|
||||
throws AuthException, InvalidChangeOperationException, IOException, OrmException,
|
||||
throws AuthException, InvalidChangeOperationException, IOException, StorageException,
|
||||
MergeConflictException, PermissionBackendException, ResourceConflictException {
|
||||
assertCanEdit(notes);
|
||||
|
||||
@@ -207,7 +207,7 @@ public class ChangeEditModifier {
|
||||
* @throws BadRequestException if the commit message is malformed
|
||||
*/
|
||||
public void modifyMessage(Repository repository, ChangeNotes notes, String newCommitMessage)
|
||||
throws AuthException, IOException, UnchangedCommitMessageException, OrmException,
|
||||
throws AuthException, IOException, UnchangedCommitMessageException, StorageException,
|
||||
PermissionBackendException, BadRequestException, ResourceConflictException {
|
||||
assertCanEdit(notes);
|
||||
newCommitMessage = CommitMessageUtil.checkAndSanitizeCommitMessage(newCommitMessage);
|
||||
@@ -250,7 +250,7 @@ public class ChangeEditModifier {
|
||||
*/
|
||||
public void modifyFile(
|
||||
Repository repository, ChangeNotes notes, String filePath, RawInput newContent)
|
||||
throws AuthException, InvalidChangeOperationException, IOException, OrmException,
|
||||
throws AuthException, InvalidChangeOperationException, IOException, StorageException,
|
||||
PermissionBackendException, ResourceConflictException {
|
||||
modifyTree(repository, notes, new ChangeFileContentModification(filePath, newContent));
|
||||
}
|
||||
@@ -268,7 +268,7 @@ public class ChangeEditModifier {
|
||||
* @throws ResourceConflictException if the project state does not permit the operation
|
||||
*/
|
||||
public void deleteFile(Repository repository, ChangeNotes notes, String file)
|
||||
throws AuthException, InvalidChangeOperationException, IOException, OrmException,
|
||||
throws AuthException, InvalidChangeOperationException, IOException, StorageException,
|
||||
PermissionBackendException, ResourceConflictException {
|
||||
modifyTree(repository, notes, new DeleteFileModification(file));
|
||||
}
|
||||
@@ -289,7 +289,7 @@ public class ChangeEditModifier {
|
||||
*/
|
||||
public void renameFile(
|
||||
Repository repository, ChangeNotes notes, String currentFilePath, String newFilePath)
|
||||
throws AuthException, InvalidChangeOperationException, IOException, OrmException,
|
||||
throws AuthException, InvalidChangeOperationException, IOException, StorageException,
|
||||
PermissionBackendException, ResourceConflictException {
|
||||
modifyTree(repository, notes, new RenameFileModification(currentFilePath, newFilePath));
|
||||
}
|
||||
@@ -307,14 +307,14 @@ public class ChangeEditModifier {
|
||||
* @throws PermissionBackendException
|
||||
*/
|
||||
public void restoreFile(Repository repository, ChangeNotes notes, String file)
|
||||
throws AuthException, InvalidChangeOperationException, IOException, OrmException,
|
||||
throws AuthException, InvalidChangeOperationException, IOException, StorageException,
|
||||
PermissionBackendException, ResourceConflictException {
|
||||
modifyTree(repository, notes, new RestoreFileModification(file));
|
||||
}
|
||||
|
||||
private void modifyTree(
|
||||
Repository repository, ChangeNotes notes, TreeModification treeModification)
|
||||
throws AuthException, IOException, OrmException, InvalidChangeOperationException,
|
||||
throws AuthException, IOException, StorageException, InvalidChangeOperationException,
|
||||
PermissionBackendException, ResourceConflictException {
|
||||
assertCanEdit(notes);
|
||||
|
||||
@@ -360,7 +360,7 @@ public class ChangeEditModifier {
|
||||
PatchSet patchSet,
|
||||
List<TreeModification> treeModifications)
|
||||
throws AuthException, IOException, InvalidChangeOperationException, MergeConflictException,
|
||||
OrmException, PermissionBackendException, ResourceConflictException {
|
||||
StorageException, PermissionBackendException, ResourceConflictException {
|
||||
assertCanEdit(notes);
|
||||
|
||||
Optional<ChangeEdit> optionalChangeEdit = lookupChangeEdit(notes);
|
||||
@@ -392,7 +392,7 @@ public class ChangeEditModifier {
|
||||
|
||||
private void assertCanEdit(ChangeNotes notes)
|
||||
throws AuthException, PermissionBackendException, IOException, ResourceConflictException,
|
||||
OrmException {
|
||||
StorageException {
|
||||
if (!currentUser.get().isIdentifiedUser()) {
|
||||
throw new AuthException("Authentication required");
|
||||
}
|
||||
@@ -443,12 +443,12 @@ public class ChangeEditModifier {
|
||||
}
|
||||
|
||||
private PatchSet getBasePatchSet(Optional<ChangeEdit> optionalChangeEdit, ChangeNotes notes)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
Optional<PatchSet> editBasePatchSet = optionalChangeEdit.map(ChangeEdit::getBasePatchSet);
|
||||
return editBasePatchSet.isPresent() ? editBasePatchSet.get() : lookupCurrentPatchSet(notes);
|
||||
}
|
||||
|
||||
private PatchSet lookupCurrentPatchSet(ChangeNotes notes) throws OrmException {
|
||||
private PatchSet lookupCurrentPatchSet(ChangeNotes notes) throws StorageException {
|
||||
return patchSetUtil.current(notes);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.edit;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.client.ChangeKind;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||
@@ -38,7 +39,6 @@ import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.RepoContext;
|
||||
import com.google.gerrit.server.update.UpdateException;
|
||||
import com.google.gerrit.server.util.time.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -146,7 +146,7 @@ public class ChangeEditUtil {
|
||||
* @param notify Notify handling that defines to whom email notifications should be sent after the
|
||||
* change edit is published.
|
||||
* @throws IOException
|
||||
* @throws OrmException
|
||||
* @throws StorageException
|
||||
* @throws UpdateException
|
||||
* @throws RestApiException
|
||||
*/
|
||||
@@ -156,7 +156,7 @@ public class ChangeEditUtil {
|
||||
CurrentUser user,
|
||||
ChangeEdit edit,
|
||||
NotifyResolver.Result notify)
|
||||
throws IOException, OrmException, RestApiException, UpdateException {
|
||||
throws IOException, StorageException, RestApiException, UpdateException {
|
||||
Change change = edit.getChange();
|
||||
try (Repository repo = gitManager.openRepository(change.getProject());
|
||||
ObjectInserter oi = repo.newObjectInserter();
|
||||
@@ -210,9 +210,9 @@ public class ChangeEditUtil {
|
||||
*
|
||||
* @param edit change edit to delete
|
||||
* @throws IOException
|
||||
* @throws OrmException
|
||||
* @throws StorageException
|
||||
*/
|
||||
public void delete(ChangeEdit edit) throws IOException, OrmException {
|
||||
public void delete(ChangeEdit edit) throws IOException, StorageException {
|
||||
Change change = edit.getChange();
|
||||
try (Repository repo = gitManager.openRepository(change.getProject())) {
|
||||
deleteRef(repo, edit);
|
||||
@@ -226,7 +226,7 @@ public class ChangeEditUtil {
|
||||
checkArgument(pos > 0, "invalid edit ref: %s", ref.getName());
|
||||
String psId = ref.getName().substring(pos + 1);
|
||||
return psUtil.get(notes, new PatchSet.Id(notes.getChange().getId(), Integer.parseInt(psId)));
|
||||
} catch (OrmException | NumberFormatException e) {
|
||||
} catch (StorageException | NumberFormatException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.events;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.registration.DynamicItem;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
import com.google.gerrit.lifecycle.LifecycleModule;
|
||||
@@ -34,7 +35,6 @@ import com.google.gerrit.server.plugincontext.PluginSetEntryContext;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.project.ProjectState;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@@ -78,7 +78,7 @@ public class EventBroker implements EventDispatcher {
|
||||
|
||||
@Override
|
||||
public void postEvent(Change change, ChangeEvent event)
|
||||
throws OrmException, PermissionBackendException {
|
||||
throws StorageException, PermissionBackendException {
|
||||
fireEvent(change, event);
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public class EventBroker implements EventDispatcher {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postEvent(Event event) throws OrmException, PermissionBackendException {
|
||||
public void postEvent(Event event) throws StorageException, PermissionBackendException {
|
||||
fireEvent(event);
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class EventBroker implements EventDispatcher {
|
||||
}
|
||||
|
||||
protected void fireEvent(Change change, ChangeEvent event)
|
||||
throws OrmException, PermissionBackendException {
|
||||
throws StorageException, PermissionBackendException {
|
||||
for (PluginSetEntryContext<UserScopedEventListener> c : listeners) {
|
||||
CurrentUser user = c.call(UserScopedEventListener::getUser);
|
||||
if (isVisibleTo(change, user)) {
|
||||
@@ -134,7 +134,7 @@ public class EventBroker implements EventDispatcher {
|
||||
fireEventForUnrestrictedListeners(event);
|
||||
}
|
||||
|
||||
protected void fireEvent(Event event) throws OrmException, PermissionBackendException {
|
||||
protected void fireEvent(Event event) throws StorageException, PermissionBackendException {
|
||||
for (PluginSetEntryContext<UserScopedEventListener> c : listeners) {
|
||||
CurrentUser user = c.call(UserScopedEventListener::getUser);
|
||||
if (isVisibleTo(event, user)) {
|
||||
@@ -159,7 +159,7 @@ public class EventBroker implements EventDispatcher {
|
||||
}
|
||||
|
||||
protected boolean isVisibleTo(Change change, CurrentUser user)
|
||||
throws OrmException, PermissionBackendException {
|
||||
throws StorageException, PermissionBackendException {
|
||||
if (change == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -194,7 +194,7 @@ public class EventBroker implements EventDispatcher {
|
||||
}
|
||||
|
||||
protected boolean isVisibleTo(Event event, CurrentUser user)
|
||||
throws OrmException, PermissionBackendException {
|
||||
throws StorageException, PermissionBackendException {
|
||||
if (event instanceof RefEvent) {
|
||||
RefEvent refEvent = (RefEvent) event;
|
||||
String ref = refEvent.getRefName();
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
|
||||
package com.google.gerrit.server.events;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.Branch;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
|
||||
/** Interface for posting (dispatching) Events */
|
||||
public interface EventDispatcher {
|
||||
@@ -27,10 +27,11 @@ public interface EventDispatcher {
|
||||
*
|
||||
* @param change The change that the event is related to
|
||||
* @param event The event to post
|
||||
* @throws OrmException on failure to post the event due to DB error
|
||||
* @throws StorageException on failure to post the event due to DB error
|
||||
* @throws PermissionBackendException on failure of permission checks
|
||||
*/
|
||||
void postEvent(Change change, ChangeEvent event) throws OrmException, PermissionBackendException;
|
||||
void postEvent(Change change, ChangeEvent event)
|
||||
throws StorageException, PermissionBackendException;
|
||||
|
||||
/**
|
||||
* Post a stream event that is related to a branch
|
||||
@@ -56,8 +57,8 @@ public interface EventDispatcher {
|
||||
* specific postEvent methods for those use cases.
|
||||
*
|
||||
* @param event The event to post.
|
||||
* @throws OrmException on failure to post the event due to DB error
|
||||
* @throws StorageException on failure to post the event due to DB error
|
||||
* @throws PermissionBackendException on failure of permission checks
|
||||
*/
|
||||
void postEvent(Event event) throws OrmException, PermissionBackendException;
|
||||
void postEvent(Event event) throws StorageException, PermissionBackendException;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.common.data.SubmitRecord;
|
||||
import com.google.gerrit.common.data.SubmitRequirement;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.registration.DynamicItem;
|
||||
import com.google.gerrit.index.IndexConfig;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
@@ -63,7 +64,6 @@ import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.InternalChangeQuery;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -155,7 +155,8 @@ public class EventFactory {
|
||||
* @param notes
|
||||
* @return object suitable for serialization to JSON
|
||||
*/
|
||||
public ChangeAttribute asChangeAttribute(Change change, ChangeNotes notes) throws OrmException {
|
||||
public ChangeAttribute asChangeAttribute(Change change, ChangeNotes notes)
|
||||
throws StorageException {
|
||||
ChangeAttribute a = asChangeAttribute(change);
|
||||
Set<String> hashtags = notes.load().getHashtags();
|
||||
if (!hashtags.isEmpty()) {
|
||||
@@ -200,7 +201,7 @@ public class EventFactory {
|
||||
* @param a
|
||||
* @param notes
|
||||
*/
|
||||
public void addAllReviewers(ChangeAttribute a, ChangeNotes notes) throws OrmException {
|
||||
public void addAllReviewers(ChangeAttribute a, ChangeNotes notes) throws StorageException {
|
||||
Collection<Account.Id> reviewers = approvalsUtil.getReviewers(notes).all();
|
||||
if (!reviewers.isEmpty()) {
|
||||
a.allReviewers = Lists.newArrayListWithCapacity(reviewers.size());
|
||||
@@ -271,7 +272,7 @@ public class EventFactory {
|
||||
try {
|
||||
addDependsOn(rw, ca, change, currentPs);
|
||||
addNeededBy(rw, ca, change, currentPs);
|
||||
} catch (OrmException | IOException e) {
|
||||
} catch (StorageException | IOException e) {
|
||||
// Squash DB exceptions and leave dependency lists partially filled.
|
||||
}
|
||||
// Remove empty lists so a confusing label won't be displayed in the output.
|
||||
@@ -284,7 +285,7 @@ public class EventFactory {
|
||||
}
|
||||
|
||||
private void addDependsOn(RevWalk rw, ChangeAttribute ca, Change change, PatchSet currentPs)
|
||||
throws OrmException, IOException {
|
||||
throws StorageException, IOException {
|
||||
RevCommit commit = rw.parseCommit(ObjectId.fromString(currentPs.getRevision().get()));
|
||||
final List<String> parentNames = new ArrayList<>(commit.getParentCount());
|
||||
for (RevCommit p : commit.getParents()) {
|
||||
@@ -317,7 +318,7 @@ public class EventFactory {
|
||||
}
|
||||
|
||||
private void addNeededBy(RevWalk rw, ChangeAttribute ca, Change change, PatchSet currentPs)
|
||||
throws OrmException, IOException {
|
||||
throws StorageException, IOException {
|
||||
if (currentPs.getGroups().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -494,7 +495,7 @@ public class EventFactory {
|
||||
}
|
||||
}
|
||||
p.kind = changeKindCache.getChangeKind(change, patchSet);
|
||||
} catch (IOException | OrmException e) {
|
||||
} catch (IOException | StorageException e) {
|
||||
logger.atSevere().withCause(e).log("Cannot load patch set data for %s", patchSet.getId());
|
||||
} catch (PatchListObjectTooLargeException e) {
|
||||
logger.atWarning().log("Cannot get size information for %s: %s", pId, e.getMessage());
|
||||
@@ -506,7 +507,7 @@ public class EventFactory {
|
||||
|
||||
// TODO: The same method exists in PatchSetInfoFactory, find a common place
|
||||
// for it
|
||||
private UserIdentity toUserIdentity(PersonIdent who) throws IOException, OrmException {
|
||||
private UserIdentity toUserIdentity(PersonIdent who) throws IOException, StorageException {
|
||||
UserIdentity u = new UserIdentity();
|
||||
u.setName(who.getName());
|
||||
u.setEmail(who.getEmailAddress());
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.google.common.collect.Sets;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ApprovalInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
@@ -55,7 +56,6 @@ import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gerrit.server.plugincontext.PluginItemContext;
|
||||
import com.google.gerrit.server.project.NoSuchChangeException;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -135,15 +135,15 @@ public class StreamEventsApiListener
|
||||
this.changeNotesFactory = changeNotesFactory;
|
||||
}
|
||||
|
||||
private ChangeNotes getNotes(ChangeInfo info) throws OrmException {
|
||||
private ChangeNotes getNotes(ChangeInfo info) throws StorageException {
|
||||
try {
|
||||
return changeNotesFactory.createChecked(new Change.Id(info._number));
|
||||
} catch (NoSuchChangeException e) {
|
||||
throw new OrmException(e);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private PatchSet getPatchSet(ChangeNotes notes, RevisionInfo info) throws OrmException {
|
||||
private PatchSet getPatchSet(ChangeNotes notes, RevisionInfo info) throws StorageException {
|
||||
return psUtil.get(notes, PatchSet.Id.fromRef(info.ref));
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ public class StreamEventsApiListener
|
||||
() -> {
|
||||
try {
|
||||
return eventFactory.asChangeAttribute(change, notes);
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
@@ -248,7 +248,7 @@ public class StreamEventsApiListener
|
||||
event.oldAssignee = accountAttributeSupplier(ev.getOldAssignee());
|
||||
|
||||
dispatcher.run(d -> d.postEvent(change, event));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log("Failed to dispatch event");
|
||||
}
|
||||
}
|
||||
@@ -265,7 +265,7 @@ public class StreamEventsApiListener
|
||||
event.oldTopic = ev.getOldTopic();
|
||||
|
||||
dispatcher.run(d -> d.postEvent(change, event));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log("Failed to dispatch event");
|
||||
}
|
||||
}
|
||||
@@ -283,7 +283,7 @@ public class StreamEventsApiListener
|
||||
event.uploader = accountAttributeSupplier(ev.getWho());
|
||||
|
||||
dispatcher.run(d -> d.postEvent(change, event));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log("Failed to dispatch event");
|
||||
}
|
||||
}
|
||||
@@ -303,7 +303,7 @@ public class StreamEventsApiListener
|
||||
approvalsAttributeSupplier(change, ev.getNewApprovals(), ev.getOldApprovals());
|
||||
|
||||
dispatcher.run(d -> d.postEvent(change, event));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log("Failed to dispatch event");
|
||||
}
|
||||
}
|
||||
@@ -321,7 +321,7 @@ public class StreamEventsApiListener
|
||||
event.reviewer = accountAttributeSupplier(reviewer);
|
||||
dispatcher.run(d -> d.postEvent(event));
|
||||
}
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log("Failed to dispatch event");
|
||||
}
|
||||
}
|
||||
@@ -349,7 +349,7 @@ public class StreamEventsApiListener
|
||||
event.removed = hashtagArray(ev.getRemovedHashtags());
|
||||
|
||||
dispatcher.run(d -> d.postEvent(change, event));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log("Failed to dispatch event");
|
||||
}
|
||||
}
|
||||
@@ -386,7 +386,7 @@ public class StreamEventsApiListener
|
||||
event.approvals = approvalsAttributeSupplier(change, ev.getApprovals(), ev.getOldApprovals());
|
||||
|
||||
dispatcher.run(d -> d.postEvent(change, event));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log("Failed to dispatch event");
|
||||
}
|
||||
}
|
||||
@@ -404,7 +404,7 @@ public class StreamEventsApiListener
|
||||
event.reason = ev.getReason();
|
||||
|
||||
dispatcher.run(d -> d.postEvent(change, event));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log("Failed to dispatch event");
|
||||
}
|
||||
}
|
||||
@@ -422,7 +422,7 @@ public class StreamEventsApiListener
|
||||
event.newRev = ev.getNewRevisionId();
|
||||
|
||||
dispatcher.run(d -> d.postEvent(change, event));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log("Failed to dispatch event");
|
||||
}
|
||||
}
|
||||
@@ -440,7 +440,7 @@ public class StreamEventsApiListener
|
||||
event.reason = ev.getReason();
|
||||
|
||||
dispatcher.run(d -> d.postEvent(change, event));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log("Failed to dispatch event");
|
||||
}
|
||||
}
|
||||
@@ -458,7 +458,7 @@ public class StreamEventsApiListener
|
||||
event.patchSet = patchSetAttributeSupplier(change, patchSet);
|
||||
|
||||
dispatcher.run(d -> d.postEvent(change, event));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log("Failed to dispatch event");
|
||||
}
|
||||
}
|
||||
@@ -476,7 +476,7 @@ public class StreamEventsApiListener
|
||||
event.patchSet = patchSetAttributeSupplier(change, patchSet);
|
||||
|
||||
dispatcher.run(d -> d.postEvent(change, event));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log("Failed to dispatch event");
|
||||
}
|
||||
}
|
||||
@@ -496,7 +496,7 @@ public class StreamEventsApiListener
|
||||
event.approvals = approvalsAttributeSupplier(change, ev.getApprovals(), ev.getOldApprovals());
|
||||
|
||||
dispatcher.run(d -> d.postEvent(change, event));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log("Failed to dispatch event");
|
||||
}
|
||||
}
|
||||
@@ -512,7 +512,7 @@ public class StreamEventsApiListener
|
||||
event.deleter = accountAttributeSupplier(ev.getWho());
|
||||
|
||||
dispatcher.run(d -> d.postEvent(change, event));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log("Failed to dispatch event");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
@@ -22,7 +23,6 @@ import com.google.gerrit.extensions.events.AssigneeChangedListener;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.server.account.AccountState;
|
||||
import com.google.gerrit.server.plugincontext.PluginSetContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.sql.Timestamp;
|
||||
@@ -53,7 +53,7 @@ public class AssigneeChanged {
|
||||
util.accountInfo(oldAssignee),
|
||||
when);
|
||||
listeners.runEach(l -> l.onAssigneeChanged(event));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log("Couldn't fire event");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
@@ -28,7 +29,6 @@ import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gerrit.server.plugincontext.PluginSetContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -72,7 +72,7 @@ public class ChangeAbandoned {
|
||||
} catch (PatchListNotAvailableException
|
||||
| GpgException
|
||||
| IOException
|
||||
| OrmException
|
||||
| StorageException
|
||||
| PermissionBackendException e) {
|
||||
logger.atSevere().withCause(e).log("Couldn't fire event");
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
@@ -22,7 +23,6 @@ import com.google.gerrit.extensions.events.ChangeDeletedListener;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.server.account.AccountState;
|
||||
import com.google.gerrit.server.plugincontext.PluginSetContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.sql.Timestamp;
|
||||
@@ -47,7 +47,7 @@ public class ChangeDeleted {
|
||||
try {
|
||||
Event event = new Event(util.changeInfo(change), util.accountInfo(deleter), when);
|
||||
listeners.runEach(l -> l.onChangeDeleted(event));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log("Couldn't fire event");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
@@ -28,7 +29,6 @@ import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gerrit.server.plugincontext.PluginSetContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -66,7 +66,7 @@ public class ChangeMerged {
|
||||
} catch (PatchListNotAvailableException
|
||||
| GpgException
|
||||
| IOException
|
||||
| OrmException
|
||||
| StorageException
|
||||
| PermissionBackendException e) {
|
||||
logger.atSevere().withCause(e).log("Couldn't fire event");
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
@@ -28,7 +29,6 @@ import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gerrit.server.plugincontext.PluginSetContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -66,7 +66,7 @@ public class ChangeRestored {
|
||||
} catch (PatchListNotAvailableException
|
||||
| GpgException
|
||||
| IOException
|
||||
| OrmException
|
||||
| StorageException
|
||||
| PermissionBackendException e) {
|
||||
logger.atSevere().withCause(e).log("Couldn't fire event");
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.extensions.events.ChangeRevertedListener;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.server.plugincontext.PluginSetContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.sql.Timestamp;
|
||||
@@ -45,7 +45,7 @@ public class ChangeReverted {
|
||||
try {
|
||||
Event event = new Event(util.changeInfo(change), util.changeInfo(revertChange), when);
|
||||
listeners.runEach(l -> l.onChangeReverted(event));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log("Couldn't fire event");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ApprovalInfo;
|
||||
@@ -29,7 +30,6 @@ import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gerrit.server.plugincontext.PluginSetContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -76,7 +76,7 @@ public class CommentAdded {
|
||||
} catch (PatchListNotAvailableException
|
||||
| GpgException
|
||||
| IOException
|
||||
| OrmException
|
||||
| StorageException
|
||||
| PermissionBackendException e) {
|
||||
logger.atSevere().withCause(e).log("Couldn't fire event");
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.client.ListChangesOption;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ApprovalInfo;
|
||||
@@ -32,7 +33,6 @@ import com.google.gerrit.server.change.RevisionJson;
|
||||
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -74,18 +74,18 @@ public class EventUtil {
|
||||
this.revisionJsonFactory = revisionJsonFactory;
|
||||
}
|
||||
|
||||
public ChangeInfo changeInfo(Change change) throws OrmException {
|
||||
public ChangeInfo changeInfo(Change change) throws StorageException {
|
||||
return changeJsonFactory.create(CHANGE_OPTIONS).format(change);
|
||||
}
|
||||
|
||||
public RevisionInfo revisionInfo(Project project, PatchSet ps)
|
||||
throws OrmException, PatchListNotAvailableException, GpgException, IOException,
|
||||
throws StorageException, PatchListNotAvailableException, GpgException, IOException,
|
||||
PermissionBackendException {
|
||||
return revisionInfo(project.getNameKey(), ps);
|
||||
}
|
||||
|
||||
public RevisionInfo revisionInfo(Project.NameKey project, PatchSet ps)
|
||||
throws OrmException, PatchListNotAvailableException, GpgException, IOException,
|
||||
throws StorageException, PatchListNotAvailableException, GpgException, IOException,
|
||||
PermissionBackendException {
|
||||
ChangeData cd = changeDataFactory.create(project, ps.getId().getParentKey());
|
||||
return revisionJsonFactory.create(CHANGE_OPTIONS).getRevisionInfo(cd, ps);
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.common.collect.ImmutableSortedSet;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
@@ -23,7 +24,6 @@ import com.google.gerrit.extensions.events.HashtagsEditedListener;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.server.account.AccountState;
|
||||
import com.google.gerrit.server.plugincontext.PluginSetContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.sql.Timestamp;
|
||||
@@ -58,7 +58,7 @@ public class HashtagsEdited {
|
||||
new Event(
|
||||
util.changeInfo(change), util.accountInfo(editor), hashtags, added, removed, when);
|
||||
listeners.runEach(l -> l.onHashtagsEdited(event));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log("Couldn't fire event");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
@@ -27,7 +28,6 @@ import com.google.gerrit.server.account.AccountState;
|
||||
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gerrit.server.plugincontext.PluginSetContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -58,7 +58,7 @@ public class PrivateStateChanged {
|
||||
util.accountInfo(account),
|
||||
when);
|
||||
listeners.runEach(l -> l.onPrivateStateChanged(event));
|
||||
} catch (OrmException
|
||||
} catch (StorageException
|
||||
| PatchListNotAvailableException
|
||||
| GpgException
|
||||
| IOException
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
@@ -29,7 +30,6 @@ import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gerrit.server.plugincontext.PluginSetContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -73,7 +73,7 @@ public class ReviewerAdded {
|
||||
} catch (PatchListNotAvailableException
|
||||
| GpgException
|
||||
| IOException
|
||||
| OrmException
|
||||
| StorageException
|
||||
| PermissionBackendException e) {
|
||||
logger.atSevere().withCause(e).log("Couldn't fire event");
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ApprovalInfo;
|
||||
@@ -29,7 +30,6 @@ import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gerrit.server.plugincontext.PluginSetContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -80,7 +80,7 @@ public class ReviewerDeleted {
|
||||
} catch (PatchListNotAvailableException
|
||||
| GpgException
|
||||
| IOException
|
||||
| OrmException
|
||||
| StorageException
|
||||
| PermissionBackendException e) {
|
||||
logger.atSevere().withCause(e).log("Couldn't fire event");
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
@@ -29,7 +30,6 @@ import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gerrit.server.plugincontext.PluginSetContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -87,7 +87,7 @@ public class RevisionCreated {
|
||||
} catch (PatchListNotAvailableException
|
||||
| GpgException
|
||||
| IOException
|
||||
| OrmException
|
||||
| StorageException
|
||||
| PermissionBackendException e) {
|
||||
logger.atSevere().withCause(e).log("Couldn't fire event");
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
@@ -22,7 +23,6 @@ import com.google.gerrit.extensions.events.TopicEditedListener;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.server.account.AccountState;
|
||||
import com.google.gerrit.server.plugincontext.PluginSetContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.sql.Timestamp;
|
||||
@@ -48,7 +48,7 @@ public class TopicEdited {
|
||||
Event event =
|
||||
new Event(util.changeInfo(change), util.accountInfo(account), oldTopicName, when);
|
||||
listeners.runEach(l -> l.onTopicEdited(event));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log("Couldn't fire event");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ApprovalInfo;
|
||||
@@ -29,7 +30,6 @@ import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gerrit.server.plugincontext.PluginSetContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -80,7 +80,7 @@ public class VoteDeleted {
|
||||
} catch (PatchListNotAvailableException
|
||||
| GpgException
|
||||
| IOException
|
||||
| OrmException
|
||||
| StorageException
|
||||
| PermissionBackendException e) {
|
||||
logger.atSevere().withCause(e).log("Couldn't fire event");
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
package com.google.gerrit.server.extensions.events;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.common.AccountInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
@@ -27,7 +28,6 @@ import com.google.gerrit.server.account.AccountState;
|
||||
import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gerrit.server.plugincontext.PluginSetContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
@@ -59,7 +59,7 @@ public class WorkInProgressStateChanged {
|
||||
util.accountInfo(account),
|
||||
when);
|
||||
listeners.runEach(l -> l.onWorkInProgressStateChanged(event));
|
||||
} catch (OrmException
|
||||
} catch (StorageException
|
||||
| PatchListNotAvailableException
|
||||
| GpgException
|
||||
| IOException
|
||||
|
||||
@@ -28,12 +28,12 @@ import com.google.common.collect.SetMultimap;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.collect.SortedSetMultimap;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.PatchSetUtil;
|
||||
import com.google.gerrit.server.change.RevisionResource;
|
||||
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Collection;
|
||||
import java.util.Deque;
|
||||
@@ -89,7 +89,7 @@ public class GroupCollector {
|
||||
}
|
||||
|
||||
private interface Lookup {
|
||||
List<String> lookup(PatchSet.Id psId) throws OrmException;
|
||||
List<String> lookup(PatchSet.Id psId) throws StorageException;
|
||||
}
|
||||
|
||||
private final ListMultimap<ObjectId, PatchSet.Id> patchSetsBySha;
|
||||
@@ -198,7 +198,7 @@ public class GroupCollector {
|
||||
}
|
||||
}
|
||||
|
||||
public SortedSetMultimap<ObjectId, String> getGroups() throws OrmException {
|
||||
public SortedSetMultimap<ObjectId, String> getGroups() throws StorageException {
|
||||
done = true;
|
||||
SortedSetMultimap<ObjectId, String> result =
|
||||
MultimapBuilder.hashKeys(groups.keySet().size()).treeSetValues().build();
|
||||
@@ -225,7 +225,7 @@ public class GroupCollector {
|
||||
}
|
||||
|
||||
private Set<String> resolveGroups(ObjectId forCommit, Collection<String> candidates)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
Set<String> actual = Sets.newTreeSet();
|
||||
Set<String> done = Sets.newHashSetWithExpectedSize(candidates.size());
|
||||
Set<String> seen = Sets.newHashSetWithExpectedSize(candidates.size());
|
||||
@@ -260,7 +260,7 @@ public class GroupCollector {
|
||||
}
|
||||
}
|
||||
|
||||
private Iterable<String> resolveGroup(ObjectId forCommit, String group) throws OrmException {
|
||||
private Iterable<String> resolveGroup(ObjectId forCommit, String group) throws StorageException {
|
||||
ObjectId id = parseGroup(forCommit, group);
|
||||
if (id != null) {
|
||||
PatchSet.Id psId = Iterables.getFirst(patchSetsBySha.get(id), null);
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.google.common.collect.Sets;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.FooterConstants;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.registration.DynamicItem;
|
||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||
import com.google.gerrit.extensions.registration.Extension;
|
||||
@@ -56,7 +57,6 @@ import com.google.gerrit.server.submit.CommitMergeStatus;
|
||||
import com.google.gerrit.server.submit.IntegrationException;
|
||||
import com.google.gerrit.server.submit.MergeIdenticalTreeException;
|
||||
import com.google.gerrit.server.submit.MergeSorter;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.google.inject.assistedinject.AssistedInject;
|
||||
@@ -237,7 +237,7 @@ public class MergeUtil {
|
||||
List<CodeReviewCommit> result = new ArrayList<>();
|
||||
try {
|
||||
result.addAll(mergeSorter.sort(toSort));
|
||||
} catch (IOException | OrmException e) {
|
||||
} catch (IOException | StorageException e) {
|
||||
throw new IntegrationException("Branch head sorting failed", e);
|
||||
}
|
||||
result.sort(CodeReviewCommit.ORDER);
|
||||
@@ -609,7 +609,7 @@ public class MergeUtil {
|
||||
private Iterable<PatchSetApproval> safeGetApprovals(ChangeNotes notes, PatchSet.Id psId) {
|
||||
try {
|
||||
return approvalsUtil.byPatchSet(notes, psId, null, null);
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log("Can't read approval records for %s", psId);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
@@ -722,7 +722,7 @@ public class MergeUtil {
|
||||
throws IntegrationException {
|
||||
try {
|
||||
return !mergeSorter.sort(Collections.singleton(toMerge)).contains(toMerge);
|
||||
} catch (IOException | OrmException e) {
|
||||
} catch (IOException | StorageException e) {
|
||||
throw new IntegrationException("Branch head sorting failed", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.google.gerrit.server.git;
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.ChangeMessage;
|
||||
import com.google.gerrit.reviewdb.client.LabelId;
|
||||
@@ -35,7 +36,6 @@ import com.google.gerrit.server.update.BatchUpdateOp;
|
||||
import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.util.RequestScopePropagator;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
@@ -105,7 +105,7 @@ public class MergedByPushOp implements BatchUpdateOp {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx) throws OrmException, IOException {
|
||||
public boolean updateChange(ChangeContext ctx) throws StorageException, IOException {
|
||||
change = ctx.getChange();
|
||||
correctBranch = refName.equals(change.getDest().get());
|
||||
if (!correctBranch) {
|
||||
@@ -193,7 +193,7 @@ public class MergedByPushOp implements BatchUpdateOp {
|
||||
change, patchSet, ctx.getAccount(), patchSet.getRevision().get(), ctx.getWhen());
|
||||
}
|
||||
|
||||
private PatchSetInfo getPatchSetInfo(ChangeContext ctx) throws IOException, OrmException {
|
||||
private PatchSetInfo getPatchSetInfo(ChangeContext ctx) throws IOException, StorageException {
|
||||
RevWalk rw = ctx.getRevWalk();
|
||||
RevCommit commit =
|
||||
rw.parseCommit(ObjectId.fromString(requireNonNull(patchSet).getRevision().get()));
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
@@ -30,7 +31,6 @@ import com.google.gerrit.server.cache.serialize.ProtobufSerializer;
|
||||
import com.google.gerrit.server.logging.TraceContext;
|
||||
import com.google.gerrit.server.notedb.ChangeNotes;
|
||||
import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -87,11 +87,11 @@ public class PureRevertCache {
|
||||
*
|
||||
* @return {@code true} if {@code claimedRevert} is a pure (clean) revert.
|
||||
* @throws IOException if there was a problem with the storage layer
|
||||
* @throws OrmException if there was a problem with the storage layer
|
||||
* @throws StorageException if there was a problem with the storage layer
|
||||
* @throws BadRequestException if there is a problem with the provided {@link ChangeNotes}
|
||||
*/
|
||||
public boolean isPureRevert(ChangeNotes claimedRevert)
|
||||
throws OrmException, IOException, BadRequestException {
|
||||
throws StorageException, IOException, BadRequestException {
|
||||
if (claimedRevert.getChange().getRevertOf() == null) {
|
||||
throw new BadRequestException("revertOf not set");
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ java_library(
|
||||
deps = [
|
||||
"//java/com/google/gerrit/common:annotations",
|
||||
"//java/com/google/gerrit/common:server",
|
||||
"//java/com/google/gerrit/exceptions",
|
||||
"//java/com/google/gerrit/extensions:api",
|
||||
"//java/com/google/gerrit/metrics",
|
||||
"//java/com/google/gerrit/reviewdb:server",
|
||||
@@ -12,7 +13,6 @@ java_library(
|
||||
"//java/com/google/gerrit/server/logging",
|
||||
"//java/com/google/gerrit/server/util/time",
|
||||
"//java/com/google/gerrit/util/cli",
|
||||
"//java/com/google/gwtorm",
|
||||
"//lib:args4j",
|
||||
"//lib:guava",
|
||||
"//lib/auto:auto-value",
|
||||
|
||||
@@ -64,6 +64,7 @@ import com.google.gerrit.common.FooterConstants;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.HashtagsInput;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.api.changes.RecipientType;
|
||||
@@ -158,7 +159,6 @@ import com.google.gerrit.server.util.MagicBranch;
|
||||
import com.google.gerrit.server.util.RequestScopePropagator;
|
||||
import com.google.gerrit.server.util.time.TimeUtil;
|
||||
import com.google.gerrit.util.cli.CmdLineParser;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
@@ -897,7 +897,7 @@ class ReceiveCommits {
|
||||
addError(e.getMessage());
|
||||
reject(magicBranchCmd, "conflict");
|
||||
} catch (RestApiException
|
||||
| OrmException
|
||||
| StorageException
|
||||
| UpdateException
|
||||
| IOException
|
||||
| ConfigInvalidException
|
||||
@@ -1938,7 +1938,7 @@ class ReceiveCommits {
|
||||
logger.atSevere().withCause(e).log("Change not found %s", changeId);
|
||||
reject(cmd, "change " + changeId + " not found");
|
||||
return;
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log("Cannot lookup existing change %s", changeId);
|
||||
reject(cmd, "database error");
|
||||
return;
|
||||
@@ -2237,7 +2237,7 @@ class ReceiveCommits {
|
||||
magicBranch.cmd.setResult(REJECTED_MISSING_OBJECT);
|
||||
logger.atSevere().withCause(e).log("Invalid pack upload; one or more objects weren't sent");
|
||||
return Collections.emptyList();
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log("Cannot query database to locate prior changes");
|
||||
reject(magicBranch.cmd, "database error");
|
||||
return Collections.emptyList();
|
||||
@@ -2267,14 +2267,14 @@ class ReceiveCommits {
|
||||
update.groups = ImmutableList.copyOf((groups.get(update.commit)));
|
||||
}
|
||||
logger.atFine().log("Finished updating groups from GroupCollector");
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atSevere().withCause(e).log("Error collecting groups for changes");
|
||||
reject(magicBranch.cmd, "internal server error");
|
||||
}
|
||||
return newChanges;
|
||||
}
|
||||
|
||||
private boolean foundInExistingRef(Collection<Ref> existingRefs) throws OrmException {
|
||||
private boolean foundInExistingRef(Collection<Ref> existingRefs) throws StorageException {
|
||||
for (Ref ref : existingRefs) {
|
||||
ChangeNotes notes =
|
||||
notesFactory.create(project.getNameKey(), Change.Id.fromRef(ref.getName()));
|
||||
@@ -2394,11 +2394,11 @@ class ReceiveCommits {
|
||||
}
|
||||
}
|
||||
|
||||
private ChangeLookup lookupByChangeKey(RevCommit c, Change.Key key) throws OrmException {
|
||||
private ChangeLookup lookupByChangeKey(RevCommit c, Change.Key key) throws StorageException {
|
||||
return new ChangeLookup(c, key, queryProvider.get().byBranchKey(magicBranch.dest, key));
|
||||
}
|
||||
|
||||
private ChangeLookup lookupByCommit(RevCommit c) throws OrmException {
|
||||
private ChangeLookup lookupByCommit(RevCommit c) throws StorageException {
|
||||
return new ChangeLookup(
|
||||
c, null, queryProvider.get().byBranchCommit(magicBranch.dest, c.getName()));
|
||||
}
|
||||
@@ -2525,8 +2525,8 @@ class ReceiveCommits {
|
||||
}
|
||||
|
||||
private void submit(Collection<CreateRequest> create, Collection<ReplaceRequest> replace)
|
||||
throws OrmException, RestApiException, UpdateException, IOException, ConfigInvalidException,
|
||||
PermissionBackendException {
|
||||
throws StorageException, RestApiException, UpdateException, IOException,
|
||||
ConfigInvalidException, PermissionBackendException {
|
||||
Map<ObjectId, Change> bySha = Maps.newHashMapWithExpectedSize(create.size() + replace.size());
|
||||
for (CreateRequest r : create) {
|
||||
requireNonNull(
|
||||
@@ -2558,7 +2558,7 @@ class ReceiveCommits {
|
||||
req.validateNewPatchSet();
|
||||
}
|
||||
}
|
||||
} catch (OrmException err) {
|
||||
} catch (StorageException err) {
|
||||
logger.atSevere().withCause(err).log(
|
||||
"Cannot read database before replacement for project %s", project.getName());
|
||||
rejectRemainingRequests(replaceByChange.values(), "internal server error");
|
||||
@@ -2582,7 +2582,7 @@ class ReceiveCommits {
|
||||
}
|
||||
}
|
||||
|
||||
private void readChangesForReplace() throws OrmException {
|
||||
private void readChangesForReplace() throws StorageException {
|
||||
Collection<ChangeNotes> allNotes =
|
||||
notesFactory.create(
|
||||
replaceByChange.values().stream().map(r -> r.ontoChange).collect(toList()));
|
||||
@@ -2646,10 +2646,10 @@ class ReceiveCommits {
|
||||
*
|
||||
* @return whether the new commit is valid
|
||||
* @throws IOException
|
||||
* @throws OrmException
|
||||
* @throws StorageException
|
||||
* @throws PermissionBackendException
|
||||
*/
|
||||
boolean validateNewPatchSet() throws IOException, OrmException, PermissionBackendException {
|
||||
boolean validateNewPatchSet() throws IOException, StorageException, PermissionBackendException {
|
||||
if (!validateNewPatchSetNoteDb()) {
|
||||
return false;
|
||||
}
|
||||
@@ -2671,7 +2671,7 @@ class ReceiveCommits {
|
||||
}
|
||||
|
||||
boolean validateNewPatchSetForAutoClose()
|
||||
throws IOException, OrmException, PermissionBackendException {
|
||||
throws IOException, StorageException, PermissionBackendException {
|
||||
if (!validateNewPatchSetNoteDb()) {
|
||||
return false;
|
||||
}
|
||||
@@ -2682,7 +2682,7 @@ class ReceiveCommits {
|
||||
|
||||
/** Validates the new PS against permissions and notedb status. */
|
||||
private boolean validateNewPatchSetNoteDb()
|
||||
throws IOException, OrmException, PermissionBackendException {
|
||||
throws IOException, StorageException, PermissionBackendException {
|
||||
if (notes == null) {
|
||||
reject(inputCommand, "change " + ontoChange + " not found");
|
||||
return false;
|
||||
@@ -2845,7 +2845,7 @@ class ReceiveCommits {
|
||||
}
|
||||
|
||||
/** Updates 'this' to add a new patchset. */
|
||||
private void newPatchSet() throws IOException, OrmException {
|
||||
private void newPatchSet() throws IOException, StorageException {
|
||||
RevCommit newCommit = receivePack.getRevWalk().parseCommit(newCommitId);
|
||||
psId =
|
||||
ChangeUtil.nextPatchSetIdFromAllRefsMap(allRefs(), notes.getChange().currentPatchSetId());
|
||||
@@ -2909,7 +2909,7 @@ class ReceiveCommits {
|
||||
psId.getParentKey(),
|
||||
new BatchUpdateOp() {
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx) throws OrmException {
|
||||
public boolean updateChange(ChangeContext ctx) throws StorageException {
|
||||
PatchSet ps = psUtil.get(ctx.getNotes(), psId);
|
||||
List<String> oldGroups = ps.getGroups();
|
||||
if (oldGroups == null) {
|
||||
@@ -3217,7 +3217,7 @@ class ReceiveCommits {
|
||||
"Auto-closing %s changes with existing patch sets and %s with new patch sets",
|
||||
existingPatchSets, newPatchSets);
|
||||
bu.execute();
|
||||
} catch (IOException | OrmException | PermissionBackendException e) {
|
||||
} catch (IOException | StorageException | PermissionBackendException e) {
|
||||
logger.atSevere().withCause(e).log("Failed to auto-close changes");
|
||||
return null;
|
||||
}
|
||||
@@ -3241,7 +3241,7 @@ class ReceiveCommits {
|
||||
}
|
||||
}
|
||||
|
||||
private Optional<ChangeNotes> getChangeNotes(Change.Id changeId) throws OrmException {
|
||||
private Optional<ChangeNotes> getChangeNotes(Change.Id changeId) throws StorageException {
|
||||
try {
|
||||
return Optional.of(notesFactory.createChecked(project.getNameKey(), changeId));
|
||||
} catch (NoSuchChangeException e) {
|
||||
@@ -3249,18 +3249,19 @@ class ReceiveCommits {
|
||||
}
|
||||
}
|
||||
|
||||
private <T> T executeIndexQuery(Action<T> action) throws OrmException {
|
||||
private <T> T executeIndexQuery(Action<T> action) throws StorageException {
|
||||
try {
|
||||
return retryHelper.execute(ActionType.INDEX_QUERY, action, OrmException.class::isInstance);
|
||||
return retryHelper.execute(
|
||||
ActionType.INDEX_QUERY, action, StorageException.class::isInstance);
|
||||
} catch (Exception e) {
|
||||
Throwables.throwIfUnchecked(e);
|
||||
Throwables.throwIfInstanceOf(e, OrmException.class);
|
||||
throw new OrmException(e);
|
||||
Throwables.throwIfInstanceOf(e, StorageException.class);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<Change.Key, ChangeNotes> openChangesByKeyByBranch(Branch.NameKey branch)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
Map<Change.Key, ChangeNotes> r = new HashMap<>();
|
||||
for (ChangeData cd : queryProvider.get().byBranchOpen(branch)) {
|
||||
try {
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.PatchSet;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.client.RefNames;
|
||||
@@ -27,7 +28,6 @@ import com.google.gerrit.server.index.change.ChangeField;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.InternalChangeQuery;
|
||||
import com.google.gerrit.server.util.MagicBranch;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Provider;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
@@ -118,7 +118,7 @@ public class ReceiveCommitsAdvertiseRefsHook implements AdvertiseRefsHook {
|
||||
}
|
||||
}
|
||||
return r;
|
||||
} catch (OrmException err) {
|
||||
} catch (StorageException err) {
|
||||
logger.atSevere().withCause(err).log("Cannot list open changes of %s", projectName);
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.google.common.collect.Streams;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.AddReviewerInput;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.client.ChangeKind;
|
||||
@@ -74,7 +75,6 @@ import com.google.gerrit.server.update.ChangeContext;
|
||||
import com.google.gerrit.server.update.Context;
|
||||
import com.google.gerrit.server.update.RepoContext;
|
||||
import com.google.gerrit.server.util.RequestScopePropagator;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.google.inject.util.Providers;
|
||||
@@ -242,7 +242,7 @@ public class ReplaceOp implements BatchUpdateOp {
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx)
|
||||
throws RestApiException, OrmException, IOException, PermissionBackendException,
|
||||
throws RestApiException, StorageException, IOException, PermissionBackendException,
|
||||
ConfigInvalidException {
|
||||
notes = ctx.getNotes();
|
||||
Change change = notes.getChange();
|
||||
@@ -387,7 +387,7 @@ public class ReplaceOp implements BatchUpdateOp {
|
||||
}
|
||||
|
||||
private ChangeMessage createChangeMessage(ChangeContext ctx, String reviewMessage)
|
||||
throws OrmException, IOException {
|
||||
throws StorageException, IOException {
|
||||
String approvalMessage =
|
||||
ApprovalsUtil.renderMessageWithApprovals(
|
||||
patchSetId.get(), approvals, scanLabels(ctx, approvals));
|
||||
@@ -441,7 +441,7 @@ public class ReplaceOp implements BatchUpdateOp {
|
||||
}
|
||||
|
||||
private Map<String, PatchSetApproval> scanLabels(ChangeContext ctx, Map<String, Short> approvals)
|
||||
throws OrmException, IOException {
|
||||
throws StorageException, IOException {
|
||||
Map<String, PatchSetApproval> current = new HashMap<>();
|
||||
// We optimize here and only retrieve current when approvals provided
|
||||
if (!approvals.isEmpty()) {
|
||||
@@ -486,7 +486,7 @@ public class ReplaceOp implements BatchUpdateOp {
|
||||
}
|
||||
|
||||
private List<Comment> publishComments(ChangeContext ctx, boolean workInProgress)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
List<Comment> comments =
|
||||
commentsUtil.draftByChangeAuthor(ctx.getNotes(), ctx.getUser().getAccountId());
|
||||
publishCommentUtil.publish(
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.google.gerrit.server.git.validators;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.projects.ProjectConfigEntryType;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||
import com.google.gerrit.extensions.registration.Extension;
|
||||
@@ -43,7 +44,6 @@ import com.google.gerrit.server.project.ProjectCache;
|
||||
import com.google.gerrit.server.project.ProjectConfig;
|
||||
import com.google.gerrit.server.project.ProjectState;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
@@ -301,7 +301,7 @@ public class MergeValidators {
|
||||
if (!cd.currentFilePaths().contains(AccountProperties.ACCOUNT_CONFIG)) {
|
||||
return;
|
||||
}
|
||||
} catch (IOException | OrmException e) {
|
||||
} catch (IOException | StorageException e) {
|
||||
logger.atSevere().withCause(e).log("Cannot validate account update");
|
||||
throw new MergeValidationException("account validation unavailable");
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.google.common.base.Splitter;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Streams;
|
||||
import com.google.gerrit.exceptions.DuplicateKeyException;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
@@ -32,7 +33,6 @@ import com.google.gerrit.server.git.meta.MetaDataUpdate;
|
||||
import com.google.gerrit.server.git.meta.VersionedMetaData;
|
||||
import com.google.gerrit.server.group.InternalGroup;
|
||||
import com.google.gerrit.server.util.time.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmDuplicateKeyException;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Arrays;
|
||||
@@ -110,11 +110,11 @@ public class GroupConfig extends VersionedMetaData {
|
||||
* @throws IOException if the repository can't be accessed for some reason
|
||||
* @throws ConfigInvalidException if a group with the same UUID already exists but can't be read
|
||||
* due to an invalid format
|
||||
* @throws OrmDuplicateKeyException if a group with the same UUID already exists
|
||||
* @throws DuplicateKeyException if a group with the same UUID already exists
|
||||
*/
|
||||
public static GroupConfig createForNewGroup(
|
||||
Project.NameKey projectName, Repository repository, InternalGroupCreation groupCreation)
|
||||
throws IOException, ConfigInvalidException, OrmDuplicateKeyException {
|
||||
throws IOException, ConfigInvalidException, DuplicateKeyException {
|
||||
GroupConfig groupConfig = new GroupConfig(groupCreation.getGroupUUID());
|
||||
groupConfig.load(projectName, repository);
|
||||
groupConfig.setGroupCreation(groupCreation);
|
||||
@@ -241,11 +241,10 @@ public class GroupConfig extends VersionedMetaData {
|
||||
this.allowSaveEmptyName = true;
|
||||
}
|
||||
|
||||
private void setGroupCreation(InternalGroupCreation groupCreation)
|
||||
throws OrmDuplicateKeyException {
|
||||
private void setGroupCreation(InternalGroupCreation groupCreation) throws DuplicateKeyException {
|
||||
checkLoaded();
|
||||
if (loadedGroup.isPresent()) {
|
||||
throw new OrmDuplicateKeyException(String.format("Group %s already exists", groupUuid.get()));
|
||||
throw new DuplicateKeyException(String.format("Group %s already exists", groupUuid.get()));
|
||||
}
|
||||
|
||||
this.groupCreation = Optional.of(groupCreation);
|
||||
|
||||
@@ -29,11 +29,11 @@ import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.common.data.GroupReference;
|
||||
import com.google.gerrit.exceptions.DuplicateKeyException;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.reviewdb.client.RefNames;
|
||||
import com.google.gerrit.server.git.meta.VersionedMetaData;
|
||||
import com.google.gwtorm.server.OrmDuplicateKeyException;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
@@ -114,7 +114,7 @@ public class GroupNameNotes extends VersionedMetaData {
|
||||
* @throws IOException if the repository can't be accessed for some reason
|
||||
* @throws ConfigInvalidException if the note for the specified group doesn't exist or is in an
|
||||
* invalid state
|
||||
* @throws OrmDuplicateKeyException if a group with the new name already exists
|
||||
* @throws DuplicateKeyException if a group with the new name already exists
|
||||
*/
|
||||
public static GroupNameNotes forRename(
|
||||
Project.NameKey projectName,
|
||||
@@ -122,7 +122,7 @@ public class GroupNameNotes extends VersionedMetaData {
|
||||
AccountGroup.UUID groupUuid,
|
||||
AccountGroup.NameKey oldName,
|
||||
AccountGroup.NameKey newName)
|
||||
throws IOException, ConfigInvalidException, OrmDuplicateKeyException {
|
||||
throws IOException, ConfigInvalidException, DuplicateKeyException {
|
||||
requireNonNull(oldName);
|
||||
requireNonNull(newName);
|
||||
|
||||
@@ -146,14 +146,14 @@ public class GroupNameNotes extends VersionedMetaData {
|
||||
* @return an instance of {@code GroupNameNotes} configured for a specific group creation
|
||||
* @throws IOException if the repository can't be accessed for some reason
|
||||
* @throws ConfigInvalidException in no case so far
|
||||
* @throws OrmDuplicateKeyException if a group with the new name already exists
|
||||
* @throws DuplicateKeyException if a group with the new name already exists
|
||||
*/
|
||||
public static GroupNameNotes forNewGroup(
|
||||
Project.NameKey projectName,
|
||||
Repository repository,
|
||||
AccountGroup.UUID groupUuid,
|
||||
AccountGroup.NameKey groupName)
|
||||
throws IOException, ConfigInvalidException, OrmDuplicateKeyException {
|
||||
throws IOException, ConfigInvalidException, DuplicateKeyException {
|
||||
requireNonNull(groupName);
|
||||
|
||||
GroupNameNotes groupNameNotes = new GroupNameNotes(groupUuid, null, groupName);
|
||||
@@ -363,9 +363,9 @@ public class GroupNameNotes extends VersionedMetaData {
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureNewNameIsNotUsed() throws OrmDuplicateKeyException {
|
||||
private void ensureNewNameIsNotUsed() throws DuplicateKeyException {
|
||||
if (newGroupName.isPresent() && nameConflicting) {
|
||||
throw new OrmDuplicateKeyException(
|
||||
throw new DuplicateKeyException(
|
||||
String.format("Name '%s' is already used", newGroupName.get().get()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.DuplicateKeyException;
|
||||
import com.google.gerrit.exceptions.NoSuchGroupException;
|
||||
import com.google.gerrit.git.LockFailureException;
|
||||
import com.google.gerrit.git.RefUpdateUtil;
|
||||
@@ -45,7 +46,6 @@ import com.google.gerrit.server.logging.TraceContext;
|
||||
import com.google.gerrit.server.logging.TraceContext.TraceTimer;
|
||||
import com.google.gerrit.server.update.RetryHelper;
|
||||
import com.google.gerrit.server.util.time.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmDuplicateKeyException;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import com.google.inject.assistedinject.AssistedInject;
|
||||
@@ -256,13 +256,13 @@ public class GroupsUpdate {
|
||||
* @param groupUpdate an {@code InternalGroupUpdate} which specifies optional properties of the
|
||||
* group. If this {@code InternalGroupUpdate} updates a property which was already specified
|
||||
* by the {@code InternalGroupCreation}, the value of this {@code InternalGroupUpdate} wins.
|
||||
* @throws OrmDuplicateKeyException if a group with the chosen name already exists
|
||||
* @throws DuplicateKeyException if a group with the chosen name already exists
|
||||
* @throws IOException if indexing fails, or an error occurs while reading/writing from/to NoteDb
|
||||
* @return the created {@code InternalGroup}
|
||||
*/
|
||||
public InternalGroup createGroup(
|
||||
InternalGroupCreation groupCreation, InternalGroupUpdate groupUpdate)
|
||||
throws OrmDuplicateKeyException, IOException, ConfigInvalidException {
|
||||
throws DuplicateKeyException, IOException, ConfigInvalidException {
|
||||
try (TraceTimer timer =
|
||||
TraceContext.newTimer(
|
||||
"Creating group '%s'", groupUpdate.getName().orElseGet(groupCreation::getNameKey))) {
|
||||
@@ -279,12 +279,12 @@ public class GroupsUpdate {
|
||||
* @param groupUuid the UUID of the group to update
|
||||
* @param groupUpdate an {@code InternalGroupUpdate} which indicates the desired updates on the
|
||||
* group
|
||||
* @throws OrmDuplicateKeyException if the new name of the group is used by another group
|
||||
* @throws DuplicateKeyException if the new name of the group is used by another group
|
||||
* @throws IOException if indexing fails, or an error occurs while reading/writing from/to NoteDb
|
||||
* @throws NoSuchGroupException if the specified group doesn't exist
|
||||
*/
|
||||
public void updateGroup(AccountGroup.UUID groupUuid, InternalGroupUpdate groupUpdate)
|
||||
throws OrmDuplicateKeyException, IOException, NoSuchGroupException, ConfigInvalidException {
|
||||
throws DuplicateKeyException, IOException, NoSuchGroupException, ConfigInvalidException {
|
||||
try (TraceTimer timer = TraceContext.newTimer("Updating group %s", groupUuid)) {
|
||||
Optional<Timestamp> updatedOn = groupUpdate.getUpdatedOn();
|
||||
if (!updatedOn.isPresent()) {
|
||||
@@ -301,7 +301,7 @@ public class GroupsUpdate {
|
||||
|
||||
private InternalGroup createGroupInNoteDbWithRetry(
|
||||
InternalGroupCreation groupCreation, InternalGroupUpdate groupUpdate)
|
||||
throws IOException, ConfigInvalidException, OrmDuplicateKeyException {
|
||||
throws IOException, ConfigInvalidException, DuplicateKeyException {
|
||||
try {
|
||||
return retryHelper.execute(
|
||||
RetryHelper.ActionType.GROUP_UPDATE,
|
||||
@@ -311,7 +311,7 @@ public class GroupsUpdate {
|
||||
Throwables.throwIfUnchecked(e);
|
||||
Throwables.throwIfInstanceOf(e, IOException.class);
|
||||
Throwables.throwIfInstanceOf(e, ConfigInvalidException.class);
|
||||
Throwables.throwIfInstanceOf(e, OrmDuplicateKeyException.class);
|
||||
Throwables.throwIfInstanceOf(e, DuplicateKeyException.class);
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
@@ -319,7 +319,7 @@ public class GroupsUpdate {
|
||||
@VisibleForTesting
|
||||
public InternalGroup createGroupInNoteDb(
|
||||
InternalGroupCreation groupCreation, InternalGroupUpdate groupUpdate)
|
||||
throws IOException, ConfigInvalidException, OrmDuplicateKeyException {
|
||||
throws IOException, ConfigInvalidException, DuplicateKeyException {
|
||||
try (Repository allUsersRepo = repoManager.openRepository(allUsersName)) {
|
||||
AccountGroup.NameKey groupName = groupUpdate.getName().orElseGet(groupCreation::getNameKey);
|
||||
GroupNameNotes groupNameNotes =
|
||||
@@ -341,7 +341,7 @@ public class GroupsUpdate {
|
||||
|
||||
private UpdateResult updateGroupInNoteDbWithRetry(
|
||||
AccountGroup.UUID groupUuid, InternalGroupUpdate groupUpdate)
|
||||
throws IOException, ConfigInvalidException, OrmDuplicateKeyException, NoSuchGroupException {
|
||||
throws IOException, ConfigInvalidException, DuplicateKeyException, NoSuchGroupException {
|
||||
try {
|
||||
return retryHelper.execute(
|
||||
RetryHelper.ActionType.GROUP_UPDATE,
|
||||
@@ -351,7 +351,7 @@ public class GroupsUpdate {
|
||||
Throwables.throwIfUnchecked(e);
|
||||
Throwables.throwIfInstanceOf(e, IOException.class);
|
||||
Throwables.throwIfInstanceOf(e, ConfigInvalidException.class);
|
||||
Throwables.throwIfInstanceOf(e, OrmDuplicateKeyException.class);
|
||||
Throwables.throwIfInstanceOf(e, DuplicateKeyException.class);
|
||||
Throwables.throwIfInstanceOf(e, NoSuchGroupException.class);
|
||||
throw new IOException(e);
|
||||
}
|
||||
@@ -360,7 +360,7 @@ public class GroupsUpdate {
|
||||
@VisibleForTesting
|
||||
public UpdateResult updateGroupInNoteDb(
|
||||
AccountGroup.UUID groupUuid, InternalGroupUpdate groupUpdate)
|
||||
throws IOException, ConfigInvalidException, OrmDuplicateKeyException, NoSuchGroupException {
|
||||
throws IOException, ConfigInvalidException, DuplicateKeyException, NoSuchGroupException {
|
||||
try (Repository allUsersRepo = repoManager.openRepository(allUsersName)) {
|
||||
GroupConfig groupConfig = GroupConfig.loadForGroup(allUsersName, allUsersRepo, groupUuid);
|
||||
groupConfig.setGroupUpdate(groupUpdate, auditLogFormatter);
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.index.account;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.index.Index;
|
||||
import com.google.gerrit.index.QueryOptions;
|
||||
import com.google.gerrit.index.query.DataSource;
|
||||
@@ -25,7 +26,6 @@ import com.google.gerrit.index.query.Predicate;
|
||||
import com.google.gerrit.index.query.QueryParseException;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.server.account.AccountState;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
|
||||
public class IndexedAccountQuery extends IndexedQuery<Account.Id, AccountState>
|
||||
implements DataSource<AccountState>, Matchable<AccountState> {
|
||||
@@ -37,7 +37,7 @@ public class IndexedAccountQuery extends IndexedQuery<Account.Id, AccountState>
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(AccountState accountState) throws OrmException {
|
||||
public boolean match(AccountState accountState) throws StorageException {
|
||||
Predicate<AccountState> pred = getChild(0);
|
||||
checkState(
|
||||
pred.isMatchable(),
|
||||
|
||||
@@ -42,6 +42,7 @@ import com.google.common.io.Files;
|
||||
import com.google.common.primitives.Longs;
|
||||
import com.google.gerrit.common.data.SubmitRecord;
|
||||
import com.google.gerrit.common.data.SubmitRequirement;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.index.FieldDef;
|
||||
import com.google.gerrit.index.RefState;
|
||||
import com.google.gerrit.index.SchemaUtil;
|
||||
@@ -72,7 +73,6 @@ import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.ChangeQueryBuilder;
|
||||
import com.google.gerrit.server.query.change.ChangeStatusPredicate;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
@@ -154,12 +154,12 @@ public class ChangeField {
|
||||
exact(ChangeQueryBuilder.FIELD_FILE)
|
||||
.buildRepeatable(cd -> firstNonNull(cd.currentFilePaths(), ImmutableList.of()));
|
||||
|
||||
public static Set<String> getFileParts(ChangeData cd) throws OrmException {
|
||||
public static Set<String> getFileParts(ChangeData cd) throws StorageException {
|
||||
List<String> paths;
|
||||
try {
|
||||
paths = cd.currentFilePaths();
|
||||
} catch (IOException e) {
|
||||
throw new OrmException(e);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
|
||||
Splitter s = Splitter.on('/').omitEmptyStrings();
|
||||
@@ -191,7 +191,7 @@ public class ChangeField {
|
||||
public static final FieldDef<ChangeData, Iterable<String>> EXTENSION =
|
||||
exact(ChangeQueryBuilder.FIELD_EXTENSION).buildRepeatable(ChangeField::getExtensions);
|
||||
|
||||
public static Set<String> getExtensions(ChangeData cd) throws OrmException {
|
||||
public static Set<String> getExtensions(ChangeData cd) throws StorageException {
|
||||
return extensions(cd).collect(toSet());
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ public class ChangeField {
|
||||
public static final FieldDef<ChangeData, String> ONLY_EXTENSIONS =
|
||||
exact(ChangeQueryBuilder.FIELD_ONLY_EXTENSIONS).build(ChangeField::getAllExtensionsAsList);
|
||||
|
||||
public static String getAllExtensionsAsList(ChangeData cd) throws OrmException {
|
||||
public static String getAllExtensionsAsList(ChangeData cd) throws StorageException {
|
||||
return extensions(cd).distinct().sorted().collect(joining(","));
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ public class ChangeField {
|
||||
* <p>If the change contains multiple files with the same extension the extension is returned
|
||||
* multiple times in the stream (once per file).
|
||||
*/
|
||||
private static Stream<String> extensions(ChangeData cd) throws OrmException {
|
||||
private static Stream<String> extensions(ChangeData cd) throws StorageException {
|
||||
try {
|
||||
return cd.currentFilePaths().stream()
|
||||
// Use case-insensitive file extensions even though other file fields are case-sensitive.
|
||||
@@ -223,7 +223,7 @@ public class ChangeField {
|
||||
// predicates to be case insensitive is a separate question.)
|
||||
.map(f -> Files.getFileExtension(f).toLowerCase(Locale.US));
|
||||
} catch (IOException e) {
|
||||
throw new OrmException(e);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,13 +231,13 @@ public class ChangeField {
|
||||
public static final FieldDef<ChangeData, Iterable<String>> FOOTER =
|
||||
exact(ChangeQueryBuilder.FIELD_FOOTER).buildRepeatable(ChangeField::getFooters);
|
||||
|
||||
public static Set<String> getFooters(ChangeData cd) throws OrmException {
|
||||
public static Set<String> getFooters(ChangeData cd) throws StorageException {
|
||||
try {
|
||||
return cd.commitFooters().stream()
|
||||
.map(f -> f.toString().toLowerCase(Locale.US))
|
||||
.collect(toSet());
|
||||
} catch (IOException e) {
|
||||
throw new OrmException(e);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,12 +245,12 @@ public class ChangeField {
|
||||
public static final FieldDef<ChangeData, Iterable<String>> DIRECTORY =
|
||||
exact(ChangeQueryBuilder.FIELD_DIRECTORY).buildRepeatable(ChangeField::getDirectories);
|
||||
|
||||
public static Set<String> getDirectories(ChangeData cd) throws OrmException {
|
||||
public static Set<String> getDirectories(ChangeData cd) throws StorageException {
|
||||
List<String> paths;
|
||||
try {
|
||||
paths = cd.currentFilePaths();
|
||||
} catch (IOException e) {
|
||||
throw new OrmException(e);
|
||||
throw new StorageException(e);
|
||||
}
|
||||
|
||||
Splitter s = Splitter.on('/').omitEmptyStrings();
|
||||
@@ -470,7 +470,7 @@ public class ChangeField {
|
||||
public static final FieldDef<ChangeData, Iterable<String>> EXACT_COMMIT =
|
||||
exact(ChangeQueryBuilder.FIELD_EXACTCOMMIT).buildRepeatable(ChangeField::getRevisions);
|
||||
|
||||
private static Set<String> getRevisions(ChangeData cd) throws OrmException {
|
||||
private static Set<String> getRevisions(ChangeData cd) throws StorageException {
|
||||
Set<String> revisions = new HashSet<>();
|
||||
for (PatchSet ps : cd.patchSets()) {
|
||||
if (ps.getRevision() != null) {
|
||||
@@ -489,7 +489,7 @@ public class ChangeField {
|
||||
public static final FieldDef<ChangeData, Iterable<String>> LABEL =
|
||||
exact("label2").buildRepeatable(cd -> getLabels(cd, true));
|
||||
|
||||
private static Iterable<String> getLabels(ChangeData cd, boolean owners) throws OrmException {
|
||||
private static Iterable<String> getLabels(ChangeData cd, boolean owners) throws StorageException {
|
||||
Set<String> allApprovals = new HashSet<>();
|
||||
Set<String> distinctApprovals = new HashSet<>();
|
||||
for (PatchSetApproval a : cd.currentApprovals()) {
|
||||
@@ -506,20 +506,21 @@ public class ChangeField {
|
||||
return allApprovals;
|
||||
}
|
||||
|
||||
public static Set<String> getAuthorParts(ChangeData cd) throws OrmException, IOException {
|
||||
public static Set<String> getAuthorParts(ChangeData cd) throws StorageException, IOException {
|
||||
return SchemaUtil.getPersonParts(cd.getAuthor());
|
||||
}
|
||||
|
||||
public static Set<String> getAuthorNameAndEmail(ChangeData cd) throws OrmException, IOException {
|
||||
public static Set<String> getAuthorNameAndEmail(ChangeData cd)
|
||||
throws StorageException, IOException {
|
||||
return getNameAndEmail(cd.getAuthor());
|
||||
}
|
||||
|
||||
public static Set<String> getCommitterParts(ChangeData cd) throws OrmException, IOException {
|
||||
public static Set<String> getCommitterParts(ChangeData cd) throws StorageException, IOException {
|
||||
return SchemaUtil.getPersonParts(cd.getCommitter());
|
||||
}
|
||||
|
||||
public static Set<String> getCommitterNameAndEmail(ChangeData cd)
|
||||
throws OrmException, IOException {
|
||||
throws StorageException, IOException {
|
||||
return getNameAndEmail(cd.getCommitter());
|
||||
}
|
||||
|
||||
@@ -855,7 +856,7 @@ public class ChangeField {
|
||||
return storedSubmitRecords(cd.submitRecords(opts));
|
||||
}
|
||||
|
||||
public static List<String> formatSubmitRecordValues(ChangeData cd) throws OrmException {
|
||||
public static List<String> formatSubmitRecordValues(ChangeData cd) throws StorageException {
|
||||
return formatSubmitRecordValues(
|
||||
cd.submitRecords(SUBMIT_RULE_OPTIONS_STRICT), cd.change().getOwner());
|
||||
}
|
||||
@@ -943,7 +944,7 @@ public class ChangeField {
|
||||
return result;
|
||||
});
|
||||
|
||||
private static String getTopic(ChangeData cd) throws OrmException {
|
||||
private static String getTopic(ChangeData cd) throws StorageException {
|
||||
Change c = cd.change();
|
||||
if (c == null) {
|
||||
return null;
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.index.IndexConfig;
|
||||
import com.google.gerrit.index.QueryOptions;
|
||||
import com.google.gerrit.index.query.DataSource;
|
||||
@@ -34,7 +35,6 @@ import com.google.gerrit.index.query.ResultSet;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gerrit.server.query.change.ChangeDataSource;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@@ -81,7 +81,7 @@ public class IndexedChangeQuery extends IndexedQuery<Change.Id, ChangeData>
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultSet<ChangeData> read() throws OrmException {
|
||||
public ResultSet<ChangeData> read() throws StorageException {
|
||||
final DataSource<ChangeData> currSource = source;
|
||||
final ResultSet<ChangeData> rs = currSource.read();
|
||||
|
||||
@@ -114,7 +114,7 @@ public class IndexedChangeQuery extends IndexedQuery<Change.Id, ChangeData>
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean match(ChangeData cd) throws OrmException {
|
||||
public boolean match(ChangeData cd) throws StorageException {
|
||||
if (source != null && fromSource.get(cd) == source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.util.concurrent.FutureCallback;
|
||||
import com.google.common.util.concurrent.Futures;
|
||||
import com.google.common.util.concurrent.ListeningExecutorService;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.events.GitReferenceUpdatedListener;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Branch;
|
||||
@@ -39,7 +40,6 @@ import com.google.gerrit.server.query.change.InternalChangeQuery;
|
||||
import com.google.gerrit.server.util.ManualRequestContext;
|
||||
import com.google.gerrit.server.util.OneOffRequestContext;
|
||||
import com.google.gerrit.server.util.RequestContext;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import java.io.IOException;
|
||||
@@ -152,7 +152,7 @@ public class ReindexAfterRefUpdate implements GitReferenceUpdatedListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Change> impl(RequestContext ctx) throws OrmException {
|
||||
protected List<Change> impl(RequestContext ctx) throws StorageException {
|
||||
String ref = event.getRefName();
|
||||
Project.NameKey project = new Project.NameKey(event.getProjectName());
|
||||
if (ref.equals(RefNames.REFS_CONFIG)) {
|
||||
@@ -179,7 +179,7 @@ public class ReindexAfterRefUpdate implements GitReferenceUpdatedListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void impl(RequestContext ctx) throws OrmException, IOException {
|
||||
protected Void impl(RequestContext ctx) throws StorageException, IOException {
|
||||
// Reload change, as some time may have passed since GetChanges.
|
||||
try {
|
||||
Change c =
|
||||
|
||||
@@ -18,11 +18,11 @@ import static com.google.gerrit.server.notedb.ReviewerStateInternal.CC;
|
||||
import static com.google.gerrit.server.notedb.ReviewerStateInternal.REVIEWER;
|
||||
|
||||
import com.google.gerrit.common.FooterConstants;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.restapi.UnprocessableEntityException;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.server.ReviewerSet;
|
||||
import com.google.gerrit.server.account.AccountResolver;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@@ -37,7 +37,7 @@ public class MailUtil {
|
||||
|
||||
public static MailRecipients getRecipientsFromFooters(
|
||||
AccountResolver accountResolver, List<FooterLine> footerLines)
|
||||
throws OrmException, IOException, ConfigInvalidException {
|
||||
throws StorageException, IOException, ConfigInvalidException {
|
||||
MailRecipients recipients = new MailRecipients();
|
||||
for (FooterLine footerLine : footerLines) {
|
||||
try {
|
||||
@@ -62,7 +62,7 @@ public class MailUtil {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static Account.Id toAccountId(AccountResolver accountResolver, String nameOrEmail)
|
||||
throws OrmException, UnprocessableEntityException, IOException, ConfigInvalidException {
|
||||
throws StorageException, UnprocessableEntityException, IOException, ConfigInvalidException {
|
||||
return accountResolver.resolveByNameOrEmail(nameOrEmail).asUnique().getAccount().getId();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import static java.util.stream.Collectors.toList;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.client.Side;
|
||||
import com.google.gerrit.extensions.registration.DynamicItem;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||
@@ -64,7 +65,6 @@ import com.google.gerrit.server.update.UpdateException;
|
||||
import com.google.gerrit.server.util.ManualRequestContext;
|
||||
import com.google.gerrit.server.util.OneOffRequestContext;
|
||||
import com.google.gerrit.server.util.time.TimeUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -147,7 +147,7 @@ public class MailProcessor {
|
||||
}
|
||||
|
||||
private void processImpl(BatchUpdate.Factory buf, MailMessage message)
|
||||
throws OrmException, UpdateException, RestApiException, IOException {
|
||||
throws StorageException, UpdateException, RestApiException, IOException {
|
||||
for (Extension<MailFilter> filter : mailFilters) {
|
||||
if (!filter.getProvider().get().shouldProcessMessage(message)) {
|
||||
logger.atWarning().log(
|
||||
@@ -208,7 +208,7 @@ public class MailProcessor {
|
||||
|
||||
private void persistComments(
|
||||
BatchUpdate.Factory buf, MailMessage message, MailMetadata metadata, Account.Id sender)
|
||||
throws OrmException, UpdateException, RestApiException {
|
||||
throws StorageException, UpdateException, RestApiException {
|
||||
try (ManualRequestContext ctx = oneOffRequestContext.openAs(sender)) {
|
||||
List<ChangeData> changeDataList =
|
||||
queryProvider.get().byLegacyChangeId(new Change.Id(metadata.changeNumber));
|
||||
@@ -283,11 +283,11 @@ public class MailProcessor {
|
||||
|
||||
@Override
|
||||
public boolean updateChange(ChangeContext ctx)
|
||||
throws OrmException, UnprocessableEntityException, PatchListNotAvailableException {
|
||||
throws StorageException, UnprocessableEntityException, PatchListNotAvailableException {
|
||||
patchSet = psUtil.get(ctx.getNotes(), psId);
|
||||
notes = ctx.getNotes();
|
||||
if (patchSet == null) {
|
||||
throw new OrmException("patch set not found: " + psId);
|
||||
throw new StorageException("patch set not found: " + psId);
|
||||
}
|
||||
|
||||
changeMessage = generateChangeMessage(ctx);
|
||||
@@ -358,7 +358,7 @@ public class MailProcessor {
|
||||
}
|
||||
|
||||
private PatchSet targetPatchSetForComment(
|
||||
ChangeContext ctx, MailComment mailComment, PatchSet current) throws OrmException {
|
||||
ChangeContext ctx, MailComment mailComment, PatchSet current) throws StorageException {
|
||||
if (mailComment.getInReplyTo() != null) {
|
||||
return psUtil.get(
|
||||
ctx.getNotes(),
|
||||
@@ -369,7 +369,7 @@ public class MailProcessor {
|
||||
|
||||
private Comment persistentCommentFromMailComment(
|
||||
ChangeContext ctx, MailComment mailComment, PatchSet patchSetForComment)
|
||||
throws OrmException, UnprocessableEntityException, PatchListNotAvailableException {
|
||||
throws StorageException, UnprocessableEntityException, PatchListNotAvailableException {
|
||||
String fileName;
|
||||
// The patch set that this comment is based on is different if this
|
||||
// comment was sent in reply to a comment on a previous patch set.
|
||||
@@ -412,7 +412,7 @@ public class MailProcessor {
|
||||
return "(" + numComments + (numComments > 1 ? " comments)" : " comment)");
|
||||
}
|
||||
|
||||
private Set<String> existingMessageIds(ChangeData cd) throws OrmException {
|
||||
private Set<String> existingMessageIds(ChangeData cd) throws StorageException {
|
||||
Set<String> existingMessageIds = new HashSet<>();
|
||||
cd.messages().stream()
|
||||
.forEach(
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
package com.google.gerrit.server.mail.send;
|
||||
|
||||
import com.google.gerrit.exceptions.EmailException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class AbandonedSender extends ReplyToChangeSender {
|
||||
@Inject
|
||||
public AbandonedSender(
|
||||
EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
super(ea, "abandon", ChangeEmail.newChangeData(ea, project, id));
|
||||
}
|
||||
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
package com.google.gerrit.server.mail.send;
|
||||
|
||||
import com.google.gerrit.exceptions.EmailException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
@@ -30,7 +30,7 @@ public class AddReviewerSender extends NewChangeSender {
|
||||
@Inject
|
||||
public AddReviewerSender(
|
||||
EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
super(ea, newChangeData(ea, project, id));
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.Nullable;
|
||||
import com.google.gerrit.exceptions.EmailException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.extensions.api.changes.RecipientType;
|
||||
import com.google.gerrit.extensions.restapi.AuthException;
|
||||
@@ -43,7 +44,6 @@ import com.google.gerrit.server.permissions.GlobalPermission;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gerrit.server.project.ProjectState;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.template.soy.data.SoyListData;
|
||||
import com.google.template.soy.data.SoyMapData;
|
||||
import java.io.IOException;
|
||||
@@ -84,7 +84,7 @@ public abstract class ChangeEmail extends NotificationEmail {
|
||||
protected Set<Account.Id> authors;
|
||||
protected boolean emailOnlyAuthors;
|
||||
|
||||
protected ChangeEmail(EmailArguments ea, String mc, ChangeData cd) throws OrmException {
|
||||
protected ChangeEmail(EmailArguments ea, String mc, ChangeData cd) throws StorageException {
|
||||
super(ea, mc, cd.change().getDest());
|
||||
changeData = cd;
|
||||
change = cd.change();
|
||||
@@ -150,7 +150,7 @@ public abstract class ChangeEmail extends NotificationEmail {
|
||||
if (patchSet == null) {
|
||||
try {
|
||||
patchSet = changeData.currentPatchSet();
|
||||
} catch (OrmException err) {
|
||||
} catch (StorageException err) {
|
||||
patchSet = null;
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,7 @@ public abstract class ChangeEmail extends NotificationEmail {
|
||||
if (patchSetInfo == null) {
|
||||
try {
|
||||
patchSetInfo = args.patchSetInfoFactory.get(changeData.notes(), patchSet.getId());
|
||||
} catch (PatchSetInfoNotAvailableException | OrmException err) {
|
||||
} catch (PatchSetInfoNotAvailableException | StorageException err) {
|
||||
patchSetInfo = null;
|
||||
}
|
||||
}
|
||||
@@ -169,7 +169,7 @@ public abstract class ChangeEmail extends NotificationEmail {
|
||||
|
||||
try {
|
||||
stars = changeData.stars();
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
throw new EmailException("Failed to load stars for change " + change.getChangeId(), e);
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ public abstract class ChangeEmail extends NotificationEmail {
|
||||
addByEmail(
|
||||
RecipientType.CC,
|
||||
changeData.reviewersByEmail().byState(ReviewerStateInternal.REVIEWER));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
throw new EmailException("Failed to add unregistered CCs " + change.getChangeId(), e);
|
||||
}
|
||||
}
|
||||
@@ -294,7 +294,7 @@ public abstract class ChangeEmail extends NotificationEmail {
|
||||
} else {
|
||||
try {
|
||||
ps = args.patchSetUtil.get(changeData.notes(), new PatchSet.Id(change.getId(), patchSetId));
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
throw new PatchListNotAvailableException("Failed to get patchSet");
|
||||
}
|
||||
}
|
||||
@@ -344,7 +344,7 @@ public abstract class ChangeEmail extends NotificationEmail {
|
||||
|
||||
@Override
|
||||
protected final Watchers getWatchers(NotifyType type, boolean includeWatchersFromNotifyConfig)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
if (!NotifyHandling.ALL.equals(notify.handling())) {
|
||||
return new Watchers();
|
||||
}
|
||||
@@ -364,7 +364,7 @@ public abstract class ChangeEmail extends NotificationEmail {
|
||||
for (Account.Id id : changeData.reviewers().all()) {
|
||||
add(RecipientType.CC, id);
|
||||
}
|
||||
} catch (OrmException err) {
|
||||
} catch (StorageException err) {
|
||||
logger.atWarning().withCause(err).log("Cannot CC users that reviewed updated change");
|
||||
}
|
||||
}
|
||||
@@ -380,7 +380,7 @@ public abstract class ChangeEmail extends NotificationEmail {
|
||||
for (Account.Id id : changeData.reviewers().byState(ReviewerStateInternal.REVIEWER)) {
|
||||
add(RecipientType.CC, id);
|
||||
}
|
||||
} catch (OrmException err) {
|
||||
} catch (StorageException err) {
|
||||
logger.atWarning().withCause(err).log("Cannot CC users that commented on updated change");
|
||||
}
|
||||
}
|
||||
@@ -506,7 +506,7 @@ public abstract class ChangeEmail extends NotificationEmail {
|
||||
for (Account.Id who : changeData.reviewers().byState(state)) {
|
||||
reviewers.add(getNameEmailFor(who));
|
||||
}
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atWarning().withCause(e).log("Cannot get change reviewers");
|
||||
}
|
||||
return reviewers;
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.common.data.FilenameComparator;
|
||||
import com.google.gerrit.exceptions.EmailException;
|
||||
import com.google.gerrit.exceptions.NoSuchEntityException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.NotifyHandling;
|
||||
import com.google.gerrit.mail.MailHeader;
|
||||
import com.google.gerrit.mail.MailProcessingUtil;
|
||||
@@ -41,7 +42,6 @@ import com.google.gerrit.server.patch.PatchListNotAvailableException;
|
||||
import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||
import com.google.gerrit.server.util.LabelVote;
|
||||
import com.google.gwtorm.client.KeyUtil;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.io.IOException;
|
||||
@@ -120,7 +120,7 @@ public class CommentSender extends ReplyToChangeSender {
|
||||
@GerritServerConfig Config cfg,
|
||||
@Assisted Project.NameKey project,
|
||||
@Assisted Change.Id id)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
super(ea, "comment", newChangeData(ea, project, id));
|
||||
this.commentsUtil = commentsUtil;
|
||||
this.incomingEmailEnabled =
|
||||
@@ -129,7 +129,7 @@ public class CommentSender extends ReplyToChangeSender {
|
||||
this.replyToAddress = cfg.getString("sendemail", null, "replyToAddress");
|
||||
}
|
||||
|
||||
public void setComments(List<Comment> comments) throws OrmException {
|
||||
public void setComments(List<Comment> comments) throws StorageException {
|
||||
inlineComments = comments;
|
||||
|
||||
Set<String> paths = new HashSet<>();
|
||||
@@ -316,7 +316,7 @@ public class CommentSender extends ReplyToChangeSender {
|
||||
Comment.Key key = new Comment.Key(child.parentUuid, child.key.filename, child.key.patchSetId);
|
||||
try {
|
||||
return commentsUtil.getPublished(changeData.notes(), key);
|
||||
} catch (OrmException e) {
|
||||
} catch (StorageException e) {
|
||||
logger.atWarning().log("Could not find the parent of this comment: %s", child);
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ package com.google.gerrit.server.mail.send;
|
||||
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.gerrit.exceptions.EmailException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.RecipientType;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
@@ -24,7 +25,6 @@ import com.google.gerrit.server.account.ProjectWatches.NotifyType;
|
||||
import com.google.gerrit.server.mail.send.ProjectWatch.Watchers;
|
||||
import com.google.gerrit.server.permissions.PermissionBackend;
|
||||
import com.google.gerrit.server.permissions.RefPermission;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.util.stream.StreamSupport;
|
||||
@@ -45,7 +45,7 @@ public class CreateChangeSender extends NewChangeSender {
|
||||
PermissionBackend permissionBackend,
|
||||
@Assisted Project.NameKey project,
|
||||
@Assisted Change.Id id)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
super(ea, newChangeData(ea, project, id));
|
||||
this.permissionBackend = permissionBackend;
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public class CreateChangeSender extends NewChangeSender {
|
||||
add(RecipientType.TO, matching.to);
|
||||
add(RecipientType.CC, matching.cc);
|
||||
add(RecipientType.BCC, matching.bcc);
|
||||
} catch (OrmException err) {
|
||||
} catch (StorageException err) {
|
||||
// Just don't CC everyone. Better to send a partial message to those
|
||||
// we already have queued up then to fail deliver entirely to people
|
||||
// who have a lower interest in the change.
|
||||
|
||||
@@ -15,13 +15,13 @@
|
||||
package com.google.gerrit.server.mail.send;
|
||||
|
||||
import com.google.gerrit.exceptions.EmailException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.RecipientType;
|
||||
import com.google.gerrit.mail.Address;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.util.ArrayList;
|
||||
@@ -43,7 +43,7 @@ public class DeleteReviewerSender extends ReplyToChangeSender {
|
||||
@Inject
|
||||
public DeleteReviewerSender(
|
||||
EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
super(ea, "deleteReviewer", newChangeData(ea, project, id));
|
||||
}
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@
|
||||
package com.google.gerrit.server.mail.send;
|
||||
|
||||
import com.google.gerrit.exceptions.EmailException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
@@ -32,7 +32,7 @@ public class DeleteVoteSender extends ReplyToChangeSender {
|
||||
@Inject
|
||||
protected DeleteVoteSender(
|
||||
EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
super(ea, "deleteVote", newChangeData(ea, project, id));
|
||||
}
|
||||
|
||||
|
||||
@@ -20,12 +20,12 @@ import com.google.gerrit.common.data.LabelType;
|
||||
import com.google.gerrit.common.data.LabelTypes;
|
||||
import com.google.gerrit.common.data.LabelValue;
|
||||
import com.google.gerrit.exceptions.EmailException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.PatchSetApproval;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.account.ProjectWatches.NotifyType;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
|
||||
@@ -39,7 +39,7 @@ public class MergedSender extends ReplyToChangeSender {
|
||||
|
||||
@Inject
|
||||
public MergedSender(EmailArguments ea, @Assisted Project.NameKey project, @Assisted Change.Id id)
|
||||
throws OrmException {
|
||||
throws StorageException {
|
||||
super(ea, "merged", newChangeData(ea, project, id));
|
||||
labelTypes = changeData.getLabelTypes();
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public class MergedSender extends ReplyToChangeSender {
|
||||
}
|
||||
|
||||
return format("Approvals", pos) + format("Objections", neg);
|
||||
} catch (OrmException err) {
|
||||
} catch (StorageException err) {
|
||||
// Don't list the approvals
|
||||
}
|
||||
return "";
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
package com.google.gerrit.server.mail.send;
|
||||
|
||||
import com.google.gerrit.exceptions.EmailException;
|
||||
import com.google.gerrit.exceptions.StorageException;
|
||||
import com.google.gerrit.extensions.api.changes.RecipientType;
|
||||
import com.google.gerrit.mail.Address;
|
||||
import com.google.gerrit.reviewdb.client.Account;
|
||||
import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
@@ -33,7 +33,7 @@ public abstract class NewChangeSender extends ChangeEmail {
|
||||
private final Set<Account.Id> extraCC = new HashSet<>();
|
||||
private final Set<Address> extraCCByEmail = new HashSet<>();
|
||||
|
||||
protected NewChangeSender(EmailArguments ea, ChangeData cd) throws OrmException {
|
||||
protected NewChangeSender(EmailArguments ea, ChangeData cd) throws StorageException {
|
||||
super(ea, "newchange", cd);
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user