Class ExternalIdNotes

    • Field Detail

      • defaultNoteIdResolver

        protected final Function<ExternalId,​org.eclipse.jgit.lib.ObjectId> defaultNoteIdResolver
    • Method Detail

      • loadReadOnly

        public static ExternalIdNotes loadReadOnly​(AllUsersName allUsersName,
                                                   org.eclipse.jgit.lib.Repository allUsersRepo,
                                                   org.eclipse.jgit.lib.ObjectId rev,
                                                   ExternalIdFactory externalIdFactory,
                                                   boolean isUserNameCaseInsensitiveMigrationMode)
                                            throws IOException,
                                                   org.eclipse.jgit.errors.ConfigInvalidException
        Loads the external ID notes for reading only. The external ID notes are loaded from the specified revision of the refs/meta/external-ids branch.
        Parameters:
        rev - the revision from which the external ID notes should be loaded, if null the external ID notes are loaded from the current tip, if ObjectId.zeroId() it's assumed that the refs/meta/external-ids branch doesn't exist and the loaded external IDs will be empty
        Returns:
        read-only ExternalIdNotes instance
        Throws:
        IOException
        org.eclipse.jgit.errors.ConfigInvalidException
      • load

        public static ExternalIdNotes load​(AllUsersName allUsersName,
                                           org.eclipse.jgit.lib.Repository allUsersRepo,
                                           ExternalIdFactory externalIdFactory,
                                           boolean isUserNameCaseInsensitiveMigrationMode)
                                    throws IOException,
                                           org.eclipse.jgit.errors.ConfigInvalidException
        Loads the external ID notes for updates. The external ID notes are loaded from the current tip of the refs/meta/external-ids branch.

        Use this only from init, schema upgrades and tests.

        Metrics are disabled.

        Returns:
        ExternalIdNotes instance that doesn't updates caches on save
        Throws:
        IOException
        org.eclipse.jgit.errors.ConfigInvalidException
      • getRepository

        public org.eclipse.jgit.lib.Repository getRepository()
      • get

        public Optional<ExternalId> get​(ExternalId.Key key)
                                 throws IOException,
                                        org.eclipse.jgit.errors.ConfigInvalidException
        Parses and returns the specified external ID.
        Parameters:
        key - the key of the external ID
        Returns:
        the external ID, Optional.empty() if it doesn't exist
        Throws:
        IOException
        org.eclipse.jgit.errors.ConfigInvalidException
      • get

        public Set<ExternalId> get​(Collection<ExternalId.Key> keys)
                            throws IOException,
                                   org.eclipse.jgit.errors.ConfigInvalidException
        Parses and returns the specified external IDs.
        Parameters:
        keys - the keys of the external IDs
        Returns:
        the external IDs
        Throws:
        IOException
        org.eclipse.jgit.errors.ConfigInvalidException
      • all

        public com.google.common.collect.ImmutableSet<ExternalId> all()
                                                               throws IOException
        Parses and returns all external IDs.

        Invalid external IDs are ignored.

        Returns:
        all external IDs
        Throws:
        IOException
      • upsert

        public void upsert​(ExternalId extId)
                    throws IOException,
                           org.eclipse.jgit.errors.ConfigInvalidException
        Inserts or updates an external ID.

        If the external ID already exists, it is overwritten, otherwise it is inserted.

        Throws:
        IOException
        org.eclipse.jgit.errors.ConfigInvalidException
      • upsert

        public void upsert​(Collection<ExternalId> extIds)
                    throws IOException,
                           org.eclipse.jgit.errors.ConfigInvalidException
        Inserts or updates external IDs.

        If any of the external IDs already exists, it is overwritten. New external IDs are inserted.

        Throws:
        IOException
        org.eclipse.jgit.errors.ConfigInvalidException
      • delete

        public void delete​(ExternalId extId)
        Deletes an external ID.
        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.
      • delete

        public void delete​(Collection<ExternalId> extIds)
        Deletes external IDs.
        Throws:
        IllegalStateException - is thrown if there is an existing external ID that has the same key as any of the external IDs that should be deleted, but otherwise doesn't match the that external ID.
      • deleteByKeys

        public void deleteByKeys​(Collection<ExternalId.Key> extIdKeys)
        Delete external IDs by external ID key.

        The external IDs are deleted regardless of which account they belong to.

      • replaceByKeys

        public void replaceByKeys​(Collection<ExternalId.Key> toDelete,
                                  Collection<ExternalId> toAdd)
                           throws IOException,
                                  DuplicateExternalIdKeyException
        Replaces external IDs for an account by external ID keys.

        Deletion of external IDs is done before adding the new external IDs. This means if an external ID key is specified for deletion and an external ID with the same key is specified to be added, the old external ID with that key is deleted first and then the new external ID is added (so the external ID for that key is replaced).

        The external IDs are replaced regardless of which account they belong to.

        Throws:
        IOException
        DuplicateExternalIdKeyException
      • onLoad

        protected void onLoad()
                       throws IOException,
                              org.eclipse.jgit.errors.ConfigInvalidException
        Description copied from class: VersionedMetaData
        Set up the metadata, parsing any state from the loaded revision.
        Specified by:
        onLoad in class VersionedMetaData
        Throws:
        IOException
        org.eclipse.jgit.errors.ConfigInvalidException
      • commit

        public org.eclipse.jgit.revwalk.RevCommit commit​(MetaDataUpdate update)
                                                  throws IOException
        Description copied from class: VersionedMetaData
        Update this metadata branch, recording a new commit on its reference. This method mutates its receiver.
        Overrides:
        commit in class VersionedMetaData
        Parameters:
        update - helper information to define the update that will occur.
        Returns:
        the commit that was created
        Throws:
        IOException - if there is a storage problem and the update cannot be executed as requested or if it failed because of a concurrent update to the same reference
      • onSave

        protected boolean onSave​(org.eclipse.jgit.lib.CommitBuilder commit)
                          throws IOException,
                                 org.eclipse.jgit.errors.ConfigInvalidException
        Description copied from class: VersionedMetaData
        Save any changes to the metadata in a commit.
        Specified by:
        onSave in class VersionedMetaData
        Returns:
        true if the commit should proceed, false to abort.
        Throws:
        IOException
        org.eclipse.jgit.errors.ConfigInvalidException
      • checkSameAccount

        public static Account.Id checkSameAccount​(Iterable<ExternalId> extIds,
                                                  Account.Id accountId)
        Checks that all specified external IDs belong to specified account. If no account is specified it is checked that all specified external IDs belong to the same account.
        Returns:
        the ID of the account to which all specified external IDs belong.