Class VersionedMetaData
- java.lang.Object
- 
- com.google.gerrit.server.git.VersionedMetaData
 
- 
- Direct Known Subclasses:
- AccountConfig,- ProjectConfig,- ProjectConfigSchemaUpdate,- ProjectLevelConfig,- VersionedAccountDestinations,- VersionedAccountPreferences,- VersionedAccountQueries,- VersionedAuthorizedKeys,- VersionedMetaDataOnInit,- WatchConfig
 
 public abstract class VersionedMetaData extends Object Support for metadata stored within a version controlled branch.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 SummaryNested Classes Modifier and Type Class Description static interfaceVersionedMetaData.BatchMetaDataUpdatestatic classVersionedMetaData.PathInfoPath information that does not hold references to any repository data structures, allowing the application to retain this object for long periods of time.
 - 
Field SummaryFields Modifier and Type Field Description protected org.eclipse.jgit.lib.ObjectInserterinserterprotected org.eclipse.jgit.dircache.DirCachenewTreeprotected org.eclipse.jgit.lib.ObjectReaderreaderprotected org.eclipse.jgit.revwalk.RevCommitrevisionprotected org.eclipse.jgit.revwalk.RevWalkrw
 - 
Constructor SummaryConstructors Constructor Description VersionedMetaData()
 - 
Method SummaryAll Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description org.eclipse.jgit.revwalk.RevCommitcommit(MetaDataUpdate update)Update this metadata branch, recording a new commit on its reference.org.eclipse.jgit.revwalk.RevCommitcommitToNewRef(MetaDataUpdate update, String refName)Creates a new commit and a new ref based on this commit.protected org.eclipse.jgit.lib.ObjectIdgetObjectId(String fileName)List<VersionedMetaData.PathInfo>getPathInfos(boolean recursive)protected abstract StringgetRefName()org.eclipse.jgit.lib.ObjectIdgetRevision()voidload(MetaDataUpdate update)voidload(MetaDataUpdate update, org.eclipse.jgit.lib.ObjectId id)voidload(org.eclipse.jgit.lib.Repository db)Load the current version from the branch.voidload(org.eclipse.jgit.lib.Repository db, org.eclipse.jgit.lib.ObjectId id)Load a specific version from the repository.voidload(org.eclipse.jgit.revwalk.RevWalk walk, org.eclipse.jgit.lib.ObjectId id)Load a specific version from an open walk.protected abstract voidonLoad()Set up the metadata, parsing any state from the loaded revision.protected abstract booleanonSave(org.eclipse.jgit.lib.CommitBuilder commit)Save any changes to the metadata in a commit.VersionedMetaData.BatchMetaDataUpdateopenUpdate(MetaDataUpdate update)Open a batch of updates to the same metadata ref.protected org.eclipse.jgit.lib.ConfigreadConfig(String fileName)protected byte[]readFile(String fileName)protected org.eclipse.jgit.dircache.DirCachereadTree(org.eclipse.jgit.revwalk.RevTree tree)protected StringreadUTF8(String fileName)protected voidsaveConfig(String fileName, org.eclipse.jgit.lib.Config cfg)protected voidsaveFile(String fileName, byte[] raw)protected voidsaveUTF8(String fileName, String text)protected static voidset(org.eclipse.jgit.lib.Config rc, String section, String subsection, String name, boolean value)protected static <E extends Enum<?>>
 voidset(org.eclipse.jgit.lib.Config rc, String section, String subsection, String name, E value, E defaultValue)protected static voidset(org.eclipse.jgit.lib.Config rc, String section, String subsection, String name, String value)
 
- 
- 
- 
Field Detail- 
revisionprotected org.eclipse.jgit.revwalk.RevCommit revision 
 - 
rwprotected org.eclipse.jgit.revwalk.RevWalk rw 
 - 
readerprotected org.eclipse.jgit.lib.ObjectReader reader 
 - 
inserterprotected org.eclipse.jgit.lib.ObjectInserter inserter 
 - 
newTreeprotected org.eclipse.jgit.dircache.DirCache newTree 
 
- 
 - 
Method Detail- 
getRefNameprotected abstract String getRefName() - Returns:
- name of the reference storing this configuration.
 
 - 
onLoadprotected abstract void onLoad() throws IOException, org.eclipse.jgit.errors.ConfigInvalidExceptionSet up the metadata, parsing any state from the loaded revision.- Throws:
- IOException
- org.eclipse.jgit.errors.ConfigInvalidException
 
 - 
onSaveprotected abstract boolean onSave(org.eclipse.jgit.lib.CommitBuilder commit) throws IOException, org.eclipse.jgit.errors.ConfigInvalidExceptionSave 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
 
 - 
getRevisionpublic org.eclipse.jgit.lib.ObjectId getRevision() - Returns:
- revision of the metadata that was loaded.
 
 - 
loadpublic void load(org.eclipse.jgit.lib.Repository db) throws IOException, org.eclipse.jgit.errors.ConfigInvalidExceptionLoad 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:
- db- repository to access.
- Throws:
- IOException
- org.eclipse.jgit.errors.ConfigInvalidException
 
 - 
loadpublic void load(org.eclipse.jgit.lib.Repository db, org.eclipse.jgit.lib.ObjectId id) throws IOException, org.eclipse.jgit.errors.ConfigInvalidExceptionLoad 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:
- db- repository to access.
- id- revision to load.
- Throws:
- IOException
- org.eclipse.jgit.errors.ConfigInvalidException
 
 - 
loadpublic void load(org.eclipse.jgit.revwalk.RevWalk walk, org.eclipse.jgit.lib.ObjectId id) throws IOException, org.eclipse.jgit.errors.ConfigInvalidExceptionLoad 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:
- walk- open walk to access to access.
- id- revision to load.
- Throws:
- IOException
- org.eclipse.jgit.errors.ConfigInvalidException
 
 - 
loadpublic void load(MetaDataUpdate update) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException - Throws:
- IOException
- org.eclipse.jgit.errors.ConfigInvalidException
 
 - 
loadpublic void load(MetaDataUpdate update, org.eclipse.jgit.lib.ObjectId id) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException - Throws:
- IOException
- org.eclipse.jgit.errors.ConfigInvalidException
 
 - 
commitpublic org.eclipse.jgit.revwalk.RevCommit commit(MetaDataUpdate update) throws IOException Update this metadata branch, recording a new commit on its reference.- 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
 
 - 
commitToNewRefpublic org.eclipse.jgit.revwalk.RevCommit commitToNewRef(MetaDataUpdate update, String refName) throws IOException Creates a new commit and a new ref based on this commit.- 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
 
 - 
openUpdatepublic VersionedMetaData.BatchMetaDataUpdate openUpdate(MetaDataUpdate update) 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 MetaDataUpdatewith aBatchRefUpdate.A ref update produced by this VersionedMetaData.BatchMetaDataUpdateis 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.
 
 - 
readTreeprotected 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
 
 - 
readConfigprotected org.eclipse.jgit.lib.Config readConfig(String fileName) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException - Throws:
- IOException
- org.eclipse.jgit.errors.ConfigInvalidException
 
 - 
readUTF8protected String readUTF8(String fileName) throws IOException - Throws:
- IOException
 
 - 
readFileprotected byte[] readFile(String fileName) throws IOException - Throws:
- IOException
 
 - 
getObjectIdprotected org.eclipse.jgit.lib.ObjectId getObjectId(String fileName) throws IOException - Throws:
- IOException
 
 - 
getPathInfospublic List<VersionedMetaData.PathInfo> getPathInfos(boolean recursive) throws IOException - Throws:
- IOException
 
 - 
setprotected static void set(org.eclipse.jgit.lib.Config rc, String section, String subsection, String name, String value)
 - 
setprotected static void set(org.eclipse.jgit.lib.Config rc, String section, String subsection, String name, boolean value)
 - 
setprotected static <E extends Enum<?>> void set(org.eclipse.jgit.lib.Config rc, String section, String subsection, String name, E value, E defaultValue) 
 - 
saveConfigprotected void saveConfig(String fileName, org.eclipse.jgit.lib.Config cfg) throws IOException - Throws:
- IOException
 
 - 
saveUTF8protected void saveUTF8(String fileName, String text) throws IOException - Throws:
- IOException
 
 - 
saveFileprotected void saveFile(String fileName, byte[] raw) throws IOException - Throws:
- IOException
 
 
- 
 
-