List of usage examples for org.eclipse.jgit.util MutableInteger MutableInteger
MutableInteger
From source file:com.google.gerrit.acceptance.rest.account.ExternalIdIT.java
License:Apache License
private void insertValidExternalIds() throws IOException, ConfigInvalidException, OrmException { MutableInteger i = new MutableInteger(); String scheme = "valid"; ExternalIdsUpdate u = extIdsUpdate.create(); // create valid external IDs u.insert(db, ExternalId.createWithPassword(ExternalId.Key.parse(nextId(scheme, i)), admin.id, "admin.other@example.com", "secret-password")); u.insert(db, createExternalIdWithOtherCaseEmail(nextId(scheme, i))); }
From source file:com.google.gerrit.acceptance.rest.account.ExternalIdIT.java
License:Apache License
private Set<ConsistencyProblemInfo> insertInvalidButParsableExternalIds() throws IOException, ConfigInvalidException, OrmException { MutableInteger i = new MutableInteger(); String scheme = "invalid"; ExternalIdsUpdate u = extIdsUpdate.create(); Set<ConsistencyProblemInfo> expectedProblems = new HashSet<>(); ExternalId extIdForNonExistingAccount = createExternalIdForNonExistingAccount(nextId(scheme, i)); u.insert(db, extIdForNonExistingAccount); expectedProblems.add(consistencyError("External ID '" + extIdForNonExistingAccount.key().get() + "' belongs to account that doesn't exist: " + extIdForNonExistingAccount.accountId().get())); ExternalId extIdWithInvalidEmail = createExternalIdWithInvalidEmail(nextId(scheme, i)); u.insert(db, extIdWithInvalidEmail); expectedProblems.add(consistencyError("External ID '" + extIdWithInvalidEmail.key().get() + "' has an invalid email: " + extIdWithInvalidEmail.email())); ExternalId extIdWithDuplicateEmail = createExternalIdWithDuplicateEmail(nextId(scheme, i)); u.insert(db, extIdWithDuplicateEmail); expectedProblems.add(consistencyError("Email '" + extIdWithDuplicateEmail.email() + "' is not unique, it's used by the following external IDs: '" + extIdWithDuplicateEmail.key().get() + "', 'mailto:" + extIdWithDuplicateEmail.email() + "'")); ExternalId extIdWithBadPassword = createExternalIdWithBadPassword("admin-username"); u.insert(db, extIdWithBadPassword);/*from w w w. j a va 2 s. c o m*/ expectedProblems.add(consistencyError("External ID '" + extIdWithBadPassword.key().get() + "' has an invalid password: unrecognized algorithm")); return expectedProblems; }
From source file:com.google.gerrit.acceptance.rest.account.ExternalIdIT.java
License:Apache License
private Set<ConsistencyProblemInfo> insertNonParsableExternalIds() throws IOException { MutableInteger i = new MutableInteger(); String scheme = "corrupt"; Set<ConsistencyProblemInfo> expectedProblems = new HashSet<>(); try (Repository repo = repoManager.openRepository(allUsers); RevWalk rw = new RevWalk(repo)) { String externalId = nextId(scheme, i); String noteId = insertExternalIdWithoutAccountId(repo, rw, externalId); expectedProblems.add(consistencyError("Invalid external ID config for note '" + noteId + "': Value for 'externalId." + externalId + ".accountId' is missing, expected account ID")); externalId = nextId(scheme, i);/*w ww . ja v a 2 s . co m*/ noteId = insertExternalIdWithKeyThatDoesntMatchNoteId(repo, rw, externalId); expectedProblems.add(consistencyError("Invalid external ID config for note '" + noteId + "': SHA1 of external ID '" + externalId + "' does not match note ID '" + noteId + "'")); noteId = insertExternalIdWithInvalidConfig(repo, rw, nextId(scheme, i)); expectedProblems.add(consistencyError( "Invalid external ID config for note '" + noteId + "': Invalid line in config file")); noteId = insertExternalIdWithEmptyNote(repo, rw, nextId(scheme, i)); expectedProblems.add(consistencyError("Invalid external ID config for note '" + noteId + "': Expected exactly 1 'externalId' section, found 0")); } return expectedProblems; }
From source file:com.google.gerrit.server.index.change.ChangeIndexRewriter.java
License:Apache License
private Predicate<ChangeData> rewriteImpl(Predicate<ChangeData> in, QueryOptions opts) throws QueryParseException { ChangeIndex index = indexes.getSearchIndex(); MutableInteger leafTerms = new MutableInteger(); Predicate<ChangeData> out = rewriteImpl(in, index, opts, leafTerms); if (in == out || out instanceof IndexPredicate) { return new IndexedChangeQuery(index, out, opts); } else if (out == null /* cannot rewrite */) { return in; } else {/*from w w w. j a v a 2 s .c om*/ return out; } }
From source file:com.google.gerrit.server.index.change.IndexRewriter.java
License:Apache License
public Predicate<ChangeData> rewrite(Predicate<ChangeData> in, QueryOptions opts) throws QueryParseException { ChangeIndex index = indexes.getSearchIndex(); MutableInteger leafTerms = new MutableInteger(); Predicate<ChangeData> out = rewriteImpl(in, index, opts, leafTerms); if (in == out || out instanceof IndexPredicate) { return new IndexedChangeQuery(index, out, opts); } else if (out == null /* cannot rewrite */) { return in; } else {/* www .j a v a2 s . c o m*/ return out; } }
From source file:com.google.gerrit.server.index.IndexRewriteImpl.java
License:Apache License
@Override public Predicate<ChangeData> rewrite(Predicate<ChangeData> in, int start, int limit) throws QueryParseException { checkArgument(limit > 0, "limit must be positive: %s", limit); ChangeIndex index = indexes.getSearchIndex(); // Increase the limit rather than skipping, since we don't know how many // skipped results would have been filtered out by the enclosing AndSource. limit += start;/*from w w w . j ava2 s. com*/ MutableInteger leafTerms = new MutableInteger(); Predicate<ChangeData> out = rewriteImpl(in, index, limit, leafTerms); if (in == out || out instanceof IndexPredicate) { return new IndexedChangeQuery(index, out, limit); } else if (out == null /* cannot rewrite */) { return in; } else { return out; } }
From source file:com.google.gerrit.server.notedb.ChangeRevisionNote.java
License:Apache License
@Override protected List<Comment> parse(byte[] raw, int offset) throws IOException, ConfigInvalidException { MutableInteger p = new MutableInteger(); p.value = offset;//from w w w.j av a 2 s . c o m if (isJson(raw, p.value)) { RevisionNoteData data = parseJson(noteUtil, raw, p.value); if (status == PatchLineComment.Status.PUBLISHED) { pushCert = data.pushCert; } else { pushCert = null; } return data.comments; } if (status == PatchLineComment.Status.PUBLISHED) { pushCert = parsePushCert(changeId, raw, p); trimLeadingEmptyLines(raw, p); } else { pushCert = null; } return noteUtil.parseNote(raw, p, changeId); }
From source file:com.google.gerrit.server.notedb.CommentsInNotesUtil.java
License:Apache License
public static List<PatchLineComment> parseNote(byte[] note, Change.Id changeId, Status status) throws ConfigInvalidException { List<PatchLineComment> result = Lists.newArrayList(); int sizeOfNote = note.length; Charset enc = RawParseUtils.parseEncoding(note); MutableInteger curr = new MutableInteger(); curr.value = 0;/*from w w w. ja va 2 s. co m*/ boolean isForBase = (RawParseUtils.match(note, curr.value, PATCH_SET.getBytes(UTF_8))) < 0; PatchSet.Id psId = parsePsId(note, curr, changeId, enc, isForBase ? BASE_PATCH_SET : PATCH_SET); RevId revId = new RevId(parseStringField(note, curr, changeId, enc, REVISION)); PatchLineComment c = null; while (curr.value < sizeOfNote) { String previousFileName = c == null ? null : c.getKey().getParentKey().getFileName(); c = parseComment(note, curr, previousFileName, psId, revId, isForBase, enc, status); result.add(c); } return result; }
From source file:com.google.gerrit.server.notedb.CommentsInNotesUtil.java
License:Apache License
private static PatchSet.Id parsePsId(byte[] note, MutableInteger curr, Change.Id changeId, Charset enc, String fieldName) throws ConfigInvalidException { checkHeaderLineFormat(note, curr, fieldName, enc, changeId); int startOfPsId = RawParseUtils.endOfFooterLineKey(note, curr.value) + 1; MutableInteger i = new MutableInteger(); int patchSetId = RawParseUtils.parseBase10(note, startOfPsId, i); int endOfLine = RawParseUtils.nextLF(note, curr.value); if (i.value != endOfLine - 1) { throw parseException(changeId, "could not parse %s", fieldName); }//from w ww . jav a2 s.com checkResult(patchSetId, "patchset id", changeId); curr.value = endOfLine; return new PatchSet.Id(changeId, patchSetId); }
From source file:com.google.gerrit.server.notedb.CommentsInNotesUtil.java
License:Apache License
private static int parseCommentLength(byte[] note, MutableInteger curr, Change.Id changeId, Charset enc) throws ConfigInvalidException { checkHeaderLineFormat(note, curr, LENGTH, enc, changeId); int startOfLength = RawParseUtils.endOfFooterLineKey(note, curr.value) + 1; MutableInteger i = new MutableInteger(); int commentLength = RawParseUtils.parseBase10(note, startOfLength, i); int endOfLine = RawParseUtils.nextLF(note, curr.value); if (i.value != endOfLine - 1) { throw parseException(changeId, "could not parse %s", PATCH_SET); }// ww w . j a v a2 s. c om curr.value = endOfLine; return checkResult(commentLength, "comment length", changeId); }