List of usage examples for org.eclipse.jgit.notes NoteMap remove
public void remove(AnyObjectId noteOn) throws IOException
From source file:com.google.gerrit.server.account.externalids.ExternalIdsUpdate.java
License:Apache License
/** * Removes an external ID from the note map. * * @throws IllegalStateException is thrown if there is an existing external ID that has the same * key, but otherwise doesn't match the specified external ID. *///from w w w . j a va2 s .c om public static void remove(RevWalk rw, NoteMap noteMap, ExternalId extId) throws IOException, ConfigInvalidException { ObjectId noteId = extId.key().sha1(); if (!noteMap.contains(noteId)) { return; } byte[] raw = rw.getObjectReader().open(noteMap.get(noteId), OBJ_BLOB).getCachedBytes(MAX_NOTE_SZ); ExternalId actualExtId = ExternalId.parse(noteId.name(), raw); checkState(extId.equals(actualExtId), "external id %s should be removed, but it's not matching the actual external id %s", extId.toString(), actualExtId.toString()); noteMap.remove(noteId); }
From source file:com.google.gerrit.server.account.externalids.ExternalIdsUpdate.java
License:Apache License
/** * Removes an external ID from the note map by external ID key. * * @throws IllegalStateException is thrown if an expected account ID is provided and an external * ID with the specified key exists, but belongs to another account. */// ww w .java 2 s . com private static void remove(RevWalk rw, NoteMap noteMap, ExternalId.Key extIdKey, Account.Id expectedAccountId) throws IOException, ConfigInvalidException { ObjectId noteId = extIdKey.sha1(); if (!noteMap.contains(noteId)) { return; } byte[] raw = rw.getObjectReader().open(noteMap.get(noteId), OBJ_BLOB).getCachedBytes(MAX_NOTE_SZ); ExternalId extId = ExternalId.parse(noteId.name(), raw); if (expectedAccountId != null) { checkState(expectedAccountId.equals(extId.accountId()), "external id %s should be removed for account %s," + " but external id belongs to account %s", extIdKey.get(), expectedAccountId.get(), extId.accountId().get()); } noteMap.remove(noteId); }
From source file:com.google.gerrit.server.notedb.CommentsInNotesUtil.java
License:Apache License
/** * Write comments for multiple revisions to a note map. * <p>/*from ww w. j ava 2 s . c o m*/ * Mutates the map in-place. only notes for SHA-1s found as keys in the map * are modified; all other notes are left untouched. * * @param noteMap note map to modify. * @param allComments map of revision to all comments for that revision; * callers are responsible for reading the original comments and applying * any changes. Differs from a multimap in that present-but-empty values * are significant, and indicate the note for that SHA-1 should be * deleted. * @param inserter object inserter for writing notes. * @throws IOException if an error occurred. */ public void writeCommentsToNoteMap(NoteMap noteMap, Map<RevId, List<PatchLineComment>> allComments, ObjectInserter inserter) throws IOException { for (Map.Entry<RevId, List<PatchLineComment>> e : allComments.entrySet()) { List<PatchLineComment> comments = e.getValue(); ObjectId commit = ObjectId.fromString(e.getKey().get()); if (comments.isEmpty()) { noteMap.remove(commit); continue; } Collections.sort(comments, PLC_ORDER); // We allow comments for multiple commits to be written in the same // update, even though the rest of the metadata update is associated with // a single patch set. noteMap.set(commit, inserter.insert(OBJ_BLOB, buildNote(comments))); } }