Class VersionedMetaData
- Direct Known Subclasses:
AccountConfig
,ExternalIdNotes
,GroupConfig
,GroupNameNotes
,ProjectConfig
,VersionedAccountDestinations
,VersionedAccountQueries
,VersionedAuthorizedKeys
,VersionedConfigFile
,VersionedMetaDataOnInit
Implementors are responsible for supplying implementations of the onLoad and onSave methods to read from the repository, or format an update that can later be written back to the repository.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static class
Path information that does not hold references to any repository data structures, allowing the application to retain this object for long periods of time. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.eclipse.jgit.lib.ObjectInserter
protected org.eclipse.jgit.dircache.DirCache
protected Project.NameKey
protected org.eclipse.jgit.lib.ObjectReader
protected org.eclipse.jgit.revwalk.RevCommit
The revision at which the data was loaded.protected org.eclipse.jgit.revwalk.RevWalk
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.eclipse.jgit.revwalk.RevCommit
commit
(MetaDataUpdate update) Update this metadata branch, recording a new commit on its reference.org.eclipse.jgit.revwalk.RevCommit
commit
(MetaDataUpdate update, org.eclipse.jgit.lib.ObjectInserter objInserter, org.eclipse.jgit.lib.ObjectReader objReader, org.eclipse.jgit.revwalk.RevWalk revWalk) Update this metadata branch, recording a new commit on its reference.org.eclipse.jgit.revwalk.RevCommit
commitToNewRef
(MetaDataUpdate update, String refName) Creates a new commit and a new ref based on this commit.protected org.eclipse.jgit.lib.ObjectId
getObjectId
(String fileName) getPathInfos
(boolean recursive) protected abstract String
Returns name of the reference storing this configuration.org.eclipse.jgit.lib.ObjectId
Returns revision of the metadata that was loaded.void
load
(Project.NameKey projectName, org.eclipse.jgit.lib.Repository db) Load the current version from the branch.void
load
(Project.NameKey projectName, org.eclipse.jgit.lib.Repository db, org.eclipse.jgit.lib.ObjectId id) Load a specific version from the repository.void
load
(Project.NameKey projectName, org.eclipse.jgit.revwalk.RevWalk walk, org.eclipse.jgit.lib.ObjectId id) Load a specific version from an open walk.void
load
(MetaDataUpdate update) void
load
(MetaDataUpdate update, org.eclipse.jgit.lib.ObjectId id) protected abstract void
onLoad()
Set up the metadata, parsing any state from the loaded revision.protected abstract boolean
onSave
(org.eclipse.jgit.lib.CommitBuilder commit) Save any changes to the metadata in a commit.openUpdate
(MetaDataUpdate update) Open a batch of updates to the same metadata ref.openUpdate
(MetaDataUpdate update, org.eclipse.jgit.lib.ObjectInserter objInserter, org.eclipse.jgit.lib.ObjectReader objReader, org.eclipse.jgit.revwalk.RevWalk revWalk) Open a batch of updates to the same metadata ref.protected org.eclipse.jgit.lib.Config
readConfig
(String fileName) protected org.eclipse.jgit.lib.Config
readConfig
(String fileName, Optional<? extends org.eclipse.jgit.lib.Config> baseConfig) protected byte[]
protected org.eclipse.jgit.dircache.DirCache
readTree
(org.eclipse.jgit.revwalk.RevTree tree) protected String
protected void
saveConfig
(String fileName, org.eclipse.jgit.lib.Config cfg) protected void
protected void
protected static void
protected static <E extends Enum<?>>
voidset
(org.eclipse.jgit.lib.Config rc, String section, String subsection, String name, E value, E defaultValue) protected static void
-
Field Details
-
revision
protected org.eclipse.jgit.revwalk.RevCommit revisionThe revision at which the data was loaded. Is null for data yet to be created. -
projectName
-
rw
protected org.eclipse.jgit.revwalk.RevWalk rw -
reader
protected org.eclipse.jgit.lib.ObjectReader reader -
inserter
protected org.eclipse.jgit.lib.ObjectInserter inserter -
newTree
protected org.eclipse.jgit.dircache.DirCache newTree
-
-
Constructor Details
-
VersionedMetaData
public VersionedMetaData()
-
-
Method Details
-
getRefName
Returns name of the reference storing this configuration. -
onLoad
Set up the metadata, parsing any state from the loaded revision.- Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
onSave
protected abstract boolean onSave(org.eclipse.jgit.lib.CommitBuilder commit) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException Save any changes to the metadata in a commit.- Returns:
- true if the commit should proceed, false to abort.
- Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
getRevision
public org.eclipse.jgit.lib.ObjectId getRevision()Returns revision of the metadata that was loaded. -
load
public void load(Project.NameKey projectName, org.eclipse.jgit.lib.Repository db) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException Load the current version from the branch.The repository is not held after the call completes, allowing the application to retain this object for long periods of time.
- Parameters:
projectName
- the name of the projectdb
- repository to access.- Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
load
public void load(Project.NameKey projectName, org.eclipse.jgit.lib.Repository db, org.eclipse.jgit.lib.ObjectId id) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException Load a specific version from the repository.This method is primarily useful for applying updates to a specific revision that was shown to an end-user in the user interface. If there are conflicts with another user's concurrent changes, these will be automatically detected at commit time.
The repository is not held after the call completes, allowing the application to retain this object for long periods of time.
- Parameters:
projectName
- the name of the projectdb
- repository to access.id
- revision to load.- Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
load
public void load(Project.NameKey projectName, org.eclipse.jgit.revwalk.RevWalk walk, org.eclipse.jgit.lib.ObjectId id) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException Load a specific version from an open walk.This method is primarily useful for applying updates to a specific revision that was shown to an end-user in the user interface. If there are conflicts with another user's concurrent changes, these will be automatically detected at commit time.
The caller retains ownership of the walk and is responsible for closing it. However, this instance does not hold a reference to the walk or the repository after the call completes, allowing the application to retain this object for long periods of time.
- Parameters:
projectName
- the name of the projectwalk
- open walk to access to access.id
- revision to load.- Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
load
public void load(MetaDataUpdate update) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException - Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
load
public void load(MetaDataUpdate update, org.eclipse.jgit.lib.ObjectId id) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException - Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
commit
@CanIgnoreReturnValue public org.eclipse.jgit.revwalk.RevCommit commit(MetaDataUpdate update) throws IOException Update this metadata branch, recording a new commit on its reference. This method mutates its receiver.- 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
-
commit
public org.eclipse.jgit.revwalk.RevCommit commit(MetaDataUpdate update, org.eclipse.jgit.lib.ObjectInserter objInserter, org.eclipse.jgit.lib.ObjectReader objReader, org.eclipse.jgit.revwalk.RevWalk revWalk) throws IOException Update this metadata branch, recording a new commit on its reference. This method mutates its receiver.- Parameters:
update
- helper information to define the update that will occur.objInserter
- Shared object inserter.objReader
- Shared object reader.revWalk
- Shared rev walk.- 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
-
commitToNewRef
@CanIgnoreReturnValue public org.eclipse.jgit.revwalk.RevCommit commitToNewRef(MetaDataUpdate update, String refName) throws IOException Creates a new commit and a new ref based on this commit. This method mutates its receiver.- Parameters:
update
- helper information to define the update that will occur.refName
- name of the ref that should be created- 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
-
openUpdate
Open a batch of updates to the same metadata ref.This allows making multiple commits to a single metadata ref, at the end of which is a single ref update. For batching together updates to multiple refs (each consisting of one or more commits against their respective refs), create the
MetaDataUpdate
with aBatchRefUpdate
.A ref update produced by this
VersionedMetaData.BatchMetaDataUpdate
is only committed if there is no associatedBatchRefUpdate
. As a result, the configured ref updated event is not fired if there is an associated batch.- Parameters:
update
- helper info about the update.- Throws:
IOException
- if the update failed.
-
openUpdate
public VersionedMetaData.BatchMetaDataUpdate openUpdate(MetaDataUpdate update, org.eclipse.jgit.lib.ObjectInserter objInserter, org.eclipse.jgit.lib.ObjectReader objReader, org.eclipse.jgit.revwalk.RevWalk revWalk) throws IOException Open a batch of updates to the same metadata ref.This allows making multiple commits to a single metadata ref, at the end of which is a single ref update. For batching together updates to multiple refs (each consisting of one or more commits against their respective refs), create the
MetaDataUpdate
with aBatchRefUpdate
.A ref update produced by this
VersionedMetaData.BatchMetaDataUpdate
is only committed if there is no associatedBatchRefUpdate
. As a result, the configured ref updated event is not fired if there is an associated batch.If object inserter, reader and revwalk are provided, then the updates are not flushed, allowing callers the flexibility to flush only once after several updates.
- Parameters:
update
- helper info about the update.objInserter
- Shared object inserter.objReader
- Shared object reader.revWalk
- Shared rev walk.- Throws:
IOException
- if the update failed.
-
readTree
protected org.eclipse.jgit.dircache.DirCache readTree(org.eclipse.jgit.revwalk.RevTree tree) throws IOException, org.eclipse.jgit.errors.MissingObjectException, org.eclipse.jgit.errors.IncorrectObjectTypeException - Throws:
IOException
org.eclipse.jgit.errors.MissingObjectException
org.eclipse.jgit.errors.IncorrectObjectTypeException
-
readConfig
protected org.eclipse.jgit.lib.Config readConfig(String fileName) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException - Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
readConfig
protected org.eclipse.jgit.lib.Config readConfig(String fileName, Optional<? extends org.eclipse.jgit.lib.Config> baseConfig) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException - Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
readUTF8
- Throws:
IOException
-
readFile
- Throws:
IOException
-
getObjectId
- Throws:
IOException
-
getPathInfos
- Throws:
IOException
-
set
-
set
-
set
-
saveConfig
- Throws:
IOException
-
saveUTF8
- Throws:
IOException
-
saveFile
- Throws:
IOException
-