Class RepoMetaDataUpdater
java.lang.Object
com.google.gerrit.server.restapi.project.RepoMetaDataUpdater
Updates repo refs/meta/config content.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassCreates a change for a project config update.classUpdater for a project config without review. -
Method Summary
Modifier and TypeMethodDescriptionconfigChangeCreator(Project.NameKey projectName, String message, String defaultMessage) Returns a creator for creating project config changes.configUpdater(Project.NameKey projectName, String message, String defaultMessage) Returns an updater for updating project config without review.configUpdaterWithoutPermissionsCheck(Project.NameKey projectName, String message, String defaultMessage) Returns an updater for updating project config without review and skips some permissions checks.
-
Method Details
-
configChangeCreator
@MustBeClosed public RepoMetaDataUpdater.ConfigChangeCreator configChangeCreator(Project.NameKey projectName, @Nullable String message, String defaultMessage) throws PermissionBackendException, AuthException, ResourceConflictException, IOException, org.eclipse.jgit.errors.ConfigInvalidException Returns a creator for creating project config changes.The method checks that user has required permissions.
Usage:
try(var changeCreator = repoMetaDataUpdater.configChangeCreator(projectName, message, defaultMessage)) { ProjectConfig config = changeCreator.getConfig(); // ... update project config // Create change - if the createChange method is not called, all updates are ignored and no // change is created. Response<ChangeInfo> result = changeCreator.createChange(); }- Parameters:
projectName- the name of the project whose config should be updatedmessage- the user-provided commit message. If it is not provided (i.e. it is null or empty) - thedefaultMessageis used.defaultMessage- the default commit message if the user doesn't provide one.- Throws:
PermissionBackendExceptionAuthExceptionResourceConflictExceptionIOExceptionorg.eclipse.jgit.errors.ConfigInvalidException
-
configUpdater
@MustBeClosed public RepoMetaDataUpdater.ConfigUpdater configUpdater(Project.NameKey projectName, @Nullable String message, String defaultMessage) throws AuthException, PermissionBackendException, org.eclipse.jgit.errors.ConfigInvalidException, IOException, MethodNotAllowedException Returns an updater for updating project config without review.The method checks that user has required permissions and that user can update config without review.
When the update is saved (using the
RepoMetaDataUpdater.ConfigUpdater.commitConfigUpdate()method), the project cache is updated automatically.Usage:
try(var configUpdater = repoMetaDataUpdater.configUpdater(projectName, message, defaultMessage)) { ProjectConfig config = changeCreator.getConfig(); // ... update project config // Save updated config - if the commitConfigUpdate method is not called, all updates are ignored. configUpdater.commitConfigUpdate(); }- Parameters:
projectName- the name of the project whose config should be updatedmessage- the user-provided commit message. If it is not provided (i.e. it is null or empty) - thedefaultMessageis used.defaultMessage- the default commit message if the user doesn't provide one.- Throws:
AuthExceptionPermissionBackendExceptionorg.eclipse.jgit.errors.ConfigInvalidExceptionIOExceptionMethodNotAllowedException
-
configUpdaterWithoutPermissionsCheck
@MustBeClosed public RepoMetaDataUpdater.ConfigUpdater configUpdaterWithoutPermissionsCheck(Project.NameKey projectName, @Nullable String message, String defaultMessage) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException, MethodNotAllowedException, PermissionBackendException Returns an updater for updating project config without review and skips some permissions checks.The method only checks that user can update config without review and doesn't do any other permissions checks. It should be used only when standard permissions checks from
configUpdater(com.google.gerrit.entities.Project.NameKey, java.lang.String, java.lang.String)can't be used.See
configUpdater(com.google.gerrit.entities.Project.NameKey, java.lang.String, java.lang.String)for details.- Throws:
IOExceptionorg.eclipse.jgit.errors.ConfigInvalidExceptionMethodNotAllowedExceptionPermissionBackendException
-